|
Packit Service |
82fcde |
/* Copyright (C) 2004-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <assert.h>
|
|
Packit Service |
82fcde |
#include <stdbool.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
#include <unistd.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static long int linux_sysconf (int name);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define CSHAPE(totalsize, linesize, assoc) \
|
|
Packit Service |
82fcde |
((totalsize & ~0xff) | (linesize << 4) | assoc)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
extern long __libc_alpha_cache_shape[4];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Get the value of the system variable NAME. */
|
|
Packit Service |
82fcde |
long int
|
|
Packit Service |
82fcde |
__sysconf (int name)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
long shape, index;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* We only handle the cache information here (for now). */
|
|
Packit Service |
82fcde |
if (name < _SC_LEVEL1_ICACHE_SIZE || name > _SC_LEVEL4_CACHE_LINESIZE)
|
|
Packit Service |
82fcde |
return linux_sysconf (name);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* No Alpha has L4 caches. */
|
|
Packit Service |
82fcde |
if (name >= _SC_LEVEL4_CACHE_SIZE)
|
|
Packit Service |
82fcde |
return -1;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
index = (name - _SC_LEVEL1_ICACHE_SIZE) / 3;
|
|
Packit Service |
82fcde |
shape = __libc_alpha_cache_shape[index];
|
|
Packit Service |
82fcde |
if (shape == -2)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
long shape_l1i, shape_l1d, shape_l2, shape_l3 = -1;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* ??? In the cases below for which we do not know L1 cache sizes,
|
|
Packit Service |
82fcde |
we could do timings to measure sizes. But for the Bcache, it's
|
|
Packit Service |
82fcde |
generally big enough that (without additional help) TLB effects
|
|
Packit Service |
82fcde |
get in the way. We'd either need to be able to allocate large
|
|
Packit Service |
82fcde |
pages or have the kernel do the timings from KSEG. Fortunately,
|
|
Packit Service |
82fcde |
kernels beginning with 2.6.5 will pass us this info in auxvec. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
switch (__builtin_alpha_implver ())
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
case 0: /* EV4 */
|
|
Packit Service |
82fcde |
/* EV4/LCA45 had 8k L1 caches; EV45 had 16k L1 caches. */
|
|
Packit Service |
82fcde |
/* EV4/EV45 had 128k to 16M 32-byte direct Bcache. LCA45
|
|
Packit Service |
82fcde |
had 64k to 8M 8-byte direct Bcache. Can't tell. */
|
|
Packit Service |
82fcde |
shape_l1i = shape_l1d = shape_l2 = CSHAPE (0, 5, 1);
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
case 1: /* EV5 */
|
|
Packit Service |
82fcde |
if (__builtin_alpha_amask (1 << 8))
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* MAX insns not present; either EV5 or EV56. */
|
|
Packit Service |
82fcde |
shape_l1i = shape_l1d = CSHAPE(8*1024, 5, 1);
|
|
Packit Service |
82fcde |
/* ??? L2 and L3 *can* be configured as 32-byte line. */
|
|
Packit Service |
82fcde |
shape_l2 = CSHAPE (96*1024, 6, 3);
|
|
Packit Service |
82fcde |
/* EV5/EV56 has 1M to 16M Bcache. */
|
|
Packit Service |
82fcde |
shape_l3 = CSHAPE (0, 6, 1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* MAX insns present; either PCA56 or PCA57. */
|
|
Packit Service |
82fcde |
/* PCA56 had 16k 64-byte cache; PCA57 had 32k Icache. */
|
|
Packit Service |
82fcde |
/* PCA56 had 8k 64-byte cache; PCA57 had 16k Dcache. */
|
|
Packit Service |
82fcde |
/* PCA5[67] had 512k to 4M Bcache. */
|
|
Packit Service |
82fcde |
shape_l1i = shape_l1d = shape_l2 = CSHAPE (0, 6, 1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
case 2: /* EV6 */
|
|
Packit Service |
82fcde |
shape_l1i = shape_l1d = CSHAPE(64*1024, 6, 2);
|
|
Packit Service |
82fcde |
/* EV6/EV67/EV68* had 1M to 16M Bcache. */
|
|
Packit Service |
82fcde |
shape_l2 = CSHAPE (0, 6, 1);
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
case 3: /* EV7 */
|
|
Packit Service |
82fcde |
shape_l1i = shape_l1d = CSHAPE(64*1024, 6, 2);
|
|
Packit Service |
82fcde |
shape_l2 = CSHAPE(7*1024*1024/4, 6, 7);
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
default:
|
|
Packit Service |
82fcde |
shape_l1i = shape_l1d = shape_l2 = 0;
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
__libc_alpha_cache_shape[0] = shape_l1i;
|
|
Packit Service |
82fcde |
__libc_alpha_cache_shape[1] = shape_l1d;
|
|
Packit Service |
82fcde |
__libc_alpha_cache_shape[2] = shape_l2;
|
|
Packit Service |
82fcde |
__libc_alpha_cache_shape[3] = shape_l3;
|
|
Packit Service |
82fcde |
shape = __libc_alpha_cache_shape[index];
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (shape <= 0)
|
|
Packit Service |
82fcde |
return shape;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
switch ((name - _SC_LEVEL1_ICACHE_SIZE) % 3)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
case 0: /* total size */
|
|
Packit Service |
82fcde |
return shape & -0x100;
|
|
Packit Service |
82fcde |
case 1: /* associativity */
|
|
Packit Service |
82fcde |
return shape & 0xf;
|
|
Packit Service |
82fcde |
default: /* line size */
|
|
Packit Service |
82fcde |
return 1L << ((shape >> 4) & 0xf);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Now the generic Linux version. */
|
|
Packit Service |
82fcde |
#undef __sysconf
|
|
Packit Service |
82fcde |
#define __sysconf static linux_sysconf
|
|
Packit Service |
82fcde |
#include <sysdeps/unix/sysv/linux/sysconf.c>
|