├── registers
├── .gitignore
├── adreno.xml
├── dsi
│ ├── sfpb.xml
│ ├── mmss_cc.xml
│ ├── dsi_phy_v2.xml
│ ├── dsi_phy_20nm.xml
│ └── dsi_phy_10nm.xml
├── hdmi
│ └── qfprom.xml
├── msm.xml
├── freedreno_copyright.xml
├── adreno
│ ├── ocmem.xml
│ ├── meson.build
│ └── adreno_pipe_regs.xml
├── meson.build
├── mdp
│ └── mdp_common.xml
└── text-format.txt
├── .lastsync
├── isa
├── README.rst
├── ir3-disasm.c
├── ir3-cat7.xml
├── isa.h
├── meson.build
├── ir3.xml
├── ir3-cat4.xml
└── decode.h
├── stub-mesa
├── README
├── util
│ ├── u_debug.h
│ ├── meson.build
│ ├── os_memory.h
│ ├── os_memory_stdc.h
│ ├── softfloat.h
│ ├── log.c
│ ├── log.h
│ ├── compiler.h
│ ├── fast_urem_by_const.h
│ ├── u_memory.h
│ ├── u_endian.h
│ ├── os_memory_aligned.h
│ ├── os_file.h
│ ├── u_math.c
│ ├── half_float.h
│ ├── set.h
│ └── rounding.h
├── c11_compat.h
└── no_extern_c.h
├── .gitlab-ci
├── traces
│ ├── shadow.rd.gz
│ ├── fd-clouds.rd.gz
│ ├── es2gears-a320.rd.gz
│ └── glxgears-a420.rd.gz
├── debian-install.sh
├── README.rst
├── reference
│ └── shadow.log
└── genoutput.sh
├── .gitignore
├── .editorconfig
├── extract-shaderdb.sh
├── decode
├── scripts
│ ├── test.lua
│ ├── sanity-a6xx.lua
│ └── tex3d-layout.lua
├── pager.h
├── buffers.h
├── io.h
├── rnnutil.h
├── script.h
├── pager.c
├── cffdec.h
├── redump.h
├── io.c
└── meson.build
├── ir3
├── meson.build
└── regmask.h
├── README
├── ir2
└── meson.build
├── rnn
├── aprintf.c
├── meson.build
├── colors.c
├── colors.h
├── path.c
├── rnndec.h
└── util.h
├── afuc
├── util.h
├── meson.build
├── emu-ds.c
├── asm.h
└── lexer.l
├── .gitlab-ci.yml
├── common
├── disasm.h
└── freedreno_pm4.h
├── sync-from-mesa.sh
└── meson.build
/registers/.gitignore:
--------------------------------------------------------------------------------
1 | *.xml.h
2 |
--------------------------------------------------------------------------------
/.lastsync:
--------------------------------------------------------------------------------
1 | 1a6dd7f9b1c1a43d9e1b66637e13af1de3f2c3cc
2 |
--------------------------------------------------------------------------------
/isa/README.rst:
--------------------------------------------------------------------------------
1 | ../../../docs/drivers/freedreno/isaspec.rst
--------------------------------------------------------------------------------
/stub-mesa/README:
--------------------------------------------------------------------------------
1 | A minimal set of mesa headers and stubbed mesa headers needed to build.
2 |
--------------------------------------------------------------------------------
/.gitlab-ci/traces/shadow.rd.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freedreno/envytools/HEAD/.gitlab-ci/traces/shadow.rd.gz
--------------------------------------------------------------------------------
/.gitlab-ci/traces/fd-clouds.rd.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freedreno/envytools/HEAD/.gitlab-ci/traces/fd-clouds.rd.gz
--------------------------------------------------------------------------------
/.gitlab-ci/traces/es2gears-a320.rd.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freedreno/envytools/HEAD/.gitlab-ci/traces/es2gears-a320.rd.gz
--------------------------------------------------------------------------------
/.gitlab-ci/traces/glxgears-a420.rd.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freedreno/envytools/HEAD/.gitlab-ci/traces/glxgears-a420.rd.gz
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | CMakeCache.txt
3 | CMakeFiles
4 | cmake_install.cmake
5 | install_manifest.txt
6 | CTestTestfile.cmake
7 | Testing
8 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # To use this config on you editor, follow the instructions at:
2 | # http://editorconfig.org
3 |
4 | root = true
5 |
6 | [*.{c,h,cpp,hpp,cc,hh}]
7 | indent_style = tab
8 | indent_size = 8
9 | max_line_length = 78
10 |
--------------------------------------------------------------------------------
/extract-shaderdb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | for f in $*; do
5 | d=`dirname $f`
6 | b=`basename $f`
7 | num=${b#shader-runner-}
8 | num=${num%.rd.gz}
9 | num=${num%.rd}
10 | num=${num#0}
11 | num=${num#0}
12 | num=${num#0}
13 | #echo "manhattan/$num.shader_test - "
14 | pgmdump2 --shaderdb $f 2>&1 1> /dev/null | sed "s/.*/$d\/$num.shader_test - &\n/"
15 | done
16 |
--------------------------------------------------------------------------------
/stub-mesa/util/u_debug.h:
--------------------------------------------------------------------------------
1 | /* stub for compiling srcs syncd from mesa */
2 |
3 | #ifndef U_DEBUG_H_
4 | #define U_DEBUG_H_
5 |
6 | #include "util/macros.h"
7 |
8 | #if defined(__GNUC__)
9 | #define _util_printf_format(fmt, list) __attribute__ ((format (printf, fmt, list)))
10 | #else
11 | #define _util_printf_format(fmt, list)
12 | #endif
13 |
14 | #endif /* U_DEBUG_H_ */
15 |
--------------------------------------------------------------------------------
/stub-mesa/c11_compat.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2019 Intel Corporation */
2 | /* SPDX-License-Identifier: MIT */
3 |
4 | #include "no_extern_c.h"
5 |
6 | #ifndef _C11_COMPAT_H_
7 | #define _C11_COMPAT_H_
8 |
9 | #if defined(__cplusplus)
10 | /* This is C++ code, not C */
11 | #elif (__STDC_VERSION__ >= 201112L)
12 | /* Already C11 */
13 | #else
14 |
15 |
16 | /*
17 | * C11 static_assert() macro
18 | * assert.h only defines that name for C11 and above
19 | */
20 | #ifndef static_assert
21 | #define static_assert _Static_assert
22 | #endif
23 |
24 |
25 | #endif /* !C++ && !C11 */
26 |
27 | #endif /* _C11_COMPAT_H_ */
28 |
--------------------------------------------------------------------------------
/registers/adreno.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/registers/dsi/sfpb.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/registers/hdmi/qfprom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 | seems to be something external to display block, for finding
10 | what features are enabled/supported?
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.gitlab-ci/debian-install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -o errexit
3 | set -o xtrace
4 |
5 | export DEBIAN_FRONTEND=noninteractive
6 |
7 | apt-get install -y \
8 | ca-certificates
9 |
10 | sed -i -e 's/http:\/\/deb/https:\/\/deb/g' /etc/apt/sources.list
11 | echo 'deb https://deb.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/backports.list
12 |
13 | apt-get update
14 |
15 | # Use newer packages from backports by default
16 | cat >/etc/apt/preferences <
2 |
5 |
6 |
7 |
8 | Register definitions for the display related hw blocks on
9 | msm/snapdragon
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.gitlab-ci/README.rst:
--------------------------------------------------------------------------------
1 | Continuous Integration
2 | ======================
3 |
4 | In addition to a build step, the CI setup has a basic test stage
5 | to ensure that we don't break functionality of various tools. The
6 | basic idea is to decode various files and compare the output to a
7 | reference. This means that some changes, like renaming registers
8 | or bitfields in the rnndb xml requires updating the reference
9 | output.
10 |
11 | Layout:
12 | - .gitlab-ci/
13 | - traces/ - reference devcoredump and cmdstream traces. The
14 | trace files should be kept small, and .rd files (which are
15 | already binary) should be compressed.
16 | - reference/ - reference output
17 | - genoutput.sh - script to generate output from the traces,
18 | used both by the CI test job, but it can also be used
19 | to update the reference output
20 |
21 | TODO
22 | - Maybe we could filter out some differences, like a new definition
23 | of a previously unknown register?
24 | - It would be nice to add a test for afuc.. we probably cannot add
25 | a "real" fw file to this tree, but maybe could either fetch it
26 | from the linux-firmware git tree, or create our own dummy fw.
27 |
28 |
--------------------------------------------------------------------------------
/.gitlab-ci/reference/shadow.log:
--------------------------------------------------------------------------------
1 | Analyzing Data...
2 | Reading src/freedreno/.gitlab-ci/traces/shadow.rd.gz...
3 | Parsing src/freedreno/.gitlab-ci/traces/shadow.rd.gz
4 |
5 | Blit:
6 | -----
7 | MRT[0x28b4000:0x0]: 256x144 FMT6_16_UNORM (MSAA_ONE) CLEARED
8 |
9 |
10 |
11 | NULL BATCH!
12 |
13 | Blit:
14 | -----
15 | MRT[0x20ae000:0x0]: 480x272 FMT6_16_UNORM (MSAA_ONE) CLEARED
16 |
17 | Batch:
18 | -------
19 | # of draws: 1
20 | mode: RM6_GMEM
21 | bin size: 768x320 (35 bins)
22 | DEPTHTEST DEPTHWRITE
23 | MRT[0x4715000:0x0]: 3840x2160 FMT6_Z24_UNORM_S8_UINT (MSAA_ONE) CLEARED RESOLVED
24 |
25 |
26 |
27 | Blit:
28 | -----
29 | MRT[0x27d1000:0x0]: 256x144 FMT6_16_UNORM (MSAA_ONE) CLEARED
30 |
31 |
32 |
33 | Blit:
34 | -----
35 | MRT[0x28a0000:0x0]: 256x144 FMT6_16_UNORM (MSAA_ONE) CLEARED
36 |
37 | Batch:
38 | -------
39 | # of draws: 2
40 | mode: RM6_GMEM
41 | bin size: 640x192 (18 bins)
42 | DEPTHTEST DEPTHWRITE
43 | MRT[0x28fc000:0x0]: 1920x1080 FMT6_Z24_UNORM_S8_UINT (MSAA_ONE) CLEARED RESOLVED
44 | MRT[0x18ae000:0x0]: 1920x1080 FMT6_8_8_8_8_UNORM (MSAA_ONE) CLEARED RESOLVED
45 | MRT[0x0:0x0]: 1920x1080 FMT6_8_8_8_8_UNORM (MSAA_ONE) CLEARED RESOLVED
46 | SRC[0x4715000:0x46f3000]: 3840x2160 FMT6_Z24_UNORM_S8_UINT (MSAA_ONE)
47 |
48 |
49 |
--------------------------------------------------------------------------------
/decode/pager.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef __PAGER_H__
25 | #define __PAGER_H__
26 |
27 | void pager_open(void);
28 | int pager_close(void);
29 |
30 | #endif /* __PAGER_H__ */
31 |
--------------------------------------------------------------------------------
/.gitlab-ci/genoutput.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # This file contains all of the cmdlines used to generate output
4 | # for the test step in the CI pipeline. It can also be used to
5 | # regenerate reference output
6 |
7 | set -x
8 | set -e
9 |
10 | # input/output directories:
11 | base=.
12 | traces=$base/.gitlab-ci/traces
13 | output=$base/.gitlab-ci/out
14 |
15 | # use the --update arg to update reference output:
16 | if [ "$1" = "--update" ]; then
17 | output=.gitlab-ci/reference
18 | fi
19 |
20 | mkdir -p $output
21 |
22 | # binary locations:
23 | cffdump=./install/bin/cffdump
24 | crashdec=./install/bin/crashdec
25 |
26 | # helper to filter out paths that can change depending on
27 | # who is building:
28 | basepath=`dirname $0`
29 | basepath=`dirname $basepath`
30 | basepath=`pwd $basepath`
31 | filter() {
32 | out=$1
33 | grep -vF "$basepath
34 | Assertion" > $out
35 | }
36 |
37 | #
38 | # The Tests:
39 | #
40 |
41 | # dump only a single frame, and single tile pass, to keep the
42 | # reference output size managable
43 | $cffdump --frame 0 --once $traces/fd-clouds.rd.gz | filter $output/fd-clouds.log
44 | $cffdump --frame 0 --once $traces/es2gears-a320.rd.gz | filter $output/es2gears-a320.log
45 | $cffdump --frame 1 --once $traces/glxgears-a420.rd.gz | filter $output/glxgears-a420.log
46 |
47 | # test a lua script to ensure we don't break scripting API:
48 | $cffdump --script $base/decode/scripts/parse-submits.lua $traces/shadow.rd.gz | filter $output/shadow.log
49 |
50 | $crashdec -sf $traces/crash.devcore | filter $output/crash.log
51 |
52 |
--------------------------------------------------------------------------------
/ir3/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | libfreedreno_ir3 = static_library(
22 | 'freedreno_ir3',
23 | [
24 | 'disasm-a3xx.c',
25 | 'instr-a3xx.h',
26 | ],
27 | include_directories : [
28 | inc_freedreno,
29 | inc_include,
30 | inc_src,
31 | ],
32 | c_args : [no_override_init_args],
33 | gnu_symbol_visibility : 'hidden',
34 | link_with: [libir3decode],
35 | dependencies : [],
36 | build_by_default : false,
37 | )
38 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | envytools - Tools for people envious of nvidia's blob driver.
2 |
3 | The canonical repo is at: http://github.com/pathscale/envytools/
4 |
5 |
6 | = Contents =
7 |
8 | Subdirectories:
9 |
10 | - hwdocs: plain-text documentation of the GPUs
11 | - envydis: Disassembler and assembler for various ISAs found on nvidia GPUs
12 | - rnn: Tools and libraries for the rules-ng-ng XML register database format
13 | - rnndb: rnn database of nvidia MMIO registers, FIFO methods, and memory
14 | structures.
15 | - nvbios: Tools to decode the card description structures found in nvidia
16 | VBIOS
17 | - nva: Tools to directly access the GPU registers
18 | - vstream: Tools to decode and encode raw video bitstreams
19 | - vdpow: A tool aiding in VP3 reverse engineering
20 | - easm: Utility code dealing with assembly language parsing & printing.
21 | - util: Misc utility code shared between envytools modules
22 |
23 |
24 | = Building, installing =
25 |
26 | Dependencies: cmake, libxml2, flex, bison, pkg-config
27 | Optional dependencies needed by nva: libpciaccess
28 | Optional dependencies needed by vdpow: vdpau, libx11
29 |
30 | If your distribution has -dev or -devel packages, you'll also need ones
31 | corresponding to the dependencies above.
32 |
33 | To build, use
34 |
35 | $ cmake .
36 | $ make
37 |
38 | To install [which is optional], use
39 |
40 | $ make install
41 |
42 | If you want to install to a non-default directory, you'll also need to pass
43 | it as an option to cmake before building, eg.:
44 |
45 | $ cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr/local .
46 |
--------------------------------------------------------------------------------
/ir2/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | libfreedreno_ir2 = static_library(
22 | 'freedreno_ir2',
23 | [
24 | 'disasm-a2xx.c',
25 | 'instr-a2xx.h',
26 | freedreno_xml_header_files,
27 | ],
28 | include_directories : [
29 | inc_freedreno,
30 | inc_include,
31 | inc_src,
32 | ],
33 | c_args : [no_override_init_args],
34 | gnu_symbol_visibility : 'hidden',
35 | dependencies : [],
36 | build_by_default : false,
37 | )
38 |
--------------------------------------------------------------------------------
/rnn/aprintf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009-2011 Marcin Kościelnicki
3 | * All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a
6 | * copy of this software and associated documentation files (the "Software"),
7 | * to deal in the Software without restriction, including without limitation
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | * and/or sell copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice (including the next
13 | * paragraph) shall be included in all copies or substantial portions of the
14 | * Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | * OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | #include "util.h"
26 | #include
27 |
28 | char *aprintf(const char *format, ...) {
29 | va_list va;
30 | va_start(va, format);
31 | size_t sz = vsnprintf(0, 0, format, va);
32 | va_end(va);
33 | char *res = malloc(sz + 1);
34 | va_start(va, format);
35 | vsnprintf(res, sz + 1, format, va);
36 | va_end(va);
37 | return res;
38 | }
39 |
--------------------------------------------------------------------------------
/registers/freedreno_copyright.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 | Initial Author.
10 |
11 |
12 |
13 | many a3xx/a4xx contributions
14 |
15 |
16 |
17 | Permission is hereby granted, free of charge, to any person obtaining
18 | a copy of this software and associated documentation files (the
19 | "Software"), to deal in the Software without restriction, including
20 | without limitation the rights to use, copy, modify, merge, publish,
21 | distribute, sublicense, and/or sell copies of the Software, and to
22 | permit persons to whom the Software is furnished to do so, subject to
23 | the following conditions:
24 |
25 | The above copyright notice and this permission notice (including the
26 | next paragraph) shall be included in all copies or substantial
27 | portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32 | IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
33 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/decode/buffers.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef __BUFFERS_H__
25 | #define __BUFFERS_H__
26 |
27 | #include
28 | #include
29 |
30 | uint64_t gpuaddr(void *hostptr);
31 | uint64_t gpubaseaddr(uint64_t gpuaddr);
32 | void *hostptr(uint64_t gpuaddr);
33 | unsigned hostlen(uint64_t gpuaddr);
34 | bool has_dumped(uint64_t gpuaddr, unsigned enable_mask);
35 |
36 | void reset_buffers(void);
37 | void add_buffer(uint64_t gpuaddr, unsigned int len, void *hostptr);
38 |
39 | #ifndef ARRAY_SIZE
40 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
41 | #endif
42 |
43 | #endif /* __BUFFERS_H__ */
44 |
--------------------------------------------------------------------------------
/registers/dsi/mmss_cc.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 | Multimedia sub-system clock control.. appears to be used by DSI
10 | for clocks..
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/registers/adreno/ocmem.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/isa/ir3-disasm.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2020 Google, Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include "util/os_file.h"
33 |
34 | #include "isa.h"
35 |
36 |
37 | static void
38 | disasm_instr_cb(void *d, unsigned n, uint64_t instr)
39 | {
40 | uint32_t *dwords = (uint32_t *)&instr;
41 | printf("%3d[%08x_%08x] ", n, dwords[1], dwords[0]);
42 | }
43 |
44 | int
45 | main(int argc, char **argv)
46 | {
47 | size_t sz;
48 | void *raw = os_read_file(argv[1], &sz);
49 |
50 | isa_decode(raw, sz, stdout, &(struct isa_decode_options) {
51 | .show_errors = true,
52 | .branch_labels = true,
53 | .instr_cb = disasm_instr_cb,
54 | });
55 |
56 | return 0;
57 | }
58 |
--------------------------------------------------------------------------------
/registers/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2019 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | xml_files = [
22 | 'adreno.xml',
23 | 'freedreno_copyright.xml',
24 | 'rules-ng.xsd',
25 | ]
26 |
27 | gen_header_py = files('gen_header.py')
28 |
29 | freedreno_xml_header_files = []
30 |
31 | foreach f : xml_files
32 | _name = f + '.h'
33 | freedreno_xml_header_files += custom_target(
34 | _name,
35 | input: [gen_header_py, f],
36 | output: _name,
37 | command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@'],
38 | capture: true,
39 | )
40 | _gzname = f + '.gz'
41 | custom_target(
42 | _gzname,
43 | input: f,
44 | output: _gzname,
45 | command: [prog_gzip, '-kc', '@INPUT@'],
46 | capture: true,
47 | install_dir: rnn_install_path,
48 | install: install_fd_decode_tools,
49 | build_by_default: install_fd_decode_tools,
50 | )
51 | endforeach
52 |
53 | subdir('adreno')
54 |
--------------------------------------------------------------------------------
/decode/io.h:
--------------------------------------------------------------------------------
1 | /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2 |
3 | /*
4 | * Copyright (C) 2014 Rob Clark
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the "Software"),
8 | * to deal in the Software without restriction, including without limitation
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 | * and/or sell copies of the Software, and to permit persons to whom the
11 | * Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice (including the next
14 | * paragraph) shall be included in all copies or substantial portions of the
15 | * Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | * Authors:
26 | * Rob Clark
27 | */
28 |
29 | #ifndef IO_H_
30 | #define IO_H_
31 |
32 | /* Simple API to abstract reading from file which might be compressed.
33 | * Maybe someday I'll add writing..
34 | */
35 |
36 | struct io;
37 |
38 | struct io *io_open(const char *filename);
39 | struct io *io_openfd(int fd);
40 | void io_close(struct io *io);
41 | unsigned io_offset(struct io *io);
42 | int io_readn(struct io *io, void *buf, int nbytes);
43 |
44 | static inline int
45 | check_extension(const char *path, const char *ext)
46 | {
47 | return strcmp(path + strlen(path) - strlen(ext), ext) == 0;
48 | }
49 |
50 | #endif /* IO_H_ */
51 |
--------------------------------------------------------------------------------
/afuc/util.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2021 Google, Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef _UTIL_H_
25 | #define _UTIL_H_
26 |
27 | #include
28 |
29 | /*
30 | * AFUC disasm / asm helpers
31 | */
32 |
33 | unsigned afuc_control_reg(const char *name);
34 | char * afuc_control_reg_name(unsigned id);
35 |
36 | unsigned afuc_pipe_reg(const char *name);
37 | char * afuc_pipe_reg_name(unsigned id);
38 | bool afuc_pipe_reg_is_void(unsigned id);
39 |
40 | unsigned afuc_gpu_reg(const char *name);
41 | char * afuc_gpu_reg_name(unsigned id);
42 |
43 | unsigned afuc_gpr_reg(const char *name);
44 |
45 | int afuc_pm4_id(const char *name);
46 | const char * afuc_pm_id_name(unsigned id);
47 |
48 | enum afuc_color {
49 | AFUC_ERR,
50 | AFUC_LBL,
51 | };
52 |
53 | void afuc_printc(enum afuc_color c, const char *fmt, ...);
54 |
55 | int afuc_util_init(int gpuver, bool colors);
56 |
57 | #endif /* _UTIL_H_ */
58 |
--------------------------------------------------------------------------------
/rnn/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | libfreedreno_rnn_files = files(
22 | 'aprintf.c',
23 | 'colors.c',
24 | 'colors.h',
25 | 'path.c',
26 | 'rnn.c',
27 | 'rnn.h',
28 | 'rnndec.c',
29 | 'rnndec.h',
30 | 'util.h',
31 | )
32 |
33 | libfreedreno_rnn = static_library(
34 | 'freedreno_rnn',
35 | libfreedreno_rnn_files,
36 | include_directories: [
37 | inc_src,
38 | inc_include,
39 | ],
40 | c_args : [
41 | no_override_init_args,
42 | '-DRNN_DEF_PATH="' + rnn_path + '"',
43 | ],
44 | gnu_symbol_visibility: 'hidden',
45 | dependencies: [ dep_libxml2, idep_mesautil ],
46 | build_by_default: false,
47 | )
48 |
49 | headergen2 = executable(
50 | 'headergen2',
51 | 'headergen2.c',
52 | include_directories: [],
53 | c_args : [no_override_init_args],
54 | gnu_symbol_visibility: 'hidden',
55 | dependencies: [],
56 | link_with: libfreedreno_rnn,
57 | build_by_default: with_tools.contains('freedreno'),
58 | install: false
59 | )
60 |
--------------------------------------------------------------------------------
/rnn/colors.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Marcin Kościelnicki
3 | * All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a
6 | * copy of this software and associated documentation files (the "Software"),
7 | * to deal in the Software without restriction, including without limitation
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | * and/or sell copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice (including the next
13 | * paragraph) shall be included in all copies or substantial portions of the
14 | * Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | * OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | #include "colors.h"
26 |
27 | const struct envy_colors envy_null_colors = {
28 | .reset = "",
29 | .iname = "",
30 | .rname = "",
31 | .mod = "",
32 | .sym = "",
33 | .reg = "",
34 | .regsp = "",
35 | .num = "",
36 | .mem = "",
37 | .btarg = "",
38 | .ctarg = "",
39 | .bctarg = "",
40 | .eval = "",
41 | .comm = "",
42 | .err = "",
43 | };
44 |
45 | const struct envy_colors envy_def_colors = {
46 | .reset = "\x1b[0m",
47 | .iname = "\x1b[0;32m",
48 | .rname = "\x1b[0;32m",
49 | .mod = "\x1b[0;36m",
50 | .sym = "\x1b[0;36m",
51 | .reg = "\x1b[0;31m",
52 | .regsp = "\x1b[0;35m",
53 | .num = "\x1b[0;33m",
54 | .mem = "\x1b[0;35m",
55 | .btarg = "\x1b[0;35m",
56 | .ctarg = "\x1b[0;1;37m",
57 | .bctarg = "\x1b[0;1;35m",
58 | .eval = "\x1b[0;35m",
59 | .comm = "\x1b[0;34m",
60 | .err = "\x1b[0;1;31m",
61 | };
62 |
--------------------------------------------------------------------------------
/rnn/colors.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Marcin Kościelnicki
3 | * All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a
6 | * copy of this software and associated documentation files (the "Software"),
7 | * to deal in the Software without restriction, including without limitation
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | * and/or sell copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice (including the next
13 | * paragraph) shall be included in all copies or substantial portions of the
14 | * Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | * OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | #ifndef COLORS_H
26 | #define COLORS_H
27 |
28 | struct envy_colors {
29 | const char *reset;
30 | const char *iname; /* instruction name */
31 | const char *rname; /* register or bitfield name */
32 | const char *mod; /* instruction modifier */
33 | const char *sym; /* auxiliary char like { , + */
34 | const char *reg; /* ISA register */
35 | const char *regsp; /* special ISA register */
36 | const char *num; /* immediate number */
37 | const char *mem; /* memory reference */
38 | const char *btarg; /* branch target */
39 | const char *ctarg; /* call target */
40 | const char *bctarg; /* branch and call target */
41 | const char *eval; /* enum value */
42 | const char *comm; /* comment */
43 | const char *err; /* error */
44 | };
45 |
46 | extern const struct envy_colors envy_null_colors;
47 | extern const struct envy_colors envy_def_colors;
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | # This is the tag of the docker image used for the build jobs. If the
2 | # image doesn't exist yet, the containers stage generates it.
3 | #
4 | # In order to generate a new image, one should generally change the tag.
5 | # While removing the image from the registry would also work, that's not
6 | # recommended except for ephemeral images during development: Replacing
7 | # an image after a significant amount of time might pull in newer
8 | # versions of gcc/clang or other packages, which might break the build
9 | # with older commits using the same tag.
10 | #
11 | # After merging a change resulting in generating a new image to the
12 | # main repository, it's recommended to remove the image from the source
13 | # repository's container registry, so that the image from the main
14 | # repository's registry will be used there as well.
15 | variables:
16 | UPSTREAM_REPO: freedreno/envytools
17 | DEBIAN_TAG: "2021-05-16-mako"
18 | DEBIAN_VERSION: buster-slim
19 | DEBIAN_IMAGE: "$CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG"
20 |
21 | include:
22 | - project: 'wayland/ci-templates'
23 | ref: 0a9bdd33a98f05af6761ab118b5074952242aab0
24 | file: '/templates/debian.yml'
25 |
26 | stages:
27 | - containers
28 | - build
29 | - test
30 |
31 | # When & how to run the CI
32 | .ci-run-policy:
33 | except:
34 | - schedules
35 | retry:
36 | max: 2
37 | when:
38 | - runner_system_failure
39 |
40 | # CONTAINERS
41 |
42 | debian:
43 | stage: containers
44 | extends:
45 | - .ci-run-policy
46 | - .debian@container-ifnot-exists
47 | variables:
48 | GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
49 | DEBIAN_EXEC: 'bash .gitlab-ci/debian-install.sh'
50 |
51 |
52 | # BUILD
53 |
54 | build:
55 | stage: build
56 | extends:
57 | - .ci-run-policy
58 | image: $DEBIAN_IMAGE
59 | needs:
60 | - debian
61 | script:
62 | - meson debug --prefix=`pwd`/install
63 | - ninja -C debug install
64 | - ./.gitlab-ci/genoutput.sh
65 | - diff -r -I '^Reading' -I '^Parsing' -I 'Assertion' .gitlab-ci/reference .gitlab-ci/out
66 | - ./debug/rnn/headergen2 adreno.xml
67 | - ./debug/rnn/headergen2 msm.xml
68 |
--------------------------------------------------------------------------------
/stub-mesa/no_extern_c.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2014 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the "Software"),
8 | * to deal in the Software without restriction, including without limitation
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 | * and/or sell copies of the Software, and to permit persons to whom the
11 | * Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included
14 | * in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | * OTHER DEALINGS IN THE SOFTWARE.
23 | *
24 | **************************************************************************/
25 |
26 |
27 | /*
28 | * Including system's headers inside `extern "C" { ... }` is not safe, as system
29 | * headers may have C++ code in them, and C++ code inside extern "C"
30 | * leads to syntactically incorrect code.
31 | *
32 | * This is because putting code inside extern "C" won't make __cplusplus define
33 | * go away, that is, the system header being included thinks is free to use C++
34 | * as it sees fits.
35 | *
36 | * Including non-system headers inside extern "C" is not safe either, because
37 | * non-system headers end up including system headers, hence fall in the above
38 | * case too.
39 | *
40 | * Conclusion, includes inside extern "C" is simply not portable.
41 | *
42 | *
43 | * This header helps surface these issues.
44 | */
45 |
46 | #ifdef __cplusplus
47 | template class _IncludeInsideExternCNotPortable;
48 | #endif
49 |
--------------------------------------------------------------------------------
/stub-mesa/util/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2017 Intel Corporation
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | inc_util = include_directories('.')
22 |
23 | files_mesa_util = files(
24 | 'bitscan.h',
25 | 'bitset.h',
26 | 'compiler.h',
27 | 'half_float.c',
28 | 'half_float.h',
29 | 'hash_table.c',
30 | 'hash_table.h',
31 | 'list.h',
32 | 'log.c',
33 | 'log.h',
34 | 'macros.h',
35 | 'os_file.h',
36 | 'ralloc.c',
37 | 'ralloc.h',
38 | 'rb_tree.c',
39 | 'rb_tree.h',
40 | 'set.c',
41 | 'set.h',
42 | 'softfloat.c',
43 | 'softfloat.h',
44 | 'u_debug.h',
45 | 'u_endian.h',
46 | 'u_math.c',
47 | 'u_math.h',
48 | )
49 |
50 |
51 | deps_for_libmesa_util = [
52 | ]
53 |
54 | _libmesa_util = static_library(
55 | 'mesa_util',
56 | [files_mesa_util],
57 | include_directories : [inc_include, inc_src, inc_gallium],
58 | dependencies : deps_for_libmesa_util,
59 | gnu_symbol_visibility : 'hidden',
60 | build_by_default : false
61 | )
62 |
63 | idep_mesautil = declare_dependency(
64 | link_with : _libmesa_util,
65 | include_directories : inc_util,
66 | # dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m, dep_valgrind],
67 | )
68 |
69 |
--------------------------------------------------------------------------------
/rnn/path.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Marcin Kościelnicki
3 | * All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a
6 | * copy of this software and associated documentation files (the "Software"),
7 | * to deal in the Software without restriction, including without limitation
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | * and/or sell copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice (including the next
13 | * paragraph) shall be included in all copies or substantial portions of the
14 | * Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | * OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | #include "util.h"
26 | #include
27 |
28 | FILE *find_in_path(const char *name, const char *path, char **pfullname) {
29 | if (!path)
30 | return 0;
31 | while (path) {
32 | const char *npath = strchr(path, ':');
33 | size_t plen;
34 | if (npath) {
35 | plen = npath - path;
36 | npath++;
37 | } else {
38 | plen = strlen(path);
39 | }
40 | if (plen) {
41 | /* also look for .gz compressed xml: */
42 | const char *exts[] = { "", ".gz" };
43 | for (int i = 0; i < ARRAY_SIZE(exts); i++) {
44 | char *fullname;
45 |
46 | int ret = asprintf(&fullname, "%.*s/%s%s", (int)plen, path, name, exts[i]);
47 | if (ret < 0)
48 | return NULL;
49 |
50 | FILE *file = fopen(fullname, "r");
51 | if (file) {
52 | if (pfullname)
53 | *pfullname = fullname;
54 | else
55 | free(fullname);
56 | return file;
57 | }
58 | free(fullname);
59 | }
60 | }
61 | path = npath;
62 | }
63 | return 0;
64 | }
65 |
--------------------------------------------------------------------------------
/stub-mesa/util/os_memory.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2010 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sub license, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice (including the
15 | * next paragraph) shall be included in all copies or substantial portions
16 | * of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | **************************************************************************/
27 |
28 |
29 | /*
30 | * OS memory management abstractions
31 | */
32 |
33 |
34 | #ifndef _OS_MEMORY_H_
35 | #define _OS_MEMORY_H_
36 |
37 | #if defined(EMBEDDED_DEVICE)
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | void *
44 | os_malloc(size_t size);
45 |
46 | void *
47 | os_calloc(size_t count, size_t size);
48 |
49 | void
50 | os_free(void *ptr);
51 |
52 | void *
53 | os_realloc(void *ptr, size_t old_size, size_t new_size);
54 |
55 | void *
56 | os_malloc_aligned(size_t size, size_t alignment);
57 |
58 | void
59 | os_free_aligned(void *ptr);
60 |
61 | void *
62 | os_realloc_aligned(void *ptr, size_t oldsize, size_t newsize, size_t alignemnt);
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 |
68 | #else
69 |
70 | # include "os_memory_stdc.h"
71 |
72 | #endif
73 |
74 | #endif /* _OS_MEMORY_H_ */
75 |
--------------------------------------------------------------------------------
/stub-mesa/util/os_memory_stdc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2008-2010 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sub license, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice (including the
15 | * next paragraph) shall be included in all copies or substantial portions
16 | * of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | **************************************************************************/
27 |
28 |
29 | /*
30 | * OS memory management abstractions for the standard C library.
31 | */
32 |
33 |
34 | #ifndef _OS_MEMORY_H_
35 | #error "Must not be included directly. Include os_memory.h instead"
36 | #endif
37 |
38 | #include
39 |
40 |
41 | #define os_malloc(_size) malloc(_size)
42 | #define os_calloc(_count, _size ) calloc(_count, _size )
43 | #define os_free(_ptr) free(_ptr)
44 |
45 | #define os_realloc( _old_ptr, _old_size, _new_size) \
46 | realloc(_old_ptr, _new_size + 0*(_old_size))
47 |
48 | #if DETECT_OS_WINDOWS
49 |
50 | #include
51 |
52 | #define os_malloc_aligned(_size, _align) _aligned_malloc(_size, _align)
53 | #define os_free_aligned(_ptr) _aligned_free(_ptr)
54 | #define os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment) _aligned_realloc(_ptr, _newsize, _alignment)
55 |
56 | #else
57 |
58 | #include "os_memory_aligned.h"
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/decode/scripts/sanity-a6xx.lua:
--------------------------------------------------------------------------------
1 | -- Parse cmdstream dump and check for common errors
2 | -- 1) Check for overflowing HLSQ_xS_CNTL.CONSTLEN
3 | -- 2) Check for constant uploades that overwrite each other. The
4 | -- range checking is reset on each draw, since it is a valid
5 | -- use-case to do partial constant upload. But if we see two
6 | -- CP_LOAD_STATE* that overwrite the same range of constants
7 | -- within the same draw, that is almost certainly unintentional.
8 | --
9 | -- TODO add more checks
10 | -- TODO maybe some parts could be shared across
11 | -- different generations
12 |
13 | --local posix = require "posix"
14 |
15 | function printf(fmt, ...)
16 | return io.write(string.format(fmt, ...))
17 | end
18 |
19 | function dbg(fmt, ...)
20 | --printf(fmt, ...)
21 | end
22 |
23 | stages = {
24 | "SB6_VS_SHADER",
25 | "SB6_HS_SHADER",
26 | "SB6_DS_SHADER",
27 | "SB6_GS_SHADER",
28 | "SB6_FS_SHADER",
29 | "SB6_CS_SHADER",
30 | }
31 |
32 | -- maps shader stage to HLSQ_xS_CNTL register name:
33 | cntl_regs = {
34 | ["SB6_VS_SHADER"] = "HLSQ_VS_CNTL",
35 | ["SB6_HS_SHADER"] = "HLSQ_HS_CNTL",
36 | ["SB6_DS_SHADER"] = "HLSQ_DS_CNTL",
37 | ["SB6_GS_SHADER"] = "HLSQ_GS_CNTL",
38 | ["SB6_FS_SHADER"] = "HLSQ_FS_CNTL",
39 | ["SB6_CS_SHADER"] = "HLSQ_CS_CNTL",
40 | }
41 |
42 | -- initialize constant updated ranges:
43 | -- constranges[stagename] -> table of offsets that have been uploaded
44 | constranges = {}
45 | function reset_constranges()
46 | for i,stage in ipairs(stages) do
47 | constranges[stage] = {}
48 | end
49 | end
50 |
51 | reset_constranges()
52 |
53 | printf("Checking cmdstream...\n")
54 |
55 | local r = rnn.init("a630")
56 |
57 | function draw(primtype, nindx)
58 | printf("draw!\n")
59 | -- reset ranges of uploaded consts on each draw:
60 | reset_constranges()
61 | end
62 |
63 | function CP_LOAD_STATE6(pkt, size)
64 | if tostring(pkt[0].STATE_TYPE) ~= "ST6_CONSTANTS" then
65 | return
66 | end
67 | dbg("got CP_LOAD_STATE6\n")
68 | stage = tostring(pkt[0].STATE_BLOCK)
69 | max = pkt[0].DST_OFF + pkt[0].NUM_UNIT
70 | cntl_reg = cntl_regs[stage]
71 | dbg("looking for %s.. max=%d vs %d\n", cntl_reg, max, r[cntl_reg].CONSTLEN)
72 | if max > r[cntl_reg].CONSTLEN then
73 | printf("ERROR: invalid max constant offset for stage %s: %d vs %d\n", stage, max, r[cntl_reg].CONSTLEN)
74 | end
75 |
76 | end
77 |
--------------------------------------------------------------------------------
/rnn/rnndec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Marcin Kościelnicki
3 | * All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a
6 | * copy of this software and associated documentation files (the "Software"),
7 | * to deal in the Software without restriction, including without limitation
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | * and/or sell copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice (including the next
13 | * paragraph) shall be included in all copies or substantial portions of the
14 | * Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | * OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | #ifndef RNNDEC_H
26 | #define RNNDEC_H
27 |
28 | #include "rnn.h"
29 | #include "colors.h"
30 |
31 | struct rnndecvariant {
32 | struct rnnenum *en;
33 | int variant;
34 | };
35 |
36 | struct rnndeccontext {
37 | struct rnndb *db;
38 | struct rnndecvariant **vars;
39 | int varsnum;
40 | int varsmax;
41 | const struct envy_colors *colors;
42 | };
43 |
44 | struct rnndecaddrinfo {
45 | struct rnntypeinfo *typeinfo;
46 | int width;
47 | char *name;
48 | };
49 |
50 | struct rnndeccontext *rnndec_newcontext(struct rnndb *db);
51 | int rnndec_varadd(struct rnndeccontext *ctx, char *varset, const char *variant);
52 | int rnndec_varmatch(struct rnndeccontext *ctx, struct rnnvarinfo *vi);
53 | const char *rnndec_decode_enum(struct rnndeccontext *ctx, const char *enumname, uint64_t enumval);
54 | char *rnndec_decodeval(struct rnndeccontext *ctx, struct rnntypeinfo *ti, uint64_t value);
55 | int rnndec_checkaddr(struct rnndeccontext *ctx, struct rnndomain *domain, uint64_t addr, int write);
56 | struct rnndecaddrinfo *rnndec_decodeaddr(struct rnndeccontext *ctx, struct rnndomain *domain, uint64_t addr, int write);
57 | uint64_t rnndec_decodereg(struct rnndeccontext *ctx, struct rnndomain *domain, const char *name);
58 |
59 | #endif
60 |
--------------------------------------------------------------------------------
/afuc/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | afuc_parser = custom_target(
22 | 'parser.[ch]',
23 | input: 'parser.y',
24 | output: ['parser.c', 'parser.h'],
25 | command: [
26 | prog_bison, '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'
27 | ]
28 | )
29 |
30 | afuc_lexer = custom_target(
31 | 'lexer.c',
32 | input: 'lexer.l',
33 | output: 'lexer.c',
34 | command: [
35 | prog_flex, '-o', '@OUTPUT@', '@INPUT@'
36 | ]
37 | )
38 |
39 | asm = executable(
40 | 'afuc-asm',
41 | [
42 | 'asm.c',
43 | 'util.c',
44 | 'util.h',
45 | afuc_lexer,
46 | afuc_parser,
47 | ],
48 | include_directories: [
49 | inc_freedreno_rnn, inc_include, inc_src, inc_util,
50 | ],
51 | link_with: [
52 | libfreedreno_rnn,
53 | ],
54 | dependencies: [],
55 | build_by_default : with_tools.contains('freedreno'),
56 | install: install_fd_decode_tools,
57 | )
58 |
59 | disasm = executable(
60 | 'afuc-disasm',
61 | [
62 | 'disasm.c',
63 | 'emu.c',
64 | 'emu.h',
65 | 'emu-ds.c',
66 | 'emu-regs.c',
67 | 'emu-ui.c',
68 | 'util.c',
69 | 'util.h',
70 | ],
71 | include_directories: [
72 | inc_freedreno,
73 | inc_freedreno_rnn,
74 | inc_include,
75 | inc_src,
76 | inc_util,
77 | ],
78 | link_with: [
79 | libfreedreno_rnn,
80 | ],
81 | dependencies: [
82 | ],
83 | build_by_default : with_tools.contains('freedreno'),
84 | install: install_fd_decode_tools,
85 | )
86 |
--------------------------------------------------------------------------------
/common/disasm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2012 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef DISASM_H_
25 | #define DISASM_H_
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | #include "compiler/shader_enums.h"
32 |
33 | /* bitmask of debug flags */
34 | enum debug_t {
35 | PRINT_RAW = 0x1, /* dump raw hexdump */
36 | PRINT_VERBOSE = 0x2,
37 | PRINT_STATS = 0x4,
38 | EXPAND_REPEAT = 0x8,
39 | };
40 |
41 | struct shader_stats {
42 | /* instructions counts rpnN, and instlen does not */
43 | int instructions, instlen;
44 | int nops;
45 | int ss, sy;
46 | int constlen;
47 | int halfreg;
48 | int fullreg;
49 | uint16_t sstall;
50 | uint16_t mov_count;
51 | uint16_t cov_count;
52 | uint16_t last_baryf;
53 | uint16_t instrs_per_cat[8];
54 | };
55 |
56 | int disasm_a2xx(uint32_t *dwords, int sizedwords, int level,
57 | gl_shader_stage type);
58 | int disasm_a3xx(uint32_t *dwords, int sizedwords, int level, FILE *out,
59 | unsigned gpu_id);
60 | int disasm_a3xx_stat(uint32_t *dwords, int sizedwords, int level, FILE *out,
61 | unsigned gpu_id, struct shader_stats *stats);
62 | int try_disasm_a3xx(uint32_t *dwords, int sizedwords, int level, FILE *out,
63 | unsigned gpu_id);
64 |
65 | void disasm_a2xx_set_debug(enum debug_t debug);
66 | void disasm_a3xx_set_debug(enum debug_t debug);
67 |
68 | #endif /* DISASM_H_ */
69 |
--------------------------------------------------------------------------------
/registers/adreno/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2019 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | xml_files = [
22 | 'a2xx.xml',
23 | 'a3xx.xml',
24 | 'a4xx.xml',
25 | 'a5xx.xml',
26 | 'a6xx.xml',
27 | 'a6xx_gmu.xml',
28 | 'ocmem.xml',
29 | 'adreno_control_regs.xml',
30 | 'adreno_pipe_regs.xml',
31 | 'adreno_common.xml',
32 | 'adreno_pm4.xml',
33 | ]
34 |
35 | foreach f : xml_files
36 | _name = f + '.h'
37 | freedreno_xml_header_files += custom_target(
38 | _name,
39 | input: [gen_header_py, f],
40 | output: _name,
41 | command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@'],
42 | capture: true,
43 | )
44 | _gzname = f + '.gz'
45 | custom_target(
46 | _gzname,
47 | input: f,
48 | output: _gzname,
49 | command: [prog_gzip, '-kc', '@INPUT@'],
50 | capture: true,
51 | install_dir: rnn_install_path + '/adreno',
52 | install: install_fd_decode_tools,
53 | build_by_default: install_fd_decode_tools,
54 | )
55 | endforeach
56 |
57 | freedreno_xml_header_files += custom_target(
58 | 'a6xx-pack.xml.h',
59 | input: [gen_header_py, 'a6xx.xml'],
60 | output: 'a6xx-pack.xml.h',
61 | command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@', '--pack-structs'],
62 | capture: true,
63 | )
64 |
65 | freedreno_xml_header_files += custom_target(
66 | 'adreno-pm4-pack.xml.h',
67 | input: [gen_header_py, 'adreno_pm4.xml'],
68 | output: 'adreno-pm4-pack.xml.h',
69 | command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@', '--pack-structs'],
70 | capture: true,
71 | )
72 |
--------------------------------------------------------------------------------
/decode/rnnutil.h:
--------------------------------------------------------------------------------
1 | /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2 |
3 | /*
4 | * Copyright (C) 2014 Rob Clark
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the "Software"),
8 | * to deal in the Software without restriction, including without limitation
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 | * and/or sell copies of the Software, and to permit persons to whom the
11 | * Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice (including the next
14 | * paragraph) shall be included in all copies or substantial portions of the
15 | * Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | * Authors:
26 | * Rob Clark
27 | */
28 |
29 | #ifndef RNNUTIL_H_
30 | #define RNNUTIL_H_
31 |
32 | #include
33 | #include
34 | #include
35 |
36 | #include "rnn.h"
37 | #include "rnndec.h"
38 |
39 | struct rnn {
40 | struct rnndb *db;
41 | struct rnndeccontext *vc, *vc_nocolor;
42 | struct rnndomain *dom[2];
43 | const char *variant;
44 | };
45 |
46 | union rnndecval {
47 | uint32_t u;
48 | int32_t i;
49 | float f;
50 | };
51 |
52 | void _rnn_init(struct rnn *rnn, int nocolor);
53 | struct rnn *rnn_new(int nocolor);
54 | void rnn_load_file(struct rnn *rnn, char *file, char *domain);
55 | void rnn_load(struct rnn *rnn, const char *gpuname);
56 | uint32_t rnn_regbase(struct rnn *rnn, const char *name);
57 | const char *rnn_regname(struct rnn *rnn, uint32_t regbase, int color);
58 | struct rnndecaddrinfo *rnn_reginfo(struct rnn *rnn, uint32_t regbase);
59 | const char *rnn_enumname(struct rnn *rnn, const char *name, uint32_t val);
60 |
61 | struct rnndelem *rnn_regelem(struct rnn *rnn, const char *name);
62 | struct rnndelem *rnn_regoff(struct rnn *rnn, uint32_t offset);
63 | enum rnnttype rnn_decodelem(struct rnn *rnn, struct rnntypeinfo *info,
64 | uint32_t regval, union rnndecval *val);
65 |
66 | #endif /* RNNUTIL_H_ */
67 |
--------------------------------------------------------------------------------
/decode/script.h:
--------------------------------------------------------------------------------
1 | /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2 |
3 | /*
4 | * Copyright (C) 2014 Rob Clark
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the "Software"),
8 | * to deal in the Software without restriction, including without limitation
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 | * and/or sell copies of the Software, and to permit persons to whom the
11 | * Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice (including the next
14 | * paragraph) shall be included in all copies or substantial portions of the
15 | * Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | * Authors:
26 | * Rob Clark
27 | */
28 |
29 | #ifndef SCRIPT_H_
30 | #define SCRIPT_H_
31 |
32 | #include
33 |
34 | // XXX make script support optional
35 | #define ENABLE_SCRIPTING 1
36 |
37 | #ifdef ENABLE_SCRIPTING
38 |
39 | /* called at start to load the script: */
40 | int script_load(const char *file);
41 |
42 | /* called at start of each cmdstream file: */
43 | void script_start_cmdstream(const char *name);
44 |
45 | /* called at each DRAW_INDX, calls script drawidx fxn to process
46 | * the current state
47 | */
48 | __attribute__((weak))
49 | void script_draw(const char *primtype, uint32_t nindx);
50 |
51 | struct rnn;
52 | struct rnndomain;
53 | __attribute__((weak))
54 | void script_packet(uint32_t *dwords, uint32_t sizedwords,
55 | struct rnn *rnn,
56 | struct rnndomain *dom);
57 |
58 | /* maybe at some point it is interesting to add additional script
59 | * hooks for CP_EVENT_WRITE, etc?
60 | */
61 |
62 | /* called at end of each cmdstream file: */
63 | void script_end_cmdstream(void);
64 |
65 | void script_start_submit(void);
66 | void script_end_submit(void);
67 |
68 | /* called after last cmdstream file: */
69 | void script_finish(void);
70 |
71 | #else
72 | // TODO no-op stubs..
73 | #endif
74 |
75 | #endif /* SCRIPT_H_ */
76 |
--------------------------------------------------------------------------------
/isa/ir3-cat7.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 | {SY}{JP}{NAME}{G}{L}{R}{W}
34 |
35 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
36 | xxxxxxxxxxxx
37 | x
38 | x1xxxx
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | 111
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 0000
57 |
58 |
59 |
60 | 0001
61 |
62 |
63 |
--------------------------------------------------------------------------------
/stub-mesa/util/softfloat.h:
--------------------------------------------------------------------------------
1 | /*
2 | * License for Berkeley SoftFloat Release 3e
3 | *
4 | * John R. Hauser
5 | * 2018 January 20
6 | *
7 | * The following applies to the whole of SoftFloat Release 3e as well as to
8 | * each source file individually.
9 | *
10 | * Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
11 | * University of California. All rights reserved.
12 | *
13 | * Redistribution and use in source and binary forms, with or without
14 | * modification, are permitted provided that the following conditions are met:
15 | *
16 | * 1. Redistributions of source code must retain the above copyright notice,
17 | * this list of conditions, and the following disclaimer.
18 | *
19 | * 2. Redistributions in binary form must reproduce the above copyright
20 | * notice, this list of conditions, and the following disclaimer in the
21 | * documentation and/or other materials provided with the distribution.
22 | *
23 | * 3. Neither the name of the University nor the names of its contributors
24 | * may be used to endorse or promote products derived from this software
25 | * without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
28 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
30 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
31 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 | *
38 | *
39 | * The functions listed in this file are modified versions of the ones
40 | * from the Berkeley SoftFloat 3e Library.
41 | */
42 |
43 | #ifndef _SOFTFLOAT_H_
44 | #define _SOFTFLOAT_H_
45 |
46 | #include
47 | #include
48 |
49 | #ifdef __cplusplus
50 | extern "C" {
51 | #endif
52 |
53 | double _mesa_double_add_rtz(double a, double b);
54 | double _mesa_double_sub_rtz(double a, double b);
55 | double _mesa_double_mul_rtz(double a, double b);
56 | double _mesa_double_fma_rtz(double a, double b, double c);
57 | float _mesa_float_fma_rtz(float a, float b, float c);
58 | float _mesa_double_to_f32(double x, bool rtz);
59 | uint16_t _mesa_float_to_half_rtz_slow(float x);
60 |
61 | #ifdef __cplusplus
62 | } /* extern C */
63 | #endif
64 |
65 | #endif /* _SOFTFLOAT_H */
66 |
--------------------------------------------------------------------------------
/isa/isa.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2020 Google, Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef _ISA_H_
25 | #define _ISA_H_
26 |
27 | #include
28 | #include
29 |
30 | #include
31 |
32 | struct isa_decode_value {
33 | /** for {NAME} */
34 | const char *str;
35 | /** for all other fields */
36 | uint64_t num;
37 | };
38 |
39 | struct isa_decode_hook {
40 | const char *fieldname;
41 | void (*cb)(void *data, struct isa_decode_value *val);
42 | };
43 |
44 | struct isa_decode_options {
45 | uint32_t gpu_id;
46 |
47 | /** show errors detected in decoding, like unexpected dontcare bits */
48 | bool show_errors;
49 |
50 | /**
51 | * If non-zero, maximum # of instructions that are unmatched before
52 | * bailing, ie. to trigger stopping if we start trying to decode
53 | * random garbage.
54 | */
55 | unsigned max_errors;
56 |
57 | /** Generate branch target labels */
58 | bool branch_labels;
59 |
60 | /**
61 | * Flag which can be set, for ex, but decode hook to trigger end of
62 | * decoding
63 | */
64 | bool stop;
65 |
66 | /**
67 | * Data passed back to decode hooks
68 | */
69 | void *cbdata;
70 |
71 | /**
72 | * Callback for field decode
73 | */
74 | void (*field_cb)(void *data, const char *field_name, struct isa_decode_value *val);
75 |
76 | /**
77 | * Callback prior to instruction decode
78 | */
79 | void (*instr_cb)(void *data, unsigned n, uint64_t instr);
80 | };
81 |
82 | void isa_decode(void *bin, int sz, FILE *out, const struct isa_decode_options *options);
83 |
84 |
85 | struct ir3_shader_variant;
86 | void * isa_assemble(struct ir3_shader_variant *v);
87 |
88 | #endif /* _ISA_H_ */
89 |
--------------------------------------------------------------------------------
/decode/pager.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | #include "pager.h"
35 |
36 | static pid_t pager_pid;
37 |
38 | static void
39 | pager_death(int n)
40 | {
41 | exit(0);
42 | }
43 |
44 | void
45 | pager_open(void)
46 | {
47 | int fd[2];
48 |
49 | if (pipe(fd) < 0) {
50 | fprintf(stderr, "Failed to create pager pipe: %m\n");
51 | exit(-1);
52 | }
53 |
54 | pager_pid = fork();
55 | if (pager_pid < 0) {
56 | fprintf(stderr, "Failed to fork pager: %m\n");
57 | exit(-1);
58 | }
59 |
60 | if (pager_pid == 0) {
61 | const char *less_opts;
62 |
63 | dup2(fd[0], STDIN_FILENO);
64 | close(fd[0]);
65 | close(fd[1]);
66 |
67 | less_opts = "FRSMKX";
68 | setenv("LESS", less_opts, 1);
69 |
70 | execlp("less", "less", NULL);
71 |
72 | } else {
73 | /* we want to kill the parent process when pager exits: */
74 | signal(SIGCHLD, pager_death);
75 | dup2(fd[1], STDOUT_FILENO);
76 | close(fd[0]);
77 | close(fd[1]);
78 | }
79 | }
80 |
81 | int
82 | pager_close(void)
83 | {
84 | siginfo_t status;
85 |
86 | close(STDOUT_FILENO);
87 |
88 | while (true) {
89 | memset(&status, 0, sizeof(status));
90 | if (waitid(P_PID, pager_pid, &status, WEXITED) < 0) {
91 | if (errno == EINTR)
92 | continue;
93 | return -errno;
94 | }
95 |
96 | return 0;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/stub-mesa/util/log.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 Google, Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | * IN THE SOFTWARE.
22 | */
23 |
24 | #include
25 |
26 | #ifdef ANDROID
27 | #include
28 | #else
29 | #include
30 | #endif
31 |
32 | //#include "util/detect_os.h"
33 | #include "util/log.h"
34 |
35 | #ifdef ANDROID
36 | static inline android_LogPriority
37 | level_to_android(enum mesa_log_level l)
38 | {
39 | switch (l) {
40 | case MESA_LOG_ERROR: return ANDROID_LOG_ERROR;
41 | case MESA_LOG_WARN: return ANDROID_LOG_WARN;
42 | case MESA_LOG_INFO: return ANDROID_LOG_INFO;
43 | case MESA_LOG_DEBUG: return ANDROID_LOG_DEBUG;
44 | }
45 |
46 | unreachable("bad mesa_log_level");
47 | }
48 | #endif
49 |
50 | #ifndef ANDROID
51 | static inline const char *
52 | level_to_str(enum mesa_log_level l)
53 | {
54 | switch (l) {
55 | case MESA_LOG_ERROR: return "error";
56 | case MESA_LOG_WARN: return "warning";
57 | case MESA_LOG_INFO: return "info";
58 | case MESA_LOG_DEBUG: return "debug";
59 | }
60 |
61 | unreachable("bad mesa_log_level");
62 | }
63 | #endif
64 |
65 | void
66 | mesa_log(enum mesa_log_level level, const char *tag, const char *format, ...)
67 | {
68 | va_list va;
69 |
70 | va_start(va, format);
71 | mesa_log_v(level, tag, format, va);
72 | va_end(va);
73 | }
74 |
75 | void
76 | mesa_log_v(enum mesa_log_level level, const char *tag, const char *format,
77 | va_list va)
78 | {
79 | #ifdef ANDROID
80 | __android_log_vprint(level_to_android(level), tag, format, va);
81 | #else
82 | #if !DETECT_OS_WINDOWS
83 | flockfile(stderr);
84 | #endif
85 | fprintf(stderr, "%s: %s: ", tag, level_to_str(level));
86 | vfprintf(stderr, format, va);
87 | fprintf(stderr, "\n");
88 | #if !DETECT_OS_WINDOWS
89 | funlockfile(stderr);
90 | #endif
91 | #endif
92 | }
93 |
--------------------------------------------------------------------------------
/stub-mesa/util/log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | * IN THE SOFTWARE.
22 | */
23 |
24 | #ifndef MESA_LOG_H
25 | #define MESA_LOG_H
26 |
27 | #include
28 |
29 | #include "util/macros.h"
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | #ifndef MESA_LOG_TAG
36 | #define MESA_LOG_TAG "MESA"
37 | #endif
38 |
39 | enum mesa_log_level {
40 | MESA_LOG_ERROR,
41 | MESA_LOG_WARN,
42 | MESA_LOG_INFO,
43 | MESA_LOG_DEBUG,
44 | };
45 |
46 | void PRINTFLIKE(3, 4)
47 | mesa_log(enum mesa_log_level, const char *tag, const char *format, ...);
48 |
49 | void
50 | mesa_log_v(enum mesa_log_level, const char *tag, const char *format,
51 | va_list va);
52 |
53 | #define mesa_loge(fmt, ...) mesa_log(MESA_LOG_ERROR, (MESA_LOG_TAG), (fmt), ##__VA_ARGS__)
54 | #define mesa_logw(fmt, ...) mesa_log(MESA_LOG_WARN, (MESA_LOG_TAG), (fmt), ##__VA_ARGS__)
55 | #define mesa_logi(fmt, ...) mesa_log(MESA_LOG_INFO, (MESA_LOG_TAG), (fmt), ##__VA_ARGS__)
56 | #ifdef DEBUG
57 | #define mesa_logd(fmt, ...) mesa_log(MESA_LOG_DEBUG, (MESA_LOG_TAG), (fmt), ##__VA_ARGS__)
58 | #else
59 | #define mesa_logd(fmt, ...) __mesa_log_use_args((fmt), ##__VA_ARGS__)
60 | #endif
61 |
62 | #define mesa_loge_v(fmt, va) mesa_log_v(MESA_LOG_ERROR, (MESA_LOG_TAG), (fmt), (va))
63 | #define mesa_logw_v(fmt, va) mesa_log_v(MESA_LOG_WARN, (MESA_LOG_TAG), (fmt), (va))
64 | #define mesa_logi_v(fmt, va) mesa_log_v(MESA_LOG_INFO, (MESA_LOG_TAG), (fmt), (va))
65 | #ifdef DEBUG
66 | #define mesa_logd_v(fmt, va) mesa_log_v(MESA_LOG_DEBUG, (MESA_LOG_TAG), (fmt), (va))
67 | #else
68 | #define mesa_logd_v(fmt, va) __mesa_log_use_args((fmt), (va))
69 | #endif
70 |
71 |
72 | #ifndef DEBUG
73 | /* Suppres -Wunused */
74 | static inline void PRINTFLIKE(1, 2)
75 | __mesa_log_use_args(UNUSED const char *format, ...) { }
76 | #endif
77 |
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 | #endif /* MESA_LOG_H */
83 |
--------------------------------------------------------------------------------
/stub-mesa/util/compiler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Mesa 3-D graphics library
3 | *
4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 | * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a
8 | * copy of this software and associated documentation files (the "Software"),
9 | * to deal in the Software without restriction, including without limitation
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 | * and/or sell copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 |
27 | /**
28 | * \file compiler.h
29 | * Compiler-related stuff.
30 | */
31 |
32 |
33 | #ifndef COMPILER_H
34 | #define COMPILER_H
35 |
36 |
37 | #include
38 |
39 | #include "util/macros.h"
40 |
41 | #include "c99_compat.h" /* inline, __func__, etc. */
42 |
43 |
44 | /**
45 | * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.
46 | * Do not use these unless absolutely necessary!
47 | * Try to use a runtime test instead.
48 | * For now, only used by some DRI hardware drivers for color/texel packing.
49 | */
50 | #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
51 | #if defined(__linux__)
52 | #include
53 | #define CPU_TO_LE32( x ) bswap_32( x )
54 | #elif defined(__APPLE__)
55 | #include
56 | #define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x )
57 | #elif defined(__OpenBSD__)
58 | #include
59 | #define CPU_TO_LE32( x ) htole32( x )
60 | #else /*__linux__ */
61 | #include
62 | #define CPU_TO_LE32( x ) bswap32( x )
63 | #endif /*__linux__*/
64 | #define MESA_BIG_ENDIAN 1
65 | #else
66 | #define CPU_TO_LE32( x ) ( x )
67 | #define MESA_LITTLE_ENDIAN 1
68 | #endif
69 | #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
70 |
71 |
72 |
73 | #define IEEE_ONE 0x3f800000
74 |
75 | #ifndef __has_attribute
76 | # define __has_attribute(x) 0
77 | #endif
78 |
79 | #if __cplusplus >= 201703L || __STDC_VERSION__ > 201710L
80 | /* Standard C++17/C23 attribute */
81 | #define FALLTHROUGH [[fallthrough]]
82 | #elif __has_attribute(fallthrough)
83 | /* Non-standard but supported by at least gcc and clang */
84 | #define FALLTHROUGH __attribute__((fallthrough))
85 | #else
86 | #define FALLTHROUGH do { } while(0)
87 | #endif
88 |
89 | #endif /* COMPILER_H */
90 |
--------------------------------------------------------------------------------
/isa/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | isa_depend_files = [
22 | 'ir3-common.xml',
23 | 'ir3-cat0.xml',
24 | 'ir3-cat1.xml',
25 | 'ir3-cat2.xml',
26 | 'ir3-cat3.xml',
27 | 'ir3-cat4.xml',
28 | 'ir3-cat5.xml',
29 | 'ir3-cat6.xml',
30 | 'ir3-cat7.xml',
31 | 'isa.py',
32 | ]
33 |
34 | ir3_isa_c = custom_target(
35 | 'ir3-isa.c',
36 | input: ['decode.py', 'ir3.xml'],
37 | output: 'ir3-isa.c',
38 | command: [
39 | prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'
40 | ],
41 | depend_files: isa_depend_files,
42 | )
43 |
44 | decode_files = [
45 | ir3_isa_c,
46 | 'isa.h',
47 | 'decode.h',
48 | 'decode.c',
49 | ]
50 |
51 | libir3decode = static_library(
52 | 'ir3decode',
53 | decode_files,
54 | dependencies: idep_mesautil,
55 | include_directories: [
56 | inc_include,
57 | inc_src,
58 | # Hack for src/util/half_float.h indirect dependency on
59 | # gallium headers:
60 | inc_gallium,
61 | ],
62 | gnu_symbol_visibility: 'hidden',
63 | )
64 |
65 | ir3disasm = executable(
66 | 'ir3-disasm',
67 | ['ir3-disasm.c'],
68 | link_with: libir3decode,
69 | build_by_default: with_tools.contains('freedreno'),
70 | include_directories: [
71 | inc_src,
72 | ],
73 | install: false,
74 | )
75 |
76 | encode_h = custom_target(
77 | 'encode.h',
78 | input: ['encode.py', 'ir3.xml'],
79 | output: 'encode.h',
80 | command: [
81 | prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'
82 | ],
83 | depend_files: isa_depend_files,
84 | )
85 |
86 | encode_files = [
87 | encode_h,
88 | 'encode.c',
89 | 'isa.h',
90 | ]
91 |
92 | ## HACK don't try to build encode lib, it depends on too
93 | ## much mesa
94 | #libir3encode = static_library(
95 | # 'ir3encode',
96 | # encode_files,
97 | # dependencies: [idep_mesautil, idep_nir],
98 | # include_directories: [
99 | # inc_src,
100 | # inc_include,
101 | # inc_freedreno,
102 | # inc_gallium,
103 | # ],
104 | # gnu_symbol_visibility: 'hidden',
105 | #)
106 |
--------------------------------------------------------------------------------
/registers/mdp/mdp_common.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | bits per component (non-alpha channel)
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | bits per component (alpha channel)
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/stub-mesa/util/fast_urem_by_const.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2010 Valve Software
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | * IN THE SOFTWARE.
22 | */
23 |
24 | #include
25 |
26 | /*
27 | * Code for fast 32-bit unsigned remainder, based off of "Faster Remainder by
28 | * Direct Computation: Applications to Compilers and Software Libraries,"
29 | * available at https://arxiv.org/pdf/1902.01961.pdf.
30 | *
31 | * util_fast_urem32(n, d, REMAINDER_MAGIC(d)) returns the same thing as
32 | * n % d for any unsigned n and d, however it compiles down to only a few
33 | * multiplications, so it should be faster than plain uint32_t modulo if the
34 | * same divisor is used many times.
35 | */
36 |
37 | #define REMAINDER_MAGIC(divisor) \
38 | ((uint64_t) ~0ull / (divisor) + 1)
39 |
40 | /*
41 | * Get bits 64-96 of a 32x64-bit multiply. If __int128_t is available, we use
42 | * it, which usually compiles down to one instruction on 64-bit architectures.
43 | * Otherwise on 32-bit architectures we usually get four instructions (one
44 | * 32x32->64 multiply, one 32x32->32 multiply, and one 64-bit add).
45 | */
46 |
47 | static inline uint32_t
48 | _mul32by64_hi(uint32_t a, uint64_t b)
49 | {
50 | #ifdef HAVE_UINT128
51 | return ((__uint128_t) b * a) >> 64;
52 | #else
53 | /*
54 | * Let b = b0 + 2^32 * b1. Then a * b = a * b0 + 2^32 * a * b1. We would
55 | * have to do a 96-bit addition to get the full result, except that only
56 | * one term has non-zero lower 32 bits, which means that to get the high 32
57 | * bits, we only have to add the high 64 bits of each term. Unfortunately,
58 | * we have to do the 64-bit addition in case the low 32 bits overflow.
59 | */
60 | uint32_t b0 = (uint32_t) b;
61 | uint32_t b1 = b >> 32;
62 | return ((((uint64_t) a * b0) >> 32) + (uint64_t) a * b1) >> 32;
63 | #endif
64 | }
65 |
66 | static inline uint32_t
67 | util_fast_urem32(uint32_t n, uint32_t d, uint64_t magic)
68 | {
69 | uint64_t lowbits = magic * n;
70 | uint32_t result = _mul32by64_hi(d, lowbits);
71 | assert(result == n % d);
72 | return result;
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/stub-mesa/util/u_memory.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2008 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sub license, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice (including the
15 | * next paragraph) shall be included in all copies or substantial portions
16 | * of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | **************************************************************************/
27 |
28 |
29 | /*
30 | * Memory functions
31 | */
32 |
33 |
34 | #ifndef U_MEMORY_H
35 | #define U_MEMORY_H
36 |
37 | #include "util/u_debug.h"
38 | #include "util/os_memory.h"
39 |
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 |
46 | #define MALLOC(_size) os_malloc(_size)
47 |
48 | #define CALLOC(_count, _size) os_calloc(_count, _size)
49 |
50 | #define FREE(_ptr ) os_free(_ptr)
51 |
52 | #define REALLOC(_ptr, _old_size, _size) os_realloc(_ptr, _old_size, _size)
53 |
54 | #define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
55 |
56 | #define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
57 |
58 | #define CALLOC_VARIANT_LENGTH_STRUCT(T,more_size) ((struct T *) CALLOC(1, sizeof(struct T) + more_size))
59 |
60 |
61 | #define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment)
62 | #define align_free(_ptr) os_free_aligned(_ptr)
63 | #define align_realloc(_ptr, _oldsize, _newsize, _alignment) os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment)
64 |
65 | static inline void *
66 | align_calloc(size_t size, unsigned long alignment)
67 | {
68 | void *ptr = align_malloc(size, alignment);
69 | if (ptr)
70 | memset(ptr, 0, size);
71 | return ptr;
72 | }
73 |
74 | /**
75 | * Duplicate a block of memory.
76 | */
77 | static inline void *
78 | mem_dup(const void *src, size_t size)
79 | {
80 | void *dup = MALLOC(size);
81 | if (dup)
82 | memcpy(dup, src, size);
83 | return dup;
84 | }
85 |
86 |
87 | /**
88 | * Offset of a field in a struct, in bytes.
89 | */
90 | #define Offset(TYPE, MEMBER) ((uintptr_t)&(((TYPE *)NULL)->MEMBER))
91 |
92 |
93 |
94 | #ifdef __cplusplus
95 | }
96 | #endif
97 |
98 |
99 | #endif /* U_MEMORY_H */
100 |
--------------------------------------------------------------------------------
/registers/adreno/adreno_pipe_regs.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
30 |
31 |
32 | Special type to mark registers with no payload.
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/stub-mesa/util/u_endian.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2007-2008 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sub license, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice (including the
15 | * next paragraph) shall be included in all copies or substantial portions
16 | * of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | **************************************************************************/
27 | #ifndef U_ENDIAN_H
28 | #define U_ENDIAN_H
29 |
30 | #ifdef HAVE_ENDIAN_H
31 | #include
32 |
33 | #if __BYTE_ORDER == __LITTLE_ENDIAN
34 | # define UTIL_ARCH_LITTLE_ENDIAN 1
35 | # define UTIL_ARCH_BIG_ENDIAN 0
36 | #elif __BYTE_ORDER == __BIG_ENDIAN
37 | # define UTIL_ARCH_LITTLE_ENDIAN 0
38 | # define UTIL_ARCH_BIG_ENDIAN 1
39 | #endif
40 |
41 | #elif defined(__APPLE__)
42 | #include
43 |
44 | #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
45 | # define UTIL_ARCH_LITTLE_ENDIAN 1
46 | # define UTIL_ARCH_BIG_ENDIAN 0
47 | #elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
48 | # define UTIL_ARCH_LITTLE_ENDIAN 0
49 | # define UTIL_ARCH_BIG_ENDIAN 1
50 | #endif
51 |
52 | #elif defined(__sun)
53 | #include
54 |
55 | #if defined(_LITTLE_ENDIAN)
56 | # define UTIL_ARCH_LITTLE_ENDIAN 1
57 | # define UTIL_ARCH_BIG_ENDIAN 0
58 | #elif defined(_BIG_ENDIAN)
59 | # define UTIL_ARCH_LITTLE_ENDIAN 0
60 | # define UTIL_ARCH_BIG_ENDIAN 1
61 | #endif
62 |
63 | #elif defined(__OpenBSD__) || defined(__NetBSD__) || \
64 | defined(__FreeBSD__) || defined(__DragonFly__)
65 | #include
66 | #include
67 |
68 | #if _BYTE_ORDER == _LITTLE_ENDIAN
69 | # define UTIL_ARCH_LITTLE_ENDIAN 1
70 | # define UTIL_ARCH_BIG_ENDIAN 0
71 | #elif _BYTE_ORDER == _BIG_ENDIAN
72 | # define UTIL_ARCH_LITTLE_ENDIAN 0
73 | # define UTIL_ARCH_BIG_ENDIAN 1
74 | #endif
75 |
76 | #elif defined(_WIN32) || defined(ANDROID)
77 |
78 | #define UTIL_ARCH_LITTLE_ENDIAN 1
79 | #define UTIL_ARCH_BIG_ENDIAN 0
80 |
81 | #endif
82 |
83 | #if !defined(UTIL_ARCH_LITTLE_ENDIAN) || !defined(UTIL_ARCH_BIG_ENDIAN)
84 | # error "UTIL_ARCH_LITTLE_ENDIAN and/or UTIL_ARCH_BIG_ENDIAN were unset."
85 | #elif UTIL_ARCH_LITTLE_ENDIAN == UTIL_ARCH_BIG_ENDIAN
86 | # error "UTIL_ARCH_LITTLE_ENDIAN and UTIL_ARCH_BIG_ENDIAN must not both be 1 or 0."
87 | #endif
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/decode/cffdec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef __CFFDEC_H__
25 | #define __CFFDEC_H__
26 |
27 | #include
28 |
29 | enum query_mode {
30 | /* default mode, dump all queried regs on each draw: */
31 | QUERY_ALL = 0,
32 |
33 | /* only dump if any of the queried regs were written
34 | * since last draw:
35 | */
36 | QUERY_WRITTEN,
37 |
38 | /* only dump if any of the queried regs changed since
39 | * last draw:
40 | */
41 | QUERY_DELTA,
42 | };
43 |
44 | struct cffdec_options {
45 | unsigned gpu_id;
46 | int draw_filter;
47 | int color;
48 | int dump_shaders;
49 | int summary;
50 | int allregs;
51 | int dump_textures;
52 | int decode_markers;
53 | char *script;
54 |
55 | int query_compare; /* binning vs SYSMEM/GMEM compare mode */
56 | int query_mode; /* enum query_mode */
57 | char **querystrs;
58 | int nquery;
59 |
60 | /* In "once" mode, only decode a cmdstream buffer once (per draw
61 | * mode, in the case of a6xx+ where a single cmdstream buffer can
62 | * be used for both binning and draw pass), rather than each time
63 | * encountered (ie. once per tile/bin in GMEM draw passes)
64 | */
65 | int once;
66 |
67 | /* for crashdec, where we know CP_IBx_REM_SIZE, we can use this
68 | * to highlight the cmdstream not parsed yet, to make it easier
69 | * to see how far along the CP is.
70 | */
71 | struct {
72 | uint64_t base;
73 | uint32_t rem;
74 | } ibs[4];
75 | };
76 |
77 | void printl(int lvl, const char *fmt, ...);
78 | const char *pktname(unsigned opc);
79 | uint32_t regbase(const char *name);
80 | const char *regname(uint32_t regbase, int color);
81 | bool reg_written(uint32_t regbase);
82 | uint32_t reg_lastval(uint32_t regbase);
83 | uint32_t reg_val(uint32_t regbase);
84 | void reg_set(uint32_t regbase, uint32_t val);
85 | void reset_regs(void);
86 | void cffdec_init(const struct cffdec_options *options);
87 | void dump_register_val(uint32_t regbase, uint32_t dword, int level);
88 | void dump_commands(uint32_t *dwords, uint32_t sizedwords, int level);
89 |
90 | #endif /* __CFFDEC_H__ */
91 |
--------------------------------------------------------------------------------
/sync-from-mesa.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 | #set -x
5 |
6 | mesa="$1"
7 |
8 | if [ ! -d "$mesa" ]; then
9 | echo "using: $0 "
10 | exit 1
11 | fi
12 |
13 | cd `dirname $0`
14 | envytools=`pwd`
15 |
16 | # TODO sync more of the mesa gitlab-ci.. but for now just syncing
17 | # the reference decodes should be enough to not break when regs
18 | # are updated
19 | sync_paths="
20 | afuc
21 | common/disasm.h
22 | decode
23 | isa
24 | ir2
25 | ir3/disasm-a3xx.c
26 | ir3/instr-a3xx.h
27 | ir3/regmask.h
28 | registers
29 | rnn
30 | .gitlab-ci/reference/crash.log
31 | .gitlab-ci/reference/es2gears-a320.log
32 | .gitlab-ci/reference/fd-clouds.log
33 | .gitlab-ci/reference/glxgears-a420.log
34 | .gitlab-ci/reference/shadow.log
35 | "
36 |
37 | # src path in mesa tree to find $sync_paths:
38 | mesa_sync_path="src/freedreno"
39 |
40 | inmesa() {
41 | log " - in mesa: $*"
42 | (cd $mesa; $*)
43 | }
44 |
45 | inmesaq() {
46 | (cd $mesa; $*)
47 | }
48 |
49 | inenvytools() {
50 | log " - in envytools: $*"
51 | (cd $envytools; $*)
52 | }
53 |
54 | inenvytoolsq() {
55 | (cd $envytools; $*)
56 | }
57 |
58 | log() {
59 | echo $*
60 | }
61 |
62 | commitinfo() {
63 | commitid=$1
64 | format=$2
65 | inmesaq git show $commitid -s --format="$format"
66 | }
67 |
68 | syncit() {
69 | commitid=$1
70 |
71 | log "syncing from: $commitid"
72 |
73 | inmesa git checkout $commitid
74 | for p in $sync_paths; do
75 | log " + syncing: $p"
76 | inenvytools rm -rf $p
77 | inmesa cp -r $mesa_sync_path/$p $envytools/$p
78 |
79 | # HACK: this file doesn't exist on mesa side (yet)
80 | inenvytools git checkout registers/.gitignore
81 |
82 | # HACK: this file has hack to not build isa encoder
83 | # which depends on too much of ir3/nir/etc
84 | inenvytools git checkout isa/meson.build
85 |
86 | inenvytools git add $p
87 | done
88 |
89 | inenvytoolsq echo $commitid > .lastsync
90 | inenvytools git add .lastsync
91 |
92 | author=`commitinfo $commitid '%an'`
93 | email=`commitinfo $commitid '%ae'`
94 | date=`commitinfo $commitid '%aD'`
95 | subject=`commitinfo $commitid '%s'`
96 | body=`commitinfo $commitid '%b'`
97 |
98 | git commit \
99 | --author="$author \<$email\>" \
100 | --date="$date" \
101 | -m "$subject" \
102 | -m "Sync from mesa commit $commitid" \
103 | -m "$body"
104 |
105 | # Do local build + CI to make sure things are ok:
106 | inenvytools ninja -C debug install
107 | inenvytools ./.gitlab-ci/genoutput.sh
108 | inenvytools diff -r -I '^Reading' -I '^Parsing' -I 'Assertion' .gitlab-ci/reference .gitlab-ci/out
109 | }
110 |
111 |
112 | mesapaths=""
113 | for p in $sync_paths; do
114 | mesapaths="$mesapaths $mesa_sync_path/$p"
115 | done
116 |
117 | # Find commits to sync:
118 | lastsync=`inenvytoolsq cat .lastsync`
119 |
120 | inmesa git reset --hard HEAD
121 | inmesa git checkout main
122 | inmesa git pull --rebase origin main
123 |
124 | log "Commits available to sync:"
125 | inmesa git --no-pager log --oneline ${lastsync}..HEAD -- $mesapaths
126 |
127 | commitids=`inmesaq git log --reverse --format='%H' ${lastsync}..HEAD -- $mesapaths`
128 |
129 | for commitid in $commitids; do
130 | syncit $commitid
131 | done
132 |
133 | # For now, push to syncit branch on success. I might switch this to push
134 | # directly to master after it has proven reliable for some time
135 | inenvytools git push -f gitlab syncit
136 |
--------------------------------------------------------------------------------
/registers/dsi/dsi_phy_v2.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/isa/ir3.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | Encoding of an ir3 instruction. All instructions are 64b.
53 |
54 |
55 |
56 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/registers/text-format.txt:
--------------------------------------------------------------------------------
1 | 1. Introduction to rules-ng-ng text format
2 |
3 | This-specification defines a text format that can be converted to and from rules-ng-ng XML.
4 | It is intended to allow to create rules-ng-ng files with much less typing and with a more readable text.
5 | xml2text can convert rules-ng-ng XML to this text format
6 | text2xml can convert this text format to rules-ng-ng XML
7 |
8 | This specification is an addendum to the rules-ng-ng specification and assumes familiarity with it.
9 |
10 | 2. Format
11 |
12 | 2.1. Line format
13 |
14 | The initial indentation of a line is divided by 8 and the result determines the position in the document structure (similar to the Python language).
15 | A "//" anywhere in the line causes the rest to be converted to an XML comment (like C++)
16 | A line starting with ":" creates a tag with the rest of the line (excluding anything starting with //).
17 | The content of multiple lines starting with ":" is merged in a single tag.
18 |
19 | 2.2. Tokenization
20 |
21 | The line is then tokenized.
22 | Token are generally continuous strings on non-whitespace characters, with some exceptions
23 | Some characters (such as ":", "=" and "-") form a single-character token.
24 | Text within double quotes generates a tag.
25 | Any token formatted as ATTR(VALUE) generates an ATTR="VALUE" attribute. No whitespace allowed between ATTR and the '(' character.
26 | Any token formatted as (VALUE) generates a variants="VALUE" attribute.
27 | Any token formatted as (VARSET=VALUE) generates a varset="VARSET" variants="VALUE" attribute.
28 |
29 | 2.3. Special token sequences
30 |
31 | These sequences are recognized and extracted before matching the line format:
32 |
33 | : NUM
34 | set REGLIKE to regNUM
35 | you must specify a type if the reg is anonymous
36 | the : is recognized only if it is the third or successive token (and not the last) to avoid ambiguity with bitfields and generic tags
37 |
38 | { STRIDE }
39 | stride="STRIDE" attribute
40 |
41 | [ LENGTH ]
42 | length="LENGTH" attribute
43 |
44 | !FLAGS
45 | access="FLAGS"
46 | no whitespace allowed after '!'
47 |
48 | :=
49 | at the end of the line
50 | set REGLIKE to "stripe"
51 |
52 | =
53 | at the end of the line
54 | set REGLIKE to "array"
55 |
56 | inline
57 | at the beginning of the line
58 | inline="yes" attribute
59 |
60 | 2.4. Line patterns
61 |
62 | The following line patterns are understood.
63 | Only word tokens are used to match lines.
64 | All tokens with special meaning are treated separately as described above.
65 | [FOO] means that FOO is optional
66 |
67 | #import "FILE"
68 |
69 |
70 | #pragma regNUM
71 | REGLIKE is now set by default to regNUM instead of reg32
72 |
73 | @TAG [NAME]
74 |
75 | use this if there are no children
76 |
77 | TAG [NAME] :
78 |
79 | use this if there are children
80 |
81 | TOKEN
82 | if inside a reg or enum and TOKEN starts with a digit
83 | if inside a reg or enum and TOKEN does not start with a digit
84 | otherwise
85 |
86 | POS NAME
87 | if inside a reg or bitset
88 | otherwise
89 |
90 | LOW - HIGH NAME [TYPE]
91 |
92 |
93 | VALUE = NAME
94 |
95 |
96 | use WHAT NAME
97 |
98 |
99 | OFFSET NAME [TYPE]
100 |
101 |
102 |
--------------------------------------------------------------------------------
/rnn/util.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010-2011 Marcin Kościelnicki
3 | * Copyright (C) 2010 Francisco Jerez
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the "Software"),
8 | * to deal in the Software without restriction, including without limitation
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 | * and/or sell copies of the Software, and to permit persons to whom the
11 | * Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice (including the next
14 | * paragraph) shall be included in all copies or substantial portions of the
15 | * Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef UTIL_H
27 | #define UTIL_H
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | #define ADDARRAY(a, e) \
34 | do { \
35 | if ((a ## num) >= (a ## max)) { \
36 | if (!(a ## max)) \
37 | (a ## max) = 16; \
38 | else \
39 | (a ## max) *= 2; \
40 | (a) = realloc((a), (a ## max)*sizeof(*(a))); \
41 | } \
42 | (a)[(a ## num)++] = (e); \
43 | } while(0)
44 |
45 | #define FINDARRAY(a, tmp, pred) \
46 | ({ \
47 | int __i; \
48 | \
49 | for (__i = 0; __i < (a ## num); __i++) { \
50 | tmp = (a)[__i]; \
51 | if (pred) \
52 | break; \
53 | } \
54 | \
55 | tmp = ((pred) ? tmp : NULL); \
56 | })
57 |
58 | /* ceil(log2(x)) */
59 | static inline int clog2(uint64_t x) {
60 | if (!x)
61 | return x;
62 | int r = 0;
63 | while (x - 1 > (1ull << r) - 1)
64 | r++;
65 | return r;
66 | }
67 |
68 | #define ARRAY_SIZE(a) (sizeof (a) / sizeof *(a))
69 |
70 | #define min(a,b) \
71 | ({ \
72 | typeof (a) _a = (a); \
73 | typeof (b) _b = (b); \
74 | _a < _b ? _a : _b; \
75 | })
76 |
77 | #define max(a,b) \
78 | ({ \
79 | typeof (a) _a = (a); \
80 | typeof (b) _b = (b); \
81 | _a > _b ? _a : _b; \
82 | })
83 |
84 | #define CEILDIV(a, b) (((a) + (b) - 1)/(b))
85 |
86 | #define extr(a, b, c) ((uint64_t)(a) << (64 - (b) - (c)) >> (64 - (c)))
87 | #define extrs(a, b, c) ((int64_t)(a) << (64 - (b) - (c)) >> (64 - (c)))
88 | #define sext(a, b) extrs(a, 0, b+1)
89 | #define bflmask(a) ((2ull << ((a)-1)) - 1)
90 | #define insrt(a, b, c, d) ((a) = ((a) & ~(bflmask(c) << (b))) | ((d) & bflmask(c)) << (b))
91 |
92 | struct envy_loc {
93 | int lstart;
94 | int cstart;
95 | int lend;
96 | int cend;
97 | const char *file;
98 | };
99 |
100 | #define LOC_FORMAT(loc, str) "%s:%d.%d-%d.%d: " str, (loc).file, (loc).lstart, (loc).cstart, (loc).lend, (loc).cend
101 |
102 | uint32_t elf_hash(const char *str);
103 |
104 | FILE *find_in_path(const char *name, const char *path, char **pfullname);
105 |
106 | struct astr {
107 | char *str;
108 | size_t len;
109 | };
110 |
111 | void print_escaped_astr(FILE *out, struct astr *astr);
112 |
113 | char *aprintf(const char *format, ...);
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/afuc/emu-ds.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2021 Google, Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include "emu.h"
30 | #include "util.h"
31 |
32 | /*
33 | * Emulation for draw-state (ie. CP_SET_DRAW_STATE) related control registers:
34 | */
35 |
36 | EMU_CONTROL_REG(DRAW_STATE_SET);
37 | EMU_CONTROL_REG(DRAW_STATE_SEL);
38 | EMU_CONTROL_REG(DRAW_STATE_ACTIVE_BITMASK);
39 | EMU_CONTROL_REG(DRAW_STATE_HDR);
40 | EMU_CONTROL_REG(DRAW_STATE_BASE);
41 | EMU_CONTROL_REG(SDS_BASE);
42 | EMU_CONTROL_REG(SDS_DWORDS);
43 |
44 | uint32_t
45 | emu_get_draw_state_reg(struct emu *emu, unsigned n)
46 | {
47 | // TODO maybe we don't need to do anything here
48 | return emu->control_regs.val[n];
49 | }
50 |
51 | void
52 | emu_set_draw_state_reg(struct emu *emu, unsigned n, uint32_t val)
53 | {
54 | struct emu_draw_state *ds = &emu->draw_state;
55 | unsigned cur_idx = emu_get_reg32(emu, &DRAW_STATE_SEL);
56 |
57 | if (n == emu_reg_offset(&DRAW_STATE_SET)) {
58 | if (ds->write_idx == 0) {
59 | cur_idx = (val >> 24) & 0x1f;
60 | ds->state[cur_idx].count = val & 0xffff;
61 | ds->state[cur_idx].mode_mask = (val >> 20) & 0x7;
62 |
63 | unsigned active_mask = emu_get_reg32(emu, &DRAW_STATE_ACTIVE_BITMASK);
64 | active_mask |= (1 << cur_idx);
65 |
66 | emu_set_reg32(emu, &DRAW_STATE_ACTIVE_BITMASK, active_mask);
67 | emu_set_reg32(emu, &DRAW_STATE_SEL, cur_idx);
68 | } else {
69 | ds->state[cur_idx].base_lohi[ds->write_idx - 1] = val;
70 | }
71 |
72 | ds->write_idx = (ds->write_idx + 1) % 3;
73 | } else if (n == emu_reg_offset(&DRAW_STATE_SEL)) {
74 | emu_set_reg32(emu, &DRAW_STATE_HDR, ds->state[val].hdr);
75 | emu_set_reg64(emu, &DRAW_STATE_BASE, ds->state[val].base);
76 |
77 | /* It seems that SDS_BASE/SDS_DWORDS is also per draw-state group,
78 | * and that when a new state-group is selected, SQE compares to
79 | * the previous values to new DRAW_STATE_BASE & count to detect
80 | * that new state has been appended to existing draw-state group:
81 | */
82 | unsigned prev_idx = ds->prev_draw_state_sel;
83 | ds->state[prev_idx].sds_base = emu_get_reg64(emu, &SDS_BASE);
84 | ds->state[prev_idx].sds_dwords = emu_get_reg32(emu, &SDS_DWORDS);
85 |
86 | emu_set_reg64(emu, &SDS_BASE, ds->state[val].sds_base);
87 | emu_set_reg32(emu, &SDS_DWORDS, ds->state[val].sds_dwords);
88 |
89 | ds->prev_draw_state_sel = val;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/afuc/asm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef _ASM_H_
25 | #define _ASM_H_
26 |
27 | #include
28 | #include
29 | #include "afuc.h"
30 |
31 | extern int gpuver;
32 |
33 | /**
34 | * Intermediate representation for an instruction, before final encoding.
35 | * This mostly exists because we need to resolve label offset's in a 2nd
36 | * pass, but also so that parser.y doesn't really need to care so much
37 | * about the different encodings for 2src regs vs 1src+immed, or mnemonics
38 | */
39 | struct asm_instruction {
40 | int tok;
41 | int dst;
42 | int src1;
43 | int src2;
44 | int immed;
45 | int shift;
46 | int bit;
47 | int xmov;
48 | uint32_t literal;
49 | const char *label;
50 |
51 | bool has_immed : 1;
52 | bool has_shift : 1;
53 | bool has_bit : 1;
54 | bool is_literal : 1;
55 | bool rep : 1;
56 | };
57 |
58 | struct asm_label {
59 | unsigned offset;
60 | const char *label;
61 | };
62 |
63 | struct asm_instruction *next_instr(int tok);
64 | void decl_label(const char *str);
65 |
66 | static inline uint32_t
67 | parse_reg(const char *str)
68 | {
69 | char *retstr;
70 | long int ret;
71 |
72 | if (!strcmp(str, "$rem"))
73 | return REG_REM;
74 | else if (!strcmp(str, "$memdata"))
75 | return REG_MEMDATA;
76 | else if (!strcmp(str, "$addr"))
77 | return REG_ADDR;
78 | else if (!strcmp(str, "$regdata"))
79 | return REG_REGDATA;
80 | else if (!strcmp(str, "$usraddr"))
81 | return REG_USRADDR;
82 | else if (!strcmp(str, "$data"))
83 | return 0x1f;
84 |
85 | ret = strtol(str + 1, &retstr, 16);
86 |
87 | if (*retstr != '\0') {
88 | printf("invalid register: %s\n", str);
89 | exit(2);
90 | }
91 |
92 | return ret;
93 | }
94 |
95 | static inline uint32_t
96 | parse_literal(const char *str)
97 | {
98 | char *retstr;
99 | long int ret;
100 |
101 | ret = strtol(str + 1, &retstr, 16);
102 |
103 | if (*retstr != ']') {
104 | printf("invalid literal: %s\n", str);
105 | exit(2);
106 | }
107 |
108 | return ret;
109 | }
110 |
111 | static inline uint32_t
112 | parse_bit(const char *str)
113 | {
114 | return strtol(str + 1, NULL, 10);
115 | }
116 |
117 | unsigned parse_control_reg(const char *name);
118 |
119 | /* string trailing ':' off label: */
120 | static inline const char *
121 | parse_label_decl(const char *str)
122 | {
123 | char *s = strdup(str);
124 | s[strlen(s) - 1] = '\0';
125 | return s;
126 | }
127 |
128 | void yyset_in(FILE *_in_str);
129 |
130 | #endif /* _ASM_H_ */
131 |
--------------------------------------------------------------------------------
/decode/redump.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2012 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef REDUMP_H_
25 | #define REDUMP_H_
26 |
27 | enum rd_sect_type {
28 | RD_NONE,
29 | RD_TEST, /* ascii text */
30 | RD_CMD, /* ascii text */
31 | RD_GPUADDR, /* u32 gpuaddr, u32 size */
32 | RD_CONTEXT, /* raw dump */
33 | RD_CMDSTREAM, /* raw dump */
34 | RD_CMDSTREAM_ADDR, /* gpu addr of cmdstream */
35 | RD_PARAM, /* u32 param_type, u32 param_val, u32 bitlen */
36 | RD_FLUSH, /* empty, clear previous params */
37 | RD_PROGRAM, /* shader program, raw dump */
38 | RD_VERT_SHADER,
39 | RD_FRAG_SHADER,
40 | RD_BUFFER_CONTENTS,
41 | RD_GPU_ID,
42 | };
43 |
44 | /* RD_PARAM types: */
45 | enum rd_param_type {
46 | RD_PARAM_SURFACE_WIDTH,
47 | RD_PARAM_SURFACE_HEIGHT,
48 | RD_PARAM_SURFACE_PITCH,
49 | RD_PARAM_COLOR,
50 | RD_PARAM_BLIT_X,
51 | RD_PARAM_BLIT_Y,
52 | RD_PARAM_BLIT_WIDTH,
53 | RD_PARAM_BLIT_HEIGHT,
54 | RD_PARAM_BLIT_X2, /* BLIT_X + BLIT_WIDTH */
55 | RD_PARAM_BLIT_Y2, /* BLIT_Y + BLIT_WIDTH */
56 | };
57 |
58 | void rd_start(const char *name, const char *fmt, ...) __attribute__((weak));
59 | void rd_end(void) __attribute__((weak));
60 | void rd_write_section(enum rd_sect_type type, const void *buf, int sz)
61 | __attribute__((weak));
62 |
63 | /* for code that should run with and without libwrap, use the following
64 | * macros which check if the fxns are present before calling
65 | */
66 | #define RD_START(n, f, ...) \
67 | do { \
68 | if (rd_start) \
69 | rd_start(n, f, ##__VA_ARGS__); \
70 | } while (0)
71 | #define RD_END() \
72 | do { \
73 | if (rd_end) \
74 | rd_end(); \
75 | } while (0)
76 | #define RD_WRITE_SECTION(t, b, s) \
77 | do { \
78 | if (rd_write_section) \
79 | rd_write_section(t, b, s); \
80 | } while (0)
81 |
82 | #ifndef ARRAY_SIZE
83 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
84 | #endif
85 | #undef ALIGN
86 | #define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1))
87 |
88 | #define min(a, b) (((a) < (b)) ? (a) : (b))
89 | #define max(a, b) (((a) > (b)) ? (a) : (b))
90 |
91 | #endif /* REDUMP_H_ */
92 |
--------------------------------------------------------------------------------
/stub-mesa/util/os_memory_aligned.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2008-2010 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sub license, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice (including the
15 | * next paragraph) shall be included in all copies or substantial portions
16 | * of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | **************************************************************************/
27 |
28 |
29 | /*
30 | * Memory alignment wrappers.
31 | */
32 |
33 |
34 | #ifndef _OS_MEMORY_H_
35 | #error "Must not be included directly. Include os_memory.h instead"
36 | #endif
37 |
38 |
39 | /**
40 | * Add two size_t values with integer overflow check.
41 | * TODO: leverage __builtin_add_overflow where available
42 | */
43 | static inline bool
44 | add_overflow_size_t(size_t a, size_t b, size_t *res)
45 | {
46 | *res = a + b;
47 | return *res < a || *res < b;
48 | }
49 |
50 |
51 | #if defined(HAVE_POSIX_MEMALIGN)
52 |
53 | static inline void *
54 | os_malloc_aligned(size_t size, size_t alignment)
55 | {
56 | void *ptr;
57 | alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
58 | if(posix_memalign(&ptr, alignment, size) != 0)
59 | return NULL;
60 | return ptr;
61 | }
62 |
63 | #define os_free_aligned(_ptr) free(_ptr)
64 |
65 | #else
66 |
67 | /**
68 | * Return memory on given byte alignment
69 | */
70 | static inline void *
71 | os_malloc_aligned(size_t size, size_t alignment)
72 | {
73 | char *ptr, *buf;
74 | size_t alloc_size;
75 |
76 | /*
77 | * Calculate
78 | *
79 | * alloc_size = size + alignment + sizeof(void *)
80 | *
81 | * while checking for overflow.
82 | */
83 | if (add_overflow_size_t(size, alignment, &alloc_size) ||
84 | add_overflow_size_t(alloc_size, sizeof(void *), &alloc_size)) {
85 | return NULL;
86 | }
87 |
88 | ptr = (char *) os_malloc(alloc_size);
89 | if (!ptr)
90 | return NULL;
91 |
92 | buf = (char *)(((uintptr_t)ptr + sizeof(void *) + alignment - 1) & ~((uintptr_t)(alignment - 1)));
93 | *(char **)(buf - sizeof(void *)) = ptr;
94 |
95 | return buf;
96 | }
97 |
98 |
99 | /**
100 | * Free memory returned by os_malloc_aligned().
101 | */
102 | static inline void
103 | os_free_aligned(void *ptr)
104 | {
105 | if (ptr) {
106 | void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
107 | void *realAddr = *cubbyHole;
108 | os_free(realAddr);
109 | }
110 | }
111 |
112 | #endif
113 |
114 | /**
115 | * Reallocate memeory, with alignment
116 | */
117 | static inline void *
118 | os_realloc_aligned(void *ptr, size_t oldsize, size_t newsize, size_t alignment)
119 | {
120 | const size_t copySize = MIN2(oldsize, newsize);
121 | void *newBuf = os_malloc_aligned(newsize, alignment);
122 | if (newBuf && ptr && copySize > 0) {
123 | memcpy(newBuf, ptr, copySize);
124 | }
125 |
126 | os_free_aligned(ptr);
127 | return newBuf;
128 | }
129 |
--------------------------------------------------------------------------------
/stub-mesa/util/os_file.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Intel Corporation
3 | * SPDX-License-Identifier: MIT
4 | *
5 | * File operations helpers
6 | */
7 |
8 | #ifndef _OS_FILE_H_
9 | #define _OS_FILE_H_
10 |
11 | #include
12 | #include
13 |
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 |
18 | /*
19 | * Create a new file and opens it for writing-only.
20 | * If the given filename already exists, nothing is done and NULL is returned.
21 | * `errno` gets set to the failure reason; if that is not EEXIST, the caller
22 | * might want to do something other than trying again.
23 | */
24 | FILE *
25 | os_file_create_unique(const char *filename, int filemode);
26 |
27 | /*
28 | * Duplicate a file descriptor, making sure not to keep it open after an exec*()
29 | */
30 | int
31 | os_dupfd_cloexec(int fd);
32 |
33 | /*
34 | * Read a file.
35 | * Returns a char* that the caller must free(), or NULL and sets errno.
36 | * If size is not null and no error occured it's set to the size of the
37 | * file.
38 | */
39 | #include
40 | #include
41 | #include
42 | #include
43 | static ssize_t
44 | readN(int fd, char *buf, size_t len)
45 | {
46 | int err = -ENODATA;
47 | size_t total = 0;
48 | do {
49 | ssize_t ret = read(fd, buf + total, len - total);
50 |
51 | if (ret < 0)
52 | ret = -errno;
53 |
54 | if (ret == -EINTR || ret == -EAGAIN)
55 | continue;
56 |
57 | if (ret <= 0) {
58 | err = ret;
59 | break;
60 | }
61 |
62 | total += ret;
63 | } while (total != len);
64 |
65 | return total ? (ssize_t)total : err;
66 | }
67 |
68 | static inline
69 | char *
70 | os_read_file(const char *filename, size_t *size)
71 | {
72 | /* Note that this also serves as a slight margin to avoid a 2x grow when
73 | * the file is just a few bytes larger when we read it than when we
74 | * fstat'ed it.
75 | * The string's NULL terminator is also included in here.
76 | */
77 | size_t len = 64;
78 |
79 | int fd = open(filename, O_RDONLY);
80 | if (fd == -1) {
81 | /* errno set by open() */
82 | return NULL;
83 | }
84 |
85 | /* Pre-allocate a buffer at least the size of the file if we can read
86 | * that information.
87 | */
88 | struct stat stat;
89 | if (fstat(fd, &stat) == 0)
90 | len += stat.st_size;
91 |
92 | char *buf = malloc(len);
93 | if (!buf) {
94 | close(fd);
95 | errno = -ENOMEM;
96 | return NULL;
97 | }
98 |
99 | ssize_t actually_read;
100 | size_t offset = 0, remaining = len - 1;
101 | while ((actually_read = readN(fd, buf + offset, remaining)) == (ssize_t)remaining) {
102 | char *newbuf = realloc(buf, 2 * len);
103 | if (!newbuf) {
104 | free(buf);
105 | close(fd);
106 | errno = -ENOMEM;
107 | return NULL;
108 | }
109 |
110 | buf = newbuf;
111 | len *= 2;
112 | offset += actually_read;
113 | remaining = len - offset - 1;
114 | }
115 |
116 | close(fd);
117 |
118 | if (actually_read > 0)
119 | offset += actually_read;
120 |
121 | /* Final resize to actual size */
122 | len = offset + 1;
123 | char *newbuf = realloc(buf, len);
124 | if (!newbuf) {
125 | free(buf);
126 | errno = -ENOMEM;
127 | return NULL;
128 | }
129 | buf = newbuf;
130 |
131 | buf[offset] = '\0';
132 |
133 | if (size)
134 | *size = offset;
135 |
136 | return buf;
137 | }
138 |
139 | /*
140 | * Try to determine if two file descriptors reference the same file description
141 | *
142 | * Return values:
143 | * - 0: They reference the same file description
144 | * - > 0: They do not reference the same file description
145 | * - < 0: Unable to determine whether they reference the same file description
146 | */
147 | int
148 | os_same_file_description(int fd1, int fd2);
149 |
150 | #ifdef __cplusplus
151 | }
152 | #endif
153 |
154 | #endif /* _OS_FILE_H_ */
155 |
--------------------------------------------------------------------------------
/registers/dsi/dsi_phy_20nm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/stub-mesa/util/u_math.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | *
3 | * Copyright 2008 VMware, Inc.
4 | * All Rights Reserved.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sub license, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice (including the
15 | * next paragraph) shall be included in all copies or substantial portions
16 | * of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | **************************************************************************/
27 |
28 |
29 |
30 | //#include "pipe/p_config.h"
31 | #include "util/u_math.h"
32 | //#include "util/u_cpu_detect.h"
33 |
34 | #if defined(PIPE_ARCH_SSE)
35 | #include
36 | /* This is defined in pmmintrin.h, but it can only be included when -msse3 is
37 | * used, so just define it here to avoid further. */
38 | #ifndef _MM_DENORMALS_ZERO_MASK
39 | #define _MM_DENORMALS_ZERO_MASK 0x0040
40 | #endif
41 | #endif
42 |
43 |
44 | /** 2^x, for x in [-1.0, 1.0) */
45 | float pow2_table[POW2_TABLE_SIZE];
46 |
47 |
48 | static void
49 | init_pow2_table(void)
50 | {
51 | int i;
52 | for (i = 0; i < POW2_TABLE_SIZE; i++)
53 | pow2_table[i] = exp2f((i - POW2_TABLE_OFFSET) / POW2_TABLE_SCALE);
54 | }
55 |
56 |
57 | /** log2(x), for x in [1.0, 2.0) */
58 | float log2_table[LOG2_TABLE_SIZE];
59 |
60 |
61 | static void
62 | init_log2_table(void)
63 | {
64 | unsigned i;
65 | for (i = 0; i < LOG2_TABLE_SIZE; i++)
66 | log2_table[i] = (float) log2(1.0 + i * (1.0 / LOG2_TABLE_SCALE));
67 | }
68 |
69 |
70 | /**
71 | * One time init for math utilities.
72 | */
73 | void
74 | util_init_math(void)
75 | {
76 | static bool initialized = false;
77 | if (!initialized) {
78 | init_pow2_table();
79 | init_log2_table();
80 | initialized = true;
81 | }
82 | }
83 |
84 | /**
85 | * Fetches the contents of the fpstate (mxcsr on x86) register.
86 | *
87 | * On platforms without support for it just returns 0.
88 | */
89 | unsigned
90 | util_fpstate_get(void)
91 | {
92 | unsigned mxcsr = 0;
93 |
94 | #if defined(PIPE_ARCH_SSE)
95 | if (util_cpu_caps.has_sse) {
96 | mxcsr = _mm_getcsr();
97 | }
98 | #endif
99 |
100 | return mxcsr;
101 | }
102 |
103 | /**
104 | * Make sure that the fp treats the denormalized floating
105 | * point numbers as zero.
106 | *
107 | * This is the behavior required by D3D10. OpenGL doesn't care.
108 | */
109 | unsigned
110 | util_fpstate_set_denorms_to_zero(unsigned current_mxcsr)
111 | {
112 | #if defined(PIPE_ARCH_SSE)
113 | if (util_cpu_caps.has_sse) {
114 | /* Enable flush to zero mode */
115 | current_mxcsr |= _MM_FLUSH_ZERO_MASK;
116 | if (util_cpu_caps.has_daz) {
117 | /* Enable denormals are zero mode */
118 | current_mxcsr |= _MM_DENORMALS_ZERO_MASK;
119 | }
120 | util_fpstate_set(current_mxcsr);
121 | }
122 | #endif
123 | return current_mxcsr;
124 | }
125 |
126 | /**
127 | * Set the state of the fpstate (mxcsr on x86) register.
128 | *
129 | * On platforms without support for it's a noop.
130 | */
131 | void
132 | util_fpstate_set(unsigned mxcsr)
133 | {
134 | #if defined(PIPE_ARCH_SSE)
135 | if (util_cpu_caps.has_sse) {
136 | _mm_setcsr(mxcsr);
137 | }
138 | #endif
139 | }
140 |
--------------------------------------------------------------------------------
/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Rob Clark
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | project(
22 | 'envytools',
23 | 'c',
24 | version: '0.0.1',
25 | license: 'MIT',
26 | meson_version: '>= 0.48',
27 | default_options : ['c_std=c99', 'warning_level=2'],
28 | )
29 |
30 | cc = meson.get_compiler('c')
31 |
32 | c_args = [
33 | '-D_GNU_SOURCE',
34 | ]
35 |
36 | foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h', 'sys/shm.h', 'cet.h']
37 | if cc.check_header(h)
38 | c_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
39 | endif
40 | endforeach
41 |
42 | _trial = [
43 | '-Werror=return-type',
44 | '-Werror=empty-body',
45 | '-Werror=incompatible-pointer-types',
46 | '-Werror=int-conversion',
47 | '-Wimplicit-fallthrough',
48 | '-Wno-missing-field-initializers',
49 | '-Wno-format-truncation',
50 | '-fno-math-errno',
51 | '-fno-trapping-math',
52 | '-Qunused-arguments',
53 | '-Wno-unused-parameter',
54 | '-Wno-sign-compare',
55 | '-Wno-pointer-sign',
56 | '-Wno-unused-function',
57 | '-fno-common',
58 | ]
59 | foreach a : _trial
60 | if cc.has_argument(a)
61 | c_args += a
62 | endif
63 | endforeach
64 |
65 | foreach a : c_args
66 | add_project_arguments(a, language: 'c')
67 | endforeach
68 |
69 | no_override_init_args = []
70 | # TODO once we've sync'd back warnings fixes from mesa, we should switch
71 | # to using a similar set of warning flags
72 |
73 | # compat with mesa's meson.build.. all this tree builds is freedreno
74 | # tools:
75 | with_tools = ['freedreno']
76 | inc_include = include_directories('.')
77 | inc_gallium = inc_include
78 | inc_src = include_directories('stub-mesa')
79 | inc_util = inc_src
80 |
81 | null_dep = dependency('', required : false)
82 | idep_mesautil = null_dep
83 | idep_nir = null_dep
84 |
85 | inc_freedreno = include_directories(['.', './registers', './common'])
86 | inc_freedreno_rnn = include_directories('rnn')
87 |
88 | rnn_src_path = meson.source_root() + '/registers'
89 | rnn_install_path = get_option('datadir') + '/freedreno/registers'
90 | rnn_path = rnn_src_path + ':' + get_option('prefix') + '/' + rnn_install_path
91 |
92 | dep_lua = dependency('lua53', required: false)
93 | if not dep_lua.found()
94 | dep_lua = dependency('lua52', required: false)
95 | endif
96 | if not dep_lua.found()
97 | dep_lua = dependency('lua', required: true)
98 | endif
99 |
100 | dep_libarchive = dependency('libarchive', required: true)
101 | dep_libxml2 = dependency('libxml-2.0', required: false)
102 | prog_gzip = find_program('gzip', required: false)
103 |
104 | install_fd_decode_tools = true
105 |
106 | prog_python = import('python').find_installation('python3')
107 | prog_bison = find_program('bison', required: true)
108 | prog_flex = find_program('flex', required: true)
109 |
110 | subdir('stub-mesa/util')
111 |
112 | # TODO in mesa, move other dependencies into src/freedreno/meson.build
113 | # and out of individual subdirectories. For envytools tree, we want
114 | # to make lua/libarchive required, whereas in mesa they are optional.
115 | # The easiest way to accomplish that would be to move them here.
116 |
117 | subdir('registers')
118 | subdir('isa')
119 | subdir('ir2')
120 | subdir('ir3')
121 | subdir('rnn')
122 | subdir('decode')
123 | subdir('afuc')
124 |
125 |
--------------------------------------------------------------------------------
/stub-mesa/util/half_float.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Mesa 3-D graphics library
3 | *
4 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
5 | * Copyright (C) 2018-2019 Intel Corporation
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a
8 | * copy of this software and associated documentation files (the "Software"),
9 | * to deal in the Software without restriction, including without limitation
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 | * and/or sell copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef _HALF_FLOAT_H_
27 | #define _HALF_FLOAT_H_
28 |
29 | #include
30 | #include
31 | #include
32 | //#include "util/u_cpu_detect.h"
33 |
34 | #if defined(USE_X86_64_ASM)
35 | #include
36 | #endif
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | #define FP16_ONE ((uint16_t) 0x3c00)
43 | #define FP16_ZERO ((uint16_t) 0)
44 |
45 | uint16_t _mesa_float_to_half_slow(float val);
46 | float _mesa_half_to_float_slow(uint16_t val);
47 | uint8_t _mesa_half_to_unorm8(uint16_t v);
48 | uint16_t _mesa_uint16_div_64k_to_half(uint16_t v);
49 |
50 | /*
51 | * _mesa_float_to_float16_rtz_slow is no more than a wrapper to the counterpart
52 | * softfloat.h call. Still, softfloat.h conversion API is meant to be kept
53 | * private. In other words, only use the API published here, instead of
54 | * calling directly the softfloat.h one.
55 | */
56 | uint16_t _mesa_float_to_float16_rtz_slow(float val);
57 |
58 | static inline uint16_t
59 | _mesa_float_to_half(float val)
60 | {
61 | #if defined(USE_X86_64_ASM)
62 | if (util_cpu_caps.has_f16c) {
63 | __m128 in = {val};
64 | __m128i out;
65 |
66 | /* $0 = round to nearest */
67 | __asm volatile("vcvtps2ph $0, %1, %0" : "=v"(out) : "v"(in));
68 | return out[0];
69 | }
70 | #endif
71 | return _mesa_float_to_half_slow(val);
72 | }
73 |
74 | static inline float
75 | _mesa_half_to_float(uint16_t val)
76 | {
77 | #if defined(USE_X86_64_ASM)
78 | if (util_cpu_caps.has_f16c) {
79 | __m128i in = {val};
80 | __m128 out;
81 |
82 | __asm volatile("vcvtph2ps %1, %0" : "=v"(out) : "v"(in));
83 | return out[0];
84 | }
85 | #endif
86 | return _mesa_half_to_float_slow(val);
87 | }
88 |
89 | static inline uint16_t
90 | _mesa_float_to_float16_rtz(float val)
91 | {
92 | #if defined(USE_X86_64_ASM)
93 | if (util_cpu_caps.has_f16c) {
94 | __m128 in = {val};
95 | __m128i out;
96 |
97 | /* $3 = round towards zero (truncate) */
98 | __asm volatile("vcvtps2ph $3, %1, %0" : "=v"(out) : "v"(in));
99 | return out[0];
100 | }
101 | #endif
102 | return _mesa_float_to_float16_rtz_slow(val);
103 | }
104 |
105 | static inline uint16_t
106 | _mesa_float_to_float16_rtne(float val)
107 | {
108 | return _mesa_float_to_half(val);
109 | }
110 |
111 | static inline bool
112 | _mesa_half_is_negative(uint16_t h)
113 | {
114 | return !!(h & 0x8000);
115 | }
116 |
117 |
118 | #ifdef __cplusplus
119 |
120 | /* Helper class for disambiguating fp16 from uint16_t in C++ overloads */
121 |
122 | struct float16_t {
123 | uint16_t bits;
124 | float16_t(float f) : bits(_mesa_float_to_half(f)) {}
125 | float16_t(double d) : bits(_mesa_float_to_half(d)) {}
126 | float16_t(uint16_t raw_bits) : bits(raw_bits) {}
127 | static float16_t one() { return float16_t(FP16_ONE); }
128 | static float16_t zero() { return float16_t(FP16_ZERO); }
129 | };
130 |
131 | #endif
132 |
133 |
134 | #ifdef __cplusplus
135 | } /* extern C */
136 | #endif
137 |
138 | #endif /* _HALF_FLOAT_H_ */
139 |
--------------------------------------------------------------------------------
/decode/io.c:
--------------------------------------------------------------------------------
1 | /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2 |
3 | /*
4 | * Copyright (C) 2014 Rob Clark
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a
7 | * copy of this software and associated documentation files (the "Software"),
8 | * to deal in the Software without restriction, including without limitation
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 | * and/or sell copies of the Software, and to permit persons to whom the
11 | * Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice (including the next
14 | * paragraph) shall be included in all copies or substantial portions of the
15 | * Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | * Authors:
26 | * Rob Clark
27 | */
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | #include "io.h"
38 |
39 | struct io {
40 | struct archive *a;
41 | struct archive_entry *entry;
42 | unsigned offset;
43 | };
44 |
45 | static void
46 | io_error(struct io *io)
47 | {
48 | fprintf(stderr, "%s\n", archive_error_string(io->a));
49 | io_close(io);
50 | }
51 |
52 | static struct io *
53 | io_new(void)
54 | {
55 | struct io *io = calloc(1, sizeof(*io));
56 | int ret;
57 |
58 | if (!io)
59 | return NULL;
60 |
61 | io->a = archive_read_new();
62 | ret = archive_read_support_filter_gzip(io->a);
63 | if (ret != ARCHIVE_OK) {
64 | io_error(io);
65 | return NULL;
66 | }
67 |
68 | ret = archive_read_support_filter_none(io->a);
69 | if (ret != ARCHIVE_OK) {
70 | io_error(io);
71 | return NULL;
72 | }
73 |
74 | ret = archive_read_support_format_all(io->a);
75 | if (ret != ARCHIVE_OK) {
76 | io_error(io);
77 | return NULL;
78 | }
79 |
80 | ret = archive_read_support_format_raw(io->a);
81 | if (ret != ARCHIVE_OK) {
82 | io_error(io);
83 | return NULL;
84 | }
85 |
86 | return io;
87 | }
88 |
89 | struct io *
90 | io_open(const char *filename)
91 | {
92 | struct io *io = io_new();
93 | int ret;
94 |
95 | if (!io)
96 | return NULL;
97 |
98 | ret = archive_read_open_filename(io->a, filename, 10240);
99 | if (ret != ARCHIVE_OK) {
100 | io_error(io);
101 | return NULL;
102 | }
103 |
104 | ret = archive_read_next_header(io->a, &io->entry);
105 | if (ret != ARCHIVE_OK) {
106 | io_error(io);
107 | return NULL;
108 | }
109 |
110 | return io;
111 | }
112 |
113 | struct io *
114 | io_openfd(int fd)
115 | {
116 | struct io *io = io_new();
117 | int ret;
118 |
119 | if (!io)
120 | return NULL;
121 |
122 | ret = archive_read_open_fd(io->a, fd, 10240);
123 | if (ret != ARCHIVE_OK) {
124 | io_error(io);
125 | return NULL;
126 | }
127 |
128 | ret = archive_read_next_header(io->a, &io->entry);
129 | if (ret != ARCHIVE_OK) {
130 | io_error(io);
131 | return NULL;
132 | }
133 |
134 | return io;
135 | }
136 |
137 | void
138 | io_close(struct io *io)
139 | {
140 | archive_read_free(io->a);
141 | free(io);
142 | }
143 |
144 | unsigned
145 | io_offset(struct io *io)
146 | {
147 | return io->offset;
148 | }
149 |
150 | #include
151 | int
152 | io_readn(struct io *io, void *buf, int nbytes)
153 | {
154 | char *ptr = buf;
155 | int ret = 0;
156 | while (nbytes > 0) {
157 | int n = archive_read_data(io->a, ptr, nbytes);
158 | if (n < 0) {
159 | fprintf(stderr, "%s\n", archive_error_string(io->a));
160 | return n;
161 | }
162 | if (n == 0)
163 | break;
164 | ptr += n;
165 | nbytes -= n;
166 | ret += n;
167 | io->offset += n;
168 | }
169 | return ret;
170 | }
171 |
--------------------------------------------------------------------------------
/ir3/regmask.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef REGMASK_H_
25 | #define REGMASK_H_
26 |
27 | #include
28 | #include "util/bitset.h"
29 |
30 | #define MAX_REG 256
31 |
32 | typedef BITSET_DECLARE(regmaskstate_t, 2 * MAX_REG);
33 |
34 | typedef struct {
35 | bool mergedregs;
36 | regmaskstate_t mask;
37 | } regmask_t;
38 |
39 | static inline bool
40 | __regmask_get(regmask_t *regmask, bool half, unsigned n)
41 | {
42 | if (regmask->mergedregs) {
43 | /* a6xx+ case, with merged register file, we track things in terms
44 | * of half-precision registers, with a full precisions register
45 | * using two half-precision slots:
46 | */
47 | if (half) {
48 | return BITSET_TEST(regmask->mask, n);
49 | } else {
50 | n *= 2;
51 | return BITSET_TEST(regmask->mask, n) ||
52 | BITSET_TEST(regmask->mask, n + 1);
53 | }
54 | } else {
55 | /* pre a6xx case, with separate register file for half and full
56 | * precision:
57 | */
58 | if (half)
59 | n += MAX_REG;
60 | return BITSET_TEST(regmask->mask, n);
61 | }
62 | }
63 |
64 | static inline void
65 | __regmask_set(regmask_t *regmask, bool half, unsigned n)
66 | {
67 | if (regmask->mergedregs) {
68 | /* a6xx+ case, with merged register file, we track things in terms
69 | * of half-precision registers, with a full precisions register
70 | * using two half-precision slots:
71 | */
72 | if (half) {
73 | BITSET_SET(regmask->mask, n);
74 | } else {
75 | n *= 2;
76 | BITSET_SET(regmask->mask, n);
77 | BITSET_SET(regmask->mask, n + 1);
78 | }
79 | } else {
80 | /* pre a6xx case, with separate register file for half and full
81 | * precision:
82 | */
83 | if (half)
84 | n += MAX_REG;
85 | BITSET_SET(regmask->mask, n);
86 | }
87 | }
88 |
89 | static inline void
90 | __regmask_clear(regmask_t *regmask, bool half, unsigned n)
91 | {
92 | if (regmask->mergedregs) {
93 | /* a6xx+ case, with merged register file, we track things in terms
94 | * of half-precision registers, with a full precisions register
95 | * using two half-precision slots:
96 | */
97 | if (half) {
98 | BITSET_CLEAR(regmask->mask, n);
99 | } else {
100 | n *= 2;
101 | BITSET_CLEAR(regmask->mask, n);
102 | BITSET_CLEAR(regmask->mask, n + 1);
103 | }
104 | } else {
105 | /* pre a6xx case, with separate register file for half and full
106 | * precision:
107 | */
108 | if (half)
109 | n += MAX_REG;
110 | BITSET_CLEAR(regmask->mask, n);
111 | }
112 | }
113 |
114 | static inline void
115 | regmask_init(regmask_t *regmask, bool mergedregs)
116 | {
117 | memset(®mask->mask, 0, sizeof(regmask->mask));
118 | regmask->mergedregs = mergedregs;
119 | }
120 |
121 | static inline void
122 | regmask_or(regmask_t *dst, regmask_t *a, regmask_t *b)
123 | {
124 | assert(dst->mergedregs == a->mergedregs);
125 | assert(dst->mergedregs == b->mergedregs);
126 |
127 | for (unsigned i = 0; i < ARRAY_SIZE(dst->mask); i++)
128 | dst->mask[i] = a->mask[i] | b->mask[i];
129 | }
130 |
131 | #endif /* REGMASK_H_ */
132 |
--------------------------------------------------------------------------------
/decode/scripts/tex3d-layout.lua:
--------------------------------------------------------------------------------
1 | -- Parse logs from test-quad-textured-3d.c to exctract layer/level
2 | -- offsets
3 | --
4 | -- We figure out the offsets from blits, but there may be some
5 | -- unrelated blits. So just save all of them until we find the
6 | -- texture state for the 3d texture. This gives us the base
7 | -- address, and the miplevel #0 width/height/depth. Then work
8 | -- backwards from there finding the blits to the same dst buffer
9 | -- and deducing the miplevel from the minified dimensions
10 |
11 | local posix = require "posix"
12 |
13 | io.write("Analyzing Data...\n")
14 |
15 | local allblits = {}
16 | local nallblits = 0
17 | local r = rnn.init("a630")
18 |
19 | function minify(val, lvls)
20 | val = val >> lvls
21 | if val < 1 then
22 | return 1
23 | end
24 | return val
25 | end
26 |
27 | function printf(fmt, ...)
28 | return io.write(string.format(fmt, ...))
29 | end
30 |
31 | function start_cmdstream(name)
32 | io.write("Parsing " .. name .. "\n")
33 | allblits = {}
34 | nallblits = 0
35 | end
36 |
37 | function draw(primtype, nindx)
38 | if primtype ~= "BLIT_OP_SCALE" then
39 | return
40 | end
41 |
42 | -- Just in case, filter out anything that isn't starting
43 | -- at 0,0
44 | if r.GRAS_2D_DST_TL.X ~= 0 or r.GRAS_2D_DST_TL.Y ~= 0 then
45 | return
46 | end
47 |
48 | local blit = {}
49 |
50 | blit.width = r.GRAS_2D_DST_BR.X + 1
51 | blit.height = r.GRAS_2D_DST_BR.Y + 1
52 | blit.pitch = r.RB_2D_DST_SIZE.PITCH
53 | blit.addr = r.RB_2D_DST_LO | (r.RB_2D_DST_HI << 32)
54 | blit.base = bos.base(blit.addr)
55 | blit.endaddr = 0 -- filled in later
56 | --printf("Found blit: 0x%x (0x%x)\n", blit.addr, blit.base)
57 |
58 | allblits[nallblits] = blit
59 | nallblits = nallblits + 1
60 | end
61 |
62 | function A6XX_TEX_CONST(pkt, size)
63 | -- ignore any texture state w/ DEPTH=1, these aren't the 3d tex state we
64 | -- are looking for
65 | if pkt[5].DEPTH <= 1 then
66 | return
67 | end
68 |
69 | local base = pkt[4].BASE_LO | (pkt[5].BASE_HI << 32)
70 | local width0 = pkt[1].WIDTH
71 | local height0 = pkt[1].HEIGHT
72 | local depth0 = pkt[5].DEPTH
73 |
74 | printf("Found texture state: %ux%ux%u (MIN_LAYERSZ=0x%x)\n",
75 | width0, height0, depth0, pkt[3].MIN_LAYERSZ)
76 |
77 | -- Note that in some case the texture has some extra page or so
78 | -- at the beginning:
79 | local basebase = bos.base(base)
80 | printf("base: 0x%x (0x%x)\n", base, basebase)
81 |
82 | -- see if we can find the associated blits.. The blob always seems to
83 | -- start from the lower (larger) mipmap levels and layers, so we don't
84 | -- need to sort by dst address. Also, while we are at it, fill in the
85 | -- end-addr (at least for everything but the last blit)
86 | local blits = {}
87 | local nblits = 0
88 | local lastblit = nil
89 | for n = 0,nallblits-1 do
90 | local blit = allblits[n]
91 | --printf("blit addr: 0x%x (0x%x)\n", blit.addr, blit.base)
92 | if blit.base == basebase and blit.addr >= base then
93 | blits[nblits] = blit
94 | nblits = nblits + 1
95 | if lastblit then
96 | lastblit.endaddr = blit.addr
97 | end
98 | lastblit = blit
99 | end
100 | end
101 |
102 | -- now go thru the relevant blits and print out interesting details
103 | local level = 0
104 | local layer = 0
105 | local w = width0 -- track current width/height to detect changing
106 | local h = height0 -- mipmap level
107 | for n = 0,nblits-1 do
108 | local blit = blits[n]
109 | --printf("%u: %ux%u, addr=%x\n", n, blit.width, blit.height, blit.addr)
110 | if w ~= blit.width or h ~= blit.height then
111 | level = level + 1
112 | layer = 0
113 |
114 | if blit.width ~= minify(w, 1) or blit.height ~= minify(h, 1) then
115 | printf("I am confused! %ux%u vs %ux%u\n", blit.width, blit.height, minify(w, 1), minify(h, 1))
116 | printf("addr=%x\n", blit.addr)
117 | --return
118 | end
119 |
120 | w = blit.width
121 | h = blit.height
122 | end
123 |
124 | printf("level=%u, layer=%u, sz=%ux%u, pitch=%u, offset=0x%x, addr=%x",
125 | level, layer, w, h, blit.pitch, blit.addr - base, blit.addr)
126 | if blit.endaddr ~= 0 then
127 | local layersz = blit.endaddr - blit.addr
128 | local alignedheight = layersz / blit.pitch
129 | printf(", layersz=0x%x, alignedheight=%f", layersz, alignedheight)
130 | end
131 | printf("\n")
132 |
133 | layer = layer + 1
134 | end
135 | printf("\n\n")
136 | end
137 |
138 |
--------------------------------------------------------------------------------
/decode/meson.build:
--------------------------------------------------------------------------------
1 | # Copyright © 2020 Google, Inc
2 |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy
4 | # of this software and associated documentation files (the "Software"), to deal
5 | # in the Software without restriction, including without limitation the rights
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | # copies of the Software, and to permit persons to whom the Software is
8 | # furnished to do so, subject to the following conditions:
9 |
10 | # The above copyright notice and this permission notice shall be included in
11 | # all copies or substantial portions of the Software.
12 |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | # SOFTWARE.
20 |
21 | # Shared cmdstream decoding:
22 | libfreedreno_cffdec = static_library(
23 | 'freedreno_cffdec',
24 | [
25 | 'buffers.c',
26 | 'buffers.h',
27 | 'cffdec.c',
28 | 'cffdec.h',
29 | 'pager.c',
30 | 'pager.h',
31 | 'rnnutil.c',
32 | 'rnnutil.h',
33 | 'util.h',
34 | ],
35 | include_directories: [
36 | inc_freedreno,
37 | inc_freedreno_rnn,
38 | inc_include,
39 | inc_src,
40 | ],
41 | c_args : [ no_override_init_args ],
42 | gnu_symbol_visibility: 'hidden',
43 | dependencies: [],
44 | link_with: [
45 | libfreedreno_rnn,
46 | libfreedreno_ir2, # for disasm_a2xx
47 | libfreedreno_ir3, # for disasm_a3xx
48 | _libmesa_util,
49 | ],
50 | build_by_default: false,
51 | )
52 |
53 | if dep_libarchive.found()
54 | libfreedreno_io = static_library(
55 | 'libfreedreno_io',
56 | [
57 | 'io.c',
58 | 'io.h',
59 | ],
60 | include_directories: [],
61 | c_args : [no_override_init_args],
62 | gnu_symbol_visibility: 'hidden',
63 | dependencies: [
64 | dep_libarchive,
65 | ],
66 | build_by_default: false,
67 | )
68 | endif
69 |
70 | if dep_lua.found() and dep_libarchive.found()
71 | cffdump = executable(
72 | 'cffdump',
73 | [
74 | 'cffdump.c',
75 | 'script.c',
76 | 'script.h'
77 | ],
78 | include_directories: [
79 | inc_freedreno,
80 | inc_freedreno_rnn,
81 | inc_include,
82 | inc_src,
83 | ],
84 | c_args : [no_override_init_args],
85 | gnu_symbol_visibility: 'hidden',
86 | dependencies: [
87 | dep_lua,
88 | ],
89 | link_with: [
90 | libfreedreno_cffdec,
91 | libfreedreno_io,
92 | ],
93 | build_by_default: with_tools.contains('freedreno'),
94 | install: install_fd_decode_tools,
95 | )
96 | endif
97 |
98 | crashdec = executable(
99 | 'crashdec',
100 | 'crashdec.c',
101 | include_directories: [
102 | inc_freedreno,
103 | inc_freedreno_rnn,
104 | inc_include,
105 | inc_src,
106 | ],
107 | gnu_symbol_visibility: 'hidden',
108 | dependencies: [],
109 | link_with: [
110 | libfreedreno_cffdec,
111 | ],
112 | build_by_default: with_tools.contains('freedreno'),
113 | install: install_fd_decode_tools,
114 | )
115 |
116 | if dep_libarchive.found()
117 | pgmdump = executable(
118 | 'pgmdump',
119 | 'pgmdump.c',
120 | include_directories: [
121 | inc_freedreno,
122 | inc_include,
123 | inc_src,
124 | ],
125 | gnu_symbol_visibility: 'hidden',
126 | dependencies: [],
127 | link_with: [
128 | libfreedreno_cffdec,
129 | libfreedreno_io,
130 | libfreedreno_ir2, # for disasm_a2xx
131 | libfreedreno_ir3, # for disasm_a3xx
132 | ],
133 | build_by_default: with_tools.contains('freedreno'),
134 | install: false,
135 | )
136 | pgmdump2 = executable(
137 | 'pgmdump2',
138 | 'pgmdump2.c',
139 | include_directories: [
140 | inc_freedreno,
141 | inc_include,
142 | inc_src,
143 | ],
144 | gnu_symbol_visibility: 'hidden',
145 | dependencies: [],
146 | link_with: [
147 | libfreedreno_cffdec,
148 | libfreedreno_io,
149 | libfreedreno_ir2, # for disasm_a2xx
150 | libfreedreno_ir3, # for disasm_a3xx
151 | ],
152 | build_by_default: with_tools.contains('freedreno'),
153 | install: false,
154 | )
155 | endif
156 |
--------------------------------------------------------------------------------
/stub-mesa/util/set.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2009-2012 Intel Corporation
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | * IN THE SOFTWARE.
22 | *
23 | * Authors:
24 | * Eric Anholt
25 | *
26 | */
27 |
28 | #ifndef _SET_H
29 | #define _SET_H
30 |
31 | #include
32 | #include
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | struct set_entry {
39 | uint32_t hash;
40 | const void *key;
41 | };
42 |
43 | struct set {
44 | void *mem_ctx;
45 | struct set_entry *table;
46 | uint32_t (*key_hash_function)(const void *key);
47 | bool (*key_equals_function)(const void *a, const void *b);
48 | uint32_t size;
49 | uint32_t rehash;
50 | uint64_t size_magic;
51 | uint64_t rehash_magic;
52 | uint32_t max_entries;
53 | uint32_t size_index;
54 | uint32_t entries;
55 | uint32_t deleted_entries;
56 | };
57 |
58 | struct set *
59 | _mesa_set_create(void *mem_ctx,
60 | uint32_t (*key_hash_function)(const void *key),
61 | bool (*key_equals_function)(const void *a,
62 | const void *b));
63 | struct set *
64 | _mesa_set_create_u32_keys(void *mem_ctx);
65 |
66 | struct set *
67 | _mesa_set_clone(struct set *set, void *dst_mem_ctx);
68 |
69 | void
70 | _mesa_set_destroy(struct set *set,
71 | void (*delete_function)(struct set_entry *entry));
72 | void
73 | _mesa_set_resize(struct set *set, uint32_t entries);
74 | void
75 | _mesa_set_clear(struct set *set,
76 | void (*delete_function)(struct set_entry *entry));
77 |
78 | struct set_entry *
79 | _mesa_set_add(struct set *set, const void *key);
80 | struct set_entry *
81 | _mesa_set_add_pre_hashed(struct set *set, uint32_t hash, const void *key);
82 |
83 | struct set_entry *
84 | _mesa_set_search_or_add(struct set *set, const void *key);
85 | struct set_entry *
86 | _mesa_set_search_or_add_pre_hashed(struct set *set, uint32_t hash,
87 | const void *key);
88 |
89 | struct set_entry *
90 | _mesa_set_search(const struct set *set, const void *key);
91 | struct set_entry *
92 | _mesa_set_search_pre_hashed(const struct set *set, uint32_t hash,
93 | const void *key);
94 |
95 | struct set_entry *
96 | _mesa_set_search_and_add(struct set *set, const void *key, bool *replaced);
97 | struct set_entry *
98 | _mesa_set_search_and_add_pre_hashed(struct set *set, uint32_t hash,
99 | const void *key, bool *replaced);
100 |
101 | void
102 | _mesa_set_remove(struct set *set, struct set_entry *entry);
103 | void
104 | _mesa_set_remove_key(struct set *set, const void *key);
105 |
106 | struct set_entry *
107 | _mesa_set_next_entry(const struct set *set, struct set_entry *entry);
108 |
109 | struct set_entry *
110 | _mesa_set_random_entry(struct set *set,
111 | int (*predicate)(struct set_entry *entry));
112 |
113 | struct set *
114 | _mesa_pointer_set_create(void *mem_ctx);
115 |
116 | bool
117 | _mesa_set_intersects(struct set *a, struct set *b);
118 |
119 | /**
120 | * This foreach function is safe against deletion, but not against
121 | * insertion (which may rehash the set, making entry a dangling
122 | * pointer).
123 | */
124 | #define set_foreach(set, entry) \
125 | for (struct set_entry *entry = _mesa_set_next_entry(set, NULL); \
126 | entry != NULL; \
127 | entry = _mesa_set_next_entry(set, entry))
128 |
129 | #ifdef __cplusplus
130 | } /* extern C */
131 | #endif
132 |
133 | #endif /* _SET_H */
134 |
--------------------------------------------------------------------------------
/isa/ir3-cat4.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 | {SY}{SS}{JP}{SAT}{REPEAT}{UL}{NAME} {DST_HALF}{DST}, {SRC}
34 |
35 |
36 |
37 |
38 |
39 | xxxxxxxxxxxxxxxx
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | Destination register is opposite precision as source, ie.
49 | if {FULL} is true then destination is half precision, and
50 | visa versa.
51 |
52 |
53 |
54 | xxxxx
55 |
56 | Full precision source registers
57 |
58 |
59 |
60 |
61 | 100
62 |
63 |
64 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | 000000
75 |
76 |
77 |
78 | 000001
79 |
80 |
81 |
82 | 000010
83 |
84 |
85 |
86 | 000011
87 |
88 |
89 |
90 | 000100
91 |
92 |
93 |
94 | 000101
95 |
96 |
97 |
98 | 000110
99 |
100 |
101 |
107 |
108 |
109 | 001001
110 |
111 |
112 |
113 | 001010
114 |
115 |
116 |
117 | 001011
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/stub-mesa/util/rounding.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 Intel Corporation
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | * IN THE SOFTWARE.
22 | */
23 |
24 | #ifndef _ROUNDING_H
25 | #define _ROUNDING_H
26 |
27 | #include "c99_math.h"
28 |
29 | #include
30 | #include
31 |
32 | #if defined(__SSE__) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1)) || defined(_M_X64)
33 | #include
34 | #include
35 | #endif
36 |
37 | #ifdef __SSE4_1__
38 | #include
39 | #endif
40 |
41 | /* The C standard library has functions round()/rint()/nearbyint() that round
42 | * their arguments according to the rounding mode set in the floating-point
43 | * control register. While there are trunc()/ceil()/floor() functions that do
44 | * a specific operation without modifying the rounding mode, there is no
45 | * roundeven() in any version of C.
46 | *
47 | * Technical Specification 18661 (ISO/IEC TS 18661-1:2014) adds roundeven(),
48 | * but it's unfortunately not implemented by glibc.
49 | *
50 | * This implementation differs in that it does not raise the inexact exception.
51 | *
52 | * We use rint() to implement these functions, with the assumption that the
53 | * floating-point rounding mode has not been changed from the default Round
54 | * to Nearest.
55 | */
56 |
57 | /**
58 | * \brief Rounds \c x to the nearest integer, with ties to the even integer.
59 | */
60 | static inline float
61 | _mesa_roundevenf(float x)
62 | {
63 | #ifdef __SSE4_1__
64 | float ret;
65 | __m128 m = _mm_load_ss(&x);
66 | m = _mm_round_ss(m, m, _MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC);
67 | _mm_store_ss(&ret, m);
68 | return ret;
69 | #else
70 | return rintf(x);
71 | #endif
72 | }
73 |
74 | /**
75 | * \brief Rounds \c x to the nearest integer, with ties to the even integer.
76 | */
77 | static inline double
78 | _mesa_roundeven(double x)
79 | {
80 | #ifdef __SSE4_1__
81 | double ret;
82 | __m128d m = _mm_load_sd(&x);
83 | m = _mm_round_sd(m, m, _MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC);
84 | _mm_store_sd(&ret, m);
85 | return ret;
86 | #else
87 | return rint(x);
88 | #endif
89 | }
90 |
91 | /**
92 | * \brief Rounds \c x to the nearest integer, with ties to the even integer,
93 | * and returns the value as a long int.
94 | */
95 | static inline long
96 | _mesa_lroundevenf(float x)
97 | {
98 | #if defined(__SSE__) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1)) || defined(_M_X64)
99 | #if LONG_MAX == INT64_MAX
100 | return _mm_cvtss_si64(_mm_load_ss(&x));
101 | #elif LONG_MAX == INT32_MAX
102 | return _mm_cvtss_si32(_mm_load_ss(&x));
103 | #else
104 | #error "Unsupported long size"
105 | #endif
106 | #else
107 | return lrintf(x);
108 | #endif
109 | }
110 |
111 |
112 | /**
113 | * \brief Rounds \c x to the nearest integer, with ties to the even integer,
114 | * and returns the value as a long int.
115 | */
116 | static inline long
117 | _mesa_lroundeven(double x)
118 | {
119 | #if defined(__SSE2__) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64)
120 | #if LONG_MAX == INT64_MAX
121 | return _mm_cvtsd_si64(_mm_load_sd(&x));
122 | #elif LONG_MAX == INT32_MAX
123 | return _mm_cvtsd_si32(_mm_load_sd(&x));
124 | #else
125 | #error "Unsupported long size"
126 | #endif
127 | #else
128 | return lrint(x);
129 | #endif
130 | }
131 |
132 | /**
133 | * \brief Rounds \c x to the nearest integer, with ties to the even integer,
134 | * and returns the value as an int64_t.
135 | */
136 | static inline int64_t
137 | _mesa_i64roundevenf(float x)
138 | {
139 | #if LONG_MAX == INT64_MAX
140 | return _mesa_lroundevenf(x);
141 | #elif LONG_MAX == INT32_MAX
142 | return llrintf(x);
143 | #else
144 | #error "Unsupported long size"
145 | #endif
146 | }
147 |
148 | #endif
149 |
--------------------------------------------------------------------------------
/registers/dsi/dsi_phy_10nm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/isa/decode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2020 Google, Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #ifndef _DECODE_H_
25 | #define _DECODE_H_
26 |
27 | #include
28 | #include
29 |
30 | /*
31 | * Defines the tables which are generated from xml for disassembly
32 | */
33 |
34 | struct decode_scope;
35 |
36 | /* TODO we could maybe make this a uint8_t array, with some helpers, to
37 | * support arbitrary sized patterns.. or add AND/OR/SHIFT support to
38 | * util/bitset.h?
39 | */
40 | typedef uint64_t bitmask_t;
41 |
42 | struct isa_bitset;
43 |
44 | /**
45 | * Table of enum values
46 | */
47 | struct isa_enum {
48 | unsigned num_values;
49 | struct {
50 | unsigned val;
51 | const char *display;
52 | } values[];
53 | };
54 |
55 | /**
56 | * An expression used to for conditional overrides, derived fields, etc
57 | */
58 | typedef uint64_t (*isa_expr_t)(struct decode_scope *scope);
59 |
60 | /**
61 | * Used by generated expr functions
62 | */
63 | uint64_t isa_decode_field(struct decode_scope *scope, const char *field_name);
64 |
65 | /**
66 | * For bitset fields, there are some cases where we want to "remap" field
67 | * names, essentially allowing one to parameterize a nested bitset when
68 | * it resolves fields in an enclosing bitset.
69 | */
70 | struct isa_field_params {
71 | unsigned num_params;
72 | struct {
73 | const char *name;
74 | const char *as;
75 | } params[];
76 | };
77 |
78 | /**
79 | * Description of a single field within a bitset case.
80 | */
81 | struct isa_field {
82 | const char *name;
83 | isa_expr_t expr; /* for virtual "derived" fields */
84 | unsigned low;
85 | unsigned high;
86 | enum {
87 | /* Basic types: */
88 | TYPE_BRANCH, /* branch target, like INT but optional labeling*/
89 | TYPE_INT,
90 | TYPE_UINT,
91 | TYPE_HEX,
92 | TYPE_OFFSET, /* Like INT but formated with +/- or omitted if ==0 */
93 | TYPE_UOFFSET, /* Like UINT but formated with + or omitted if ==0 */
94 | TYPE_FLOAT,
95 | TYPE_BOOL,
96 | TYPE_ENUM,
97 |
98 | /* To assert a certain value in a given range of bits.. not
99 | * used for pattern matching, but allows an override to specify
100 | * that a certain bitpattern in some "unused" bits is expected
101 | */
102 | TYPE_ASSERT,
103 |
104 | /* For fields that are decoded with another bitset hierarchy: */
105 | TYPE_BITSET,
106 | } type;
107 | union {
108 | const struct isa_bitset **bitsets; /* if type==BITSET */
109 | uint64_t val; /* if type==ASSERT */
110 | const struct isa_enum *enums; /* if type==ENUM */
111 | const char *display; /* if type==BOOL */
112 | };
113 |
114 | /**
115 | * type==BITSET fields can also optionally provide remapping for
116 | * field names
117 | */
118 | const struct isa_field_params *params;
119 | };
120 |
121 | /**
122 | * A bitset consists of N "cases", with the last one (with case->expr==NULL)
123 | * being the default.
124 | *
125 | * When resolving a field, display template string, etc, all the cases with
126 | * an expression that evaluates to non-zero are consider, falling back to
127 | * the last (default) case.
128 | */
129 | struct isa_case {
130 | isa_expr_t expr;
131 | const char *display;
132 | unsigned num_fields;
133 | struct isa_field fields[];
134 | };
135 |
136 | /**
137 | * An individual bitset, the leaves of a bitset inheritance hiearchy will
138 | * have the match and mask to match a single instruction (or arbitrary
139 | * bit-pattern) against.
140 | */
141 | struct isa_bitset {
142 | const struct isa_bitset *parent;
143 | const char *name;
144 | struct {
145 | unsigned min;
146 | unsigned max;
147 | } gen;
148 | bitmask_t match;
149 | bitmask_t dontcare;
150 | bitmask_t mask;
151 | unsigned num_cases;
152 | const struct isa_case *cases[];
153 | };
154 |
155 | #endif /* _DECODE_H_ */
156 |
--------------------------------------------------------------------------------
/afuc/lexer.l:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | %{
25 | #include
26 | #include "parser.h"
27 | #include "asm.h"
28 |
29 | #define YY_NO_INPUT
30 | #define YY_NO_UNPUT
31 |
32 | #define TOKEN(t) (yylval.tok = t)
33 | extern YYSTYPE yylval;
34 |
35 | %}
36 |
37 | %option noyywrap
38 |
39 | %%
40 | "\n" yylineno++;
41 | [ \t] ; /* ignore whitespace */
42 | ";"[^\n]*"\n" yylineno++; /* ignore comments */
43 | 0|[1-9][0-9]* yylval.num = strtoul(yytext, NULL, 0); return T_INT;
44 | "0x"[0-9a-fA-F]* yylval.num = strtoul(yytext, NULL, 0); return T_HEX;
45 |
46 | "$"[0-9a-fA-F][0-9a-fA-F] yylval.num = parse_reg(yytext); return T_REGISTER;
47 | "$"[a-zA-Z][a-zA-Z0-9]* yylval.num = parse_reg(yytext); return T_REGISTER;
48 | "b"[0-9][0-9]* yylval.num = parse_bit(yytext); return T_BIT;
49 | "@"[a-zA-Z_][a-zA-Z0-9_]* yylval.num = parse_control_reg(yytext); return T_CONTROL_REG;
50 | "#"[a-zA-Z_][a-zA-Z0-9_]* yylval.str = strdup(yytext+1); return T_LABEL_REF; /* label reference */
51 | [a-zA-Z_][a-zA-Z0-9_]*":" yylval.str = parse_label_decl(yytext); return T_LABEL_DECL; /* label declaration */
52 | "["[0-9a-fA-F][0-9a-fA-F]*"]" yylval.num = parse_literal(yytext); return T_LITERAL;
53 |
54 | /* instructions: */
55 | "nop" return TOKEN(T_OP_NOP);
56 | "add" return TOKEN(T_OP_ADD);
57 | "addhi" return TOKEN(T_OP_ADDHI);
58 | "sub" return TOKEN(T_OP_SUB);
59 | "subhi" return TOKEN(T_OP_SUBHI);
60 | "and" return TOKEN(T_OP_AND);
61 | "or" return TOKEN(T_OP_OR);
62 | "xor" return TOKEN(T_OP_XOR);
63 | "not" return TOKEN(T_OP_NOT);
64 | "shl" return TOKEN(T_OP_SHL);
65 | "ushr" return TOKEN(T_OP_USHR);
66 | "ishr" return TOKEN(T_OP_ISHR);
67 | "rot" return TOKEN(T_OP_ROT);
68 | "mul8" return TOKEN(T_OP_MUL8);
69 | "min" return TOKEN(T_OP_MIN);
70 | "max" return TOKEN(T_OP_MAX);
71 | "cmp" return TOKEN(T_OP_CMP);
72 | "msb" return TOKEN(T_OP_MSB);
73 | "mov" return TOKEN(T_OP_MOV);
74 | "cwrite" return TOKEN(T_OP_CWRITE);
75 | "cread" return TOKEN(T_OP_CREAD);
76 | "store" return TOKEN(T_OP_STORE);
77 | "load" return TOKEN(T_OP_LOAD);
78 | "brne" return TOKEN(T_OP_BRNE);
79 | "breq" return TOKEN(T_OP_BREQ);
80 | "ret" return TOKEN(T_OP_RET);
81 | "iret" return TOKEN(T_OP_IRET);
82 | "call" return TOKEN(T_OP_CALL);
83 | "jump" return TOKEN(T_OP_JUMP);
84 | "waitin" return TOKEN(T_OP_WAITIN);
85 | "preemptleave" return TOKEN(T_OP_PREEMPTLEAVE);
86 | "setsecure" return TOKEN(T_OP_SETSECURE);
87 | "<<" return TOKEN(T_LSHIFT);
88 | "(rep)" return TOKEN(T_REP);
89 | "(xmov"[1-3]")" yylval.num = yytext[5] - '\0'; return T_XMOV;
90 |
91 | "," return ',';
92 | "[" return '[';
93 | "]" return ']';
94 | "+" return '+';
95 |
96 | . fprintf(stderr, "error at line %d: Unknown token: %s\n", yyget_lineno(), yytext); yyterminate();
97 |
98 | %%
99 |
--------------------------------------------------------------------------------
/common/freedreno_pm4.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012-2018 Rob Clark
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and associated documentation files (the "Software"),
6 | * to deal in the Software without restriction, including without limitation
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | * and/or sell copies of the Software, and to permit persons to whom the
9 | * Software is furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice (including the next
12 | * paragraph) shall be included in all copies or substantial portions of the
13 | * Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | * Authors:
24 | * Rob Clark
25 | */
26 |
27 | #ifndef FREEDRENO_PM4_H_
28 | #define FREEDRENO_PM4_H_
29 |
30 | #include
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | #define CP_TYPE0_PKT 0x00000000
37 | #define CP_TYPE2_PKT 0x80000000
38 | #define CP_TYPE3_PKT 0xc0000000
39 | #define CP_TYPE4_PKT 0x40000000
40 | #define CP_TYPE7_PKT 0x70000000
41 |
42 | /*
43 | * Helpers for pm4 pkt header building/parsing:
44 | */
45 |
46 | static inline unsigned
47 | pm4_odd_parity_bit(unsigned val)
48 | {
49 | /* See: http://graphics.stanford.edu/~seander/bithacks.html#ParityParallel
50 | * note that we want odd parity so 0x6996 is inverted.
51 | */
52 | val ^= val >> 16;
53 | val ^= val >> 8;
54 | val ^= val >> 4;
55 | val &= 0xf;
56 | return (~0x6996 >> val) & 1;
57 | }
58 |
59 | static inline uint32_t
60 | pm4_pkt0_hdr(uint16_t regindx, uint16_t cnt)
61 | {
62 | return CP_TYPE0_PKT | ((cnt - 1) << 16) | (regindx & 0x7fff);
63 | }
64 |
65 | static inline uint32_t
66 | pm4_pkt3_hdr(uint8_t opcode, uint16_t cnt)
67 | {
68 | return CP_TYPE3_PKT | ((cnt - 1) << 16) | ((opcode & 0xff) << 8);
69 | }
70 |
71 | static inline uint32_t
72 | pm4_pkt4_hdr(uint16_t regindx, uint16_t cnt)
73 | {
74 | return CP_TYPE4_PKT | cnt | (pm4_odd_parity_bit(cnt) << 7) |
75 | ((regindx & 0x3ffff) << 8) |
76 | ((pm4_odd_parity_bit(regindx) << 27));
77 | }
78 |
79 | static inline uint32_t
80 | pm4_pkt7_hdr(uint8_t opcode, uint16_t cnt)
81 | {
82 | return CP_TYPE7_PKT | cnt | (pm4_odd_parity_bit(cnt) << 15) |
83 | ((opcode & 0x7f) << 16) |
84 | ((pm4_odd_parity_bit(opcode) << 23));
85 | }
86 |
87 | /*
88 | * Helpers for packet parsing:
89 | */
90 |
91 | #define pkt_is_type0(pkt) (((pkt)&0XC0000000) == CP_TYPE0_PKT)
92 | #define type0_pkt_size(pkt) ((((pkt) >> 16) & 0x3FFF) + 1)
93 | #define type0_pkt_offset(pkt) ((pkt)&0x7FFF)
94 |
95 | #define pkt_is_type2(pkt) ((pkt) == CP_TYPE2_PKT)
96 |
97 | #define pkt_is_type3(pkt) \
98 | ((((pkt)&0xC0000000) == CP_TYPE3_PKT) && (((pkt)&0x80FE) == 0))
99 |
100 | #define cp_type3_opcode(pkt) (((pkt) >> 8) & 0xFF)
101 | #define type3_pkt_size(pkt) ((((pkt) >> 16) & 0x3FFF) + 1)
102 |
103 | static inline uint
104 | pm4_calc_odd_parity_bit(uint val)
105 | {
106 | return (0x9669 >> (0xf & ((val) ^ ((val) >> 4) ^ ((val) >> 8) ^
107 | ((val) >> 12) ^ ((val) >> 16) ^ ((val) >> 20) ^
108 | ((val) >> 24) ^ ((val) >> 28)))) &
109 | 1;
110 | }
111 |
112 | #define pkt_is_type4(pkt) \
113 | ((((pkt)&0xF0000000) == CP_TYPE4_PKT) && \
114 | ((((pkt) >> 27) & 0x1) == \
115 | pm4_calc_odd_parity_bit(type4_pkt_offset(pkt))) && \
116 | ((((pkt) >> 7) & 0x1) == pm4_calc_odd_parity_bit(type4_pkt_size(pkt))))
117 |
118 | #define type4_pkt_offset(pkt) (((pkt) >> 8) & 0x7FFFF)
119 | #define type4_pkt_size(pkt) ((pkt)&0x7F)
120 |
121 | #define pkt_is_type7(pkt) \
122 | ((((pkt)&0xF0000000) == CP_TYPE7_PKT) && (((pkt)&0x0F000000) == 0) && \
123 | ((((pkt) >> 23) & 0x1) == \
124 | pm4_calc_odd_parity_bit(cp_type7_opcode(pkt))) && \
125 | ((((pkt) >> 15) & 0x1) == pm4_calc_odd_parity_bit(type7_pkt_size(pkt))))
126 |
127 | #define cp_type7_opcode(pkt) (((pkt) >> 16) & 0x7F)
128 | #define type7_pkt_size(pkt) ((pkt)&0x3FFF)
129 |
130 | #ifdef __cplusplus
131 | } /* end of extern "C" */
132 | #endif
133 |
134 | #endif /* FREEDRENO_PM4_H_ */
135 |
--------------------------------------------------------------------------------