Skip to content
Snippets Groups Projects
Select Git revision
  • v1.1-rc0
  • master default
  • sp/trace-zero-ranges
  • stable-2.5
  • stable-2.4
  • stable-2.3
  • stable-2.2
  • stable-2.1
  • stable-2.0
  • stable-1.7
  • stable-1.6
  • stable-1.5
  • stable-1.4
  • stable-1.3
  • stable-1.2
  • stable-1.1
  • stable-1.0
  • stable-0.15
  • stable-0.14
  • stable-0.13
  • stable-0.12
  • v2.7.0-rc1
  • v2.7.0-rc0
  • v2.6.0
  • v2.5.1.1
  • v2.6.0-rc5
  • v2.6.0-rc4
  • v2.6.0-rc3
  • v2.6.0-rc2
  • v2.6.0-rc1
  • v2.6.0-rc0
  • v2.5.1
  • v2.5.0
  • v2.5.0-rc4
  • v2.5.0-rc3
  • v2.5.0-rc2
  • v2.5.0-rc1
  • v2.5.0-rc0
  • v2.4.1
  • v2.4.0.1
  • v2.3.1
41 results

cache-utils.c

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    cache-utils.c 2.15 KiB
    #include "cache-utils.h"
    
    #if defined(_ARCH_PPC)
    struct qemu_cache_conf qemu_cache_conf = {
        .dcache_bsize = 16,
        .icache_bsize = 16
    };
    
    #if defined _AIX
    #include <sys/systemcfg.h>
    
    static void ppc_init_cacheline_sizes(void)
    {
        qemu_cache_conf.icache_bsize = _system_configuration.icache_line;
        qemu_cache_conf.dcache_bsize = _system_configuration.dcache_line;
    }
    
    #elif defined __linux__
    
    #define QEMU_AT_NULL        0
    #define QEMU_AT_DCACHEBSIZE 19
    #define QEMU_AT_ICACHEBSIZE 20
    
    static void ppc_init_cacheline_sizes(char **envp)
    {
        unsigned long *auxv;
    
        while (*envp++);
    
        for (auxv = (unsigned long *) envp; *auxv != QEMU_AT_NULL; auxv += 2) {
            switch (*auxv) {
            case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
            case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
            default: break;
            }
        }
    }
    
    #elif defined __APPLE__
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/sysctl.h>
    
    static void ppc_init_cacheline_sizes(void)
    {
        size_t len;
        unsigned cacheline;
        int name[2] = { CTL_HW, HW_CACHELINE };
    
        len = sizeof(cacheline);
        if (sysctl(name, 2, &cacheline, &len, NULL, 0)) {
            perror("sysctl CTL_HW HW_CACHELINE failed");
        } else {
            qemu_cache_conf.dcache_bsize = cacheline;
            qemu_cache_conf.icache_bsize = cacheline;
        }
    }
    #endif
    
    #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    #include <errno.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/sysctl.h>
    
    static void ppc_init_cacheline_sizes(void)
    {
        size_t len = 4;