/* This program is part of the TACLeBench benchmark suite. Version V 1.x Name: ndes Author: unknown Function: A lot of bit manipulation, shifts, array and matrix calculations. Source: Changes: no major functional changes License: May be used, modified, and re-distributed freely. */ /* A read from this address will result in an known value of 1 */ #include "extra.h" #define KNOWN_VALUE 1 #define NDES_WORSTCASE 1 /* Declaration of global variables */ typedef struct NDES_IMMENSE { unsigned long l, r; } ndes_immense; typedef struct NDES_GREAT { unsigned long l, c, r; } ndes_great; unsigned long ndes_bit[33]; ndes_immense ndes_inp, ndes_key, ndes_out; int ndes_newkey, ndes_isw; static ndes_immense ndes_icd; static char ndes_ipc1[57]; static char ndes_ipc2[49]; #ifdef NDES_WORSTCASE int ndes_value = 1; #else int ndes_value = 0; #endif /* Forward funtion prototypes */ void ndes_des( ndes_immense inp, ndes_immense key, int *newkey, int isw, ndes_immense *out ); void ndes_cyfun( unsigned long ir, ndes_great k, unsigned long *iout ); unsigned long ndes_getbit( ndes_immense source, int bitno, int nbits ); void ndes_ks( /*immense key, */int n, ndes_great *kn ); void ndes_init( void ); int ndes_return( void ); void ndes_main( void ); //int main( void ); /* Initialization */ void ndes_init() { unsigned int i; volatile char ndes_ipc1_tmp[57] = { 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 }; volatile char ndes_ipc2_tmp[49] = { 0, 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 }; for ( i = 0; i < 57; i++ ) ndes_ipc1[i] = ndes_ipc1_tmp[i]; for ( i = 0; i < 49; i++ ) ndes_ipc2[i] = ndes_ipc2_tmp[i]; ndes_inp.l = KNOWN_VALUE * 35; ndes_inp.r = KNOWN_VALUE * 26; ndes_key.l = KNOWN_VALUE * 2; ndes_key.r = KNOWN_VALUE * 16; ndes_newkey = ndes_value; ndes_isw = ndes_value; } /* Arithmetic functions */ void ndes_des( ndes_immense inp, ndes_immense key, int *newkey, int isw, ndes_immense *out ) { volatile char ip[65] = { 0, 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 }; volatile char ipm[65] = { 0, 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 }; static ndes_great kns[17]; #ifdef NDES_WORSTCASE static int initflag = 1; #else static int initflag = 0; #endif int ii, i, j, k; unsigned long ic, shifter; ndes_immense itmp; ndes_great pg; if ( initflag ) { initflag = 0; ndes_bit[1] = shifter = 1L; _Pragma( "loopbound min 31 max 31" ) for ( j = 2; j <= 32; j++ ) ndes_bit[j] = ( shifter <<= 1 ); } if ( *newkey ) { *newkey = 0; ndes_icd.r = ndes_icd.l = 0L; _Pragma( "loopbound min 28 max 28" ) for ( j = 28, k = 56; j >= 1; j--, k-- ) { ndes_icd.r = ( ndes_icd.r << 1 ) | ndes_getbit( key, ndes_ipc1[j], 32 ); ndes_icd.l = ndes_icd.l << 1; ndes_icd.l = ( ndes_icd.l ) | ndes_getbit( key, ndes_ipc1[k], 32 ); } _Pragma( "loopbound min 16 max 16" ) for ( i = 1; i <= 16; i++ ) { pg = kns[i]; ndes_ks( /* key,*/ i, &pg ); kns[i] = pg; } } itmp.r = itmp.l = 0L; _Pragma( "loopbound min 32 max 32" ) for ( j = 32, k = 64; j >= 1; j--, k-- ) { itmp.r = itmp.r << 1; itmp.r = ( itmp.r ) | ndes_getbit( inp, ip[j], 32 ); itmp.l = itmp.l << 1; itmp.l = ( itmp.l ) | ndes_getbit( inp, ip[k], 32 ); } _Pragma( "loopbound min 16 max 16" ) for ( i = 1; i <= 16; i++ ) { ii = ( isw == 1 ? 17 - i : i ); ndes_cyfun( itmp.l, kns[ii], &ic ); ic ^= itmp.r; itmp.r = itmp.l; itmp.l = ic; } ic = itmp.r; itmp.r = itmp.l; itmp.l = ic; ( *out ).r = ( *out ).l = 0L; _Pragma( "loopbound min 32 max 32" ) for ( j = 32, k = 64; j >= 1; j--, k-- ) { ( *out ).r = ( *out ).r << 1; ( *out ).r = ( ( *out ).r ) | ndes_getbit( itmp, ipm[j], 32 ); ( *out ).l = ( *out ).l << 1; ( *out ).l = ( ( *out ).l ) | ndes_getbit( itmp, ipm[k], 32 ); } } void ndes_cyfun( unsigned long ir, ndes_great k, unsigned long *iout ) { volatile long iet[49] = {0, 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1 }; volatile long ipp[33] = {0, 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; volatile long is[16][4][9] = {{{ 0 , 14 , 15 , 10 , 7 , 2 , 12 , 4 , 13 }, { 0 , 0 , 3 , 13 , 13 , 14 , 10 , 13 , 1 }, { 0 , 4 , 0 , 13 , 10 , 4 , 9 , 1 , 7 }, { 0 , 15 , 13 , 1 , 3 , 11 , 4 , 6 , 2 }}, {{ 0 , 4 , 1 , 0 , 13 , 12 , 1 , 11 , 2 }, { 0 , 15 , 13 , 7 , 8 , 11 , 15 , 0 , 15 }, { 0 , 1 , 14 , 6 , 6 , 2 , 14 , 4 , 11 }, { 0 , 12 , 8 , 10 , 15 , 8 , 3 , 11 , 1 }}, {{ 0 , 13 , 8 , 9 , 14 , 4 , 10 , 2 , 8 }, { 0 , 7 , 4 , 0 , 11 , 2 , 4 , 11 , 13 }, { 0 , 14 , 7 , 4 , 9 , 1 , 15 , 11 , 4 }, { 0 , 8 , 10 , 13 , 0 , 12 , 2 , 13 , 14 }}, {{ 0 , 1 , 14 , 14 , 3 , 1 , 15 , 14 , 4 }, { 0 , 4 , 7 , 9 , 5 , 12 , 2 , 7 , 8 }, { 0 , 8 , 11 , 9 , 0 , 11 , 5 , 13 , 1 }, { 0 , 2 , 1 , 0 , 6 , 7 , 12 , 8 , 7 }}, {{ 0 , 2 , 6 , 6 , 0 , 7 , 9 , 15 , 6 }, { 0 , 14 , 15 , 3 , 6 , 4 , 7 , 4 , 10 }, { 0 , 13 , 10 , 8 , 12 , 10 , 2 , 12 , 9 }, { 0 , 4 , 3 , 6 , 10 , 1 , 9 , 1 , 4 }}, {{ 0 , 15 , 11 , 3 , 6 , 10 , 2 , 0 , 15 }, { 0 , 2 , 2 , 4 , 15 , 7 , 12 , 9 , 3 }, { 0 , 6 , 4 , 15 , 11 , 13 , 8 , 3 ,/* * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef NVGPU_CLK_VIN_H #define NVGPU_CLK_VIN_H #include "boardobj/boardobj.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" struct vin_device; struct clk_pmupstate; struct avfsvinobjs { struct boardobjgrp_e32 super; u8 calibration_rev_vbios; u8 calibration_rev_fused; bool vin_is_disable_allowed; }; typedef u32 vin_device_state_load(struct gk20a *g, struct clk_pmupstate *clk, struct vin_device *pdev); struct vin_device { struct boardobj super; u8 id; u8 volt_domain; u8 volt_domain_vbios; u32 flls_shared_mask; vin_device_state_load *state_load; }; struct vin_device_v10 { struct vin_device super; struct ctrl_clk_vin_device_info_data_v10 data; }; struct vin_device_v20 { struct vin_device super; struct ctrl_clk_vin_device_info_data_v20 data; }; /* get vin device object from descriptor table index*/ #define CLK_GET_VIN_DEVICE(pvinobjs, dev_index) \ ((struct vin_device *)BOARDOBJGRP_OBJ_GET_BY_IDX( \ ((struct boardobjgrp *)&(pvinobjs->super.super)), (dev_index))) boardobj_construct construct_vindevice; boardobj_pmudatainit vindeviceinit_pmudata_super;