unstick r358179

Revision 358179

Date:
2020/02/20 19:07:29
Author:
dim
Revision Log:
Merge ^/head r358131 through r358178.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • projects/clang1000-import

     
  • projects/clang1000-import/bin/sh/miscbltin.c

     
    66 66
    67 67 #undef eflag
    68 68
    69 #define READ_BUFLEN 1024
    70 struct fdctx {
    71 int fd;
    72 size_t off; /* offset in buf */
    73 size_t buflen;
    74 char *ep; /* tail pointer */
    75 char buf[READ_BUFLEN];
    76 };
    77
    78 static void fdctx_init(int, struct fdctx *);
    79 static void fdctx_destroy(struct fdctx *);
    80 static ssize_t fdgetc(struct fdctx *, char *);
    69 81 int readcmd(int, char **);
    70 82 int umaskcmd(int, char **);
    71 83 int ulimitcmd(int, char **);
    72 84
    85 static void
    86 fdctx_init(int fd, struct fdctx *fdc)
    87 {
    88 off_t cur;
    89
    90 /* Check if fd is seekable. */
    91 cur = lseek(fd, 0, SEEK_CUR);
    92 *fdc = (struct fdctx){
    93 .fd = fd,
    94 .buflen = (cur != -1) ? READ_BUFLEN : 1,
    95 .ep = &fdc->buf[0], /* No data */
    96 };
    97 }
    98
    99 static ssize_t
    100 fdgetc(struct fdctx *fdc, char *c)
    101 {
    102 ssize_t nread;
    103
    104 if (&fdc->buf[fdc->off] == fdc->ep) {
    105 nread = read(fdc->fd, fdc->buf, fdc->buflen);
    106 if (nread > 0) {
    107 fdc->off = 0;
    108 fdc->ep = fdc->buf + nread;
    109 } else
    110 return (nread);
    111 }
    112 *c = fdc->buf[fdc->off++];
    113
    114 return (1);
    115 }
    116
    117 static void
    118 fdctx_destroy(struct fdctx *fdc)
    119 {
    120 size_t residue;
    121
    122 if (fdc->buflen > 1) {
    123 /*
    124 * Reposition the file offset. Here is the layout of buf:
    125 *
    126 * | off
    127 * v
    128 * |*****************|-------|
    129 * buf ep buf+buflen
    130 * |<- residue ->|
    131 *
    132 * off: current character
    133 * ep: offset just after read(2)
    134 * residue: length for reposition
    135 */
    136 residue = (fdc->ep - fdc->buf) - fdc->off;
    137 if (residue > 0)
    138 (void) lseek(fdc->fd, -residue, SEEK_CUR);
    139 }
    140 }
    141
    73 142 /*
    74 143 * The read builtin. The -r option causes backslashes to be treated like
    75 144 * ordinary characters.
     
    108 177 fd_set ifds;
    109 178 ssize_t nread;
    110 179 int sig;
    180 struct fdctx fdctx;
    111 181
    112 182 rflag = 0;
    113 183 prompt = NULL;
     
    173 243 backslash = 0;
    174 244 STARTSTACKSTR(p);
    175 245 lastnonifs = lastnonifsws = -1;
    246 fdctx_init(STDIN_FILENO, &fdctx);
    176 247 for (;;) {
    177 nread = read(STDIN_FILENO, &c, 1);
    248 nread = fdgetc(&fdctx, &c);
    178 249 if (nread == -1) {
    179 250 if (errno == EINTR) {
    180 251 sig = pendingsig;
     
    260 331 STARTSTACKSTR(p);
    261 332 lastnonifs = lastnonifsws = -1;
    262 333 }
    334 fdctx_destroy(&fdctx);
    263 335 STACKSTRNUL(p);
    264 336
    265 337 /*
  • projects/clang1000-import/lib/libc/stdlib/realpath.c

     
    42 42 #include <stdlib.h>
    43 43 #include <string.h>
    44 44 #include <unistd.h>
    45 #include <fcntl.h>
    45 46 #include "un-namespace.h"
    47 #include "libc_private.h"
    46 48
    49 extern int __realpathat(int fd, const char *path, char *buf, size_t size,
    50 int flags);
    51
    47 52 /*
    48 53 * Find the real name of path, by removing all ".", ".." and symlink
    49 54 * components. Returns (resolved) on success, or (NULL) on failure,
    50 55 * in which case the path which caused trouble is left in (resolved).
    51 56 */
    52 static char *
    57 static char * __noinline
    53 58 realpath1(const char *path, char *resolved)
    54 59 {
    55 60 struct stat sb;
     
    223 228 if (resolved == NULL)
    224 229 return (NULL);
    225 230 }
    231 if (__getosreldate() >= 1300080) {
    232 if (__realpathat(AT_FDCWD, path, resolved, PATH_MAX, 0) == 0)
    233 return (resolved);
    234 }
    226 235 res = realpath1(path, resolved);
    227 236 if (res == NULL)
    228 237 free(m);
  • projects/clang1000-import/lib/ncurses/ncurses/Makefile

     
    13 13 .include "${.CURDIR:H}/config.mk"
    14 14
    15 15 LIB= ncurses${LIB_SUFFIX}
    16 SHLIB_MAJOR= 8
    16 SHLIB_MAJOR= 9
    17 17
    18 18 NO_LINT=
    19 19
     
    292 292 make_keys MKterm.h.awk comp_captab.c curses.head
    293 293
    294 294 CFLAGS+= -DFREEBSD_NATIVE -DTERMIOS
    295 CFLAGS.lib_freeall.c+= -Wno-missing-prototypes
    296 295
    297 296 # Installed
    298 297 HEADERS= curses.h term.h termcap.h unctrl.h
  • projects/clang1000-import/libexec/rtld-elf/rtld-libc/Makefile.inc

     
    49 49 sysarch __sysctl issetugid __getcwd utrace \
    50 50 thr_self thr_kill pread mmap lseek _exit _fstat _fstatat _fstatfs \
    51 51 getdirentries _getdirentries _close _fcntl _open _openat _read \
    52 _sigprocmask _write readlink _setjmp setjmp setjmperr
    52 _sigprocmask _write readlink __realpathat _setjmp setjmp setjmperr
    53 53
    54 54
    55 55 # Finally add additional architecture-dependent libc dependencies
  • projects/clang1000-import/ObsoleteFiles.inc

     
    273 273 OLD_DIRS+=usr/lib/clang/9.0.1/lib
    274 274 OLD_DIRS+=usr/lib/clang/9.0.1
    275 275
    276 # 20200220: Upgrade of ncurses, shlib bumped to version 9
    277 OLD_LIBS+=lib/libncurses.so.8
    278 OLD_LIBS+=lib/libncursesw.so.8
    279 OLD_LIBS+=usr/lib32/libncurses.so.8
    280 OLD_LIBS+=usr/lib32/libncursesw.so.8
    281
    276 282 # 20200206: Remove elf2aout
    277 283 OLD_FILES+=usr/bin/elf2aout
    278 284 OLD_FILES+=usr/share/man/man1/elf2aout.1.gz
  • projects/clang1000-import/share/man/man4/Makefile

     
    192 192 ${_hv_vmbus.4} \
    193 193 ${_hv_vss.4} \
    194 194 hwpmc.4 \
    195 ${_hwpstate_intel.4} \
    195 196 iavf.4 \
    196 197 ichsmb.4 \
    197 198 ${_ichwd.4} \
     
    787 788 _hv_utils.4= hv_utils.4
    788 789 _hv_vmbus.4= hv_vmbus.4
    789 790 _hv_vss.4= hv_vss.4
    791 _hwpstate_intel.4= hwpstate_intel.4
    790 792 _i8254.4= i8254.4
    791 793 _ichwd.4= ichwd.4
    792 794 _if_bxe.4= if_bxe.4
  • projects/clang1000-import/stand/efi/libefi/efi_driver_utils.c

     
    52 52 }
    53 53
    54 54 handles = malloc(hsize);
    55 if (handles == NULL)
    56 return (EFI_OUT_OF_RESOURCES);
    55 57 nhandles = hsize / sizeof(EFI_HANDLE);
    56 58
    57 59 status = BS->LocateHandle(ByProtocol, filter, NULL,
  • projects/clang1000-import/stand/efi/libefi/efihttp.c

     
    701 701 return (0);
    702 702 if (where == SEEK_SET && fh->offset < offset) {
    703 703 buf = malloc(1500);
    704 if (buf == NULL)
    705 return (ENOMEM);
    704 706 res = offset - fh->offset;
    705 707 while (res > 0) {
    706 708 err = _efihttp_fs_read(f, buf, min(1500, res), &res2);
  • projects/clang1000-import/stand/efi/libefi/efinet.c

     
    371 371 status = BS->LocateHandle(ByProtocol, &sn_guid, NULL, &sz, NULL);
    372 372 if (status == EFI_BUFFER_TOO_SMALL) {
    373 373 handles = (EFI_HANDLE *)malloc(sz);
    374 if (handles == NULL)
    375 return (ENOMEM);
    374 376 status = BS->LocateHandle(ByProtocol, &sn_guid, NULL, &sz,
    375 377 handles);
    376 378 if (EFI_ERROR(status))
  • projects/clang1000-import/stand/efi/libefi/efipart.c

     
    363 363 status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin);
    364 364 if (status == EFI_BUFFER_TOO_SMALL) {
    365 365 hin = malloc(sz);
    366 if (hin == NULL)
    367 return (ENOMEM);
    366 368 status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz,
    367 369 hin);
    368 370 if (EFI_ERROR(status))
  • projects/clang1000-import/stand/efi/libefi/efizfs.c

     
    86 86 zfsinfo_t *zi;
    87 87
    88 88 zi = malloc(sizeof(zfsinfo_t));
    89 zi->zi_handle = handle;
    90 zi->zi_pool_guid = guid;
    91 STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link);
    89 if (zi != NULL) {
    90 zi->zi_handle = handle;
    91 zi->zi_pool_guid = guid;
    92 STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link);
    93 }
    92 94 }
    93 95
    94 96 void
  • projects/clang1000-import/stand/efi/libefi/handles.c

     
    52 52 nentries += count;
    53 53 sz = nentries * sizeof(struct entry);
    54 54 entry = (entry == NULL) ? malloc(sz) : realloc(entry, sz);
    55 if (entry == NULL)
    56 return (ENOMEM);
    55 57 for (unit = 0; idx < nentries; idx++, unit++) {
    56 58 entry[idx].handle = handles[unit];
    57 59 if (aliases != NULL)
  • projects/clang1000-import/stand/efi/loader/main.c

     
    852 852 }
    853 853 }
    854 854
    855 caddr_t
    856 ptov(uintptr_t x)
    857 {
    858 return ((caddr_t)x);
    859 }
    855 860
    856
    857 861 EFI_STATUS
    858 862 main(int argc, CHAR16 *argv[])
    859 863 {
  • projects/clang1000-import/stand/efi/loader/Makefile

     
    22 22 framebuffer.c \
    23 23 main.c \
    24 24 self_reloc.c \
    25 smbios.c \
    26 25 vers.c
    27 26
    28 27 CFLAGS+= -I${.CURDIR}/../loader
     
    45 44
    46 45 .PATH: ${.CURDIR}/../loader
    47 46 .PATH: ${.CURDIR}/../loader/arch/${MACHINE}
    48 # For smbios.c XXX need to abstract properly
    49 .PATH: ${BOOTSRC}/i386/libi386
    50 47 .include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc"
    51 48
    52 49 CFLAGS+= -I${.CURDIR}
     
    57 54 CFLAGS+= -I${BOOTSRC}/i386/libi386
    58 55 CFLAGS+= -DEFI
    59 56
    60 .if !defined(BOOT_HIDE_SERIAL_NUMBERS)
    61 # Export serial numbers, UUID, and asset tag from loader.
    62 CFLAGS+= -DSMBIOS_SERIAL_NUMBERS
    63 .if defined(BOOT_LITTLE_ENDIAN_UUID)
    64 # Use little-endian UUID format as defined in SMBIOS 2.6.
    65 CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
    66 .elif defined(BOOT_NETWORK_ENDIAN_UUID)
    67 # Use network-endian UUID format for backward compatibility.
    68 CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
    69 .endif
    70 .endif
    71
    72 57 .if defined(HAVE_FDT) && ${MK_FDT} != "no"
    73 58 .include "${BOOTSRC}/fdt.mk"
    74 59 LIBEFI_FDT= ${BOOTOBJ}/efi/fdt/libefi_fdt.a
  • projects/clang1000-import/stand/i386/libi386/Makefile

     
    9 9 comconsole.c devicename.c elf32_freebsd.c \
    10 10 elf64_freebsd.c multiboot.c multiboot_tramp.S relocater_tramp.S \
    11 11 i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.S \
    12 smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c
    12 time.c vidconsole.c amd64_tramp.S spinconsole.c
    13 13 .PATH: ${ZFSSRC}
    14 14 SRCS+= devicename_stubs.c
    15 15 CFLAGS+= -I${ZFSSRC}
     
    28 28 CFLAGS+= -DDISK_DEBUG
    29 29 .endif
    30 30
    31 .if !defined(BOOT_HIDE_SERIAL_NUMBERS)
    32 # Export serial numbers, UUID, and asset tag from loader.
    33 CFLAGS+= -DSMBIOS_SERIAL_NUMBERS
    34 .if defined(BOOT_LITTLE_ENDIAN_UUID)
    35 # Use little-endian UUID format as defined in SMBIOS 2.6.
    36 CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
    37 .elif defined(BOOT_NETWORK_ENDIAN_UUID)
    38 # Use network-endian UUID format for backward compatibility.
    39 CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
    40 .endif
    41 .endif
    42
    43 31 # terminal emulation
    44 32 CFLAGS.vidconsole.c+= -I${SRCTOP}/sys/teken
    45 33 CFLAGS.teken.c+= -I${SRCTOP}/sys/teken
  • projects/clang1000-import/stand/i386/libi386/smbios.c

     
    1 /*-
    2 * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
    3 * All rights reserved.
    4 *
    5 * Redistribution and use in source and binary forms, with or without
    6 * modification, are permitted provided that the following conditions
    7 * are met:
    8 * 1. Redistributions of source code must retain the above copyright
    9 * notice, this list of conditions and the following disclaimer.
    10 * 2. Redistributions in binary form must reproduce the above copyright
    11 * notice, this list of conditions and the following disclaimer in the
    12 * documentation and/or other materials provided with the distribution.
    13 *
    14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    24 * SUCH DAMAGE.
    25 */
    26
    27 #include <sys/cdefs.h>
    28 __FBSDID("$FreeBSD$");
    29
    30 #include <stand.h>
    31 #include <bootstrap.h>
    32 #include <sys/endian.h>
    33
    34 #ifdef EFI
    35 /* In EFI, we don't need PTOV(). */
    36 #define PTOV(x) (caddr_t)(x)
    37 #else
    38 #include "btxv86.h"
    39 #endif
    40 #include "smbios.h"
    41
    42 /*
    43 * Detect SMBIOS and export information about the SMBIOS into the
    44 * environment.
    45 *
    46 * System Management BIOS Reference Specification, v2.6 Final
    47 * http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf
    48 */
    49
    50 /*
    51 * 2.1.1 SMBIOS Structure Table Entry Point
    52 *
    53 * "On non-EFI systems, the SMBIOS Entry Point structure, described below, can
    54 * be located by application software by searching for the anchor-string on
    55 * paragraph (16-byte) boundaries within the physical memory address range
    56 * 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate anchor
    57 * string that is used by some existing DMI browsers."
    58 */
    59 #define SMBIOS_START 0xf0000
    60 #define SMBIOS_LENGTH 0x10000
    61 #define SMBIOS_STEP 0x10
    62 #define SMBIOS_SIG "_SM_"
    63 #define SMBIOS_DMI_SIG "_DMI_"
    64
    65 #define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off)))
    66 #define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off)))
    67 #define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off)))
    68
    69 #define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01)
    70 #define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base))
    71
    72 struct smbios_attr {
    73 int probed;
    74 caddr_t addr;
    75 size_t length;
    76 size_t count;
    77 int major;
    78 int minor;
    79 int ver;
    80 const char* bios_vendor;
    81 const char* maker;
    82 const char* product;
    83 uint32_t enabled_memory;
    84 uint32_t old_enabled_memory;
    85 uint8_t enabled_sockets;
    86 uint8_t populated_sockets;
    87 };
    88
    89 static struct smbios_attr smbios;
    90
    91 static uint8_t
    92 smbios_checksum(const caddr_t addr, const uint8_t len)
    93 {
    94 uint8_t sum;
    95 int i;
    96
    97 for (sum = 0, i = 0; i < len; i++)
    98 sum += SMBIOS_GET8(addr, i);
    99 return (sum);
    100 }
    101
    102 static caddr_t
    103 smbios_sigsearch(const caddr_t addr, const uint32_t len)
    104 {
    105 caddr_t cp;
    106
    107 /* Search on 16-byte boundaries. */
    108 for (cp = addr; cp < addr + len; cp += SMBIOS_STEP)
    109 if (strncmp(cp, SMBIOS_SIG, 4) == 0 &&
    110 smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 &&
    111 strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 &&
    112 smbios_checksum(cp + 0x10, 0x0f) == 0)
    113 return (cp);
    114 return (NULL);
    115 }
    116
    117 static const char*
    118 smbios_getstring(caddr_t addr, const int offset)
    119 {
    120 caddr_t cp;
    121 int i, idx;
    122
    123 idx = SMBIOS_GET8(addr, offset);
    124 if (idx != 0) {
    125 cp = SMBIOS_GETSTR(addr);
    126 for (i = 1; i < idx; i++)
    127 cp += strlen(cp) + 1;
    128 return cp;
    129 }
    130 return (NULL);
    131 }
    132
    133 static void
    134 smbios_setenv(const char *name, caddr_t addr, const int offset)
    135 {
    136 const char* val;
    137
    138 val = smbios_getstring(addr, offset);
    139 if (val != NULL)
    140 setenv(name, val, 1);
    141 }
    142
    143 #ifdef SMBIOS_SERIAL_NUMBERS
    144
    145 #define UUID_SIZE 16
    146 #define UUID_TYPE uint32_t
    147 #define UUID_STEP sizeof(UUID_TYPE)
    148 #define UUID_ALL_BITS (UUID_SIZE / UUID_STEP)
    149 #define UUID_GET(base, off) (*(UUID_TYPE *)((base) + (off)))
    150
    151 static void
    152 smbios_setuuid(const char *name, const caddr_t addr, const int ver)
    153 {
    154 char uuid[37];
    155 int byteorder, i, ones, zeros;
    156 UUID_TYPE n;
    157 uint32_t f1;
    158 uint16_t f2, f3;
    159
    160 for (i = 0, ones = 0, zeros = 0; i < UUID_SIZE; i += UUID_STEP) {
    161 n = UUID_GET(addr, i) + 1;
    162 if (zeros == 0 && n == 0)
    163 ones++;
    164 else if (ones == 0 && n == 1)
    165 zeros++;
    166 else
    167 break;
    168 }
    169
    170 if (ones != UUID_ALL_BITS && zeros != UUID_ALL_BITS) {
    171 /*
    172 * 3.3.2.1 System UUID
    173 *
    174 * "Although RFC 4122 recommends network byte order for all
    175 * fields, the PC industry (including the ACPI, UEFI, and
    176 * Microsoft specifications) has consistently used
    177 * little-endian byte encoding for the first three fields:
    178 * time_low, time_mid, time_hi_and_version. The same encoding,
    179 * also known as wire format, should also be used for the
    180 * SMBIOS representation of the UUID."
    181 *
    182 * Note: We use network byte order for backward compatibility
    183 * unless SMBIOS version is 2.6+ or little-endian is forced.
    184 */
    185 #if defined(SMBIOS_LITTLE_ENDIAN_UUID)
    186 byteorder = LITTLE_ENDIAN;
    187 #elif defined(SMBIOS_NETWORK_ENDIAN_UUID)
    188 byteorder = BIG_ENDIAN;
    189 #else
    190 byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN;
    191 #endif
    192 if (byteorder != LITTLE_ENDIAN) {
    193 f1 = ntohl(SMBIOS_GET32(addr, 0));
    194 f2 = ntohs(SMBIOS_GET16(addr, 4));
    195 f3 = ntohs(SMBIOS_GET16(addr, 6));
    196 } else {
    197 f1 = le32toh(SMBIOS_GET32(addr, 0));
    198 f2 = le16toh(SMBIOS_GET16(addr, 4));
    199 f3 = le16toh(SMBIOS_GET16(addr, 6));
    200 }
    201 sprintf(uuid,
    202 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
    203 f1, f2, f3, SMBIOS_GET8(addr, 8), SMBIOS_GET8(addr, 9),
    204 SMBIOS_GET8(addr, 10), SMBIOS_GET8(addr, 11),
    205 SMBIOS_GET8(addr, 12), SMBIOS_GET8(addr, 13),
    206 SMBIOS_GET8(addr, 14), SMBIOS_GET8(addr, 15));
    207 setenv(name, uuid, 1);
    208 }
    209 }
    210
    211 #undef UUID_SIZE
    212 #undef UUID_TYPE
    213 #undef UUID_STEP
    214 #undef UUID_ALL_BITS
    215 #undef UUID_GET
    216
    217 #endif
    218
    219 static caddr_t
    220 smbios_parse_table(const caddr_t addr)
    221 {
    222 caddr_t cp;
    223 int proc, size, osize, type;
    224
    225 type = SMBIOS_GET8(addr, 0); /* 3.1.2 Structure Header Format */
    226 switch(type) {
    227 case 0: /* 3.3.1 BIOS Information (Type 0) */
    228 smbios_setenv("smbios.bios.vendor", addr, 0x04);
    229 smbios_setenv("smbios.bios.version", addr, 0x05);
    230 smbios_setenv("smbios.bios.reldate", addr, 0x08);
    231 break;
    232
    233 case 1: /* 3.3.2 System Information (Type 1) */
    234 smbios_setenv("smbios.system.maker", addr, 0x04);
    235 smbios_setenv("smbios.system.product", addr, 0x05);
    236 smbios_setenv("smbios.system.version", addr, 0x06);
    237 #ifdef SMBIOS_SERIAL_NUMBERS
    238 smbios_setenv("smbios.system.serial", addr, 0x07);
    239 smbios_setuuid("smbios.system.uuid", addr + 0x08, smbios.ver);
    240 #endif
    241 if (smbios.major > 2 ||
    242 (smbios.major == 2 && smbios.minor >= 4)) {
    243 smbios_setenv("smbios.system.sku", addr, 0x19);
    244 smbios_setenv("smbios.system.family", addr, 0x1a);
    245 }
    246 break;
    247
    248 case 2: /* 3.3.3 Base Board (or Module) Information (Type 2) */
    249 smbios_setenv("smbios.planar.maker", addr, 0x04);
    250 smbios_setenv("smbios.planar.product", addr, 0x05);
    251 smbios_setenv("smbios.planar.version", addr, 0x06);
    252 #ifdef SMBIOS_SERIAL_NUMBERS
    253 smbios_setenv("smbios.planar.serial", addr, 0x07);
    254 smbios_setenv("smbios.planar.tag", addr, 0x08);
    255 #endif
    256 smbios_setenv("smbios.planar.location", addr, 0x0a);
    257 break;
    258
    259 case 3: /* 3.3.4 System Enclosure or Chassis (Type 3) */
    260 smbios_setenv("smbios.chassis.maker", addr, 0x04);
    261 smbios_setenv("smbios.chassis.version", addr, 0x06);
    262 #ifdef SMBIOS_SERIAL_NUMBERS
    263 smbios_setenv("smbios.chassis.serial", addr, 0x07);
    264 smbios_setenv("smbios.chassis.tag", addr, 0x08);
    265 #endif
    266 break;
    267
    268 case 4: /* 3.3.5 Processor Information (Type 4) */
    269 /*
    270 * Offset 18h: Processor Status
    271 *
    272 * Bit 7 Reserved, must be 0
    273 * Bit 6 CPU Socket Populated
    274 * 1 - CPU Socket Populated
    275 * 0 - CPU Socket Unpopulated
    276 * Bit 5:3 Reserved, must be zero
    277 * Bit 2:0 CPU Status
    278 * 0h - Unknown
    279 * 1h - CPU Enabled
    280 * 2h - CPU Disabled by User via BIOS Setup
    281 * 3h - CPU Disabled by BIOS (POST Error)
    282 * 4h - CPU is Idle, waiting to be enabled
    283 * 5-6h - Reserved
    284 * 7h - Other
    285 */
    286 proc = SMBIOS_GET8(addr, 0x18);
    287 if ((proc & 0x07) == 1)
    288 smbios.enabled_sockets++;
    289 if ((proc & 0x40) != 0)
    290 smbios.populated_sockets++;
    291 break;
    292
    293 case 6: /* 3.3.7 Memory Module Information (Type 6, Obsolete) */
    294 /*
    295 * Offset 0Ah: Enabled Size
    296 *
    297 * Bit 7 Bank connection
    298 * 1 - Double-bank connection
    299 * 0 - Single-bank connection
    300 * Bit 6:0 Size (n), where 2**n is the size in MB
    301 * 7Dh - Not determinable (Installed Size only)
    302 * 7Eh - Module is installed, but no memory
    303 * has been enabled
    304 * 7Fh - Not installed
    305 */
    306 osize = SMBIOS_GET8(addr, 0x0a) & 0x7f;
    307 if (osize > 0 && osize < 22)
    308 smbios.old_enabled_memory += 1 << (osize + 10);
    309 break;
    310
    311 case 17: /* 3.3.18 Memory Device (Type 17) */
    312 /*
    313 * Offset 0Ch: Size
    314 *
    315 * Bit 15 Granularity
    316 * 1 - Value is in kilobytes units
    317 * 0 - Value is in megabytes units
    318 * Bit 14:0 Size
    319 */
    320 size = SMBIOS_GET16(addr, 0x0c);
    321 if (size != 0 && size != 0xffff)
    322 smbios.enabled_memory += (size & 0x8000) != 0 ?
    323 (size & 0x7fff) : (size << 10);
    324 break;
    325
    326 default: /* skip other types */
    327 break;
    328 }
    329
    330 /* Find structure terminator. */
    331 cp = SMBIOS_GETSTR(addr);
    332 while (SMBIOS_GET16(cp, 0) != 0)
    333 cp++;
    334
    335 return (cp + 2);
    336 }
    337
    338 static caddr_t
    339 smbios_find_struct(int type)
    340 {
    341 caddr_t dmi;
    342 size_t i;
    343
    344 if (smbios.addr == NULL)
    345 return (NULL);
    346
    347 for (dmi = smbios.addr, i = 0;
    348 dmi < smbios.addr + smbios.length && i < smbios.count; i++) {
    349 if (SMBIOS_GET8(dmi, 0) == type)
    350 return dmi;
    351 /* Find structure terminator. */
    352 dmi = SMBIOS_GETSTR(dmi);
    353 while (SMBIOS_GET16(dmi, 0) != 0)
    354 dmi++;
    355 dmi += 2;
    356 }
    357
    358 return (NULL);
    359 }
    360
    361 static void
    362 smbios_probe(const caddr_t addr)
    363 {
    364 caddr_t saddr, info;
    365 uintptr_t paddr;
    366
    367 if (smbios.probed)
    368 return;
    369 smbios.probed = 1;
    370
    371 /* Search signatures and validate checksums. */
    372 saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START),
    373 SMBIOS_LENGTH);
    374 if (saddr == NULL)
    375 return;
    376
    377 smbios.length = SMBIOS_GET16(saddr, 0x16); /* Structure Table Length */
    378 paddr = SMBIOS_GET32(saddr, 0x18); /* Structure Table Address */
    379 smbios.count = SMBIOS_GET16(saddr, 0x1c); /* No of SMBIOS Structures */
    380 smbios.ver = SMBIOS_GET8(saddr, 0x1e); /* SMBIOS BCD Revision */
    381
    382 if (smbios.ver != 0) {
    383 smbios.major = smbios.ver >> 4;
    384 smbios.minor = smbios.ver & 0x0f;
    385 if (smbios.major > 9 || smbios.minor > 9)
    386 smbios.ver = 0;
    387 }
    388 if (smbios.ver == 0) {
    389 smbios.major = SMBIOS_GET8(saddr, 0x06);/* SMBIOS Major Version */
    390 smbios.minor = SMBIOS_GET8(saddr, 0x07);/* SMBIOS Minor Version */
    391 }
    392 smbios.ver = (smbios.major << 8) | smbios.minor;
    393 smbios.addr = PTOV(paddr);
    394
    395 /* Get system information from SMBIOS */
    396 info = smbios_find_struct(0x00);
    397 if (info != NULL) {
    398 smbios.bios_vendor = smbios_getstring(info, 0x04);
    399 }
    400 info = smbios_find_struct(0x01);
    401 if (info != NULL) {
    402 smbios.maker = smbios_getstring(info, 0x04);
    403 smbios.product = smbios_getstring(info, 0x05);
    404 }
    405 }
    406
    407 void
    408 smbios_detect(const caddr_t addr)
    409 {
    410 char buf[16];
    411 caddr_t dmi;
    412 size_t i;
    413
    414 smbios_probe(addr);
    415 if (smbios.addr == NULL)
    416 return;
    417
    418 for (dmi = smbios.addr, i = 0;
    419 dmi < smbios.addr + smbios.length && i < smbios.count; i++)
    420 dmi = smbios_parse_table(dmi);
    421
    422 sprintf(buf, "%d.%d", smbios.major, smbios.minor);
    423 setenv("smbios.version", buf, 1);
    424 if (smbios.enabled_memory > 0 || smbios.old_enabled_memory > 0) {
    425 sprintf(buf, "%u", smbios.enabled_memory > 0 ?
    426 smbios.enabled_memory : smbios.old_enabled_memory);
    427 setenv("smbios.memory.enabled", buf, 1);
    428 }
    429 if (smbios.enabled_sockets > 0) {
    430 sprintf(buf, "%u", smbios.enabled_sockets);
    431 setenv("smbios.socket.enabled", buf, 1);
    432 }
    433 if (smbios.populated_sockets > 0) {
    434 sprintf(buf, "%u", smbios.populated_sockets);
    435 setenv("smbios.socket.populated", buf, 1);
    436 }
    437 }
    438
    439 static int
    440 smbios_match_str(const char* s1, const char* s2)
    441 {
    442 return (s1 == NULL || (s2 != NULL && !strcmp(s1, s2)));
    443 }
    444
    445 int
    446 smbios_match(const char* bios_vendor, const char* maker,
    447 const char* product)
    448 {
    449 /* XXXRP currently, only called from non-EFI. */
    450 smbios_probe(NULL);
    451 return (smbios_match_str(bios_vendor, smbios.bios_vendor) &&
    452 smbios_match_str(maker, smbios.maker) &&
    453 smbios_match_str(product, smbios.product));
    454 }
  • projects/clang1000-import/stand/i386/libi386/smbios.h

     
    1 /*-
    2 * Copyright (c) 2015 Rui Paulo <rpaulo@FreeBSD.org>
    3 * All rights reserved.
    4 *
    5 * Redistribution and use in source and binary forms, with or without
    6 * modification, are permitted provided that the following conditions
    7 * are met:
    8 * 1. Redistributions of source code must retain the above copyright
    9 * notice, this list of conditions and the following disclaimer.
    10 * 2. Redistributions in binary form must reproduce the above copyright
    11 * notice, this list of conditions and the following disclaimer in the
    12 * documentation and/or other materials provided with the distribution.
    13 *
    14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    17 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    22 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    23 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    24 * POSSIBILITY OF SUCH DAMAGE.
    25 *
    26 * $FreeBSD$
    27 */
    28 #ifndef _SMBIOS_H_
    29 #define _SMBIOS_H_
    30
    31 void smbios_detect(const caddr_t);
    32 int smbios_match(const char *, const char *, const char *);
    33
    34 #endif /* _SMBIOS_H_ */
  • projects/clang1000-import/stand/i386/loader/main.c

     
    45 45 #include "bootstrap.h"
    46 46 #include "common/bootargs.h"
    47 47 #include "libi386/libi386.h"
    48 #include "libi386/smbios.h"
    48 #include <smbios.h>
    49 49 #include "btxv86.h"
    50 50
    51 51 #ifdef LOADER_ZFS_SUPPORT
     
    86 86 static void *heap_top;
    87 87 static void *heap_bottom;
    88 88
    89 caddr_t
    90 ptov(uintptr_t x)
    91 {
    92 return (PTOV(x));
    93 }
    94
    89 95 int
    90 96 main(void)
    91 97 {
  • projects/clang1000-import/stand/libsa/Makefile

     
    137 137 SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
    138 138 fstat.c close.c lseek.c open.c read.c write.c readdir.c
    139 139
    140 # SMBios routines
    141 SRCS+= smbios.c
    142 .if !defined(BOOT_HIDE_SERIAL_NUMBERS)
    143 # Export serial numbers, UUID, and asset tag from loader.
    144 CFLAGS.smbios.c+= -DSMBIOS_SERIAL_NUMBERS
    145 .if defined(BOOT_LITTLE_ENDIAN_UUID)
    146 # Use little-endian UUID format as defined in SMBIOS 2.6.
    147 CFLAGS.smbios.c+= -DSMBIOS_LITTLE_ENDIAN_UUID
    148 .elif defined(BOOT_NETWORK_ENDIAN_UUID)
    149 # Use network-endian UUID format for backward compatibility.
    150 CFLAGS.smbios.c+= -DSMBIOS_NETWORK_ENDIAN_UUID
    151 .endif
    152 .endif
    153
    140 154 # network routines
    141 155 SRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
    142 156
  • projects/clang1000-import/stand/libsa/smbios.c

     
    1 /*-
    2 * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
    3 * All rights reserved.
    4 *
    5 * Redistribution and use in source and binary forms, with or without
    6 * modification, are permitted provided that the following conditions
    7 * are met:
    8 * 1. Redistributions of source code must retain the above copyright
    9 * notice, this list of conditions and the following disclaimer.
    10 * 2. Redistributions in binary form must reproduce the above copyright
    11 * notice, this list of conditions and the following disclaimer in the
    12 * documentation and/or other materials provided with the distribution.
    13 *
    14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    24 * SUCH DAMAGE.
    25 */
    26
    27 #include <sys/cdefs.h>
    28 __FBSDID("$FreeBSD$");
    29
    30 #include <stand.h>
    31 #include <sys/endian.h>
    32
    33 #define PTOV(x) ptov(x)
    34
    35 /*
    36 * Detect SMBIOS and export information about the SMBIOS into the
    37 * environment.
    38 *
    39 * System Management BIOS Reference Specification, v2.6 Final
    40 * http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf
    41 */
    42
    43 /*
    44 * 2.1.1 SMBIOS Structure Table Entry Point
    45 *
    46 * "On non-EFI systems, the SMBIOS Entry Point structure, described below, can
    47 * be located by application software by searching for the anchor-string on
    48 * paragraph (16-byte) boundaries within the physical memory address range
    49 * 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate anchor
    50 * string that is used by some existing DMI browsers."
    51 */
    52 #define SMBIOS_START 0xf0000
    53 #define SMBIOS_LENGTH 0x10000
    54 #define SMBIOS_STEP 0x10
    55 #define SMBIOS_SIG "_SM_"
    56 #define SMBIOS_DMI_SIG "_DMI_"
    57
    58 #define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off)))
    59 #define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off)))
    60 #define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off)))
    61
    62 #define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01)
    63 #define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base))
    64
    65 struct smbios_attr {
    66 int probed;
    67 caddr_t addr;
    68 size_t length;
    69 size_t count;
    70 int major;
    71 int minor;
    72 int ver;
    73 const char* bios_vendor;
    74 const char* maker;
    75 const char* product;
    76 uint32_t enabled_memory;
    77 uint32_t old_enabled_memory;
    78 uint8_t enabled_sockets;
    79 uint8_t populated_sockets;
    80 };
    81
    82 static struct smbios_attr smbios;
    83
    84 static uint8_t
    85 smbios_checksum(const caddr_t addr, const uint8_t len)
    86 {
    87 uint8_t sum;
    88 int i;
    89
    90 for (sum = 0, i = 0; i < len; i++)
    91 sum += SMBIOS_GET8(addr, i);
    92 return (sum);
    93 }
    94
    95 static caddr_t
    96 smbios_sigsearch(const caddr_t addr, const uint32_t len)
    97 {
    98 caddr_t cp;
    99
    100 /* Search on 16-byte boundaries. */
    101 for (cp = addr; cp < addr + len; cp += SMBIOS_STEP)
    102 if (strncmp(cp, SMBIOS_SIG, 4) == 0 &&
    103 smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 &&
    104 strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 &&
    105 smbios_checksum(cp + 0x10, 0x0f) == 0)
    106 return (cp);
    107 return (NULL);
    108 }
    109
    110 static const char*
    111 smbios_getstring(caddr_t addr, const int offset)
    112 {
    113 caddr_t cp;
    114 int i, idx;
    115
    116 idx = SMBIOS_GET8(addr, offset);
    117 if (idx != 0) {
    118 cp = SMBIOS_GETSTR(addr);
    119 for (i = 1; i < idx; i++)
    120 cp += strlen(cp) + 1;
    121 return cp;
    122 }
    123 return (NULL);
    124 }
    125
    126 static void
    127 smbios_setenv(const char *name, caddr_t addr, const int offset)
    128 {
    129 const char* val;
    130
    131 val = smbios_getstring(addr, offset);
    132 if (val != NULL)
    133 setenv(name, val, 1);
    134 }
    135
    136 #ifdef SMBIOS_SERIAL_NUMBERS
    137
    138 #define UUID_SIZE 16
    139 #define UUID_TYPE uint32_t
    140 #define UUID_STEP sizeof(UUID_TYPE)
    141 #define UUID_ALL_BITS (UUID_SIZE / UUID_STEP)
    142 #define UUID_GET(base, off) (*(UUID_TYPE *)((base) + (off)))
    143
    144 static void
    145 smbios_setuuid(const char *name, const caddr_t addr, const int ver)
    146 {
    147 char uuid[37];
    148 int byteorder, i, ones, zeros;
    149 UUID_TYPE n;
    150 uint32_t f1;
    151 uint16_t f2, f3;
    152
    153 for (i = 0, ones = 0, zeros = 0; i < UUID_SIZE; i += UUID_STEP) {
    154 n = UUID_GET(addr, i) + 1;
    155 if (zeros == 0 && n == 0)
    156 ones++;
    157 else if (ones == 0 && n == 1)
    158 zeros++;
    159 else
    160 break;
    161 }
    162
    163 if (ones != UUID_ALL_BITS && zeros != UUID_ALL_BITS) {
    164 /*
    165 * 3.3.2.1 System UUID
    166 *
    167 * "Although RFC 4122 recommends network byte order for all
    168 * fields, the PC industry (including the ACPI, UEFI, and
    169 * Microsoft specifications) has consistently used
    170 * little-endian byte encoding for the first three fields:
    171 * time_low, time_mid, time_hi_and_version. The same encoding,
    172 * also known as wire format, should also be used for the
    173 * SMBIOS representation of the UUID."
    174 *
    175 * Note: We use network byte order for backward compatibility
    176 * unless SMBIOS version is 2.6+ or little-endian is forced.
    177 */
    178 #if defined(SMBIOS_LITTLE_ENDIAN_UUID)
    179 byteorder = LITTLE_ENDIAN;
    180 #elif defined(SMBIOS_NETWORK_ENDIAN_UUID)
    181 byteorder = BIG_ENDIAN;
    182 #else
    183 byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN;
    184 #endif
    185 if (byteorder != LITTLE_ENDIAN) {
    186 f1 = ntohl(SMBIOS_GET32(addr, 0));
    187 f2 = ntohs(SMBIOS_GET16(addr, 4));
    188 f3 = ntohs(SMBIOS_GET16(addr, 6));
    189 } else {
    190 f1 = le32toh(SMBIOS_GET32(addr, 0));
    191 f2 = le16toh(SMBIOS_GET16(addr, 4));
    192 f3 = le16toh(SMBIOS_GET16(addr, 6));
    193 }
    194 sprintf(uuid,
    195 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
    196 f1, f2, f3, SMBIOS_GET8(addr, 8), SMBIOS_GET8(addr, 9),
    197 SMBIOS_GET8(addr, 10), SMBIOS_GET8(addr, 11),
    198 SMBIOS_GET8(addr, 12), SMBIOS_GET8(addr, 13),
    199 SMBIOS_GET8(addr, 14), SMBIOS_GET8(addr, 15));
    200 setenv(name, uuid, 1);
    201 }
    202 }
    203
    204 #undef UUID_SIZE
    205 #undef UUID_TYPE
    206 #undef UUID_STEP
    207 #undef UUID_ALL_BITS
    208 #undef UUID_GET
    209
    210 #endif
    211
    212 static caddr_t
    213 smbios_parse_table(const caddr_t addr)
    214 {
    215 caddr_t cp;
    216 int proc, size, osize, type;
    217
    218 type = SMBIOS_GET8(addr, 0); /* 3.1.2 Structure Header Format */
    219 switch(type) {
    220 case 0: /* 3.3.1 BIOS Information (Type 0) */
    221 smbios_setenv("smbios.bios.vendor", addr, 0x04);
    222 smbios_setenv("smbios.bios.version", addr, 0x05);
    223 smbios_setenv("smbios.bios.reldate", addr, 0x08);
    224 break;
    225
    226 case 1: /* 3.3.2 System Information (Type 1) */
    227 smbios_setenv("smbios.system.maker", addr, 0x04);
    228 smbios_setenv("smbios.system.product", addr, 0x05);
    229 smbios_setenv("smbios.system.version", addr, 0x06);
    230 #ifdef SMBIOS_SERIAL_NUMBERS
    231 smbios_setenv("smbios.system.serial", addr, 0x07);
    232 smbios_setuuid("smbios.system.uuid", addr + 0x08, smbios.ver);
    233 #endif
    234 if (smbios.major > 2 ||
    235 (smbios.major == 2 && smbios.minor >= 4)) {
    236 smbios_setenv("smbios.system.sku", addr, 0x19);
    237 smbios_setenv("smbios.system.family", addr, 0x1a);
    238 }
    239 break;
    240
    241 case 2: /* 3.3.3 Base Board (or Module) Information (Type 2) */
    242 smbios_setenv("smbios.planar.maker", addr, 0x04);
    243 smbios_setenv("smbios.planar.product", addr, 0x05);
    244 smbios_setenv("smbios.planar.version", addr, 0x06);
    245 #ifdef SMBIOS_SERIAL_NUMBERS
    246 smbios_setenv("smbios.planar.serial", addr, 0x07);
    247 smbios_setenv("smbios.planar.tag", addr, 0x08);
    248 #endif
    249 smbios_setenv("smbios.planar.location", addr, 0x0a);
    250 break;
    251
    252 case 3: /* 3.3.4 System Enclosure or Chassis (Type 3) */
    253 smbios_setenv("smbios.chassis.maker", addr, 0x04);
    254 smbios_setenv("smbios.chassis.version", addr, 0x06);
    255 #ifdef SMBIOS_SERIAL_NUMBERS
    256 smbios_setenv("smbios.chassis.serial", addr, 0x07);
    257 smbios_setenv("smbios.chassis.tag", addr, 0x08);
    258 #endif
    259 break;
    260
    261 case 4: /* 3.3.5 Processor Information (Type 4) */
    262 /*
    263 * Offset 18h: Processor Status
    264 *
    265 * Bit 7 Reserved, must be 0
    266 * Bit 6 CPU Socket Populated
    267 * 1 - CPU Socket Populated
    268 * 0 - CPU Socket Unpopulated
    269 * Bit 5:3 Reserved, must be zero
    270 * Bit 2:0 CPU Status
    271 * 0h - Unknown
    272 * 1h - CPU Enabled
    273 * 2h - CPU Disabled by User via BIOS Setup
    274 * 3h - CPU Disabled by BIOS (POST Error)
    275 * 4h - CPU is Idle, waiting to be enabled
    276 * 5-6h - Reserved
    277 * 7h - Other
    278 */
    279 proc = SMBIOS_GET8(addr, 0x18);
    280 if ((proc & 0x07) == 1)
    281 smbios.enabled_sockets++;
    282 if ((proc & 0x40) != 0)
    283 smbios.populated_sockets++;
    284 break;
    285
    286 case 6: /* 3.3.7 Memory Module Information (Type 6, Obsolete) */
    287 /*
    288 * Offset 0Ah: Enabled Size
    289 *
    290 * Bit 7 Bank connection
    291 * 1 - Double-bank connection
    292 * 0 - Single-bank connection
    293 * Bit 6:0 Size (n), where 2**n is the size in MB
    294 * 7Dh - Not determinable (Installed Size only)
    295 * 7Eh - Module is installed, but no memory
    296 * has been enabled
    297 * 7Fh - Not installed
    298 */
    299 osize = SMBIOS_GET8(addr, 0x0a) & 0x7f;
    300 if (osize > 0 && osize < 22)
    301 smbios.old_enabled_memory += 1 << (osize + 10);
    302 break;
    303
    304 case 17: /* 3.3.18 Memory Device (Type 17) */
    305 /*
    306 * Offset 0Ch: Size
    307 *
    308 * Bit 15 Granularity
    309 * 1 - Value is in kilobytes units
    310 * 0 - Value is in megabytes units
    311 * Bit 14:0 Size
    312 */
    313 size = SMBIOS_GET16(addr, 0x0c);
    314 if (size != 0 && size != 0xffff)
    315 smbios.enabled_memory += (size & 0x8000) != 0 ?
    316 (size & 0x7fff) : (size << 10);
    317 break;
    318
    319 default: /* skip other types */
    320 break;
    321 }
    322
    323 /* Find structure terminator. */
    324 cp = SMBIOS_GETSTR(addr);
    325 while (SMBIOS_GET16(cp, 0) != 0)
    326 cp++;
    327
    328 return (cp + 2);
    329 }
    330
    331 static caddr_t
    332 smbios_find_struct(int type)
    333 {
    334 caddr_t dmi;
    335 size_t i;
    336
    337 if (smbios.addr == NULL)
    338 return (NULL);
    339
    340 for (dmi = smbios.addr, i = 0;
    341 dmi < smbios.addr + smbios.length && i < smbios.count; i++) {
    342 if (SMBIOS_GET8(dmi, 0) == type)
    343 return dmi;
    344 /* Find structure terminator. */
    345 dmi = SMBIOS_GETSTR(dmi);
    346 while (SMBIOS_GET16(dmi, 0) != 0)
    347 dmi++;
    348 dmi += 2;
    349 }
    350
    351 return (NULL);
    352 }
    353
    354 static void
    355 smbios_probe(const caddr_t addr)
    356 {
    357 caddr_t saddr, info;
    358 uintptr_t paddr;
    359
    360 if (smbios.probed)
    361 return;
    362 smbios.probed = 1;
    363
    364 /* Search signatures and validate checksums. */
    365 saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START),
    366 SMBIOS_LENGTH);
    367 if (saddr == NULL)
    368 return;
    369
    370 smbios.length = SMBIOS_GET16(saddr, 0x16); /* Structure Table Length */
    371 paddr = SMBIOS_GET32(saddr, 0x18); /* Structure Table Address */
    372 smbios.count = SMBIOS_GET16(saddr, 0x1c); /* No of SMBIOS Structures */
    373 smbios.ver = SMBIOS_GET8(saddr, 0x1e); /* SMBIOS BCD Revision */
    374
    375 if (smbios.ver != 0) {
    376 smbios.major = smbios.ver >> 4;
    377 smbios.minor = smbios.ver & 0x0f;
    378 if (smbios.major > 9 || smbios.minor > 9)
    379 smbios.ver = 0;
    380 }
    381 if (smbios.ver == 0) {
    382 smbios.major = SMBIOS_GET8(saddr, 0x06);/* SMBIOS Major Version */
    383 smbios.minor = SMBIOS_GET8(saddr, 0x07);/* SMBIOS Minor Version */
    384 }
    385 smbios.ver = (smbios.major << 8) | smbios.minor;
    386 smbios.addr = PTOV(paddr);
    387
    388 /* Get system information from SMBIOS */
    389 info = smbios_find_struct(0x00);
    390 if (info != NULL) {
    391 smbios.bios_vendor = smbios_getstring(info, 0x04);
    392 }
    393 info = smbios_find_struct(0x01);
    394 if (info != NULL) {
    395 smbios.maker = smbios_getstring(info, 0x04);
    396 smbios.product = smbios_getstring(info, 0x05);
    397 }
    398 }
    399
    400 void
    401 smbios_detect(const caddr_t addr)
    402 {
    403 char buf[16];
    404 caddr_t dmi;
    405 size_t i;
    406
    407 smbios_probe(addr);
    408 if (smbios.addr == NULL)
    409 return;
    410
    411 for (dmi = smbios.addr, i = 0;
    412 dmi < smbios.addr + smbios.length && i < smbios.count; i++)
    413 dmi = smbios_parse_table(dmi);
    414
    415 sprintf(buf, "%d.%d", smbios.major, smbios.minor);
    416 setenv("smbios.version", buf, 1);
    417 if (smbios.enabled_memory > 0 || smbios.old_enabled_memory > 0) {
    418 sprintf(buf, "%u", smbios.enabled_memory > 0 ?
    419 smbios.enabled_memory : smbios.old_enabled_memory);
    420 setenv("smbios.memory.enabled", buf, 1);
    421 }
    422 if (smbios.enabled_sockets > 0) {
    423 sprintf(buf, "%u", smbios.enabled_sockets);
    424 setenv("smbios.socket.enabled", buf, 1);
    425 }
    426 if (smbios.populated_sockets > 0) {
    427 sprintf(buf, "%u", smbios.populated_sockets);
    428 setenv("smbios.socket.populated", buf, 1);
    429 }
    430 }
    431
    432 static int
    433 smbios_match_str(const char* s1, const char* s2)
    434 {
    435 return (s1 == NULL || (s2 != NULL && !strcmp(s1, s2)));
    436 }
    437
    438 int
    439 smbios_match(const char* bios_vendor, const char* maker,
    440 const char* product)
    441 {
    442 /* XXXRP currently, only called from non-EFI. */
    443 smbios_probe(NULL);
    444 return (smbios_match_str(bios_vendor, smbios.bios_vendor) &&
    445 smbios_match_str(maker, smbios.maker) &&
    446 smbios_match_str(product, smbios.product));
    447 }
  • projects/clang1000-import/stand/libsa/smbios.h

     
    1 /*-
    2 * Copyright (c) 2015 Rui Paulo <rpaulo@FreeBSD.org>
    3 * All rights reserved.
    4 *
    5 * Redistribution and use in source and binary forms, with or without
    6 * modification, are permitted provided that the following conditions
    7 * are met:
    8 * 1. Redistributions of source code must retain the above copyright
    9 * notice, this list of conditions and the following disclaimer.
    10 * 2. Redistributions in binary form must reproduce the above copyright
    11 * notice, this list of conditions and the following disclaimer in the
    12 * documentation and/or other materials provided with the distribution.
    13 *
    14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    17 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    22 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    23 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    24 * POSSIBILITY OF SUCH DAMAGE.
    25 *
    26 * $FreeBSD$
    27 */
    28 #ifndef _SMBIOS_H_
    29 #define _SMBIOS_H_
    30
    31 void smbios_detect(const caddr_t);
    32 int smbios_match(const char *, const char *, const char *);
    33
    34 #endif /* _SMBIOS_H_ */
  • projects/clang1000-import/stand/libsa/stand.h

     
    452 452 #define reallocf(x, y) Reallocf(x, y, NULL, 0)
    453 453 #endif
    454 454
    455 /*
    456 * va <-> pa routines. MD code must supply.
    457 */
    458 caddr_t ptov(uintptr_t);
    459
    455 460 #endif /* STAND_H */
  • projects/clang1000-import/sys/bsm/audit_kevents.h

     
    657 657 #define AUE_LGETUUID 43261 /* CADETS. */
    658 658 #define AUE_EXECVEAT 43262 /* FreeBSD/Linux. */
    659 659 #define AUE_SHMRENAME 43263 /* FreeBSD-specific. */
    660 #define AUE_REALPATHAT 43264 /* FreeBSD-specific. */
    660 661
    661 662 /*
    662 663 * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the
  • projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscall.h

     
    500 500 #define FREEBSD32_SYS_shm_open2 571
    501 501 #define FREEBSD32_SYS_shm_rename 572
    502 502 #define FREEBSD32_SYS_sigfastblock 573
    503 #define FREEBSD32_SYS_MAXSYSCALL 574
    503 #define FREEBSD32_SYS___realpathat 574
    504 #define FREEBSD32_SYS_MAXSYSCALL 575
  • projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscalls.c

     
    610 610 "shm_open2", /* 571 = shm_open2 */
    611 611 "shm_rename", /* 572 = shm_rename */
    612 612 "sigfastblock", /* 573 = sigfastblock */
    613 "__realpathat", /* 574 = __realpathat */
    613 614 };
  • projects/clang1000-import/sys/compat/freebsd32/freebsd32_sysent.c

     
    663 663 { AS(shm_open2_args), (sy_call_t *)sys_shm_open2, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 571 = shm_open2 */
    664 664 { AS(shm_rename_args), (sy_call_t *)sys_shm_rename, AUE_SHMRENAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 572 = shm_rename */
    665 665 { AS(sigfastblock_args), (sy_call_t *)sys_sigfastblock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 573 = sigfastblock */
    666 { AS(__realpathat_args), (sy_call_t *)sys___realpathat, AUE_REALPATHAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 574 = __realpathat */
    666 667 };
  • projects/clang1000-import/sys/compat/freebsd32/freebsd32_systrace_args.c

     
    3363 3363 *n_args = 2;
    3364 3364 break;
    3365 3365 }
    3366 /* __realpathat */
    3367 case 574: {
    3368 struct __realpathat_args *p = params;
    3369 iarg[0] = p->fd; /* int */
    3370 uarg[1] = (intptr_t) p->path; /* const char * */
    3371 uarg[2] = (intptr_t) p->buf; /* char * */
    3372 uarg[3] = p->size; /* size_t */
    3373 iarg[4] = p->flags; /* int */
    3374 *n_args = 5;
    3375 break;
    3376 }
    3366 3377 default:
    3367 3378 *n_args = 0;
    3368 3379 break;
     
    9062 9073 break;
    9063 9074 };
    9064 9075 break;
    9076 /* __realpathat */
    9077 case 574:
    9078 switch(ndx) {
    9079 case 0:
    9080 p = "int";
    9081 break;
    9082 case 1:
    9083 p = "userland const char *";
    9084 break;
    9085 case 2:
    9086 p = "userland char *";
    9087 break;
    9088 case 3:
    9089 p = "size_t";
    9090 break;
    9091 case 4:
    9092 p = "int";
    9093 break;
    9094 default:
    9095 break;
    9096 };
    9097 break;
    9065 9098 default:
    9066 9099 break;
    9067 9100 };
     
    10956 10989 if (ndx == 0 || ndx == 1)
    10957 10990 p = "int";
    10958 10991 break;
    10992 /* __realpathat */
    10993 case 574:
    10994 if (ndx == 0 || ndx == 1)
    10995 p = "int";
    10996 break;
    10959 10997 default:
    10960 10998 break;
    10961 10999 };
  • projects/clang1000-import/sys/compat/freebsd32/syscalls.master

     
    1160 1160 572 AUE_SHMRENAME NOPROTO { int shm_rename(const char *path_from, \
    1161 1161 const char *path_to, int flags); }
    1162 1162 573 AUE_NULL NOPROTO { int sigfastblock(int cmd, uint32_t *ptr); }
    1163 574 AUE_REALPATHAT NOPROTO { int __realpathat(int fd, const char *path, \
    1164 char *buf, size_t size, int flags); }
    1163 1165
    1164 1166 ; vim: syntax=off
  • projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/list.h

     
    449 449 __list_cut_position(list, head, entry);
    450 450 }
    451 451
    452 static inline int list_is_first(const struct list_head *list,
    453 const struct list_head *head)
    454 {
    455
    456 return (list->prev == head);
    457 }
    458
    452 459 static inline int list_is_last(const struct list_head *list,
    453 460 const struct list_head *head)
    454 461 {
  • projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/string.h

     
    154 154 return (NULL);
    155 155 }
    156 156
    157 static inline size_t
    158 str_has_prefix(const char *str, const char *prefix)
    159 {
    160 size_t len;
    161
    162 len = strlen(prefix);
    163 return (strncmp(str, prefix, len) == 0 ? len : 0);
    164 }
    165
    157 166 #endif /* _LINUX_STRING_H_ */
  • projects/clang1000-import/sys/dev/ath/if_ath.c

     
    760 760 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq",
    761 761 device_get_nameunit(sc->sc_dev));
    762 762
    763 NET_TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc);
    763 TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc);
    764 764 TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc);
    765 765 TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc);
    766 766 TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc);
  • projects/clang1000-import/sys/dev/ath/if_ath_rx.c

     
    656 656 int is_good = 0;
    657 657 struct ath_rx_edma *re = &sc->sc_rxedma[qtype];
    658 658
    659 NET_EPOCH_ASSERT();
    660
    659 661 /*
    660 662 * Calculate the correct 64 bit TSF given
    661 663 * the TSF64 register value and rs_tstamp.
     
    1074 1076 int kickpcu = 0;
    1075 1077 int ret;
    1076 1078
    1079 NET_EPOCH_ASSERT();
    1080
    1077 1081 /* XXX we must not hold the ATH_LOCK here */
    1078 1082 ATH_UNLOCK_ASSERT(sc);
    1079 1083 ATH_PCU_UNLOCK_ASSERT(sc);
     
    1293 1297 ath_legacy_rx_tasklet(void *arg, int npending)
    1294 1298 {
    1295 1299 struct ath_softc *sc = arg;
    1300 struct epoch_tracker et;
    1296 1301
    1297 1302 ATH_KTR(sc, ATH_KTR_RXPROC, 1, "ath_rx_proc: pending=%d", npending);
    1298 1303 DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s: pending %u\n", __func__, npending);
     
    1305 1310 }
    1306 1311 ATH_PCU_UNLOCK(sc);
    1307 1312
    1313 NET_EPOCH_ENTER(et);
    1308 1314 ath_rx_proc(sc, 1);
    1315 NET_EPOCH_EXIT(et);
    1309 1316 }
    1310 1317
    1311 1318 static void
    1312 1319 ath_legacy_flushrecv(struct ath_softc *sc)
    1313 1320 {
    1314
    1321 struct epoch_tracker et;
    1322 NET_EPOCH_ENTER(et);
    1315 1323 ath_rx_proc(sc, 0);
    1324 NET_EPOCH_EXIT(et);
    1316 1325 }
    1317 1326
    1318 1327 static void
  • projects/clang1000-import/sys/dev/ath/if_ath_rx_edma.c

     
    521 521 int16_t nf;
    522 522 ath_bufhead rxlist;
    523 523 struct mbuf *m;
    524 struct epoch_tracker et;
    524 525
    525 526 TAILQ_INIT(&rxlist);
    526 527
     
    537 538 TAILQ_CONCAT(&rxlist, &sc->sc_rx_rxlist[qtype], bf_list);
    538 539 ATH_RX_UNLOCK(sc);
    539 540
    541 NET_EPOCH_ENTER(et);
    542
    540 543 /* Handle the completed descriptors */
    541 544 /*
    542 545 * XXX is this SAFE call needed? The ath_buf entries
     
    560 563 if (ngood) {
    561 564 sc->sc_lastrx = tsf;
    562 565 }
    566 NET_EPOCH_EXIT(et);
    563 567
    564 568 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 1,
    565 569 "ath edma rx deferred proc: ngood=%d\n",
  • projects/clang1000-import/sys/dev/pci/pcireg.h

     
    151 151 #define PCIY_SATA 0x12 /* SATA */
    152 152 #define PCIY_PCIAF 0x13 /* PCI Advanced Features */
    153 153 #define PCIY_EA 0x14 /* PCI Extended Allocation */
    154 #define PCIY_FPB 0x15 /* Flattening Portal Bridge */
    154 155
    155 156 /* Extended Capability Register Fields */
    156 157
     
    194 195 #define PCIZ_LN_REQ 0x001c /* LN Requester */
    195 196 #define PCIZ_DPC 0x001d /* Downstream Port Containment */
    196 197 #define PCIZ_L1PM 0x001e /* L1 PM Substates */
    198 #define PCIZ_PTM 0x001f /* Precision Time Measurement */
    199 #define PCIZ_M_PCIE 0x0020 /* PCIe over M-PHY */
    200 #define PCIZ_FRS 0x0021 /* FRS Queuing */
    201 #define PCIZ_RTR 0x0022 /* Readiness Time Reporting */
    202 #define PCIZ_DVSEC 0x0023 /* Designated Vendor-Specific */
    203 #define PCIZ_VF_REBAR 0x0024 /* VF Resizable BAR */
    204 #define PCIZ_DLNK 0x0025 /* Data Link Feature */
    205 #define PCIZ_16GT 0x0026 /* Physical Layer 16.0 GT/s */
    206 #define PCIZ_LMR 0x0027 /* Lane Margining at Receiver */
    207 #define PCIZ_HIER_ID 0x0028 /* Hierarchy ID */
    208 #define PCIZ_NPEM 0x0029 /* Native PCIe Enclosure Management */
    209 #define PCIZ_PL32 0x002a /* Physical Layer 32.0 GT/s */
    210 #define PCIZ_AP 0x002b /* Alternate Protocol */
    211 #define PCIZ_SFI 0x002c /* System Firmware Intermediary */
    197 212
    198 213 /* config registers for header type 0 devices */
    199 214
     
    334 349 #define PCIS_STORAGE_NVM 0x08
    335 350 #define PCIP_STORAGE_NVM_NVMHCI_1_0 0x01
    336 351 #define PCIP_STORAGE_NVM_ENTERPRISE_NVMHCI_1_0 0x02
    352 #define PCIS_STORAGE_UFS 0x09
    353 #define PCIP_STORAGE_UFS_UFSHCI_1_0 0x01
    337 354 #define PCIS_STORAGE_OTHER 0x80
    338 355
    339 356 #define PCIC_NETWORK 0x02
     
    344 361 #define PCIS_NETWORK_ISDN 0x04
    345 362 #define PCIS_NETWORK_WORLDFIP 0x05
    346 363 #define PCIS_NETWORK_PICMG 0x06
    364 #define PCIS_NETWORK_INFINIBAND 0x07
    365 #define PCIS_NETWORK_HFC 0x08
    347 366 #define PCIS_NETWORK_OTHER 0x80
    348 367
    349 368 #define PCIC_DISPLAY 0x03
     
    357 376 #define PCIS_MULTIMEDIA_AUDIO 0x01
    358 377 #define PCIS_MULTIMEDIA_TELE 0x02
    359 378 #define PCIS_MULTIMEDIA_HDA 0x03
    379 #define PCIP_MULTIMEDIA_HDA_VENDOR 0x01
    360 380 #define PCIS_MULTIMEDIA_OTHER 0x80
    361 381
    362 382 #define PCIC_MEMORY 0x05
     
    377 397 #define PCIS_BRIDGE_RACEWAY 0x08
    378 398 #define PCIS_BRIDGE_PCI_TRANSPARENT 0x09
    379 399 #define PCIS_BRIDGE_INFINIBAND 0x0a
    400 #define PCIS_BRIDGE_AS_PCI 0x0b
    401 #define PCIS_BRIDGE_AS_PCI_ASI_SIG 0x01
    380 402 #define PCIS_BRIDGE_OTHER 0x80
    381 403
    382 404 #define PCIC_SIMPLECOMM 0x07
     
    408 430 #define PCIS_BASEPERIPH_PCIHOT 0x04
    409 431 #define PCIS_BASEPERIPH_SDHC 0x05
    410 432 #define PCIS_BASEPERIPH_IOMMU 0x06
    433 #define PCIS_BASEPERIPH_RCEC 0x07
    411 434 #define PCIS_BASEPERIPH_OTHER 0x80
    412 435
    413 436 #define PCIC_INPUTDEV 0x09
     
    450 473 #define PCIP_SERIALBUS_IPMI_BT 0x02
    451 474 #define PCIS_SERIALBUS_SERCOS 0x08
    452 475 #define PCIS_SERIALBUS_CANBUS 0x09
    476 #define PCIS_SERIALBUS_MIPI_I3C 0x0a
    453 477
    454 478 #define PCIC_WIRELESS 0x0d
    455 479 #define PCIS_WIRELESS_IRDA 0x00
     
    459 483 #define PCIS_WIRELESS_BROADBAND 0x12
    460 484 #define PCIS_WIRELESS_80211A 0x20
    461 485 #define PCIS_WIRELESS_80211B 0x21
    486 #define PCIS_WIRELESS_CELL 0x40
    487 #define PCIS_WIRELESS_CELL_E 0x41
    462 488 #define PCIS_WIRELESS_OTHER 0x80
    463 489
    464 490 #define PCIC_INTELLIIO 0x0e
  • projects/clang1000-import/sys/dev/virtio/mmio/virtio_mmio.c

     
    196 196 return (ENXIO);
    197 197 }
    198 198
    199 if (bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE,
    199 if (bus_setup_intr(dev, sc->res[1], type | INTR_MPSAFE,
    200 200 NULL, vtmmio_vq_intr, sc, &sc->ih)) {
    201 201 device_printf(dev, "Can't setup the interrupt\n");
    202 202 return (ENXIO);
  • projects/clang1000-import/sys/kern/init_sysent.c

     
    629 629 { AS(shm_open2_args), (sy_call_t *)sys_shm_open2, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 571 = shm_open2 */
    630 630 { AS(shm_rename_args), (sy_call_t *)sys_shm_rename, AUE_SHMRENAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 572 = shm_rename */
    631 631 { AS(sigfastblock_args), (sy_call_t *)sys_sigfastblock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 573 = sigfastblock */
    632 { AS(__realpathat_args), (sy_call_t *)sys___realpathat, AUE_REALPATHAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 574 = __realpathat */
    632 633 };
  • projects/clang1000-import/sys/kern/kern_exec.c

     
    1035 1035 imgp->vmspace_destroyed = 1;
    1036 1036 imgp->sysent = sv;
    1037 1037
    1038 td->td_pflags &= ~TDP_SIGFASTBLOCK;
    1039 td->td_sigblock_ptr = NULL;
    1040 td->td_sigblock_val = 0;
    1038 sigfastblock_clear(td);
    1041 1039
    1042 1040 /* May be called with Giant held */
    1043 1041 EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp);
  • projects/clang1000-import/sys/kern/kern_sig.c

     
    157 157 SYSCTL_INT(_kern, OID_AUTO, lognosys, CTLFLAG_RWTUN, &kern_lognosys, 0,
    158 158 "Log invalid syscalls");
    159 159
    160 __read_frequently bool sigfastblock_fetch_always = false;
    161 SYSCTL_BOOL(_kern, OID_AUTO, sigfastblock_fetch_always, CTLFLAG_RWTUN,
    162 &sigfastblock_fetch_always, 0,
    163 "Fetch sigfastblock word on each syscall entry for proper "
    164 "blocking semantic");
    165
    160 166 SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL);
    161 167
    162 168 /*
     
    2005 2011 code = ksi->ksi_code;
    2006 2012 KASSERT(_SIG_VALID(sig), ("invalid signal"));
    2007 2013
    2014 sigfastblock_fetch(td);
    2008 2015 PROC_LOCK(p);
    2009 2016 ps = p->p_sigacts;
    2010 2017 mtx_lock(&ps->ps_mtx);
     
    3952 3959 }
    3953 3960 }
    3954 3961
    3962 static void
    3963 sigfastblock_failed(struct thread *td, bool sendsig, bool write)
    3964 {
    3965 ksiginfo_t ksi;
    3966
    3967 /*
    3968 * Prevent further fetches and SIGSEGVs, allowing thread to
    3969 * issue syscalls despite corruption.
    3970 */
    3971 sigfastblock_clear(td);
    3972
    3973 if (!sendsig)
    3974 return;
    3975 ksiginfo_init_trap(&ksi);
    3976 ksi.ksi_signo = SIGSEGV;
    3977 ksi.ksi_code = write ? SEGV_ACCERR : SEGV_MAPERR;
    3978 ksi.ksi_addr = td->td_sigblock_ptr;
    3979 trapsignal(td, &ksi);
    3980 }
    3981
    3982 static bool
    3983 sigfastblock_fetch_sig(struct thread *td, bool sendsig, uint32_t *valp)
    3984 {
    3985 uint32_t res;
    3986
    3987 if ((td->td_pflags & TDP_SIGFASTBLOCK) == 0)
    3988 return (true);
    3989 if (fueword32((void *)td->td_sigblock_ptr, &res) == -1) {
    3990 sigfastblock_failed(td, sendsig, false);
    3991 return (false);
    3992 }
    3993 *valp = res;
    3994 td->td_sigblock_val = res & ~SIGFASTBLOCK_FLAGS;
    3995 return (true);
    3996 }
    3997
    3955 3998 int
    3956 3999 sys_sigfastblock(struct thread *td, struct sigfastblock_args *uap)
    3957 4000 {
     
    3960 4003 uint32_t oldval;
    3961 4004
    3962 4005 error = 0;
    4006 p = td->td_proc;
    3963 4007 switch (uap->cmd) {
    3964 4008 case SIGFASTBLOCK_SETPTR:
    3965 4009 if ((td->td_pflags & TDP_SIGFASTBLOCK) != 0) {
     
    3975 4019 break;
    3976 4020
    3977 4021 case SIGFASTBLOCK_UNBLOCK:
    3978 if ((td->td_pflags & TDP_SIGFASTBLOCK) != 0) {
    4022 if ((td->td_pflags & TDP_SIGFASTBLOCK) == 0) {
    3979 4023 error = EINVAL;
    3980 4024 break;
    3981 4025 }
    3982 again:
    3983 res = casueword32(td->td_sigblock_ptr, SIGFASTBLOCK_PEND,
    3984 &oldval, 0);
    3985 if (res == -1) {
    3986 error = EFAULT;
    3987 break;
    3988 }
    3989 if (res == 1) {
    4026
    4027 for (;;) {
    4028 res = casueword32(td->td_sigblock_ptr,
    4029 SIGFASTBLOCK_PEND, &oldval, 0);
    4030 if (res == -1) {
    4031 error = EFAULT;
    4032 sigfastblock_failed(td, false, true);
    4033 break;
    4034 }
    4035 if (res == 0)
    4036 break;
    4037 MPASS(res == 1);
    3990 4038 if (oldval != SIGFASTBLOCK_PEND) {
    3991 4039 error = EBUSY;
    3992 4040 break;
     
    3994 4042 error = thread_check_susp(td, false);
    3995 4043 if (error != 0)
    3996 4044 break;
    3997 goto again;
    3998 4045 }
    4046 if (error != 0)
    4047 break;
    4048
    4049 /*
    4050 * td_sigblock_val is cleared there, but not on a
    4051 * syscall exit. The end effect is that a single
    4052 * interruptible sleep, while user sigblock word is
    4053 * set, might return EINTR or ERESTART to usermode
    4054 * without delivering signal. All further sleeps,
    4055 * until userspace clears the word and does
    4056 * sigfastblock(UNBLOCK), observe current word and no
    4057 * longer get interrupted. It is slight
    4058 * non-conformance, with alternative to have read the
    4059 * sigblock word on each syscall entry.
    4060 */
    3999 4061 td->td_sigblock_val = 0;
    4000 4062
    4001 4063 /*
     
    4003 4065 * signals to current thread. But notify others about
    4004 4066 * fake unblock.
    4005 4067 */
    4006 p = td->td_proc;
    4007 4068 if (error == 0 && p->p_numthreads != 1) {
    4008 4069 PROC_LOCK(p);
    4009 4070 reschedule_signals(p, td->td_sigmask, 0);
     
    4016 4077 error = EINVAL;
    4017 4078 break;
    4018 4079 }
    4019 res = fueword32(td->td_sigblock_ptr, &oldval);
    4020 if (res == -1) {
    4080 if (!sigfastblock_fetch_sig(td, false, &oldval)) {
    4021 4081 error = EFAULT;
    4022 4082 break;
    4023 4083 }
     
    4025 4085 error = EBUSY;
    4026 4086 break;
    4027 4087 }
    4028 td->td_pflags &= ~TDP_SIGFASTBLOCK;
    4029 td->td_sigblock_val = 0;
    4088 sigfastblock_clear(td);
    4030 4089 break;
    4031 4090
    4032 4091 default:
     
    4037 4096 }
    4038 4097
    4039 4098 void
    4040 fetch_sigfastblock(struct thread *td)
    4099 sigfastblock_clear(struct thread *td)
    4041 4100 {
    4101 struct proc *p;
    4102 bool resched;
    4042 4103
    4043 4104 if ((td->td_pflags & TDP_SIGFASTBLOCK) == 0)
    4044 4105 return;
    4045 if (fueword32(td->td_sigblock_ptr, &td->td_sigblock_val) == -1) {
    4046 fetch_sigfastblock_failed(td, false);
    4047 return;
    4106 td->td_sigblock_val = 0;
    4107 resched = (td->td_pflags & TDP_SIGFASTPENDING) != 0;
    4108 td->td_pflags &= ~(TDP_SIGFASTBLOCK | TDP_SIGFASTPENDING);
    4109 if (resched) {
    4110 p = td->td_proc;
    4111 PROC_LOCK(p);
    4112 reschedule_signals(p, td->td_sigmask, 0);
    4113 PROC_UNLOCK(p);
    4048 4114 }
    4049 td->td_sigblock_val &= ~SIGFASTBLOCK_FLAGS;
    4050 4115 }
    4051 4116
    4052 4117 void
    4053 fetch_sigfastblock_failed(struct thread *td, bool write)
    4118 sigfastblock_fetch(struct thread *td)
    4054 4119 {
    4055 ksiginfo_t ksi;
    4120 uint32_t val;
    4056 4121
    4057 /*
    4058 * Prevent further fetches and SIGSEGVs, allowing thread to
    4059 * issue syscalls despite corruption.
    4060 */
    4061 td->td_pflags &= ~TDP_SIGFASTBLOCK;
    4122 (void)sigfastblock_fetch_sig(td, true, &val);
    4123 }
    4062 4124
    4063 ksiginfo_init_trap(&ksi);
    4064 ksi.ksi_signo = SIGSEGV;
    4065 ksi.ksi_code = write ? SEGV_ACCERR : SEGV_MAPERR;
    4066 ksi.ksi_addr = td->td_sigblock_ptr;
    4067 trapsignal(td, &ksi);
    4125 void
    4126 sigfastblock_setpend(struct thread *td)
    4127 {
    4128 int res;
    4129 uint32_t oldval;
    4130
    4131 if ((td->td_pflags & TDP_SIGFASTBLOCK) == 0)
    4132 return;
    4133 res = fueword32((void *)td->td_sigblock_ptr, &oldval);
    4134 if (res == -1) {
    4135 sigfastblock_failed(td, true, false);
    4136 return;
    4137 }
    4138 for (;;) {
    4139 res = casueword32(td->td_sigblock_ptr, oldval, &oldval,
    4140 oldval | SIGFASTBLOCK_PEND);
    4141 if (res == -1) {
    4142 sigfastblock_failed(td, true, true);
    4143 return;
    4144 }
    4145 if (res == 0) {
    4146 td->td_sigblock_val = oldval & ~SIGFASTBLOCK_FLAGS;
    4147 td->td_pflags &= ~TDP_SIGFASTPENDING;
    4148 break;
    4149 }
    4150 MPASS(res == 1);
    4151 if (thread_check_susp(td, false) != 0)
    4152 break;
    4153 }
    4068 4154 }
  • projects/clang1000-import/sys/kern/subr_syscall.c

     
    132 132 }
    133 133
    134 134 /*
    135 * Fetch fast sigblock value at the time of syscall
    136 * entry because sleepqueue primitives might call
    137 * cursig().
    135 * Fetch fast sigblock value at the time of syscall entry to
    136 * handle sleepqueue primitives which might call cursig().
    138 137 */
    139 fetch_sigfastblock(td);
    138 if (__predict_false(sigfastblock_fetch_always))
    139 (void)sigfastblock_fetch(td);
    140 140
    141 141 /* Let system calls set td_errno directly. */
    142 142 td->td_pflags &= ~TDP_NERRNO;
  • projects/clang1000-import/sys/kern/subr_trap.c

     
    134 134 #ifdef KTRACE
    135 135 KTRUSERRET(td);
    136 136 #endif
    137
    137 138 td_softdep_cleanup(td);
    138 139 MPASS(td->td_su == NULL);
    139 140
     
    222 223 {
    223 224 struct thread *td;
    224 225 struct proc *p;
    225 uint32_t oldval;
    226 int flags, sig, res;
    226 int flags, sig;
    227 227
    228 228 td = curthread;
    229 229 p = td->td_proc;
     
    325 325 */
    326 326 if (flags & TDF_NEEDSIGCHK || p->p_pendingcnt > 0 ||
    327 327 !SIGISEMPTY(p->p_siglist)) {
    328 fetch_sigfastblock(td);
    328 sigfastblock_fetch(td);
    329 329 PROC_LOCK(p);
    330 330 mtx_lock(&p->p_sigacts->ps_mtx);
    331 331 if ((td->td_pflags & TDP_SIGFASTBLOCK) != 0 &&
    332 332 td->td_sigblock_val != 0) {
    333 sigfastblock_setpend(td);
    333 334 reschedule_signals(p, fastblock_mask,
    334 335 SIGPROCMASK_PS_LOCKED | SIGPROCMASK_FASTBLK);
    335 336 } else {
     
    346 347 * Handle deferred update of the fast sigblock value, after
    347 348 * the postsig() loop was performed.
    348 349 */
    349 if (td->td_pflags & TDP_SIGFASTPENDING) {
    350 td->td_pflags &= ~TDP_SIGFASTPENDING;
    351 res = fueword32(td->td_sigblock_ptr, &oldval);
    352 if (res == -1) {
    353 fetch_sigfastblock_failed(td, false);
    354 } else {
    355 for (;;) {
    356 oldval |= SIGFASTBLOCK_PEND;
    357 res = casueword32(td->td_sigblock_ptr, oldval,
    358 &oldval, oldval | SIGFASTBLOCK_PEND);
    359 if (res == -1) {
    360 fetch_sigfastblock_failed(td, true);
    361 break;
    362 }
    363 if (res == 0) {
    364 td->td_sigblock_val = oldval &
    365 ~SIGFASTBLOCK_FLAGS;
    366 break;
    367 }
    368 MPASS(res == 1);
    369 res = thread_check_susp(td, false);
    370 if (res != 0)
    371 break;
    372 }
    373 }
    374 }
    350 if (td->td_pflags & TDP_SIGFASTPENDING)
    351 sigfastblock_setpend(td);
    375 352
    376 353 /*
    377 354 * We need to check to see if we have to exit or wait due to a
  • projects/clang1000-import/sys/kern/syscalls.c

     
    580 580 "shm_open2", /* 571 = shm_open2 */
    581 581 "shm_rename", /* 572 = shm_rename */
    582 582 "sigfastblock", /* 573 = sigfastblock */
    583 "__realpathat", /* 574 = __realpathat */
    583 584 };
  • projects/clang1000-import/sys/kern/syscalls.master

     
    3218 3218 _Inout_opt_ uint32_t *ptr
    3219 3219 );
    3220 3220 }
    3221 574 AUE_REALPATHAT STD {
    3222 int __realpathat(
    3223 int fd,
    3224 _In_z_ const char *path,
    3225 _Out_writes_z_(size) char *buf,
    3226 size_t size,
    3227 int flags
    3228 );
    3229 }
    3221 3230
    3222 3231 ; Please copy any additions and changes to the following compatability tables:
    3223 3232 ; sys/compat/freebsd32/syscalls.master
  • projects/clang1000-import/sys/kern/systrace_args.c

     
    3355 3355 *n_args = 2;
    3356 3356 break;
    3357 3357 }
    3358 /* __realpathat */
    3359 case 574: {
    3360 struct __realpathat_args *p = params;
    3361 iarg[0] = p->fd; /* int */
    3362 uarg[1] = (intptr_t) p->path; /* const char * */
    3363 uarg[2] = (intptr_t) p->buf; /* char * */
    3364 uarg[3] = p->size; /* size_t */
    3365 iarg[4] = p->flags; /* int */
    3366 *n_args = 5;
    3367 break;
    3368 }
    3358 3369 default:
    3359 3370 *n_args = 0;
    3360 3371 break;
     
    8967 8978 break;
    8968 8979 };
    8969 8980 break;
    8981 /* __realpathat */
    8982 case 574:
    8983 switch(ndx) {
    8984 case 0:
    8985 p = "int";
    8986 break;
    8987 case 1:
    8988 p = "userland const char *";
    8989 break;
    8990 case 2:
    8991 p = "userland char *";
    8992 break;
    8993 case 3:
    8994 p = "size_t";
    8995 break;
    8996 case 4:
    8997 p = "int";
    8998 break;
    8999 default:
    9000 break;
    9001 };
    9002 break;
    8970 9003 default:
    8971 9004 break;
    8972 9005 };
     
    10888 10921 if (ndx == 0 || ndx == 1)
    10889 10922 p = "int";
    10890 10923 break;
    10924 /* __realpathat */
    10925 case 574:
    10926 if (ndx == 0 || ndx == 1)
    10927 p = "int";
    10928 break;
    10891 10929 default:
    10892 10930 break;
    10893 10931 };
  • projects/clang1000-import/sys/kern/vfs_cache.c

     
    42 42
    43 43 #include <sys/param.h>
    44 44 #include <sys/systm.h>
    45 #include <sys/capsicum.h>
    45 46 #include <sys/counter.h>
    46 47 #include <sys/filedesc.h>
    47 48 #include <sys/fnv_hash.h>
     
    387 388 "Number of times shrinking was already in progress");
    388 389
    389 390 static void cache_zap_locked(struct namecache *ncp, bool neg_locked);
    390 static int vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
    391 static int vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf,
    392 char **freebuf, size_t *buflen);
    393 static int vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir,
    391 394 char *buf, char **retbuf, size_t *buflen);
    395 static int vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir,
    396 char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend);
    392 397
    393 398 static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries");
    394 399
     
    2201 2206 rdir = fdp->fd_rdir;
    2202 2207 vrefact(rdir);
    2203 2208 FILEDESC_SUNLOCK(fdp);
    2204 error = vn_fullpath1(td, cdir, rdir, buf, retbuf, buflen);
    2209 error = vn_fullpath_any(td, cdir, rdir, buf, retbuf, buflen);
    2205 2210 vrele(rdir);
    2206 2211 vrele(cdir);
    2207 2212
     
    2212 2217 return (error);
    2213 2218 }
    2214 2219
    2220 static int
    2221 kern___realpathat(struct thread *td, int fd, const char *path, char *buf,
    2222 size_t size, int flags, enum uio_seg pathseg)
    2223 {
    2224 struct nameidata nd;
    2225 char *retbuf, *freebuf;
    2226 int error;
    2227
    2228 if (flags != 0)
    2229 return (EINVAL);
    2230 NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | SAVENAME | WANTPARENT | AUDITVNODE1,
    2231 pathseg, path, fd, &cap_fstat_rights, td);
    2232 if ((error = namei(&nd)) != 0)
    2233 return (error);
    2234 error = vn_fullpath_hardlink(td, &nd, &retbuf, &freebuf, &size);
    2235 if (error == 0) {
    2236 error = copyout(retbuf, buf, size);
    2237 free(freebuf, M_TEMP);
    2238 }
    2239 NDFREE(&nd, 0);
    2240 return (error);
    2241 }
    2242
    2243 int
    2244 sys___realpathat(struct thread *td, struct __realpathat_args *uap)
    2245 {
    2246
    2247 return (kern___realpathat(td, uap->fd, uap->path, uap->buf, uap->size,
    2248 uap->flags, UIO_USERSPACE));
    2249 }
    2250
    2215 2251 /*
    2216 2252 * Retrieve the full filesystem path that correspond to a vnode from the name
    2217 2253 * cache (if available)
     
    2235 2271 rdir = fdp->fd_rdir;
    2236 2272 vrefact(rdir);
    2237 2273 FILEDESC_SUNLOCK(fdp);
    2238 error = vn_fullpath1(td, vn, rdir, buf, retbuf, &buflen);
    2274 error = vn_fullpath_any(td, vn, rdir, buf, retbuf, &buflen);
    2239 2275 vrele(rdir);
    2240 2276
    2241 2277 if (!error)
     
    2263 2299 return (EINVAL);
    2264 2300 buflen = MAXPATHLEN;
    2265 2301 buf = malloc(buflen, M_TEMP, M_WAITOK);
    2266 error = vn_fullpath1(td, vn, rootvnode, buf, retbuf, &buflen);
    2302 error = vn_fullpath_any(td, vn, rootvnode, buf, retbuf, &buflen);
    2267 2303 if (!error)
    2268 2304 *freebuf = buf;
    2269 2305 else
     
    2334 2370 }
    2335 2371
    2336 2372 /*
    2337 * The magic behind vn_getcwd() and vn_fullpath().
    2373 * Resolve a directory to a pathname.
    2374 *
    2375 * The name of the directory can always be found in the namecache or fetched
    2376 * from the filesystem. There is also guaranteed to be only one parent, meaning
    2377 * we can just follow vnodes up until we find the root.
    2378 *
    2379 * The vnode must be referenced.
    2338 2380 */
    2339 2381 static int
    2340 vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
    2341 char *buf, char **retbuf, size_t *len)
    2382 vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir,
    2383 char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend)
    2342 2384 {
    2343 int error, slash_prefixed;
    2344 2385 #ifdef KDTRACE_HOOKS
    2345 2386 struct vnode *startvp = vp;
    2346 2387 #endif
    2347 2388 struct vnode *vp1;
    2348 2389 size_t buflen;
    2390 int error;
    2349 2391
    2392 VNPASS(vp->v_type == VDIR || VN_IS_DOOMED(vp), vp);
    2393 VNPASS(vp->v_usecount > 0, vp);
    2394
    2350 2395 buflen = *len;
    2351 2396
    2352 buflen--;
    2353 buf[buflen] = '\0';
    2397 if (!slash_prefixed) {
    2398 MPASS(*len >= 2);
    2399 buflen--;
    2400 buf[buflen] = '\0';
    2401 }
    2402
    2354 2403 error = 0;
    2355 slash_prefixed = 0;
    2356 2404
    2357 2405 SDT_PROBE1(vfs, namecache, fullpath, entry, vp);
    2358 2406 counter_u64_add(numfullpathcalls, 1);
    2359 vref(vp);
    2360 if (vp->v_type != VDIR) {
    2361 error = vn_vptocnp(&vp, td->td_ucred, buf, &buflen);
    2362 if (error)
    2363 return (error);
    2364 if (buflen == 0) {
    2365 vrele(vp);
    2366 return (ENOMEM);
    2367 }
    2368 buf[--buflen] = '/';
    2369 slash_prefixed = 1;
    2370 }
    2371 2407 while (vp != rdir && vp != rootvnode) {
    2372 2408 /*
    2373 2409 * The vp vnode must be already fully constructed,
     
    2420 2456 break;
    2421 2457 }
    2422 2458 buf[--buflen] = '/';
    2423 slash_prefixed = 1;
    2459 slash_prefixed = true;
    2424 2460 }
    2425 2461 if (error)
    2426 2462 return (error);
     
    2437 2473 counter_u64_add(numfullpathfound, 1);
    2438 2474 vrele(vp);
    2439 2475
    2440 SDT_PROBE3(vfs, namecache, fullpath, return, 0, startvp, buf + buflen);
    2441 2476 *retbuf = buf + buflen;
    2477 SDT_PROBE3(vfs, namecache, fullpath, return, 0, startvp, *retbuf);
    2442 2478 *len -= buflen;
    2479 *len += addend;
    2443 2480 return (0);
    2444 2481 }
    2445 2482
    2483 /*
    2484 * Resolve an arbitrary vnode to a pathname.
    2485 *
    2486 * Note 2 caveats:
    2487 * - hardlinks are not tracked, thus if the vnode is not a directory this can
    2488 * resolve to a different path than the one used to find it
    2489 * - namecache is not mandatory, meaning names are not guaranteed to be added
    2490 * (in which case resolving fails)
    2491 */
    2492 static int
    2493 vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir,
    2494 char *buf, char **retbuf, size_t *buflen)
    2495 {
    2496 size_t orig_buflen;
    2497 bool slash_prefixed;
    2498 int error;
    2499
    2500 if (*buflen < 2)
    2501 return (EINVAL);
    2502
    2503 orig_buflen = *buflen;
    2504
    2505 vref(vp);
    2506 slash_prefixed = false;
    2507 if (vp->v_type != VDIR) {
    2508 *buflen -= 1;
    2509 buf[*buflen] = '\0';
    2510 error = vn_vptocnp(&vp, td->td_ucred, buf, buflen);
    2511 if (error)
    2512 return (error);
    2513 if (*buflen == 0) {
    2514 vrele(vp);
    2515 return (ENOMEM);
    2516 }
    2517 *buflen -= 1;
    2518 buf[*buflen] = '/';
    2519 slash_prefixed = true;
    2520 }
    2521
    2522 return (vn_fullpath_dir(td, vp, rdir, buf, retbuf, buflen, slash_prefixed,
    2523 orig_buflen - *buflen));
    2524 }
    2525
    2526 /*
    2527 * Resolve an arbitrary vnode to a pathname (taking care of hardlinks).
    2528 *
    2529 * Since the namecache does not track handlings, the caller is expected to first
    2530 * look up the target vnode with SAVENAME | WANTPARENT flags passed to namei.
    2531 *
    2532 * Then we have 2 cases:
    2533 * - if the found vnode is a directory, the path can be constructed just by
    2534 * fullowing names up the chain
    2535 * - otherwise we populate the buffer with the saved name and start resolving
    2536 * from the parent
    2537 */
    2538 static int
    2539 vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf,
    2540 char **freebuf, size_t *buflen)
    2541 {
    2542 char *buf, *tmpbuf;
    2543 struct filedesc *fdp;
    2544 struct vnode *rdir;
    2545 struct componentname *cnp;
    2546 struct vnode *vp;
    2547 size_t addend;
    2548 int error;
    2549 bool slash_prefixed;
    2550
    2551 if (*buflen < 2)
    2552 return (EINVAL);
    2553 if (*buflen > MAXPATHLEN)
    2554 *buflen = MAXPATHLEN;
    2555
    2556 slash_prefixed = false;
    2557
    2558 buf = malloc(*buflen, M_TEMP, M_WAITOK);
    2559 fdp = td->td_proc->p_fd;
    2560 FILEDESC_SLOCK(fdp);
    2561 rdir = fdp->fd_rdir;
    2562 vrefact(rdir);
    2563 FILEDESC_SUNLOCK(fdp);
    2564
    2565 addend = 0;
    2566 vp = ndp->ni_vp;
    2567 if (vp->v_type != VDIR) {
    2568 cnp = &ndp->ni_cnd;
    2569 addend = cnp->cn_namelen + 2;
    2570 if (*buflen < addend) {
    2571 error = ENOMEM;
    2572 goto out_bad;
    2573 }
    2574 *buflen -= addend;
    2575 tmpbuf = buf + *buflen;
    2576 tmpbuf[0] = '/';
    2577 memcpy(&tmpbuf[1], cnp->cn_nameptr, cnp->cn_namelen);
    2578 tmpbuf[addend - 1] = '\0';
    2579 slash_prefixed = true;
    2580 vp = ndp->ni_dvp;
    2581 }
    2582
    2583 vref(vp);
    2584 error = vn_fullpath_dir(td, vp, rdir, buf, retbuf, buflen, slash_prefixed, addend);
    2585 if (error != 0)
    2586 goto out_bad;
    2587
    2588 vrele(rdir);
    2589 *freebuf = buf;
    2590
    2591 return (0);
    2592 out_bad:
    2593 vrele(rdir);
    2594 free(buf, M_TEMP);
    2595 return (error);
    2596 }
    2597
    2446 2598 struct vnode *
    2447 2599 vn_dir_dd_ino(struct vnode *vp)
    2448 2600 {
  • projects/clang1000-import/sys/netinet/sctp_constants.h

     
    543 543 #define SCTP_TIMER_TYPE_ASCONF 10
    544 544 #define SCTP_TIMER_TYPE_SHUTDOWNGUARD 11
    545 545 #define SCTP_TIMER_TYPE_AUTOCLOSE 12
    546 #define SCTP_TIMER_TYPE_EVENTWAKE 13
    547 #define SCTP_TIMER_TYPE_STRRESET 14
    548 #define SCTP_TIMER_TYPE_INPKILL 15
    549 #define SCTP_TIMER_TYPE_ASOCKILL 16
    550 #define SCTP_TIMER_TYPE_ADDR_WQ 17
    551 #define SCTP_TIMER_TYPE_PRIM_DELETED 18
    546 #define SCTP_TIMER_TYPE_STRRESET 13
    547 #define SCTP_TIMER_TYPE_INPKILL 14
    548 #define SCTP_TIMER_TYPE_ASOCKILL 15
    549 #define SCTP_TIMER_TYPE_ADDR_WQ 16
    550 #define SCTP_TIMER_TYPE_PRIM_DELETED 17
    552 551 /* add new timers here - and increment LAST */
    553 #define SCTP_TIMER_TYPE_LAST 19
    552 #define SCTP_TIMER_TYPE_LAST 18
    554 553
    555 554 #define SCTP_IS_TIMER_TYPE_VALID(t) (((t) > SCTP_TIMER_TYPE_NONE) && \
    556 555 ((t) < SCTP_TIMER_TYPE_LAST))
  • projects/clang1000-import/sys/netinet6/ip6_output.c

     
    156 156
    157 157
    158 158 /*
    159 * Make an extension header from option data. hp is the source, and
    160 * mp is the destination.
    159 * Make an extension header from option data. hp is the source,
    160 * mp is the destination, and _ol is the optlen.
    161 161 */
    162 #define MAKE_EXTHDR(hp, mp) \
    162 #define MAKE_EXTHDR(hp, mp, _ol) \
    163 163 do { \
    164 164 if (hp) { \
    165 165 struct ip6_ext *eh = (struct ip6_ext *)(hp); \
     
    167 167 ((eh)->ip6e_len + 1) << 3); \
    168 168 if (error) \
    169 169 goto freehdrs; \
    170 (_ol) += (*(mp))->m_len; \
    170 171 } \
    171 172 } while (/*CONSTCOND*/ 0)
    172 173
     
    384 385 struct ip6_hdr *ip6;
    385 386 struct ifnet *ifp, *origifp;
    386 387 struct mbuf *m = m0;
    387 struct mbuf *mprev = NULL;
    388 struct mbuf *mprev;
    388 389 int hlen, tlen, len;
    389 390 struct route_in6 ip6route;
    390 391 struct rtentry *rt = NULL;
    391 392 struct sockaddr_in6 *dst, src_sa, dst_sa;
    392 393 struct in6_addr odst;
    394 u_char *nexthdrp;
    393 395 int error = 0;
    394 396 struct in6_ifaddr *ia = NULL;
    395 397 u_long mtu;
    396 398 int alwaysfrag, dontfrag;
    397 u_int32_t optlen = 0, plen = 0, unfragpartlen = 0;
    399 u_int32_t optlen, plen = 0, unfragpartlen;
    398 400 struct ip6_exthdrs exthdrs;
    399 401 struct in6_addr src0, dst0;
    400 402 u_int32_t zone;
    401 403 struct route_in6 *ro_pmtu = NULL;
    402 int hdrsplit = 0;
    404 bool hdrsplit;
    403 405 int sw_csum, tso;
    404 406 int needfiblookup;
    405 407 uint32_t fibnum;
     
    436 438 }
    437 439 #endif /* IPSEC */
    438 440
    441 /* Source address validation. */
    442 ip6 = mtod(m, struct ip6_hdr *);
    443 if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) &&
    444 (flags & IPV6_UNSPECSRC) == 0) {
    445 error = EOPNOTSUPP;
    446 IP6STAT_INC(ip6s_badscope);
    447 goto bad;
    448 }
    449 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) {
    450 error = EOPNOTSUPP;
    451 IP6STAT_INC(ip6s_badscope);
    452 goto bad;
    453 }
    454
    455 /*
    456 * If we are given packet options to add extension headers prepare them.
    457 * Calculate the total length of the extension header chain.
    458 * Keep the length of the unfragmentable part for fragmentation.
    459 */
    439 460 bzero(&exthdrs, sizeof(exthdrs));
    461 optlen = 0;
    462 unfragpartlen = 0;
    440 463 if (opt) {
    441 464 /* Hop-by-Hop options header. */
    442 MAKE_EXTHDR(opt->ip6po_hbh, &exthdrs.ip6e_hbh);
    465 MAKE_EXTHDR(opt->ip6po_hbh, &exthdrs.ip6e_hbh, optlen);
    466
    443 467 /* Destination options header (1st part). */
    444 468 if (opt->ip6po_rthdr) {
    469 #ifndef RTHDR_SUPPORT_IMPLEMENTED
    445 470 /*
    471 * If there is a routing header, discard the packet
    472 * right away here. RH0/1 are obsolete and we do not
    473 * currently support RH2/3/4.
    474 * People trying to use RH253/254 may want to disable
    475 * this check.
    476 * The moment we do support any routing header (again)
    477 * this block should check the routing type more
    478 * selectively.
    479 */
    480 error = EINVAL;
    481 goto bad;
    482 #endif
    483
    484 /*
    446 485 * Destination options header (1st part).
    447 486 * This only makes sense with a routing header.
    448 487 * See Section 9.2 of RFC 3542.
     
    452 491 * options, which might automatically be inserted in
    453 492 * the kernel.
    454 493 */
    455 MAKE_EXTHDR(opt->ip6po_dest1, &exthdrs.ip6e_dest1);
    494 MAKE_EXTHDR(opt->ip6po_dest1, &exthdrs.ip6e_dest1,
    495 optlen);
    456 496 }
    457 497 /* Routing header. */
    458 MAKE_EXTHDR(opt->ip6po_rthdr, &exthdrs.ip6e_rthdr);
    498 MAKE_EXTHDR(opt->ip6po_rthdr, &exthdrs.ip6e_rthdr, optlen);
    499
    500 unfragpartlen = optlen + sizeof(struct ip6_hdr);
    501
    502 /*
    503 * NOTE: we don't add AH/ESP length here (done in
    504 * ip6_ipsec_output()).
    505 */
    506
    459 507 /* Destination options header (2nd part). */
    460 MAKE_EXTHDR(opt->ip6po_dest2, &exthdrs.ip6e_dest2);
    508 MAKE_EXTHDR(opt->ip6po_dest2, &exthdrs.ip6e_dest2, optlen);
    461 509 }
    462 510
    463 511 /*
    464 * Calculate the total length of the extension header chain.
    465 * Keep the length of the unfragmentable part for fragmentation.
    466 */
    467 optlen = 0;
    468 if (exthdrs.ip6e_hbh)
    469 optlen += exthdrs.ip6e_hbh->m_len;
    470 if (exthdrs.ip6e_dest1)
    471 optlen += exthdrs.ip6e_dest1->m_len;
    472 if (exthdrs.ip6e_rthdr)
    473 optlen += exthdrs.ip6e_rthdr->m_len;
    474 unfragpartlen = optlen + sizeof(struct ip6_hdr);
    475
    476 /* NOTE: we don't add AH/ESP length here (done in ip6_ipsec_output). */
    477 if (exthdrs.ip6e_dest2)
    478 optlen += exthdrs.ip6e_dest2->m_len;
    479
    480 /*
    481 512 * If there is at least one extension header,
    482 513 * separate IP6 header from the payload.
    483 514 */
    484 if (optlen && !hdrsplit) {
    515 hdrsplit = false;
    516 if (optlen) {
    485 517 if ((error = ip6_splithdr(m, &exthdrs)) != 0) {
    486 518 m = NULL;
    487 519 goto freehdrs;
    488 520 }
    489 521 m = exthdrs.ip6e_ip6;
    490 hdrsplit++;
    522 ip6 = mtod(m, struct ip6_hdr *);
    523 hdrsplit = true;
    491 524 }
    492 525
    493 ip6 = mtod(m, struct ip6_hdr *);
    494
    495 526 /* Adjust mbuf packet header length. */
    496 527 m->m_pkthdr.len += optlen;
    497 528 plen = m->m_pkthdr.len - sizeof(*ip6);
     
    504 535 goto freehdrs;
    505 536 }
    506 537 m = exthdrs.ip6e_ip6;
    507 hdrsplit++;
    538 ip6 = mtod(m, struct ip6_hdr *);
    539 hdrsplit = true;
    508 540 }
    509 /* Adjust pointer. */
    510 ip6 = mtod(m, struct ip6_hdr *);
    511 541 if ((error = ip6_insert_jumboopt(&exthdrs, plen)) != 0)
    512 542 goto freehdrs;
    513 543 ip6->ip6_plen = 0;
    514 544 } else
    515 545 ip6->ip6_plen = htons(plen);
    546 nexthdrp = &ip6->ip6_nxt;
    516 547
    517 /*
    518 * Concatenate headers and fill in next header fields.
    519 * Here we have, on "m"
    520 * IPv6 payload
    521 * and we insert headers accordingly.
    522 * Finally, we should be getting:
    523 * IPv6 hbh dest1 rthdr ah* [esp* dest2 payload].
    524 *
    525 * During the header composing process "m" points to IPv6
    526 * header. "mprev" points to an extension header prior to esp.
    527 */
    528 u_char *nexthdrp = &ip6->ip6_nxt;
    529 mprev = m;
    548 if (optlen) {
    549 /*
    550 * Concatenate headers and fill in next header fields.
    551 * Here we have, on "m"
    552 * IPv6 payload
    553 * and we insert headers accordingly.
    554 * Finally, we should be getting:
    555 * IPv6 hbh dest1 rthdr ah* [esp* dest2 payload].
    556 *
    557 * During the header composing process "m" points to IPv6
    558 * header. "mprev" points to an extension header prior to esp.
    559 */
    560 mprev = m;
    530 561
    531 /*
    532 * We treat dest2 specially. This makes IPsec processing
    533 * much easier. The goal here is to make mprev point the
    534 * mbuf prior to dest2.
    535 *
    536 * Result: IPv6 dest2 payload.
    537 * m and mprev will point to IPv6 header.
    538 */
    539 if (exthdrs.ip6e_dest2) {
    540 if (!hdrsplit)
    541 panic("%s:%d: assumption failed: "
    542 "hdr not split: hdrsplit %d exthdrs %p",
    543 __func__, __LINE__, hdrsplit, &exthdrs);
    544 exthdrs.ip6e_dest2->m_next = m->m_next;
    545 m->m_next = exthdrs.ip6e_dest2;
    546 *mtod(exthdrs.ip6e_dest2, u_char *) = ip6->ip6_nxt;
    547 ip6->ip6_nxt = IPPROTO_DSTOPTS;
    548 }
    562 /*
    563 * We treat dest2 specially. This makes IPsec processing
    564 * much easier. The goal here is to make mprev point the
    565 * mbuf prior to dest2.
    566 *
    567 * Result: IPv6 dest2 payload.
    568 * m and mprev will point to IPv6 header.
    569 */
    570 if (exthdrs.ip6e_dest2) {
    571 if (!hdrsplit)
    572 panic("%s:%d: assumption failed: "
    573 "hdr not split: hdrsplit %d exthdrs %p",
    574 __func__, __LINE__, hdrsplit, &exthdrs);
    575 exthdrs.ip6e_dest2->m_next = m->m_next;
    576 m->m_next = exthdrs.ip6e_dest2;
    577 *mtod(exthdrs.ip6e_dest2, u_char *) = ip6->ip6_nxt;
    578 ip6->ip6_nxt = IPPROTO_DSTOPTS;
    579 }
    549 580
    550 /*
    551 * Result: IPv6 hbh dest1 rthdr dest2 payload.
    552 * m will point to IPv6 header. mprev will point to the
    553 * extension header prior to dest2 (rthdr in the above case).
    554 */
    555 MAKE_CHAIN(exthdrs.ip6e_hbh, mprev, nexthdrp, IPPROTO_HOPOPTS);
    556 MAKE_CHAIN(exthdrs.ip6e_dest1, mprev, nexthdrp,
    557 IPPROTO_DSTOPTS);
    558 MAKE_CHAIN(exthdrs.ip6e_rthdr, mprev, nexthdrp,
    559 IPPROTO_ROUTING);
    560
    561 /* If there is a routing header, discard the packet. */
    562 if (exthdrs.ip6e_rthdr) {
    563 error = EINVAL;
    564 goto bad;
    581 /*
    582 * Result: IPv6 hbh dest1 rthdr dest2 payload.
    583 * m will point to IPv6 header. mprev will point to the
    584 * extension header prior to dest2 (rthdr in the above case).
    585 */
    586 MAKE_CHAIN(exthdrs.ip6e_hbh, mprev, nexthdrp, IPPROTO_HOPOPTS);
    587 MAKE_CHAIN(exthdrs.ip6e_dest1, mprev, nexthdrp,
    588 IPPROTO_DSTOPTS);
    589 MAKE_CHAIN(exthdrs.ip6e_rthdr, mprev, nexthdrp,
    590 IPPROTO_ROUTING);
    565 591 }
    566 592
    567 /* Source address validation. */
    568 if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) &&
    569 (flags & IPV6_UNSPECSRC) == 0) {
    570 error = EOPNOTSUPP;
    571 IP6STAT_INC(ip6s_badscope);
    572 goto bad;
    573 }
    574 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) {
    575 error = EOPNOTSUPP;
    576 IP6STAT_INC(ip6s_badscope);
    577 goto bad;
    578 }
    579
    580 593 IP6STAT_INC(ip6s_localout);
    581 594
    582 595 /* Route packet. */
  • projects/clang1000-import/sys/security/audit/audit_bsm.c

     
    830 830 case AUE_UNLINK:
    831 831 case AUE_UNLINKAT:
    832 832 case AUE_UTIMES:
    833 case AUE_REALPATHAT:
    833 834 ATFD1_TOKENS(1);
    834 835 UPATH1_VNODE1_TOKENS;
    835 836 break;
  • projects/clang1000-import/sys/sys/param.h

     
    60 60 * in the range 5 to 9.
    61 61 */
    62 62 #undef __FreeBSD_version
    63 #define __FreeBSD_version 1300078 /* Master, propagated to newvers */
    63 #define __FreeBSD_version 1300080 /* Master, propagated to newvers */
    64 64
    65 65 /*
    66 66 * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
  • projects/clang1000-import/sys/sys/signalvar.h

     
    273 273
    274 274 #ifdef _KERNEL
    275 275 extern sigset_t fastblock_mask;
    276 extern bool sigfastblock_fetch_always;
    276 277
    277 278 /* Return nonzero if process p has an unmasked pending signal. */
    278 279 #define SIGPENDING(td) \
     
    382 383
    383 384 int cursig(struct thread *td);
    384 385 void execsigs(struct proc *p);
    385 void fetch_sigfastblock(struct thread *td);
    386 void fetch_sigfastblock_failed(struct thread *td, bool write);
    387 386 void gsignal(int pgid, int sig, ksiginfo_t *ksi);
    388 387 void killproc(struct proc *p, char *why);
    389 388 ksiginfo_t * ksiginfo_alloc(int wait);
     
    405 404 void sigexit(struct thread *td, int sig) __dead2;
    406 405 int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **);
    407 406 int sig_ffs(sigset_t *set);
    407 void sigfastblock_clear(struct thread *td);
    408 void sigfastblock_fetch(struct thread *td);
    409 void sigfastblock_setpend(struct thread *td);
    408 410 void siginit(struct proc *p);
    409 411 void signotify(struct thread *td);
    410 412 void sigqueue_delete(struct sigqueue *queue, int sig);
  • projects/clang1000-import/sys/sys/syscall.h

     
    509 509 #define SYS_shm_open2 571
    510 510 #define SYS_shm_rename 572
    511 511 #define SYS_sigfastblock 573
    512 #define SYS_MAXSYSCALL 574
    512 #define SYS___realpathat 574
    513 #define SYS_MAXSYSCALL 575
  • projects/clang1000-import/sys/sys/syscall.mk

     
    414 414 __sysctlbyname.o \
    415 415 shm_open2.o \
    416 416 shm_rename.o \
    417 sigfastblock.o
    417 sigfastblock.o \
    418 __realpathat.o
  • projects/clang1000-import/sys/sys/sysproto.h

     
    1823 1823 char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
    1824 1824 char ptr_l_[PADL_(uint32_t *)]; uint32_t * ptr; char ptr_r_[PADR_(uint32_t *)];
    1825 1825 };
    1826 struct __realpathat_args {
    1827 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
    1828 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
    1829 char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
    1830 char size_l_[PADL_(size_t)]; size_t size; char size_r_[PADR_(size_t)];
    1831 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
    1832 };
    1826 1833 int nosys(struct thread *, struct nosys_args *);
    1827 1834 void sys_sys_exit(struct thread *, struct sys_exit_args *);
    1828 1835 int sys_fork(struct thread *, struct fork_args *);
     
    2212 2219 int sys_shm_open2(struct thread *, struct shm_open2_args *);
    2213 2220 int sys_shm_rename(struct thread *, struct shm_rename_args *);
    2214 2221 int sys_sigfastblock(struct thread *, struct sigfastblock_args *);
    2222 int sys___realpathat(struct thread *, struct __realpathat_args *);
    2215 2223
    2216 2224 #ifdef COMPAT_43
    2217 2225
     
    3136 3144 #define SYS_AUE_shm_open2 AUE_SHMOPEN
    3137 3145 #define SYS_AUE_shm_rename AUE_SHMRENAME
    3138 3146 #define SYS_AUE_sigfastblock AUE_NULL
    3147 #define SYS_AUE___realpathat AUE_REALPATHAT
    3139 3148
    3140 3149 #undef PAD_
    3141 3150 #undef PADL_
  • projects/clang1000-import/sys/vm/vm_radix.c

     
    208 208 case SMR:
    209 209 return (smr_entered_load(p, vm_radix_smr));
    210 210 }
    211 /* This is unreachable, silence gcc. */
    212 panic("vm_radix_node_get: Unknown access type");
    211 213 }
    212 214
    213 215 static __inline void
  • projects/clang1000-import/sys/vm/vnode_pager.c

     
    628 628
    629 629 bwait(bp, PVM, "vnsrd");
    630 630
    631 if ((bp->b_ioflags & BIO_ERROR) != 0)
    632 error = EIO;
    631 if ((bp->b_ioflags & BIO_ERROR) != 0) {
    632 KASSERT(bp->b_error != 0,
    633 ("%s: buf error but b_error == 0\n", __func__));
    634 error = bp->b_error;
    635 }
    633 636
    634 637 /*
    635 638 * free the buffer header back to the swap buffer pool
     
    1113 1116 off_t tfoff, nextoff;
    1114 1117 int i, error;
    1115 1118
    1116 error = (bp->b_ioflags & BIO_ERROR) != 0 ? EIO : 0;
    1119 KASSERT((bp->b_ioflags & BIO_ERROR) == 0 || bp->b_error != 0,
    1120 ("%s: buf error but b_error == 0\n", __func__));
    1121 error = (bp->b_ioflags & BIO_ERROR) != 0 ? bp->b_error : 0;
    1117 1122 object = bp->b_vp->v_object;
    1118 1123
    1119 1124 if (error == 0 && bp->b_bcount != bp->b_npages * PAGE_SIZE) {
     
    1169 1174 vm_page_readahead_finish(mt);
    1170 1175 }
    1171 1176 VM_OBJECT_RUNLOCK(object);
    1172 if (error != 0)
    1173 printf("%s: I/O read error %d\n", __func__, error);
    1174 1177
    1175 1178 return (error);
    1176 1179 }
  • projects/clang1000-import/UPDATING

     
    32 32 information about prerequisites and upgrading, if you are not already
    33 33 using clang 3.5.0 or higher.
    34 34
    35 20200218:
    36 ncurses has been updated to a newer version (6.1-20200118). After an
    37 update some applications using ncurses may results have some rendering
    38 problems and would need to be rebuilt.
    35 20200220:
    36 ncurses has been updated to a newer version (6.1-20200118). Given the ABI
    37 has changed, users will have to rebuild all the ports that are linked to
    38 ncurses.
    39 39
    40 40 20200217:
    41 41 The size of struct vnet and the magic cookie have changed.
  • projects/clang1000-import/usr.bin/truss/syscalls.c

     
    115 115 .args = { { Int, 0 }, { Int, 1 }, { CapRights | OUT, 2 } } },
    116 116 { .name = "__getcwd", .ret_type = 1, .nargs = 2,
    117 117 .args = { { Name | OUT, 0 }, { Int, 1 } } },
    118 { .name = "__realpathat", .ret_type = 1, .nargs = 5,
    119 .args = { { Atfd, 0 }, { Name | IN, 1 }, { Name | OUT, 2 },
    120 { Sizet, 3 }, { Int, 4} } },
    118 121 { .name = "_umtx_op", .ret_type = 1, .nargs = 5,
    119 122 .args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 },
    120 123 { Ptr, 4 } } },
  • projects/clang1000-import/usr.sbin/pciconf/cap.c

     
    1015 1015 { PCIZ_LN_REQ, "LN Requester" },
    1016 1016 { PCIZ_DPC, "Downstream Port Containment" },
    1017 1017 { PCIZ_L1PM, "L1 PM Substates" },
    1018 { PCIZ_PTM, "Precision Time Measurement" },
    1019 { PCIZ_M_PCIE, "PCIe over M-PHY" },
    1020 { PCIZ_FRS, "FRS Queuing" },
    1021 { PCIZ_RTR, "Readiness Time Reporting" },
    1022 { PCIZ_DVSEC, "Designated Vendor-Specific" },
    1023 { PCIZ_VF_REBAR, "VF Resizable BAR" },
    1024 { PCIZ_DLNK, "Data Link Feature" },
    1025 { PCIZ_16GT, "Physical Layer 16.0 GT/s" },
    1026 { PCIZ_LMR, "Lane Margining at Receiver" },
    1027 { PCIZ_HIER_ID, "Hierarchy ID" },
    1028 { PCIZ_NPEM, "Native PCIe Enclosure Management" },
    1029 { PCIZ_PL32, "Physical Layer 32.0 GT/s" },
    1030 { PCIZ_AP, "Alternate Protocol" },
    1031 { PCIZ_SFI, "System Firmware Intermediary" },
    1018 1032 { 0, NULL }
    1019 1033 };
    1020 1034
  • projects/clang1000-import/usr.sbin/pciconf/pciconf.c

     
    665 665 {PCIC_STORAGE, PCIS_STORAGE_SATA, "SATA"},
    666 666 {PCIC_STORAGE, PCIS_STORAGE_SAS, "SAS"},
    667 667 {PCIC_STORAGE, PCIS_STORAGE_NVM, "NVM"},
    668 {PCIC_STORAGE, PCIS_STORAGE_UFS, "UFS"},
    668 669 {PCIC_NETWORK, -1, "network"},
    669 670 {PCIC_NETWORK, PCIS_NETWORK_ETHERNET, "ethernet"},
    670 671 {PCIC_NETWORK, PCIS_NETWORK_TOKENRING, "token ring"},
    671 672 {PCIC_NETWORK, PCIS_NETWORK_FDDI, "fddi"},
    672 673 {PCIC_NETWORK, PCIS_NETWORK_ATM, "ATM"},
    673 674 {PCIC_NETWORK, PCIS_NETWORK_ISDN, "ISDN"},
    675 {PCIC_NETWORK, PCIS_NETWORK_WORLDFIP, "WorldFip"},
    676 {PCIC_NETWORK, PCIS_NETWORK_PICMG, "PICMG"},
    677 {PCIC_NETWORK, PCIS_NETWORK_INFINIBAND, "InfiniBand"},
    678 {PCIC_NETWORK, PCIS_NETWORK_HFC, "host fabric"},
    674 679 {PCIC_DISPLAY, -1, "display"},
    675 680 {PCIC_DISPLAY, PCIS_DISPLAY_VGA, "VGA"},
    676 681 {PCIC_DISPLAY, PCIS_DISPLAY_XGA, "XGA"},
     
    693 698 {PCIC_BRIDGE, PCIS_BRIDGE_NUBUS, "PCI-NuBus"},
    694 699 {PCIC_BRIDGE, PCIS_BRIDGE_CARDBUS, "PCI-CardBus"},
    695 700 {PCIC_BRIDGE, PCIS_BRIDGE_RACEWAY, "PCI-RACEway"},
    701 {PCIC_BRIDGE, PCIS_BRIDGE_PCI_TRANSPARENT,
    702 "Semi-transparent PCI-to-PCI"},
    703 {PCIC_BRIDGE, PCIS_BRIDGE_INFINIBAND, "InfiniBand-PCI"},
    704 {PCIC_BRIDGE, PCIS_BRIDGE_AS_PCI,
    705 "AdvancedSwitching-PCI"},
    696 706 {PCIC_SIMPLECOMM, -1, "simple comms"},
    697 707 {PCIC_SIMPLECOMM, PCIS_SIMPLECOMM_UART, "UART"}, /* could detect 16550 */
    698 708 {PCIC_SIMPLECOMM, PCIS_SIMPLECOMM_PAR, "parallel port"},
     
    706 716 {PCIC_BASEPERIPH, PCIS_BASEPERIPH_PCIHOT, "PCI hot-plug controller"},
    707 717 {PCIC_BASEPERIPH, PCIS_BASEPERIPH_SDHC, "SD host controller"},
    708 718 {PCIC_BASEPERIPH, PCIS_BASEPERIPH_IOMMU, "IOMMU"},
    719 {PCIC_BASEPERIPH, PCIS_BASEPERIPH_RCEC,
    720 "Root Complex Event Collector"},
    709 721 {PCIC_INPUTDEV, -1, "input device"},
    710 722 {PCIC_INPUTDEV, PCIS_INPUTDEV_KEYBOARD, "keyboard"},
    711 723 {PCIC_INPUTDEV, PCIS_INPUTDEV_DIGITIZER,"digitizer"},
     
    721 733 {PCIC_SERIALBUS, PCIS_SERIALBUS_USB, "USB"},
    722 734 {PCIC_SERIALBUS, PCIS_SERIALBUS_FC, "Fibre Channel"},
    723 735 {PCIC_SERIALBUS, PCIS_SERIALBUS_SMBUS, "SMBus"},
    736 {PCIC_SERIALBUS, PCIS_SERIALBUS_INFINIBAND, "InfiniBand"},
    737 {PCIC_SERIALBUS, PCIS_SERIALBUS_IPMI, "IPMI"},
    738 {PCIC_SERIALBUS, PCIS_SERIALBUS_SERCOS, "SERCOS"},
    739 {PCIC_SERIALBUS, PCIS_SERIALBUS_CANBUS, "CANbus"},
    740 {PCIC_SERIALBUS, PCIS_SERIALBUS_MIPI_I3C, "MIPI I3C"},
    724 741 {PCIC_WIRELESS, -1, "wireless controller"},
    725 742 {PCIC_WIRELESS, PCIS_WIRELESS_IRDA, "iRDA"},
    726 743 {PCIC_WIRELESS, PCIS_WIRELESS_IR, "IR"},
    727 744 {PCIC_WIRELESS, PCIS_WIRELESS_RF, "RF"},
    745 {PCIC_WIRELESS, PCIS_WIRELESS_BLUETOOTH, "bluetooth"},
    746 {PCIC_WIRELESS, PCIS_WIRELESS_BROADBAND, "broadband"},
    747 {PCIC_WIRELESS, PCIS_WIRELESS_80211A, "ethernet 802.11a"},
    748 {PCIC_WIRELESS, PCIS_WIRELESS_80211B, "ethernet 802.11b"},
    749 {PCIC_WIRELESS, PCIS_WIRELESS_CELL,
    750 "cellular controller/modem"},
    751 {PCIC_WIRELESS, PCIS_WIRELESS_CELL_E,
    752 "cellular controller/modem plus ethernet"},
    728 753 {PCIC_INTELLIIO, -1, "intelligent I/O controller"},
    729 754 {PCIC_INTELLIIO, PCIS_INTELLIIO_I2O, "I2O"},
    730 755 {PCIC_SATCOM, -1, "satellite communication"},
  • projects/clang1000-import/usr.sbin/services_mkdb/services_mkdb.c

     
    56 56 static char tname[MAXPATHLEN];
    57 57
    58 58 #define PMASK 0xffff
    59 #define PROTOMAX 5
    59 #define PROTOMAX 6
    60 60
    61 61 static void add(DB *, StringList *, size_t, const char *, size_t *, int);
    62 62 static StringList ***parseservices(const char *, StringList *);