elfcap.c (faa201661c72339a6764f6f64e2f052f804da9b6) | elfcap.c (ebb8ac078e9265f87093fbb363e8c2cbc6ee13e6) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Copyright (c) 2011, Joyent, Inc. All rights reserved. | 24 * Copyright (c) 2012, Joyent, Inc. All rights reserved. |
25 */ 26 27/* LINTLIBRARY */ 28 29/* 30 * String conversion routine for hardware capabilities types. 31 */ 32#include <strings.h> --- 269 unchanged lines hidden (view full) --- 302 STRDESC("VMX"), STRDESC("vmx"), 303 }, 304 { /* 0x80000000 */ 305 AV_386_AMD_SVM, STRDESC("AV_386_AMD_SVM"), 306 STRDESC("AMD_SVM"), STRDESC("amd_svm"), 307 } 308}; 309 | 25 */ 26 27/* LINTLIBRARY */ 28 29/* 30 * String conversion routine for hardware capabilities types. 31 */ 32#include <strings.h> --- 269 unchanged lines hidden (view full) --- 302 STRDESC("VMX"), STRDESC("vmx"), 303 }, 304 { /* 0x80000000 */ 305 AV_386_AMD_SVM, STRDESC("AV_386_AMD_SVM"), 306 STRDESC("AMD_SVM"), STRDESC("amd_svm"), 307 } 308}; 309 |
310static const elfcap_desc_t hw2_386[ELFCAP_NUM_HW2_386] = { 311 { /* 0x00000001 */ 312 AV_386_2_F16C, STRDESC("AV_386_2_F16C"), 313 STRDESC("F16C"), STRDESC("f16c"), 314 }, 315 { /* 0x00000002 */ 316 AV_386_2_RDRAND, STRDESC("AV_386_2_RDRAND"), 317 STRDESC("RDRAND"), STRDESC("rdrand"), 318 } 319}; 320 |
|
310/* 311 * Concatenate a token to the string buffer. This can be a capabilities token 312 * or a separator token. 313 */ 314static elfcap_err_t 315token(char **ostr, size_t *olen, const elfcap_str_t *nstr) 316{ 317 if (*olen < nstr->s_len) --- 96 unchanged lines hidden (view full) --- 414 (mach == EM_SPARCV9)) 415 return (expand(style, val, hw1_sparc, ELFCAP_NUM_HW1_SPARC, 416 str, len, fmt)); 417 418 return (ELFCAP_ERR_UNKMACH); 419} 420 421/* | 321/* 322 * Concatenate a token to the string buffer. This can be a capabilities token 323 * or a separator token. 324 */ 325static elfcap_err_t 326token(char **ostr, size_t *olen, const elfcap_str_t *nstr) 327{ 328 if (*olen < nstr->s_len) --- 96 unchanged lines hidden (view full) --- 425 (mach == EM_SPARCV9)) 426 return (expand(style, val, hw1_sparc, ELFCAP_NUM_HW1_SPARC, 427 str, len, fmt)); 428 429 return (ELFCAP_ERR_UNKMACH); 430} 431 432/* |
422 * Expand a CA_SUNW_HW_2 value. Presently, there are no values, this routine 423 * is simply a place holder for future development. | 433 * Expand a CA_SUNW_HW_2 value. |
424 */ 425elfcap_err_t | 434 */ 435elfcap_err_t |
426/* ARGSUSED0 */ | |
427elfcap_hw2_to_str(elfcap_style_t style, elfcap_mask_t val, char *str, 428 size_t len, elfcap_fmt_t fmt, ushort_t mach) 429{ 430 /* 431 * Initialize the string buffer, and validate the format request. 432 */ 433 *str = '\0'; 434 if ((fmt < 0) || (fmt >= FORMAT_NELTS)) 435 return (ELFCAP_ERR_INVFMT); 436 | 436elfcap_hw2_to_str(elfcap_style_t style, elfcap_mask_t val, char *str, 437 size_t len, elfcap_fmt_t fmt, ushort_t mach) 438{ 439 /* 440 * Initialize the string buffer, and validate the format request. 441 */ 442 *str = '\0'; 443 if ((fmt < 0) || (fmt >= FORMAT_NELTS)) 444 return (ELFCAP_ERR_INVFMT); 445 |
446 if ((mach == EM_386) || (mach == EM_IA_64) || (mach == EM_AMD64)) 447 return (expand(style, val, &hw2_386[0], ELFCAP_NUM_HW2_386, 448 str, len, fmt)); 449 |
|
437 return (expand(style, val, NULL, 0, str, len, fmt)); 438} 439 440/* 441 * Expand a CA_SUNW_SF_1 value. Note, that at present these capabilities are 442 * common across all platforms. The use of "mach" is therefore redundant, but 443 * is retained for compatibility with the interface of elfcap_hw1_to_str(), and 444 * possible future expansion. --- 82 unchanged lines hidden (view full) --- 527 528 if ((mach == EM_SPARC) || (mach == EM_SPARC32PLUS) || 529 (mach == EM_SPARCV9)) 530 return (value(style, str, hw1_sparc, ELFCAP_NUM_HW1_SPARC)); 531 532 return (0); 533} 534elfcap_mask_t | 450 return (expand(style, val, NULL, 0, str, len, fmt)); 451} 452 453/* 454 * Expand a CA_SUNW_SF_1 value. Note, that at present these capabilities are 455 * common across all platforms. The use of "mach" is therefore redundant, but 456 * is retained for compatibility with the interface of elfcap_hw1_to_str(), and 457 * possible future expansion. --- 82 unchanged lines hidden (view full) --- 540 541 if ((mach == EM_SPARC) || (mach == EM_SPARC32PLUS) || 542 (mach == EM_SPARCV9)) 543 return (value(style, str, hw1_sparc, ELFCAP_NUM_HW1_SPARC)); 544 545 return (0); 546} 547elfcap_mask_t |
535/* ARGSUSED0 */ | |
536elfcap_hw2_from_str(elfcap_style_t style, const char *str, ushort_t mach) 537{ | 548elfcap_hw2_from_str(elfcap_style_t style, const char *str, ushort_t mach) 549{ |
550 if ((mach == EM_386) || (mach == EM_IA_64) || (mach == EM_AMD64)) 551 return (value(style, str, &hw2_386[0], ELFCAP_NUM_HW2_386)); 552 |
|
538 return (0); 539} 540 541/* 542 * Given a capability tag type and value, return the capabilities values 543 * contained in the string. 544 */ 545elfcap_mask_t --- 38 unchanged lines hidden --- | 553 return (0); 554} 555 556/* 557 * Given a capability tag type and value, return the capabilities values 558 * contained in the string. 559 */ 560elfcap_mask_t --- 38 unchanged lines hidden --- |