summaryrefslogtreecommitdiff
path: root/chromium/third_party
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-08-01 11:44:21 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2017-08-01 09:49:25 +0000
commit9a05d0e4db172168e429f30bc8ed62b695006490 (patch)
tree6a7a6b2f7e3410bb9ddc3ef9a200156f2bf623e1 /chromium/third_party
parent6ec7b8da05d21a3878bd21c691b41e675d74bb1c (diff)
downloadqtwebengine-chromium-9a05d0e4db172168e429f30bc8ed62b695006490.tar.gz
BASELINE: Update Chromium to 60.0.3112.78
Change-Id: I58f9d14bddb9104a666b6ef869944111ee7eadb8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party')
-rw-r--r--chromium/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h5
-rw-r--r--chromium/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp4
-rw-r--r--chromium/third_party/WebKit/Source/core/input/EventHandler.cpp71
-rw-r--r--chromium/third_party/WebKit/Source/core/input/EventHandler.h4
-rw-r--r--chromium/third_party/WebKit/Source/core/input/EventHandlerTest.cpp23
-rw-r--r--chromium/third_party/WebKit/Source/core/input/MouseEventManager.cpp10
-rw-r--r--chromium/third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp5
-rw-r--r--chromium/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp23
-rw-r--r--chromium/third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp2
-rw-r--r--chromium/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json54
-rw-r--r--chromium/third_party/WebKit/Source/platform/animation/TimingFunction.h5
-rw-r--r--chromium/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp5
-rw-r--r--chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp19
-rw-r--r--chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp34
-rw-r--r--chromium/third_party/afl/OWNERS4
-rw-r--r--chromium/third_party/afl/README.chromium22
-rw-r--r--chromium/third_party/afl/src/Makefile153
l---------chromium/third_party/afl/src/QuickStartGuide.txt1
l---------chromium/third_party/afl/src/README1
-rw-r--r--chromium/third_party/afl/src/afl-analyze.c1063
-rw-r--r--chromium/third_party/afl/src/afl-as.c544
-rw-r--r--chromium/third_party/afl/src/afl-as.h719
-rwxr-xr-xchromium/third_party/afl/src/afl-cmin447
-rw-r--r--chromium/third_party/afl/src/afl-fuzz.c8005
-rw-r--r--chromium/third_party/afl/src/afl-gcc.c336
-rw-r--r--chromium/third_party/afl/src/afl-gotcpu.c252
-rwxr-xr-xchromium/third_party/afl/src/afl-plot166
-rw-r--r--chromium/third_party/afl/src/afl-showmap.c763
-rw-r--r--chromium/third_party/afl/src/afl-tmin.c1141
-rwxr-xr-xchromium/third_party/afl/src/afl-whatsup163
-rw-r--r--chromium/third_party/afl/src/alloc-inl.h570
-rw-r--r--chromium/third_party/afl/src/config.h345
-rw-r--r--chromium/third_party/afl/src/debug.h251
-rw-r--r--chromium/third_party/afl/src/docs/COPYING202
-rw-r--r--chromium/third_party/afl/src/docs/ChangeLog2541
-rw-r--r--chromium/third_party/afl/src/docs/INSTALL183
-rw-r--r--chromium/third_party/afl/src/docs/QuickStartGuide.txt49
-rw-r--r--chromium/third_party/afl/src/docs/README507
-rw-r--r--chromium/third_party/afl/src/docs/env_variables.txt249
-rw-r--r--chromium/third_party/afl/src/docs/historical_notes.txt147
-rw-r--r--chromium/third_party/afl/src/docs/life_pro_tips.txt128
-rw-r--r--chromium/third_party/afl/src/docs/notes_for_asan.txt127
-rw-r--r--chromium/third_party/afl/src/docs/parallel_fuzzing.txt216
-rw-r--r--chromium/third_party/afl/src/docs/perf_tips.txt197
-rw-r--r--chromium/third_party/afl/src/docs/sister_projects.txt298
-rw-r--r--chromium/third_party/afl/src/docs/status_screen.txt400
-rw-r--r--chromium/third_party/afl/src/docs/technical_details.txt563
-rw-r--r--chromium/third_party/afl/src/docs/visualization/afl_gzip.pngbin594870 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/experimental/README.experiments38
-rwxr-xr-xchromium/third_party/afl/src/experimental/asan_cgroups/limit_memory.sh157
-rw-r--r--chromium/third_party/afl/src/experimental/bash_shellshock/shellshock-fuzz.diff59
-rw-r--r--chromium/third_party/afl/src/experimental/canvas_harness/canvas_harness.html170
-rwxr-xr-xchromium/third_party/afl/src/experimental/clang_asm_normalize/as75
-rwxr-xr-xchromium/third_party/afl/src/experimental/crash_triage/triage_crashes.sh89
-rwxr-xr-xchromium/third_party/afl/src/experimental/distributed_fuzzing/sync_script.sh89
-rw-r--r--chromium/third_party/afl/src/experimental/libpng_no_checksum/libpng-nocrc.patch15
-rw-r--r--chromium/third_party/afl/src/experimental/persistent_demo/persistent_demo.c89
-rw-r--r--chromium/third_party/afl/src/experimental/post_library/post_library.so.c119
-rw-r--r--chromium/third_party/afl/src/experimental/post_library/post_library_png.so.c113
-rw-r--r--chromium/third_party/afl/src/hash.h104
-rw-r--r--chromium/third_party/afl/src/libdislocator/Makefile38
-rw-r--r--chromium/third_party/afl/src/libdislocator/README.dislocator60
-rw-r--r--chromium/third_party/afl/src/libdislocator/libdislocator.so.c258
-rw-r--r--chromium/third_party/afl/src/libtokencap/Makefile38
-rw-r--r--chromium/third_party/afl/src/libtokencap/README.tokencap60
-rw-r--r--chromium/third_party/afl/src/libtokencap/libtokencap.so.c253
-rw-r--r--chromium/third_party/afl/src/llvm_mode/Makefile112
-rw-r--r--chromium/third_party/afl/src/llvm_mode/README.llvm188
-rw-r--r--chromium/third_party/afl/src/llvm_mode/afl-clang-fast.c354
-rw-r--r--chromium/third_party/afl/src/llvm_mode/afl-llvm-rt.o.c298
-rw-r--r--chromium/third_party/afl/src/qemu_mode/README.qemu125
-rwxr-xr-xchromium/third_party/afl/src/qemu_mode/build_qemu_support.sh196
-rw-r--r--chromium/third_party/afl/src/qemu_mode/patches/afl-qemu-cpu-inl.h294
-rw-r--r--chromium/third_party/afl/src/qemu_mode/patches/cpu-exec.diff33
-rw-r--r--chromium/third_party/afl/src/qemu_mode/patches/elfload.diff32
-rw-r--r--chromium/third_party/afl/src/qemu_mode/patches/syscall.diff25
-rw-r--r--chromium/third_party/afl/src/qemu_mode/patches/translate-all.diff18
-rw-r--r--chromium/third_party/afl/src/test-instr.c37
-rw-r--r--chromium/third_party/afl/src/testcases/README.testcases19
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/ar/small_archive.a8
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/bzip2/small_archive.bz2bin176 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/cab/small_archive.cabbin220 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/compress/small_archive.Zbin168 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/cpio/small_archive.cpiobin512 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/gzip/small_archive.gzbin159 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/lzo/small_archive.lzobin217 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/rar/small_archive.rarbin230 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/tar/small_archive.tarbin2048 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/xz/small_archive.xzbin228 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/common/zip/small_archive.zipbin289 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/arj/small_archive.arjbin269 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/lha/small_archive.lhabin182 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/lrzip/small_archive.lrzbin260 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/lzip/small_archive.lzbin195 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/lzma/small_archive.lzmabin182 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/rzip/small_archive.rzbin262 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/archives/exotic/zoo/small_archive.zoobin336 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/bmp/not_kitty.bmpbin630 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/gif/not_kitty.gifbin198 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/ico/not_kitty.icobin367 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/jp2/not_kitty.jp2bin293 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/jpeg/not_kitty.jpgbin413 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/jxr/not_kitty.jxrbin498 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/png/not_kitty.pngbin218 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/png/not_kitty_alpha.pngbin376 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/png/not_kitty_gamma.pngbin228 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/png/not_kitty_icc.pngbin427 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/tiff/not_kitty.tiffbin448 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/images/webp/not_kitty.webpbin226 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/multimedia/h264/small_movie.mp4bin1267 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/others/js/small_script.js1
-rw-r--r--chromium/third_party/afl/src/testcases/others/pcap/small_capture.pcapbin114 -> 0 bytes
-rw-r--r--chromium/third_party/afl/src/testcases/others/pdf/small.pdf2
-rw-r--r--chromium/third_party/afl/src/testcases/others/rtf/small_document.rtf1
-rw-r--r--chromium/third_party/afl/src/testcases/others/sql/simple_queries.sql3
-rw-r--r--chromium/third_party/afl/src/testcases/others/text/hello_world.txt1
-rw-r--r--chromium/third_party/afl/src/testcases/others/xml/small_document.xml1
-rw-r--r--chromium/third_party/afl/src/types.h82
-rwxr-xr-xchromium/third_party/afl/update.py181
-rw-r--r--chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_account_data.proto30
-rw-r--r--chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_info.proto68
-rw-r--r--chromium/third_party/cros_system_api/dbus/authpolicy/dbus-constants.h89
-rw-r--r--chromium/third_party/cros_system_api/dbus/biod/constants.proto21
-rw-r--r--chromium/third_party/cros_system_api/dbus/biod/dbus-constants.h52
-rw-r--r--chromium/third_party/cros_system_api/dbus/biod/messages.proto18
-rw-r--r--chromium/third_party/cros_system_api/dbus/chaps/OWNERS3
-rw-r--r--chromium/third_party/cros_system_api/dbus/chaps/ck_structs.proto75
-rw-r--r--chromium/third_party/cros_system_api/dbus/cros-disks/dbus-constants.h1
-rw-r--r--chromium/third_party/cros_system_api/dbus/cryptohome/dbus-constants.h19
-rw-r--r--chromium/third_party/cros_system_api/dbus/cryptohome/rpc.proto12
-rw-r--r--chromium/third_party/cros_system_api/dbus/debugd/dbus-constants.h15
-rw-r--r--chromium/third_party/cros_system_api/dbus/login_manager/arc.proto26
-rw-r--r--chromium/third_party/cros_system_api/dbus/login_manager/dbus-constants.h42
-rw-r--r--chromium/third_party/cros_system_api/dbus/power_manager/dbus-constants.h1
-rw-r--r--chromium/third_party/cros_system_api/dbus/power_manager/switch_states.proto28
-rw-r--r--chromium/third_party/cros_system_api/dbus/service_constants.h37
-rw-r--r--chromium/third_party/cros_system_api/dbus/shill/dbus-constants.h1
-rw-r--r--chromium/third_party/cros_system_api/dbus/update_engine/dbus-constants.h6
-rw-r--r--chromium/third_party/cros_system_api/system_api.gyp106
-rw-r--r--chromium/third_party/cros_system_api/system_api.pc2
-rw-r--r--[l---------]chromium/third_party/flatbuffers/src/docs/source/CONTRIBUTING.md43
-rw-r--r--chromium/third_party/fontconfig/src/INSTALL2
-rw-r--r--chromium/third_party/fontconfig/src/Makefile.am2
-rw-r--r--chromium/third_party/fontconfig/src/README275
-rwxr-xr-xchromium/third_party/fontconfig/src/autogen.sh40
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/10-hinting-full.conf13
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/10-hinting-medium.conf13
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/10-hinting-none.conf13
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/10-hinting-slight.conf13
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/10-no-sub-pixel.conf2
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/10-scale-bitmap-fonts.conf32
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/30-metric-aliases.conf189
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/30-urw-aliases.conf13
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/45-latin.conf150
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/60-latin.conf4
-rw-r--r--chromium/third_party/fontconfig/src/conf.d/Makefile.am5
-rw-r--r--chromium/third_party/fontconfig/src/config/Makedefs.in76
-rw-r--r--chromium/third_party/fontconfig/src/config/config-subst10
-rw-r--r--chromium/third_party/fontconfig/src/config/config.guess1497
-rw-r--r--chromium/third_party/fontconfig/src/config/config.sub1608
-rw-r--r--chromium/third_party/fontconfig/src/config/install.sh240
-rw-r--r--chromium/third_party/fontconfig/src/configure.ac144
-rw-r--r--chromium/third_party/fontconfig/src/doc/Makefile.am2
-rw-r--r--chromium/third_party/fontconfig/src/doc/fccache.fncs2
-rw-r--r--chromium/third_party/fontconfig/src/doc/fccharset.fncs1
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcconfig.fncs15
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcdircache.fncs11
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcformat.fncs1
-rw-r--r--chromium/third_party/fontconfig/src/doc/fclangset.fncs6
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcpattern.fncs27
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcrange.fncs75
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcstrset.fncs1
-rw-r--r--chromium/third_party/fontconfig/src/doc/fcweight.fncs47
-rw-r--r--chromium/third_party/fontconfig/src/doc/fontconfig-devel.sgml25
-rw-r--r--chromium/third_party/fontconfig/src/doc/fontconfig-user.sgml23
-rw-r--r--chromium/third_party/fontconfig/src/doc/func.sgml9
-rw-r--r--chromium/third_party/fontconfig/src/fc-blanks/Makefile.am46
-rwxr-xr-xchromium/third_party/fontconfig/src/fc-blanks/fc-blanks.py156
-rw-r--r--chromium/third_party/fontconfig/src/fc-blanks/fcblanks.tmpl.h25
-rw-r--r--chromium/third_party/fontconfig/src/fc-blanks/list-unicodeset.html119
-rw-r--r--chromium/third_party/fontconfig/src/fc-cache/fc-cache.c84
-rw-r--r--chromium/third_party/fontconfig/src/fc-cache/fc-cache.sgml33
-rw-r--r--chromium/third_party/fontconfig/src/fc-case/CaseFolding.txt285
-rw-r--r--chromium/third_party/fontconfig/src/fc-case/Makefile.am3
-rw-r--r--chromium/third_party/fontconfig/src/fc-cat/fc-cat.c18
-rw-r--r--chromium/third_party/fontconfig/src/fc-cat/fc-cat.sgml2
-rw-r--r--chromium/third_party/fontconfig/src/fc-glyphname/fc-glyphname.c2
-rw-r--r--chromium/third_party/fontconfig/src/fc-lang/README28
-rw-r--r--chromium/third_party/fontconfig/src/fc-lang/fc-lang.c2
-rw-r--r--chromium/third_party/fontconfig/src/fc-lang/ja.orth4234
-rw-r--r--chromium/third_party/fontconfig/src/fc-lang/ko.orth1
-rw-r--r--chromium/third_party/fontconfig/src/fc-lang/zh_hk.orth2249
-rw-r--r--chromium/third_party/fontconfig/src/fc-query/fc-query.c28
-rw-r--r--chromium/third_party/fontconfig/src/fc-query/fc-query.sgml12
-rw-r--r--chromium/third_party/fontconfig/src/fc-scan/fc-scan.c28
-rw-r--r--chromium/third_party/fontconfig/src/fc-scan/fc-scan.sgml14
-rw-r--r--chromium/third_party/fontconfig/src/fontconfig.pc.in2
-rw-r--r--chromium/third_party/fontconfig/src/fontconfig/fcprivate.h3
-rw-r--r--chromium/third_party/fontconfig/src/fontconfig/fontconfig.h60
-rw-r--r--chromium/third_party/fontconfig/src/fonts.conf.in66
-rw-r--r--chromium/third_party/fontconfig/src/fonts.dtd2
-rw-r--r--chromium/third_party/fontconfig/src/m4/ac_check_symbol.m448
-rw-r--r--chromium/third_party/fontconfig/src/m4/ax_pthread.m476
-rw-r--r--chromium/third_party/fontconfig/src/m4/pkg.m4214
-rw-r--r--chromium/third_party/fontconfig/src/new-version.sh21
-rw-r--r--chromium/third_party/fontconfig/src/src/Makefile.am3
-rw-r--r--chromium/third_party/fontconfig/src/src/fcarch.c5
-rw-r--r--chromium/third_party/fontconfig/src/src/fcatomic.c2
-rw-r--r--chromium/third_party/fontconfig/src/src/fcatomic.h18
-rw-r--r--chromium/third_party/fontconfig/src/src/fcblanks.c27
-rw-r--r--chromium/third_party/fontconfig/src/src/fccache.c282
-rw-r--r--chromium/third_party/fontconfig/src/src/fccfg.c128
-rw-r--r--chromium/third_party/fontconfig/src/src/fccharset.c262
-rw-r--r--chromium/third_party/fontconfig/src/src/fccompat.c39
-rw-r--r--chromium/third_party/fontconfig/src/src/fcdbg.c85
-rw-r--r--chromium/third_party/fontconfig/src/src/fcdefault.c55
-rw-r--r--chromium/third_party/fontconfig/src/src/fcdir.c167
-rw-r--r--chromium/third_party/fontconfig/src/src/fcfreetype.c877
-rw-r--r--chromium/third_party/fontconfig/src/src/fcfs.c22
-rw-r--r--chromium/third_party/fontconfig/src/src/fchash.c317
-rw-r--r--chromium/third_party/fontconfig/src/src/fcinit.c56
-rw-r--r--chromium/third_party/fontconfig/src/src/fcint.h122
-rw-r--r--chromium/third_party/fontconfig/src/src/fclang.c27
-rw-r--r--chromium/third_party/fontconfig/src/src/fclist.c4
-rw-r--r--chromium/third_party/fontconfig/src/src/fcmatch.c155
-rw-r--r--chromium/third_party/fontconfig/src/src/fcname.c45
-rw-r--r--chromium/third_party/fontconfig/src/src/fcobjs.c31
-rw-r--r--chromium/third_party/fontconfig/src/src/fcobjs.h31
-rw-r--r--chromium/third_party/fontconfig/src/src/fcobjshash.gperf.h23
-rw-r--r--chromium/third_party/fontconfig/src/src/fcpat.c81
-rw-r--r--chromium/third_party/fontconfig/src/src/fcrange.c161
-rw-r--r--chromium/third_party/fontconfig/src/src/fcstat.c101
-rw-r--r--chromium/third_party/fontconfig/src/src/fcstr.c105
-rw-r--r--chromium/third_party/fontconfig/src/src/fcweight.c109
-rw-r--r--chromium/third_party/fontconfig/src/src/fcwindows.h7
-rw-r--r--chromium/third_party/fontconfig/src/src/fcxml.c254
-rw-r--r--chromium/third_party/gestures/gestures/include/finger_metrics.h2
-rw-r--r--chromium/third_party/gestures/gestures/include/immediate_interpreter.h16
-rw-r--r--chromium/third_party/gestures/gestures/include/metrics_filter_interpreter.h4
-rw-r--r--chromium/third_party/gestures/gestures/src/immediate_interpreter.cc157
-rw-r--r--chromium/third_party/gestures/gestures/src/immediate_interpreter_unittest.cc43
-rw-r--r--chromium/third_party/libaddressinput/chromium/resources/address_input_strings_tr.xtb2
-rw-r--r--chromium/third_party/libdrm/src/Android.mk21
-rw-r--r--chromium/third_party/libdrm/src/CleanSpec.mk1
-rw-r--r--chromium/third_party/libdrm/src/Makefile.am18
-rw-r--r--chromium/third_party/libdrm/src/Makefile.sources6
-rw-r--r--chromium/third_party/libdrm/src/PRESUBMIT.cfg3
-rw-r--r--chromium/third_party/libdrm/src/amdgpu/Android.mk2
-rwxr-xr-xchromium/third_party/libdrm/src/amdgpu/amdgpu-symbol-check4
-rw-r--r--chromium/third_party/libdrm/src/amdgpu/amdgpu.h69
-rw-r--r--chromium/third_party/libdrm/src/amdgpu/amdgpu_bo.c14
-rw-r--r--chromium/third_party/libdrm/src/amdgpu/amdgpu_cs.c181
-rw-r--r--chromium/third_party/libdrm/src/amdgpu/amdgpu_internal.h16
-rw-r--r--chromium/third_party/libdrm/src/amdgpu/libdrm_amdgpu.pc.in1
-rw-r--r--chromium/third_party/libdrm/src/configure.ac91
-rwxr-xr-xchromium/third_party/libdrm/src/exynos/exynos-symbol-check3
-rw-r--r--chromium/third_party/libdrm/src/exynos/exynos_drm.c78
-rw-r--r--chromium/third_party/libdrm/src/exynos/exynos_drm.h12
-rw-r--r--chromium/third_party/libdrm/src/exynos/exynos_drmif.h26
-rw-r--r--chromium/third_party/libdrm/src/exynos/exynos_fimg2d.c174
-rw-r--r--chromium/third_party/libdrm/src/exynos/exynos_fimg2d.h4
-rw-r--r--chromium/third_party/libdrm/src/exynos/libdrm_exynos.pc.in2
-rw-r--r--chromium/third_party/libdrm/src/freedreno/Android.mk2
-rw-r--r--chromium/third_party/libdrm/src/freedreno/Makefile.am2
-rw-r--r--chromium/third_party/libdrm/src/freedreno/Makefile.sources1
-rw-r--r--chromium/third_party/libdrm/src/freedreno/README (renamed from chromium/third_party/libdrm/src/freedreno/kgsl/README)10
-rwxr-xr-xchromium/third_party/libdrm/src/freedreno/freedreno-symbol-check4
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_bo.c148
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_bo_cache.c222
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_device.c62
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_drmif.h16
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_priv.h38
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.c51
-rw-r--r--chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.h16
-rw-r--r--chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_bo.c6
-rw-r--r--chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_drm.h2
-rw-r--r--chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_pipe.c4
-rw-r--r--chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_ringbuffer.c13
-rw-r--r--chromium/third_party/libdrm/src/freedreno/kgsl/msm_kgsl.h4
-rw-r--r--chromium/third_party/libdrm/src/freedreno/msm/msm_bo.c20
-rw-r--r--chromium/third_party/libdrm/src/freedreno/msm/msm_device.c3
-rw-r--r--chromium/third_party/libdrm/src/freedreno/msm/msm_drm.h111
-rw-r--r--chromium/third_party/libdrm/src/freedreno/msm/msm_pipe.c47
-rw-r--r--chromium/third_party/libdrm/src/freedreno/msm/msm_priv.h17
-rw-r--r--chromium/third_party/libdrm/src/freedreno/msm/msm_ringbuffer.c411
-rw-r--r--chromium/third_party/libdrm/src/include/drm/drm.h69
-rw-r--r--chromium/third_party/libdrm/src/include/drm/drm_fourcc.h36
-rw-r--r--chromium/third_party/libdrm/src/include/drm/drm_mode.h197
-rw-r--r--chromium/third_party/libdrm/src/include/drm/drm_sarea.h2
-rw-r--r--chromium/third_party/libdrm/src/include/drm/evdi_drm.h85
-rw-r--r--chromium/third_party/libdrm/src/include/drm/i915_drm.h102
-rw-r--r--chromium/third_party/libdrm/src/include/drm/nouveau_drm.h1
-rw-r--r--chromium/third_party/libdrm/src/include/drm/tegra_drm.h3
-rw-r--r--chromium/third_party/libdrm/src/include/drm/vc4_drm.h300
-rw-r--r--chromium/third_party/libdrm/src/include/drm/vgem_drm.h33
-rw-r--r--chromium/third_party/libdrm/src/include/drm/virtgpu_drm.h109
-rw-r--r--chromium/third_party/libdrm/src/include/drm/vmwgfx_drm.h792
-rw-r--r--chromium/third_party/libdrm/src/intel/Android.mk2
-rw-r--r--chromium/third_party/libdrm/src/intel/Makefile.am1
-rwxr-xr-xchromium/third_party/libdrm/src/intel/intel-symbol-check2
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_bufmgr.c20
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_bufmgr.h2
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_bufmgr_fake.c3
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_bufmgr_gem.c252
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_bufmgr_priv.h21
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_chipset.h83
-rw-r--r--chromium/third_party/libdrm/src/intel/intel_decode.c4
-rw-r--r--chromium/third_party/libdrm/src/libkms/Android.mk8
-rw-r--r--chromium/third_party/libdrm/src/libkms/Makefile.am7
-rw-r--r--chromium/third_party/libdrm/src/libkms/Makefile.sources3
-rw-r--r--chromium/third_party/libdrm/src/libkms/internal.h2
-rw-r--r--chromium/third_party/libdrm/src/libkms/libkms.pc.in1
-rw-r--r--chromium/third_party/libdrm/src/libkms/linux.c10
-rw-r--r--chromium/third_party/libdrm/src/libkms/mediatek.c222
-rw-r--r--chromium/third_party/libdrm/src/man/drm-kms.xml2
-rw-r--r--chromium/third_party/libdrm/src/mediatek/Android.mk31
-rw-r--r--chromium/third_party/libdrm/src/mediatek/Makefile.am20
-rw-r--r--chromium/third_party/libdrm/src/mediatek/libdrm_mediatek.pc.in11
-rw-r--r--chromium/third_party/libdrm/src/mediatek/mediatek_drm.c299
-rw-r--r--chromium/third_party/libdrm/src/mediatek/mediatek_drm.h59
-rw-r--r--chromium/third_party/libdrm/src/mediatek/mediatek_drmif.h79
-rw-r--r--chromium/third_party/libdrm/src/nouveau/Android.mk2
-rw-r--r--chromium/third_party/libdrm/src/nouveau/Makefile.am13
-rw-r--r--chromium/third_party/libdrm/src/nouveau/abi16.c162
-rw-r--r--chromium/third_party/libdrm/src/nouveau/libdrm_nouveau.pc.in2
-rwxr-xr-xchromium/third_party/libdrm/src/nouveau/nouveau-symbol-check8
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nouveau.c574
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nouveau.h210
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/cl0080.h45
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/cl9097.h44
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/class.h141
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/if0002.h38
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/if0003.h33
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/ioctl.h132
-rw-r--r--chromium/third_party/libdrm/src/nouveau/nvif/unpack.h28
-rw-r--r--chromium/third_party/libdrm/src/nouveau/private.h8
-rw-r--r--chromium/third_party/libdrm/src/nouveau/pushbuf.c7
-rw-r--r--chromium/third_party/libdrm/src/radeon/Android.mk2
-rw-r--r--chromium/third_party/libdrm/src/radeon/Makefile.am3
-rw-r--r--chromium/third_party/libdrm/src/radeon/libdrm_radeon.pc.in1
-rw-r--r--chromium/third_party/libdrm/src/radeon/radeon_bo_gem.c2
-rw-r--r--chromium/third_party/libdrm/src/radeon/radeon_cs_gem.c2
-rw-r--r--chromium/third_party/libdrm/src/radeon/radeon_surface.c6
-rw-r--r--chromium/third_party/libdrm/src/rockchip/Android.mk27
-rw-r--r--chromium/third_party/libdrm/src/rockchip/Makefile.am20
-rw-r--r--chromium/third_party/libdrm/src/rockchip/libdrm_rockchip.pc.in11
-rw-r--r--chromium/third_party/libdrm/src/rockchip/rockchip_drm.c299
-rw-r--r--chromium/third_party/libdrm/src/rockchip/rockchip_drm.h73
-rw-r--r--chromium/third_party/libdrm/src/rockchip/rockchip_drmif.h77
-rw-r--r--chromium/third_party/libdrm/src/util_double_list.h8
-rw-r--r--chromium/third_party/libdrm/src/vc4/Makefile.am34
-rw-r--r--chromium/third_party/libdrm/src/vc4/Makefile.sources3
-rw-r--r--chromium/third_party/libdrm/src/vc4/libdrm_vc4.pc.in9
-rw-r--r--chromium/third_party/libdrm/src/vc4/vc4_packet.h397
-rw-r--r--chromium/third_party/libdrm/src/vc4/vc4_qpu_defines.h274
-rw-r--r--chromium/third_party/libdrm/src/xf86drm.c1486
-rw-r--r--chromium/third_party/libdrm/src/xf86drmMode.c83
-rw-r--r--chromium/third_party/libdrm/src/xf86drmMode.h11
-rw-r--r--[l---------]chromium/third_party/libxslt/linux/COPYING54
l---------chromium/third_party/mesa/src/src/gallium/state_trackers/d3d1x/w32api1
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_context.c267
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_drawable.c403
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_screen.c421
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_context.c267
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_drawable.c403
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_screen.c421
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_batchbuffer.c544
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_blit.c605
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffer_objects.c850
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffers.c133
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_context.c1031
-rwxr-xr-x[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_extensions.c198
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_fbo.c965
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_mipmap_tree.c1712
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel.c168
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c341
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_copy.c231
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_draw.c59
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_read.c206
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_regions.c474
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_resolve_map.c112
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_screen.c1205
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_span.c216
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_state.c196
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_syncobj.c133
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex.c223
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_copy.c172
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_format.c66
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_image.c361
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_layout.c207
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_subimage.c178
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_validate.c219
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_batchbuffer.c544
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_blit.c605
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffer_objects.c850
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffers.c133
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_context.c1031
-rwxr-xr-x[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_extensions.c198
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_fbo.c965
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_mipmap_tree.c1712
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel.c168
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c341
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_copy.c231
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_draw.c59
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_read.c206
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_regions.c474
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_resolve_map.c112
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_screen.c1205
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_span.c216
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_state.c196
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_syncobj.c133
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex.c223
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_copy.c172
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_format.c66
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_image.c361
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_layout.c207
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_subimage.c178
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_validate.c219
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.c234
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.h53
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_chipset.h42
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_cmdbuf.h114
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.c792
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.h89
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.c634
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.h531
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.c109
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.h175
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.c512
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.h61
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fbo.c981
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.c126
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.h45
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.c611
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.h107
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_pixel_read.c222
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.c218
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.h56
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.c797
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.h123
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.c162
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.h48
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tex_copy.c161
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.c834
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.h92
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.c513
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.h39
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_dri.h116
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_macros.h129
-rw-r--r--[l---------]chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_reg.h2164
-rw-r--r--chromium/third_party/minigbm/src/Makefile7
-rw-r--r--chromium/third_party/minigbm/src/amdgpu.c48
-rw-r--r--chromium/third_party/minigbm/src/cirrus.c19
-rw-r--r--chromium/third_party/minigbm/src/common.mk2
-rw-r--r--chromium/third_party/minigbm/src/cros_gralloc/cros_alloc_device.cc8
-rw-r--r--chromium/third_party/minigbm/src/drv.c87
-rw-r--r--chromium/third_party/minigbm/src/drv.h8
-rw-r--r--chromium/third_party/minigbm/src/drv_priv.h12
-rw-r--r--chromium/third_party/minigbm/src/evdi.c13
-rw-r--r--chromium/third_party/minigbm/src/exynos.c19
-rw-r--r--chromium/third_party/minigbm/src/gbm.c28
-rw-r--r--chromium/third_party/minigbm/src/gbm.h7
-rw-r--r--chromium/third_party/minigbm/src/gbm_helpers.c2
-rw-r--r--chromium/third_party/minigbm/src/gbm_helpers.h2
-rw-r--r--chromium/third_party/minigbm/src/gbm_priv.h2
-rw-r--r--chromium/third_party/minigbm/src/gma500.c10
-rw-r--r--chromium/third_party/minigbm/src/helpers.c42
-rw-r--r--chromium/third_party/minigbm/src/helpers.h3
-rw-r--r--chromium/third_party/minigbm/src/i915.c288
-rw-r--r--chromium/third_party/minigbm/src/marvell.c13
-rw-r--r--chromium/third_party/minigbm/src/mediatek.c20
-rw-r--r--chromium/third_party/minigbm/src/nouveau.c30
-rw-r--r--chromium/third_party/minigbm/src/rockchip.c98
-rw-r--r--chromium/third_party/minigbm/src/tegra.c118
-rw-r--r--chromium/third_party/minigbm/src/udl.c15
-rw-r--r--chromium/third_party/minigbm/src/util.h2
-rw-r--r--chromium/third_party/minigbm/src/vc4.c93
-rw-r--r--chromium/third_party/minigbm/src/vgem.c14
-rw-r--r--chromium/third_party/minigbm/src/virtio_gpu.c13
-rw-r--r--chromium/third_party/pyelftools/.hgignore12
-rw-r--r--chromium/third_party/pyelftools/.travis.yml8
-rw-r--r--chromium/third_party/pyelftools/CHANGES24
-rw-r--r--chromium/third_party/pyelftools/MANIFEST.in7
-rw-r--r--chromium/third_party/pyelftools/README43
-rw-r--r--chromium/third_party/pyelftools/README.rst57
-rw-r--r--chromium/third_party/pyelftools/TODO16
-rw-r--r--chromium/third_party/pyelftools/elftools/__init__.py10
-rw-r--r--chromium/third_party/pyelftools/elftools/common/ordereddict.py12
-rw-r--r--chromium/third_party/pyelftools/elftools/common/utils.py15
-rw-r--r--chromium/third_party/pyelftools/elftools/construct/README10
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/callframe.py33
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/compileunit.py69
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/descriptions.py39
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/die.py99
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/dwarfinfo.py62
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/enums.py60
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/lineprogram.py4
-rw-r--r--chromium/third_party/pyelftools/elftools/dwarf/structs.py102
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/constants.py42
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/descriptions.py92
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/dynamic.py125
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/elffile.py135
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/enums.py391
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/gnuversions.py228
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/relocation.py25
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/sections.py54
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/segments.py12
-rw-r--r--chromium/third_party/pyelftools/elftools/elf/structs.py75
-rw-r--r--chromium/third_party/pyelftools/examples/dwarf_decode_address.py29
-rw-r--r--chromium/third_party/pyelftools/examples/dwarf_die_tree.py23
-rw-r--r--chromium/third_party/pyelftools/examples/dwarf_location_lists.py12
-rw-r--r--chromium/third_party/pyelftools/examples/dwarf_range_lists.py14
-rw-r--r--chromium/third_party/pyelftools/examples/elf_low_high_api.py9
-rw-r--r--chromium/third_party/pyelftools/examples/elf_relocations.py10
-rw-r--r--chromium/third_party/pyelftools/examples/elf_show_debug_sections.py9
-rw-r--r--chromium/third_party/pyelftools/examples/elfclass_address_size.py9
-rw-r--r--chromium/third_party/pyelftools/examples/examine_dwarf_info.py21
-rw-r--r--chromium/third_party/pyelftools/examples/reference_output/dwarf_decode_address.out2
-rw-r--r--chromium/third_party/pyelftools/examples/reference_output/dwarf_die_tree.out8
-rw-r--r--chromium/third_party/pyelftools/examples/reference_output/examine_dwarf_info.out8
-rw-r--r--chromium/third_party/pyelftools/pyelftools.sublime-project9
-rwxr-xr-xchromium/third_party/pyelftools/scripts/readelf.py463
-rw-r--r--chromium/third_party/pyelftools/setup.py8
-rw-r--r--chromium/third_party/pyelftools/tox.ini3
-rw-r--r--chromium/third_party/pyelftools/z.py7
-rw-r--r--chromium/third_party/skia/src/core/SkPathRef.cpp5
l---------chromium/third_party/skia/tools/gyp1
-rw-r--r--chromium/third_party/sqlite/amalgamation/sqlite3.c79
-rw-r--r--chromium/third_party/sqlite/amalgamation/sqlite3.h29
-rw-r--r--chromium/third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch420
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3.c13
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/carray.c46
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/remember.c6
-rw-r--r--chromium/third_party/sqlite/src/src/sqlite.h.in29
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeInt.h2
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeapi.c24
-rw-r--r--chromium/third_party/sqlite/src/src/vdbemem.c11
-rw-r--r--[l---------]chromium/third_party/swiftshader/third_party/subzero/DESIGN.rst1594
-rw-r--r--[l---------]chromium/third_party/swiftshader/third_party/subzero/README.rst214
-rw-r--r--chromium/third_party/wayland-protocols/src/configure.ac1
-rw-r--r--chromium/third_party/wayland-protocols/src/stable/presentation-time/presentation-time.xml5
-rw-r--r--chromium/third_party/wayland-protocols/src/stable/viewporter/viewporter.xml3
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml4
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/input-method/input-method-unstable-v1.xml49
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml10
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml5
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml2
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v1.xml1
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v2.xml1
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml80
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml4
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v5.xml2
-rw-r--r--chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml14
-rw-r--r--chromium/third_party/wayland-protocols/src/wayland-protocols-uninstalled.pc.in5
-rw-r--r--chromium/third_party/wayland/src/Makefile.am38
-rw-r--r--chromium/third_party/wayland/src/cursor/os-compatibility.c2
-rw-r--r--chromium/third_party/wayland/src/doc/doxygen/Makefile.am1
-rw-r--r--chromium/third_party/wayland/src/doc/doxygen/wayland.doxygen.in3
-rw-r--r--chromium/third_party/wayland/src/doc/publican/sources/Client.xml2
-rw-r--r--chromium/third_party/wayland/src/protocol/wayland.xml108
-rw-r--r--chromium/third_party/wayland/src/src/wayland-client-uninstalled.pc.in3
-rw-r--r--chromium/third_party/wayland/src/src/wayland-client.c2
-rw-r--r--chromium/third_party/wayland/src/src/wayland-scanner-uninstalled.pc.in2
-rw-r--r--chromium/third_party/wayland/src/src/wayland-server-uninstalled.pc.in3
-rw-r--r--chromium/third_party/wayland/src/src/wayland-util.h143
-rw-r--r--chromium/third_party/wds/src/desktop_source/mirac_broker_source.cpp4
-rw-r--r--chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.cc17
-rw-r--r--chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_context.cc3
-rw-r--r--chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h5
-rw-r--r--chromium/third_party/xdg-utils/codereview.settings9
570 files changed, 45357 insertions, 46765 deletions
diff --git a/chromium/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h b/chromium/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h
index 155dbe0c7c5..818d78cdd58 100644
--- a/chromium/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h
+++ b/chromium/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h
@@ -27,6 +27,7 @@
#define CSSTimingFunctionValue_h
#include "core/css/CSSValue.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/animation/TimingFunction.h"
#include "platform/wtf/PassRefPtr.h"
@@ -124,7 +125,9 @@ class CSSFramesTimingFunctionValue : public CSSValue {
private:
CSSFramesTimingFunctionValue(int frames)
- : CSSValue(kFramesTimingFunctionClass), frames_(frames) {}
+ : CSSValue(kFramesTimingFunctionClass), frames_(frames) {
+ DCHECK(RuntimeEnabledFeatures::framesTimingFunctionEnabled());
+ }
int frames_;
};
diff --git a/chromium/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/chromium/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index 0388e82893c..67a0770365c 100644
--- a/chromium/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/chromium/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -451,8 +451,10 @@ static CSSValue* ConsumeAnimationTimingFunction(CSSParserTokenRange& range) {
CSSValueID function = range.Peek().FunctionId();
if (function == CSSValueSteps)
return ConsumeSteps(range);
- if (function == CSSValueFrames)
+ if (RuntimeEnabledFeatures::framesTimingFunctionEnabled() &&
+ function == CSSValueFrames) {
return ConsumeFrames(range);
+ }
if (function == CSSValueCubicBezier)
return ConsumeCubicBezier(range);
return nullptr;
diff --git a/chromium/third_party/WebKit/Source/core/input/EventHandler.cpp b/chromium/third_party/WebKit/Source/core/input/EventHandler.cpp
index 85aa0c06f3c..ab3d3ac5d45 100644
--- a/chromium/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/chromium/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -118,26 +118,6 @@ bool ShouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) {
isHTMLInputElement(ToShadowRoot(target_node)->host());
}
-bool ShouldShowIBeamForNode(const Node* node, const HitTestResult& result) {
- if (!node)
- return false;
-
- bool layout_object_selectable = false;
- if (LayoutObject* layout_object = node->GetLayoutObject()) {
- PaintLayer* layer = layout_object->EnclosingLayer();
- if (layer->GetScrollableArea() &&
- layer->GetScrollableArea()->IsPointInResizeControl(
- result.RoundedPointInMainFrame(), kResizerForPointer)) {
- return false;
- }
-
- layout_object_selectable =
- layout_object->IsText() && node->CanStartSelection();
- }
-
- return HasEditableStyle(*node) || layout_object_selectable;
-}
-
} // namespace
using namespace HTMLNames;
@@ -407,6 +387,39 @@ void EventHandler::UpdateCursor() {
}
}
+bool EventHandler::ShouldShowIBeamForNode(const Node* node,
+ const HitTestResult& result) {
+ if (!node)
+ return false;
+
+ if (LayoutObject* layout_object = node->GetLayoutObject()) {
+ PaintLayer* layer = layout_object->EnclosingLayer();
+ if (layer->GetScrollableArea() &&
+ layer->GetScrollableArea()->IsPointInResizeControl(
+ result.RoundedPointInMainFrame(), kResizerForPointer)) {
+ return false;
+ }
+
+ if (layout_object->IsText() && node->CanStartSelection())
+ return true;
+ }
+
+ // If a drag may be starting or we're capturing mouse events for a particular
+ // node, don't treat this as a selection. Note calling
+ // ComputeVisibleSelectionInDOMTreeDeprecated may update layout.
+ const bool mouse_selection =
+ !capturing_mouse_events_node_ &&
+ mouse_event_manager_->MousePressed() &&
+ GetSelectionController().MouseDownMayStartSelect() &&
+ !mouse_event_manager_->MouseDownMayStartDrag() &&
+ !frame_->Selection()
+ .ComputeVisibleSelectionInDOMTreeDeprecated()
+ .IsNone();
+ const bool mouse_selects_link = mouse_selection && result.IsOverLink();
+
+ return mouse_selects_link || HasEditableStyle(*node);
+}
+
OptionalCursor EventHandler::SelectCursor(const HitTestResult& result) {
if (scroll_manager_->InResizeMode())
return kNoCursorChange;
@@ -553,9 +566,8 @@ OptionalCursor EventHandler::SelectCursor(const HitTestResult& result) {
OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result,
Node* node,
const Cursor& i_beam) {
- if (result.GetScrollbar()) {
+ if (result.GetScrollbar())
return PointerCursor();
- }
const bool is_over_link =
!GetSelectionController().MouseDownMayStartSelect() &&
@@ -563,22 +575,9 @@ OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result,
if (UseHandCursor(node, is_over_link))
return HandCursor();
- // During selection, use an I-beam no matter what we're over.
- // If a drag may be starting or we're capturing mouse events for a particular
- // node, don't treat this as a selection. Note calling
- // ComputeVisibleSelectionInDOMTreeDeprecated may update layout.
- if (mouse_event_manager_->MousePressed() &&
- GetSelectionController().MouseDownMayStartSelect() &&
- !mouse_event_manager_->MouseDownMayStartDrag() &&
- !frame_->Selection()
- .ComputeVisibleSelectionInDOMTreeDeprecated()
- .IsNone() &&
- !capturing_mouse_events_node_) {
- return i_beam;
- }
-
if (ShouldShowIBeamForNode(node, result))
return i_beam;
+
return PointerCursor();
}
diff --git a/chromium/third_party/WebKit/Source/core/input/EventHandler.h b/chromium/third_party/WebKit/Source/core/input/EventHandler.h
index a2125c28963..5b2f5dad51f 100644
--- a/chromium/third_party/WebKit/Source/core/input/EventHandler.h
+++ b/chromium/third_party/WebKit/Source/core/input/EventHandler.h
@@ -278,6 +278,7 @@ class CORE_EXPORT EventHandler final
bool ShouldApplyTouchAdjustment(const WebGestureEvent&) const;
+ bool ShouldShowIBeamForNode(const Node*, const HitTestResult&);
OptionalCursor SelectCursor(const HitTestResult&);
OptionalCursor SelectAutoCursor(const HitTestResult&,
Node*,
@@ -384,6 +385,9 @@ class CORE_EXPORT EventHandler final
// triggering |touchstart| event was canceled. This suppresses mouse event
// firing for the current gesture sequence (i.e. until next GestureTapDown).
bool suppress_mouse_events_from_gestures_;
+
+ FRIEND_TEST_ALL_PREFIXES(EventHandlerTest, HitOnNothingDoesNotShowIBeam);
+ FRIEND_TEST_ALL_PREFIXES(EventHandlerTest, HitOnTextShowsIBeam);
};
} // namespace blink
diff --git a/chromium/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/chromium/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
index 641ba710be2..19bb57aa884 100644
--- a/chromium/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
+++ b/chromium/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
@@ -13,6 +13,7 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/layout/LayoutObject.h"
#include "core/loader/EmptyClients.h"
#include "core/page/AutoscrollController.h"
#include "core/page/Page.h"
@@ -318,6 +319,28 @@ TEST_F(EventHandlerTest, draggedSVGImagePositionTest) {
.DragDataTransferLocationForTesting());
}
+TEST_F(EventHandlerTest, HitOnNothingDoesNotShowIBeam) {
+ SetHtmlInnerHTML("");
+ HitTestResult hit =
+ GetDocument().GetFrame()->GetEventHandler().HitTestResultAtPoint(
+ LayoutPoint(10, 10));
+ EXPECT_FALSE(
+ GetDocument().GetFrame()->GetEventHandler().ShouldShowIBeamForNode(
+ GetDocument().body(), hit));
+}
+
+TEST_F(EventHandlerTest, HitOnTextShowsIBeam) {
+ SetHtmlInnerHTML("blabla");
+ Node* text = GetDocument().body()->firstChild();
+ LayoutPoint location = text->GetLayoutObject()->VisualRect().Center();
+ HitTestResult hit =
+ GetDocument().GetFrame()->GetEventHandler().HitTestResultAtPoint(
+ location);
+ EXPECT_TRUE(
+ GetDocument().GetFrame()->GetEventHandler().ShouldShowIBeamForNode(text,
+ hit));
+}
+
// Regression test for http://crbug.com/641403 to verify we use up-to-date
// layout tree for dispatching "contextmenu" event.
TEST_F(EventHandlerTest, sendContextMenuEventWithHover) {
diff --git a/chromium/third_party/WebKit/Source/core/input/MouseEventManager.cpp b/chromium/third_party/WebKit/Source/core/input/MouseEventManager.cpp
index f6f20ea6985..2c7d191af92 100644
--- a/chromium/third_party/WebKit/Source/core/input/MouseEventManager.cpp
+++ b/chromium/third_party/WebKit/Source/core/input/MouseEventManager.cpp
@@ -755,12 +755,12 @@ WebInputEventResult MouseEventManager::HandleMouseDraggedEvent(
if (!mouse_pressed_)
return WebInputEventResult::kNotHandled;
- if (event.Event().pointer_type ==
- blink::WebPointerProperties::PointerType::kPen)
- return WebInputEventResult::kNotHandled;
-
- if (HandleDrag(event, DragInitiator::kMouse))
+ // We disable the drag and drop actions on pen input.
+ if (event.Event().pointer_type !=
+ blink::WebPointerProperties::PointerType::kPen &&
+ HandleDrag(event, DragInitiator::kMouse)) {
return WebInputEventResult::kHandledSystem;
+ }
Node* target_node = event.InnerNode();
if (!target_node)
diff --git a/chromium/third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp b/chromium/third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp
index 30520dedadf..3cfa7d86c17 100644
--- a/chromium/third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp
+++ b/chromium/third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp
@@ -194,8 +194,11 @@ static CompositingReasons SubtreeReasonsForCompositing(
// We ignore LCD text here because we are required to composite
// scroll-dependant fixed position elements with composited descendants for
// correctness - even if we lose LCD.
+ //
+ // TODO(smcgruer): Only composite fixed if needed (http://crbug.com/742213)
const bool ignore_lcd_text = true;
- if (compositing_reason_finder.RequiresCompositingForScrollDependentPosition(
+ if (layer->GetLayoutObject().Style()->GetPosition() == EPosition::kFixed ||
+ compositing_reason_finder.RequiresCompositingForScrollDependentPosition(
layer, ignore_lcd_text)) {
subtree_reasons |=
kCompositingReasonPositionFixedOrStickyWithCompositedDescendants;
diff --git a/chromium/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp b/chromium/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp
index f1a2d5ce2ce..8a5bf7753d2 100644
--- a/chromium/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp
+++ b/chromium/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp
@@ -20,7 +20,7 @@
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * OF LIABILITY, WHETHER IN CONTRACTg, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
@@ -180,12 +180,6 @@ bool MediaControlsPainter::PaintMediaOverlayPlayButton(
if (!HasSource(media_element) || !media_element->paused())
return false;
- // TODO(mlamouri): it might be possible to use the PanelLayoutObject() call
- // instead.
- HTMLDivElement* panel_element = nullptr;
- if (media_element->GetMediaControls())
- panel_element = media_element->GetMediaControls()->PanelElement();
-
static Image* media_overlay_play = PlatformResource("mediaplayerOverlayPlay");
IntRect button_rect(rect);
@@ -197,7 +191,20 @@ bool MediaControlsPainter::PaintMediaOverlayPlayButton(
if (!box)
return false;
int media_height = box->PixelSnappedHeight();
- int media_panel_height = panel_element ? panel_element->clientHeight() : 0;
+
+ int media_panel_height = 0;
+ if (media_element->GetMediaControls()) {
+ if (LayoutObject* object =
+ media_element->GetMediaControls()->PanelLayoutObject()) {
+ if (object->IsBox()) {
+ media_panel_height =
+ AdjustLayoutUnitForAbsoluteZoom(ToLayoutBox(object)->ClientHeight(),
+ *ToLayoutBox(object))
+ .Round();
+ }
+ }
+ }
+
button_rect.SetX(rect.Center().X() - kMediaOverlayPlayButtonWidth / 2);
button_rect.SetY(rect.Center().Y() - kMediaOverlayPlayButtonHeight / 2 +
(media_height - rect.Height() - media_panel_height) / 2);
diff --git a/chromium/third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp b/chromium/third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp
index 798060b2bc9..cdfaaef1a50 100644
--- a/chromium/third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp
+++ b/chromium/third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp
@@ -81,6 +81,8 @@ void WorkerScriptLoader::LoadSynchronously(
ResourceLoaderOptions resource_loader_options;
resource_loader_options.allow_credentials = kAllowStoredCredentials;
+ resource_loader_options.parser_disposition =
+ ParserDisposition::kNotParserInserted;
WorkerThreadableLoader::LoadResourceSynchronously(
ToWorkerGlobalScope(execution_context), request, *this, options,
diff --git a/chromium/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5 b/chromium/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5
index 9a36bd76bc0..0a5a50935f6 100644
--- a/chromium/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5
+++ b/chromium/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5
@@ -454,6 +454,10 @@
status: "experimental",
},
{
+ name: "FramesTimingFunction",
+ status: "experimental",
+ },
+ {
name: "FrameTimingSupport",
status: "experimental",
},
diff --git a/chromium/third_party/WebKit/Source/platform/animation/TimingFunction.h b/chromium/third_party/WebKit/Source/platform/animation/TimingFunction.h
index 9a7a777c3c3..02f1e661c34 100644
--- a/chromium/third_party/WebKit/Source/platform/animation/TimingFunction.h
+++ b/chromium/third_party/WebKit/Source/platform/animation/TimingFunction.h
@@ -27,6 +27,7 @@
#include "cc/animation/timing_function.h"
#include "platform/PlatformExport.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/wtf/Assertions.h"
#include "platform/wtf/PassRefPtr.h"
#include "platform/wtf/RefCounted.h"
@@ -214,7 +215,9 @@ class PLATFORM_EXPORT FramesTimingFunction final : public TimingFunction {
private:
FramesTimingFunction(int frames)
: TimingFunction(Type::FRAMES),
- frames_(cc::FramesTimingFunction::Create(frames)) {}
+ frames_(cc::FramesTimingFunction::Create(frames)) {
+ DCHECK(RuntimeEnabledFeatures::framesTimingFunctionEnabled());
+ }
std::unique_ptr<cc::FramesTimingFunction> frames_;
};
diff --git a/chromium/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp b/chromium/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
index dddd3bb0508..65357b1147a 100644
--- a/chromium/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
+++ b/chromium/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
@@ -32,6 +32,7 @@
#include <sstream>
#include <string>
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/wtf/text/WTFString.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -51,6 +52,10 @@ namespace {
class TimingFunctionTest : public ::testing::Test {
public:
+ TimingFunctionTest() {
+ RuntimeEnabledFeatures::setFramesTimingFunctionEnabled(true);
+ }
+
void NotEqualHelperLoop(
Vector<std::pair<std::string, RefPtr<TimingFunction>>>& v) {
for (size_t i = 0; i < v.size(); ++i) {
diff --git a/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp b/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
index 5b97d0f3ad7..5c36c9a98ca 100644
--- a/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
+++ b/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
@@ -602,10 +602,15 @@ Resource* ResourceFetcher::RequestResource(
params.Options().initiator_info.name);
}
- // An URL with the "cid" scheme can only be handled by an MHTML Archive.
- // Abort the request when there is none.
- if (!archive_ && resource_request.Url().ProtocolIs(kContentIdScheme))
+ // A main resource request with the "cid" scheme can only be handled by an
+ // MHTML Archive. Abort the request when there is none.
+ // Note: There are some embedders of WebView that are using Content-ID
+ // URLs for sub-resources, even without any MHTMLArchive. Please see
+ // https://crbug.com/739658.
+ if (!archive_ && factory.GetType() == Resource::kMainResource &&
+ resource_request.Url().ProtocolIs(kContentIdScheme)) {
return nullptr;
+ }
bool is_data_url = resource_request.Url().ProtocolIsData();
bool is_static_data = is_data_url || substitute_data.IsValid() || archive_;
@@ -1369,10 +1374,8 @@ bool ResourceFetcher::StartLoad(Resource* resource) {
ResourceLoader* loader = nullptr;
{
- // Forbids JavaScript/addClient/removeClient/revalidation until start()
+ // Forbids JavaScript/revalidation until start()
// to prevent unintended state transitions.
- Resource::ProhibitAddRemoveClientInScope
- prohibit_add_remove_client_in_scope(resource);
Resource::RevalidationStartForbiddenScope
revalidation_start_forbidden_scope(resource);
ScriptForbiddenIfMainThreadScope script_forbidden_scope;
@@ -1414,6 +1417,10 @@ bool ResourceFetcher::StartLoad(Resource* resource) {
StorePerformanceTimingInitiatorInformation(resource);
resource->SetFetcherSecurityOrigin(source_origin);
+ // NotifyStartLoad() shouldn't cause AddClient/RemoveClient().
+ Resource::ProhibitAddRemoveClientInScope
+ prohibit_add_remove_client_in_scope(resource);
+
resource->NotifyStartLoad();
loader->ActivateCacheAwareLoadingIfNeeded(request);
}
diff --git a/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp b/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp
index 13638fc15d3..b445c118b08 100644
--- a/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp
+++ b/chromium/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp
@@ -760,4 +760,38 @@ TEST_F(ResourceFetcherTest, ContentTypeDataURL) {
EXPECT_EQ("text/testmimetype", resource->GetResponse().HttpContentType());
}
+TEST_F(ResourceFetcherTest, ContentIdURL) {
+ KURL url(kParsedURLString, "cid:0123456789@example.com");
+ ResourceResponse response;
+ response.SetURL(url);
+ response.SetHTTPStatusCode(200);
+ RegisterMockedURLLoadWithCustomResponse(url, response);
+
+ ResourceFetcher* fetcher = ResourceFetcher::Create(Context());
+
+ // Fetching a main resource with the Content-ID scheme must be canceled if
+ // there is no MHTMLArchive.
+ {
+ ResourceRequest resource_request(url);
+ resource_request.SetRequestContext(WebURLRequest::kRequestContextIframe);
+ resource_request.SetFrameType(WebURLRequest::kFrameTypeNested);
+ FetchParameters fetch_params(resource_request);
+ RawResource* resource =
+ RawResource::FetchMainResource(fetch_params, fetcher, SubstituteData());
+ EXPECT_EQ(nullptr, resource);
+ }
+
+ // For all the other resource type, it must not be canceled.
+ // Note: It is important not to cancel them because there are some embedders
+ // of WebView that are using Content-ID URLs for sub-resources, even without
+ // any MHTMLArchive. Please see https://crbug.com/739658.
+ {
+ ResourceRequest resource_request(url);
+ resource_request.SetRequestContext(WebURLRequest::kRequestContextVideo);
+ FetchParameters fetch_params(resource_request);
+ RawResource* resource = RawResource::FetchMedia(fetch_params, fetcher);
+ EXPECT_NE(nullptr, resource);
+ }
+}
+
} // namespace blink
diff --git a/chromium/third_party/afl/OWNERS b/chromium/third_party/afl/OWNERS
deleted file mode 100644
index f015b3257d8..00000000000
--- a/chromium/third_party/afl/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-inferno@chromium.org
-kcc@chromium.org
-mmoroz@chromium.org
-ochang@chromium.org
diff --git a/chromium/third_party/afl/README.chromium b/chromium/third_party/afl/README.chromium
deleted file mode 100644
index d5fea4278fd..00000000000
--- a/chromium/third_party/afl/README.chromium
+++ /dev/null
@@ -1,22 +0,0 @@
-Name: American Fuzzy Lop
-Short Name: AFL
-URL: http://lcamtuf.coredump.cx/afl/
-Version: 2.38b
-Date: January 29, 2017
-License: Apache 2.0
-License File: src/docs/COPYING
-Security Critical: no
-
-Description:
-Tool for in-process and out-of-process (fork) coverage-guided fuzz testing
-(fuzzing). Similar to libFuzzer.
-
-Local Modifications:
-- Use update.py to roll forward.
-- Renamed afl-2.38b/ to src/.
-- Removed the following unneeded files/directories:
- - src/experimental/argv_fuzzing/
- - src/docs/vuln_samples
- - src/testcases/others/elf
- - src/llvm_mode/afl-llvm-pass.so.cc
- - src/dictionaries/
diff --git a/chromium/third_party/afl/src/Makefile b/chromium/third_party/afl/src/Makefile
deleted file mode 100644
index 44d1ffa23f2..00000000000
--- a/chromium/third_party/afl/src/Makefile
+++ /dev/null
@@ -1,153 +0,0 @@
-#
-# american fuzzy lop - makefile
-# -----------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-
-PROGNAME = afl
-VERSION = $(shell grep '^\#define VERSION ' config.h | cut -d '"' -f2)
-
-PREFIX ?= /usr/local
-BIN_PATH = $(PREFIX)/bin
-HELPER_PATH = $(PREFIX)/lib/afl
-DOC_PATH = $(PREFIX)/share/doc/afl
-MISC_PATH = $(PREFIX)/share/afl
-
-# PROGS intentionally omit afl-as, which gets installed elsewhere.
-
-PROGS = afl-gcc afl-fuzz afl-showmap afl-tmin afl-gotcpu afl-analyze
-SH_PROGS = afl-plot afl-cmin afl-whatsup
-
-CFLAGS ?= -O3 -funroll-loops
-CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
- -DAFL_PATH=\"$(HELPER_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\" \
- -DBIN_PATH=\"$(BIN_PATH)\"
-
-ifneq "$(filter Linux GNU%,$(shell uname))" ""
- LDFLAGS += -ldl
-endif
-
-ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
- TEST_CC = afl-gcc
-else
- TEST_CC = afl-clang
-endif
-
-COMM_HDR = alloc-inl.h config.h debug.h types.h
-
-all: test_x86 $(PROGS) afl-as test_build all_done
-
-ifndef AFL_NO_X86
-
-test_x86:
- @echo "[*] Checking for the ability to compile x86 code..."
- @echo 'main() { __asm__("xorb %al, %al"); }' | $(CC) -w -x c - -o .test || ( echo; echo "Oops, looks like your compiler can't generate x86 code."; echo; echo "Don't panic! You can use the LLVM or QEMU mode, but see docs/INSTALL first."; echo "(To ignore this error, set AFL_NO_X86=1 and try again.)"; echo; exit 1 )
- @rm -f .test
- @echo "[+] Everything seems to be working, ready to compile."
-
-else
-
-test_x86:
- @echo "[!] Note: skipping x86 compilation checks (AFL_NO_X86 set)."
-
-endif
-
-afl-gcc: afl-gcc.c $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
- set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $$i; done
-
-afl-as: afl-as.c afl-as.h $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
- ln -sf afl-as as
-
-afl-fuzz: afl-fuzz.c $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
-
-afl-showmap: afl-showmap.c $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
-
-afl-tmin: afl-tmin.c $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
-
-afl-analyze: afl-analyze.c $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
-
-afl-gotcpu: afl-gotcpu.c $(COMM_HDR) | test_x86
- $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
-
-ifndef AFL_NO_X86
-
-test_build: afl-gcc afl-as afl-showmap
- @echo "[*] Testing the CC wrapper and instrumentation output..."
- unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH=. ./$(TEST_CC) $(CFLAGS) test-instr.c -o test-instr $(LDFLAGS)
- echo 0 | ./afl-showmap -m none -q -o .test-instr0 ./test-instr
- echo 1 | ./afl-showmap -m none -q -o .test-instr1 ./test-instr
- @rm -f test-instr
- @cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please ping <lcamtuf@google.com> to troubleshoot the issue."; echo; exit 1; fi
- @echo "[+] All right, the instrumentation seems to be working!"
-
-else
-
-test_build: afl-gcc afl-as afl-showmap
- @echo "[!] Note: skipping build tests (you may need to use LLVM or QEMU mode)."
-
-endif
-
-all_done: test_build
- @if [ ! "`which clang 2>/dev/null`" = "" ]; then echo "[+] LLVM users: see llvm_mode/README.llvm for a faster alternative to afl-gcc."; fi
- @echo "[+] All done! Be sure to review README - it's pretty short and useful."
- @if [ "`uname`" = "Darwin" ]; then printf "\nWARNING: Fuzzing on MacOS X is slow because of the unusually high overhead of\nfork() on this OS. Consider using Linux or *BSD. You can also use VirtualBox\n(virtualbox.org) to put AFL inside a Linux or *BSD VM.\n\n"; fi
- @! tty <&1 >/dev/null || printf "\033[0;30mNOTE: If you can read this, your terminal probably uses white background.\nThis will make the UI hard to read. See docs/status_screen.txt for advice.\033[0m\n" 2>/dev/null
-
-.NOTPARALLEL: clean
-
-clean:
- rm -f $(PROGS) afl-as as afl-g++ afl-clang afl-clang++ *.o *~ a.out core core.[1-9][0-9]* *.stackdump test .test test-instr .test-instr0 .test-instr1 qemu_mode/qemu-2.3.0.tar.bz2 afl-qemu-trace
- rm -rf out_dir qemu_mode/qemu-2.3.0
- $(MAKE) -C llvm_mode clean
- $(MAKE) -C libdislocator clean
- $(MAKE) -C libtokencap clean
-
-install: all
- mkdir -p -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
- rm -f $${DESTDIR}$(BIN_PATH)/afl-plot.sh
- install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH)
- rm -f $${DESTDIR}$(BIN_PATH)/afl-as
- if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi
-ifndef AFL_TRACE_PC
- if [ -f afl-clang-fast -a -f afl-llvm-pass.so -a -f afl-llvm-rt.o ]; then set -e; install -m 755 afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 afl-llvm-pass.so afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
-else
- if [ -f afl-clang-fast -a -f afl-llvm-rt.o ]; then set -e; install -m 755 afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
-endif
- if [ -f afl-llvm-rt-32.o ]; then set -e; install -m 755 afl-llvm-rt-32.o $${DESTDIR}$(HELPER_PATH); fi
- if [ -f afl-llvm-rt-64.o ]; then set -e; install -m 755 afl-llvm-rt-64.o $${DESTDIR}$(HELPER_PATH); fi
- set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/$$i; done
- install -m 755 afl-as $${DESTDIR}$(HELPER_PATH)
- ln -sf afl-as $${DESTDIR}$(HELPER_PATH)/as
- install -m 644 docs/README docs/ChangeLog docs/*.txt $${DESTDIR}$(DOC_PATH)
- cp -r testcases/ $${DESTDIR}$(MISC_PATH)
- cp -r dictionaries/ $${DESTDIR}$(MISC_PATH)
-
-publish: clean
- test "`basename $$PWD`" = "afl" || exit 1
- test -f ~/www/afl/releases/$(PROGNAME)-$(VERSION).tgz; if [ "$$?" = "0" ]; then echo; echo "Change program version in config.h, mmkay?"; echo; exit 1; fi
- cd ..; rm -rf $(PROGNAME)-$(VERSION); cp -pr $(PROGNAME) $(PROGNAME)-$(VERSION); \
- tar -cvz -f ~/www/afl/releases/$(PROGNAME)-$(VERSION).tgz $(PROGNAME)-$(VERSION)
- chmod 644 ~/www/afl/releases/$(PROGNAME)-$(VERSION).tgz
- ( cd ~/www/afl/releases/; ln -s -f $(PROGNAME)-$(VERSION).tgz $(PROGNAME)-latest.tgz )
- cat docs/README >~/www/afl/README.txt
- cat docs/status_screen.txt >~/www/afl/status_screen.txt
- cat docs/historical_notes.txt >~/www/afl/historical_notes.txt
- cat docs/technical_details.txt >~/www/afl/technical_details.txt
- cat docs/ChangeLog >~/www/afl/ChangeLog.txt
- cat docs/QuickStartGuide.txt >~/www/afl/QuickStartGuide.txt
- echo -n "$(VERSION)" >~/www/afl/version.txt
diff --git a/chromium/third_party/afl/src/QuickStartGuide.txt b/chromium/third_party/afl/src/QuickStartGuide.txt
deleted file mode 120000
index e1687eb5bea..00000000000
--- a/chromium/third_party/afl/src/QuickStartGuide.txt
+++ /dev/null
@@ -1 +0,0 @@
-docs/QuickStartGuide.txt \ No newline at end of file
diff --git a/chromium/third_party/afl/src/README b/chromium/third_party/afl/src/README
deleted file mode 120000
index a90f4af9594..00000000000
--- a/chromium/third_party/afl/src/README
+++ /dev/null
@@ -1 +0,0 @@
-docs/README \ No newline at end of file
diff --git a/chromium/third_party/afl/src/afl-analyze.c b/chromium/third_party/afl/src/afl-analyze.c
deleted file mode 100644
index fd0a5226eb1..00000000000
--- a/chromium/third_party/afl/src/afl-analyze.c
+++ /dev/null
@@ -1,1063 +0,0 @@
-/*
- american fuzzy lop - file format analyzer
- -----------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- A nifty utility that grabs an input file and takes a stab at explaining
- its structure by observing how changes to it affect the execution path.
-
- If the output scrolls past the edge of the screen, pipe it to 'less -r'.
-
- */
-
-#define AFL_MAIN
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-#include "alloc-inl.h"
-#include "hash.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <ctype.h>
-
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-
-static s32 child_pid; /* PID of the tested program */
-
-static u8* trace_bits; /* SHM with instrumentation bitmap */
-
-static u8 *in_file, /* Analyzer input test case */
- *prog_in, /* Targeted program input file */
- *target_path, /* Path to target binary */
- *doc_path; /* Path to docs */
-
-static u8 *in_data; /* Input data for analysis */
-
-static u32 in_len, /* Input data length */
- orig_cksum, /* Original checksum */
- total_execs, /* Total number of execs */
- exec_hangs, /* Total number of hangs */
- exec_tmout = EXEC_TIMEOUT; /* Exec timeout (ms) */
-
-static u64 mem_limit = MEM_LIMIT; /* Memory limit (MB) */
-
-static s32 shm_id, /* ID of the SHM region */
- dev_null_fd = -1; /* FD to /dev/null */
-
-static u8 edges_only, /* Ignore hit counts? */
- use_stdin = 1; /* Use stdin for program input? */
-
-static volatile u8
- stop_soon, /* Ctrl-C pressed? */
- child_timed_out; /* Child timed out? */
-
-
-/* Constants used for describing byte behavior. */
-
-#define RESP_NONE 0x00 /* Changing byte is a no-op. */
-#define RESP_MINOR 0x01 /* Some changes have no effect. */
-#define RESP_VARIABLE 0x02 /* Changes produce variable paths. */
-#define RESP_FIXED 0x03 /* Changes produce fixed patterns. */
-
-#define RESP_LEN 0x04 /* Potential length field */
-#define RESP_CKSUM 0x05 /* Potential checksum */
-#define RESP_SUSPECT 0x06 /* Potential "suspect" blob */
-
-
-/* Classify tuple counts. This is a slow & naive version, but good enough here. */
-
-static u8 count_class_lookup[256] = {
-
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 4,
- [4 ... 7] = 8,
- [8 ... 15] = 16,
- [16 ... 31] = 32,
- [32 ... 127] = 64,
- [128 ... 255] = 128
-
-};
-
-static void classify_counts(u8* mem) {
-
- u32 i = MAP_SIZE;
-
- if (edges_only) {
-
- while (i--) {
- if (*mem) *mem = 1;
- mem++;
- }
-
- } else {
-
- while (i--) {
- *mem = count_class_lookup[*mem];
- mem++;
- }
-
- }
-
-}
-
-
-/* See if any bytes are set in the bitmap. */
-
-static inline u8 anything_set(void) {
-
- u32* ptr = (u32*)trace_bits;
- u32 i = (MAP_SIZE >> 2);
-
- while (i--) if (*(ptr++)) return 1;
-
- return 0;
-
-}
-
-
-/* Get rid of shared memory and temp files (atexit handler). */
-
-static void remove_shm(void) {
-
- unlink(prog_in); /* Ignore errors */
- shmctl(shm_id, IPC_RMID, NULL);
-
-}
-
-
-/* Configure shared memory. */
-
-static void setup_shm(void) {
-
- u8* shm_str;
-
- shm_id = shmget(IPC_PRIVATE, MAP_SIZE, IPC_CREAT | IPC_EXCL | 0600);
-
- if (shm_id < 0) PFATAL("shmget() failed");
-
- atexit(remove_shm);
-
- shm_str = alloc_printf("%d", shm_id);
-
- setenv(SHM_ENV_VAR, shm_str, 1);
-
- ck_free(shm_str);
-
- trace_bits = shmat(shm_id, NULL, 0);
-
- if (!trace_bits) PFATAL("shmat() failed");
-
-}
-
-
-/* Read initial file. */
-
-static void read_initial_file(void) {
-
- struct stat st;
- s32 fd = open(in_file, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", in_file);
-
- if (fstat(fd, &st) || !st.st_size)
- FATAL("Zero-sized input file.");
-
- if (st.st_size >= TMIN_MAX_FILE)
- FATAL("Input file is too large (%u MB max)", TMIN_MAX_FILE / 1024 / 1024);
-
- in_len = st.st_size;
- in_data = ck_alloc_nozero(in_len);
-
- ck_read(fd, in_data, in_len, in_file);
-
- close(fd);
-
- OKF("Read %u byte%s from '%s'.", in_len, in_len == 1 ? "" : "s", in_file);
-
-}
-
-
-/* Write output file. */
-
-static s32 write_to_file(u8* path, u8* mem, u32 len) {
-
- s32 ret;
-
- unlink(path); /* Ignore errors */
-
- ret = open(path, O_RDWR | O_CREAT | O_EXCL, 0600);
-
- if (ret < 0) PFATAL("Unable to create '%s'", path);
-
- ck_write(ret, mem, len, path);
-
- lseek(ret, 0, SEEK_SET);
-
- return ret;
-
-}
-
-
-/* Handle timeout signal. */
-
-static void handle_timeout(int sig) {
-
- child_timed_out = 1;
- if (child_pid > 0) kill(child_pid, SIGKILL);
-
-}
-
-
-/* Execute target application. Returns exec checksum, or 0 if program
- times out. */
-
-static u32 run_target(char** argv, u8* mem, u32 len, u8 first_run) {
-
- static struct itimerval it;
- int status = 0;
-
- s32 prog_in_fd;
- u32 cksum;
-
- memset(trace_bits, 0, MAP_SIZE);
- MEM_BARRIER();
-
- prog_in_fd = write_to_file(prog_in, mem, len);
-
- child_pid = fork();
-
- if (child_pid < 0) PFATAL("fork() failed");
-
- if (!child_pid) {
-
- struct rlimit r;
-
- if (dup2(use_stdin ? prog_in_fd : dev_null_fd, 0) < 0 ||
- dup2(dev_null_fd, 1) < 0 ||
- dup2(dev_null_fd, 2) < 0) {
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- PFATAL("dup2() failed");
-
- }
-
- close(dev_null_fd);
- close(prog_in_fd);
-
- if (mem_limit) {
-
- r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;
-
-#ifdef RLIMIT_AS
-
- setrlimit(RLIMIT_AS, &r); /* Ignore errors */
-
-#else
-
- setrlimit(RLIMIT_DATA, &r); /* Ignore errors */
-
-#endif /* ^RLIMIT_AS */
-
- }
-
- r.rlim_max = r.rlim_cur = 0;
- setrlimit(RLIMIT_CORE, &r); /* Ignore errors */
-
- execv(target_path, argv);
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- exit(0);
-
- }
-
- close(prog_in_fd);
-
- /* Configure timeout, wait for child, cancel timeout. */
-
- child_timed_out = 0;
- it.it_value.tv_sec = (exec_tmout / 1000);
- it.it_value.tv_usec = (exec_tmout % 1000) * 1000;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- if (waitpid(child_pid, &status, 0) <= 0) FATAL("waitpid() failed");
-
- child_pid = 0;
- it.it_value.tv_sec = 0;
- it.it_value.tv_usec = 0;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- MEM_BARRIER();
-
- /* Clean up bitmap, analyze exit condition, etc. */
-
- if (*(u32*)trace_bits == EXEC_FAIL_SIG)
- FATAL("Unable to execute '%s'", argv[0]);
-
- classify_counts(trace_bits);
- total_execs++;
-
- if (stop_soon) {
- SAYF(cRST cLRD "\n+++ Analysis aborted by user +++\n" cRST);
- exit(1);
- }
-
- /* Always discard inputs that time out. */
-
- if (child_timed_out) {
-
- exec_hangs++;
- return 0;
-
- }
-
- cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
-
- /* We don't actually care if the target is crashing or not,
- except that when it does, the checksum should be different. */
-
- if (WIFSIGNALED(status) ||
- (WIFEXITED(status) && WEXITSTATUS(status) == MSAN_ERROR) ||
- (WIFEXITED(status) && WEXITSTATUS(status))) {
-
- cksum ^= 0xffffffff;
-
- }
-
- if (first_run) orig_cksum = cksum;
-
- return cksum;
-
-}
-
-
-#ifdef USE_COLOR
-
-/* Helper function to display a human-readable character. */
-
-static void show_char(u8 val) {
-
- switch (val) {
-
- case 0 ... 32:
- case 127 ... 255: SAYF("#%02x", val); break;
-
- default: SAYF(" %c ", val);
-
- }
-
-}
-
-
-/* Show the legend */
-
-static void show_legend(void) {
-
- SAYF(" " cLGR bgGRA " 01 " cRST " - no-op block "
- cBLK bgLGN " 01 " cRST " - suspected length field\n"
- " " cBRI bgGRA " 01 " cRST " - superficial content "
- cBLK bgYEL " 01 " cRST " - suspected cksum or magic int\n"
- " " cBLK bgCYA " 01 " cRST " - critical stream "
- cBLK bgLRD " 01 " cRST " - suspected checksummed block\n"
- " " cBLK bgMGN " 01 " cRST " - \"magic value\" section\n\n");
-
-}
-
-#endif /* USE_COLOR */
-
-
-/* Interpret and report a pattern in the input file. */
-
-static void dump_hex(u8* buf, u32 len, u8* b_data) {
-
- u32 i;
-
- for (i = 0; i < len; i++) {
-
-#ifdef USE_COLOR
- u32 rlen = 1, off;
-#else
- u32 rlen = 1;
-#endif /* ^USE_COLOR */
-
- u8 rtype = b_data[i] & 0x0f;
-
- /* Look ahead to determine the length of run. */
-
- while (i + rlen < len && (b_data[i] >> 7) == (b_data[i + rlen] >> 7)) {
-
- if (rtype < (b_data[i + rlen] & 0x0f)) rtype = b_data[i + rlen] & 0x0f;
- rlen++;
-
- }
-
- /* Try to do some further classification based on length & value. */
-
- if (rtype == RESP_FIXED) {
-
- switch (rlen) {
-
- case 2: {
-
- u16 val = *(u16*)(in_data + i);
-
- /* Small integers may be length fields. */
-
- if (val && (val <= in_len || SWAP16(val) <= in_len)) {
- rtype = RESP_LEN;
- break;
- }
-
- /* Uniform integers may be checksums. */
-
- if (val && abs(in_data[i] - in_data[i + 1]) > 32) {
- rtype = RESP_CKSUM;
- break;
- }
-
- break;
-
- }
-
- case 4: {
-
- u32 val = *(u32*)(in_data + i);
-
- /* Small integers may be length fields. */
-
- if (val && (val <= in_len || SWAP32(val) <= in_len)) {
- rtype = RESP_LEN;
- break;
- }
-
- /* Uniform integers may be checksums. */
-
- if (val && (in_data[i] >> 7 != in_data[i + 1] >> 7 ||
- in_data[i] >> 7 != in_data[i + 2] >> 7 ||
- in_data[i] >> 7 != in_data[i + 3] >> 7)) {
- rtype = RESP_CKSUM;
- break;
- }
-
- break;
-
- }
-
- case 1: case 3: case 5 ... MAX_AUTO_EXTRA - 1: break;
-
- default: rtype = RESP_SUSPECT;
-
- }
-
- }
-
- /* Print out the entire run. */
-
-#ifdef USE_COLOR
-
- for (off = 0; off < rlen; off++) {
-
- /* Every 16 digits, display offset. */
-
- if (!((i + off) % 16)) {
-
- if (off) SAYF(cRST cLCY ">");
- SAYF(cRST cGRA "%s[%06u] " cRST, (i + off) ? "\n" : "", i + off);
-
- }
-
- switch (rtype) {
-
- case RESP_NONE: SAYF(cLGR bgGRA); break;
- case RESP_MINOR: SAYF(cBRI bgGRA); break;
- case RESP_VARIABLE: SAYF(cBLK bgCYA); break;
- case RESP_FIXED: SAYF(cBLK bgMGN); break;
- case RESP_LEN: SAYF(cBLK bgLGN); break;
- case RESP_CKSUM: SAYF(cBLK bgYEL); break;
- case RESP_SUSPECT: SAYF(cBLK bgLRD); break;
-
- }
-
- show_char(in_data[i + off]);
-
- if (off != rlen - 1 && (i + off + 1) % 16) SAYF(" "); else SAYF(cRST " ");
-
- }
-
-#else
-
- SAYF(" Offset %u, length %u: ", i, rlen);
-
- switch (rtype) {
-
- case RESP_NONE: SAYF("no-op block\n"); break;
- case RESP_MINOR: SAYF("superficial content\n"); break;
- case RESP_VARIABLE: SAYF("critical stream\n"); break;
- case RESP_FIXED: SAYF("\"magic value\" section\n"); break;
- case RESP_LEN: SAYF("suspected length field\n"); break;
- case RESP_CKSUM: SAYF("suspected cksum or magic int\n"); break;
- case RESP_SUSPECT: SAYF("suspected checksummed block\n"); break;
-
- }
-
-#endif /* ^USE_COLOR */
-
- i += rlen - 1;
-
- }
-
-#ifdef USE_COLOR
- SAYF(cRST "\n");
-#endif /* USE_COLOR */
-
-}
-
-
-
-/* Actually analyze! */
-
-static void analyze(char** argv) {
-
- u32 i;
- u32 boring_len = 0, prev_xff = 0, prev_x01 = 0, prev_s10 = 0, prev_a10 = 0;
-
- u8* b_data = ck_alloc(in_len + 1);
- u8 seq_byte = 0;
-
- b_data[in_len] = 0xff; /* Intentional terminator. */
-
- ACTF("Analyzing input file (this may take a while)...\n");
-
-#ifdef USE_COLOR
- show_legend();
-#endif /* USE_COLOR */
-
- for (i = 0; i < in_len; i++) {
-
- u32 xor_ff, xor_01, sub_10, add_10;
- u8 xff_orig, x01_orig, s10_orig, a10_orig;
-
- /* Perform walking byte adjustments across the file. We perform four
- operations designed to elicit some response from the underlying
- code. */
-
- in_data[i] ^= 0xff;
- xor_ff = run_target(argv, in_data, in_len, 0);
-
- in_data[i] ^= 0xfe;
- xor_01 = run_target(argv, in_data, in_len, 0);
-
- in_data[i] = (in_data[i] ^ 0x01) - 0x10;
- sub_10 = run_target(argv, in_data, in_len, 0);
-
- in_data[i] += 0x20;
- add_10 = run_target(argv, in_data, in_len, 0);
- in_data[i] -= 0x10;
-
- /* Classify current behavior. */
-
- xff_orig = (xor_ff == orig_cksum);
- x01_orig = (xor_01 == orig_cksum);
- s10_orig = (sub_10 == orig_cksum);
- a10_orig = (add_10 == orig_cksum);
-
- if (xff_orig && x01_orig && s10_orig && a10_orig) {
-
- b_data[i] = RESP_NONE;
- boring_len++;
-
- } else if (xff_orig || x01_orig || s10_orig || a10_orig) {
-
- b_data[i] = RESP_MINOR;
- boring_len++;
-
- } else if (xor_ff == xor_01 && xor_ff == sub_10 && xor_ff == add_10) {
-
- b_data[i] = RESP_FIXED;
-
- } else b_data[i] = RESP_VARIABLE;
-
- /* When all checksums change, flip most significant bit of b_data. */
-
- if (prev_xff != xor_ff && prev_x01 != xor_01 &&
- prev_s10 != sub_10 && prev_a10 != add_10) seq_byte ^= 0x80;
-
- b_data[i] |= seq_byte;
-
- prev_xff = xor_ff;
- prev_x01 = xor_01;
- prev_s10 = sub_10;
- prev_a10 = add_10;
-
- }
-
- dump_hex(in_data, in_len, b_data);
-
- SAYF("\n");
-
- OKF("Analysis complete. Interesting bits: %0.02f%% of the input file.",
- 100.0 - ((double)boring_len * 100) / in_len);
-
- if (exec_hangs)
- WARNF(cLRD "Encountered %u timeouts - results may be skewed." cRST,
- exec_hangs);
-
- ck_free(b_data);
-
-}
-
-
-
-/* Handle Ctrl-C and the like. */
-
-static void handle_stop_sig(int sig) {
-
- stop_soon = 1;
-
- if (child_pid > 0) kill(child_pid, SIGKILL);
-
-}
-
-
-/* Do basic preparations - persistent fds, filenames, etc. */
-
-static void set_up_environment(void) {
-
- u8* x;
-
- dev_null_fd = open("/dev/null", O_RDWR);
- if (dev_null_fd < 0) PFATAL("Unable to open /dev/null");
-
- if (!prog_in) {
-
- u8* use_dir = ".";
-
- if (!access(use_dir, R_OK | W_OK | X_OK)) {
-
- use_dir = getenv("TMPDIR");
- if (!use_dir) use_dir = "/tmp";
-
- prog_in = alloc_printf("%s/.afl-tmin-temp-%u", use_dir, getpid());
-
- }
-
- }
-
- /* Set sane defaults... */
-
- x = getenv("ASAN_OPTIONS");
-
- if (x) {
-
- if (!strstr(x, "abort_on_error=1"))
- FATAL("Custom ASAN_OPTIONS set without abort_on_error=1 - please fix!");
-
- if (!strstr(x, "symbolize=0"))
- FATAL("Custom ASAN_OPTIONS set without symbolize=0 - please fix!");
-
- }
-
- x = getenv("MSAN_OPTIONS");
-
- if (x) {
-
- if (!strstr(x, "exit_code=" STRINGIFY(MSAN_ERROR)))
- FATAL("Custom MSAN_OPTIONS set without exit_code="
- STRINGIFY(MSAN_ERROR) " - please fix!");
-
- if (!strstr(x, "symbolize=0"))
- FATAL("Custom MSAN_OPTIONS set without symbolize=0 - please fix!");
-
- }
-
- setenv("ASAN_OPTIONS", "abort_on_error=1:"
- "detect_leaks=0:"
- "symbolize=0:"
- "allocator_may_return_null=1", 0);
-
- setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":"
- "symbolize=0:"
- "abort_on_error=1:"
- "allocator_may_return_null=1:"
- "msan_track_origins=0", 0);
-
- if (getenv("AFL_PRELOAD")) {
- setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
- setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
- }
-
-}
-
-
-/* Setup signal handlers, duh. */
-
-static void setup_signal_handlers(void) {
-
- struct sigaction sa;
-
- sa.sa_handler = NULL;
- sa.sa_flags = SA_RESTART;
- sa.sa_sigaction = NULL;
-
- sigemptyset(&sa.sa_mask);
-
- /* Various ways of saying "stop". */
-
- sa.sa_handler = handle_stop_sig;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-
- /* Exec timeout notifications. */
-
- sa.sa_handler = handle_timeout;
- sigaction(SIGALRM, &sa, NULL);
-
-}
-
-
-/* Detect @@ in args. */
-
-static void detect_file_args(char** argv) {
-
- u32 i = 0;
- u8* cwd = getcwd(NULL, 0);
-
- if (!cwd) PFATAL("getcwd() failed");
-
- while (argv[i]) {
-
- u8* aa_loc = strstr(argv[i], "@@");
-
- if (aa_loc) {
-
- u8 *aa_subst, *n_arg;
-
- /* Be sure that we're always using fully-qualified paths. */
-
- if (prog_in[0] == '/') aa_subst = prog_in;
- else aa_subst = alloc_printf("%s/%s", cwd, prog_in);
-
- /* Construct a replacement argv value. */
-
- *aa_loc = 0;
- n_arg = alloc_printf("%s%s%s", argv[i], aa_subst, aa_loc + 2);
- argv[i] = n_arg;
- *aa_loc = '@';
-
- if (prog_in[0] != '/') ck_free(aa_subst);
-
- }
-
- i++;
-
- }
-
- free(cwd); /* not tracked */
-
-}
-
-
-/* Display usage hints. */
-
-static void usage(u8* argv0) {
-
- SAYF("\n%s [ options ] -- /path/to/target_app [ ... ]\n\n"
-
- "Required parameters:\n\n"
-
- " -i file - input test case to be analyzed by the tool\n"
-
- "Execution control settings:\n\n"
-
- " -f file - input file read by the tested program (stdin)\n"
- " -t msec - timeout for each run (%u ms)\n"
- " -m megs - memory limit for child process (%u MB)\n"
- " -Q - use binary-only instrumentation (QEMU mode)\n\n"
-
- "Analysis settings:\n\n"
-
- " -e - look for edge coverage only, ignore hit counts\n\n"
-
- "For additional tips, please consult %s/README.\n\n",
-
- argv0, EXEC_TIMEOUT, MEM_LIMIT, doc_path);
-
- exit(1);
-
-}
-
-
-/* Find binary. */
-
-static void find_binary(u8* fname) {
-
- u8* env_path = 0;
- struct stat st;
-
- if (strchr(fname, '/') || !(env_path = getenv("PATH"))) {
-
- target_path = ck_strdup(fname);
-
- if (stat(target_path, &st) || !S_ISREG(st.st_mode) ||
- !(st.st_mode & 0111) || st.st_size < 4)
- FATAL("Program '%s' not found or not executable", fname);
-
- } else {
-
- while (env_path) {
-
- u8 *cur_elem, *delim = strchr(env_path, ':');
-
- if (delim) {
-
- cur_elem = ck_alloc(delim - env_path + 1);
- memcpy(cur_elem, env_path, delim - env_path);
- delim++;
-
- } else cur_elem = ck_strdup(env_path);
-
- env_path = delim;
-
- if (cur_elem[0])
- target_path = alloc_printf("%s/%s", cur_elem, fname);
- else
- target_path = ck_strdup(fname);
-
- ck_free(cur_elem);
-
- if (!stat(target_path, &st) && S_ISREG(st.st_mode) &&
- (st.st_mode & 0111) && st.st_size >= 4) break;
-
- ck_free(target_path);
- target_path = 0;
-
- }
-
- if (!target_path) FATAL("Program '%s' not found or not executable", fname);
-
- }
-
-}
-
-
-/* Fix up argv for QEMU. */
-
-static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
-
- char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
- u8 *tmp, *cp, *rsl, *own_copy;
-
- memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
-
- /* Now we need to actually find qemu for argv[0]. */
-
- new_argv[2] = target_path;
- new_argv[1] = "--";
-
- tmp = getenv("AFL_PATH");
-
- if (tmp) {
-
- cp = alloc_printf("%s/afl-qemu-trace", tmp);
-
- if (access(cp, X_OK))
- FATAL("Unable to find '%s'", tmp);
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- own_copy = ck_strdup(own_loc);
- rsl = strrchr(own_copy, '/');
-
- if (rsl) {
-
- *rsl = 0;
-
- cp = alloc_printf("%s/afl-qemu-trace", own_copy);
- ck_free(own_copy);
-
- if (!access(cp, X_OK)) {
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- } else ck_free(own_copy);
-
- if (!access(BIN_PATH "/afl-qemu-trace", X_OK)) {
-
- target_path = new_argv[0] = BIN_PATH "/afl-qemu-trace";
- return new_argv;
-
- }
-
- FATAL("Unable to find 'afl-qemu-trace'.");
-
-}
-
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- s32 opt;
- u8 mem_limit_given = 0, timeout_given = 0, qemu_mode = 0;
- char** use_argv;
-
- doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
-
- SAYF(cCYA "afl-analyze " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- while ((opt = getopt(argc,argv,"+i:f:m:t:eQ")) > 0)
-
- switch (opt) {
-
- case 'i':
-
- if (in_file) FATAL("Multiple -i options not supported");
- in_file = optarg;
- break;
-
- case 'f':
-
- if (prog_in) FATAL("Multiple -f options not supported");
- use_stdin = 0;
- prog_in = optarg;
- break;
-
- case 'e':
-
- if (edges_only) FATAL("Multiple -e options not supported");
- edges_only = 1;
- break;
-
- case 'm': {
-
- u8 suffix = 'M';
-
- if (mem_limit_given) FATAL("Multiple -m options not supported");
- mem_limit_given = 1;
-
- if (!strcmp(optarg, "none")) {
-
- mem_limit = 0;
- break;
-
- }
-
- if (sscanf(optarg, "%llu%c", &mem_limit, &suffix) < 1 ||
- optarg[0] == '-') FATAL("Bad syntax used for -m");
-
- switch (suffix) {
-
- case 'T': mem_limit *= 1024 * 1024; break;
- case 'G': mem_limit *= 1024; break;
- case 'k': mem_limit /= 1024; break;
- case 'M': break;
-
- default: FATAL("Unsupported suffix or bad syntax for -m");
-
- }
-
- if (mem_limit < 5) FATAL("Dangerously low value of -m");
-
- if (sizeof(rlim_t) == 4 && mem_limit > 2000)
- FATAL("Value of -m out of range on 32-bit systems");
-
- }
-
- break;
-
- case 't':
-
- if (timeout_given) FATAL("Multiple -t options not supported");
- timeout_given = 1;
-
- exec_tmout = atoi(optarg);
-
- if (exec_tmout < 10 || optarg[0] == '-')
- FATAL("Dangerously low value of -t");
-
- break;
-
- case 'Q':
-
- if (qemu_mode) FATAL("Multiple -Q options not supported");
- if (!mem_limit_given) mem_limit = MEM_LIMIT_QEMU;
-
- qemu_mode = 1;
- break;
-
- default:
-
- usage(argv[0]);
-
- }
-
- if (optind == argc || !in_file) usage(argv[0]);
-
- setup_shm();
- setup_signal_handlers();
-
- set_up_environment();
-
- find_binary(argv[optind]);
- detect_file_args(argv + optind);
-
- if (qemu_mode)
- use_argv = get_qemu_argv(argv[0], argv + optind, argc - optind);
- else
- use_argv = argv + optind;
-
- SAYF("\n");
-
- read_initial_file();
-
- ACTF("Performing dry run (mem limit = %llu MB, timeout = %u ms%s)...",
- mem_limit, exec_tmout, edges_only ? ", edges only" : "");
-
- run_target(use_argv, in_data, in_len, 1);
-
- if (child_timed_out)
- FATAL("Target binary times out (adjusting -t may help).");
-
- if (!anything_set()) FATAL("No instrumentation detected.");
-
- analyze(use_argv);
-
- OKF("We're done here. Have a nice day!\n");
-
- exit(0);
-
-}
-
diff --git a/chromium/third_party/afl/src/afl-as.c b/chromium/third_party/afl/src/afl-as.c
deleted file mode 100644
index 7686fe8a802..00000000000
--- a/chromium/third_party/afl/src/afl-as.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- american fuzzy lop - wrapper for GNU as
- ---------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- The sole purpose of this wrapper is to preprocess assembly files generated
- by GCC / clang and inject the instrumentation bits included from afl-as.h. It
- is automatically invoked by the toolchain when compiling programs using
- afl-gcc / afl-clang.
-
- Note that it's an explicit non-goal to instrument hand-written assembly,
- be it in separate .s files or in __asm__ blocks. The only aspiration this
- utility has right now is to be able to skip them gracefully and allow the
- compilation process to continue.
-
- That said, see experimental/clang_asm_normalize/ for a solution that may
- allow clang users to make things work even with hand-crafted assembly. Just
- note that there is no equivalent for GCC.
-
- */
-
-#define AFL_MAIN
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-#include "alloc-inl.h"
-
-#include "afl-as.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <fcntl.h>
-
-#include <sys/wait.h>
-#include <sys/time.h>
-
-static u8** as_params; /* Parameters passed to the real 'as' */
-
-static u8* input_file; /* Originally specified input file */
-static u8* modified_file; /* Instrumented file for the real 'as' */
-
-static u8 be_quiet, /* Quiet mode (no stderr output) */
- clang_mode, /* Running in clang mode? */
- pass_thru, /* Just pass data through? */
- just_version; /* Just show version? */
-
-static u32 inst_ratio = 100, /* Instrumentation probability (%) */
- as_par_cnt = 1; /* Number of params to 'as' */
-
-/* If we don't find --32 or --64 in the command line, default to
- instrumentation for whichever mode we were compiled with. This is not
- perfect, but should do the trick for almost all use cases. */
-
-#ifdef __x86_64__
-
-static u8 use_64bit = 1;
-
-#else
-
-static u8 use_64bit = 0;
-
-#ifdef __APPLE__
-# error "Sorry, 32-bit Apple platforms are not supported."
-#endif /* __APPLE__ */
-
-#endif /* ^__x86_64__ */
-
-
-/* Examine and modify parameters to pass to 'as'. Note that the file name
- is always the last parameter passed by GCC, so we exploit this property
- to keep the code simple. */
-
-static void edit_params(int argc, char** argv) {
-
- u8 *tmp_dir = getenv("TMPDIR"), *afl_as = getenv("AFL_AS");
- u32 i;
-
-#ifdef __APPLE__
-
- u8 use_clang_as = 0;
-
- /* On MacOS X, the Xcode cctool 'as' driver is a bit stale and does not work
- with the code generated by newer versions of clang that are hand-built
- by the user. See the thread here: http://goo.gl/HBWDtn.
-
- To work around this, when using clang and running without AFL_AS
- specified, we will actually call 'clang -c' instead of 'as -q' to
- compile the assembly file.
-
- The tools aren't cmdline-compatible, but at least for now, we can
- seemingly get away with this by making only very minor tweaks. Thanks
- to Nico Weber for the idea. */
-
- if (clang_mode && !afl_as) {
-
- use_clang_as = 1;
-
- afl_as = getenv("AFL_CC");
- if (!afl_as) afl_as = getenv("AFL_CXX");
- if (!afl_as) afl_as = "clang";
-
- }
-
-#endif /* __APPLE__ */
-
- /* Although this is not documented, GCC also uses TEMP and TMP when TMPDIR
- is not set. We need to check these non-standard variables to properly
- handle the pass_thru logic later on. */
-
- if (!tmp_dir) tmp_dir = getenv("TEMP");
- if (!tmp_dir) tmp_dir = getenv("TMP");
- if (!tmp_dir) tmp_dir = "/tmp";
-
- as_params = ck_alloc((argc + 32) * sizeof(u8*));
-
- as_params[0] = afl_as ? afl_as : (u8*)"as";
-
- as_params[argc] = 0;
-
- for (i = 1; i < argc - 1; i++) {
-
- if (!strcmp(argv[i], "--64")) use_64bit = 1;
- else if (!strcmp(argv[i], "--32")) use_64bit = 0;
-
-#ifdef __APPLE__
-
- /* The Apple case is a bit different... */
-
- if (!strcmp(argv[i], "-arch") && i + 1 < argc) {
-
- if (!strcmp(argv[i + 1], "x86_64")) use_64bit = 1;
- else if (!strcmp(argv[i + 1], "i386"))
- FATAL("Sorry, 32-bit Apple platforms are not supported.");
-
- }
-
- /* Strip options that set the preference for a particular upstream
- assembler in Xcode. */
-
- if (clang_mode && (!strcmp(argv[i], "-q") || !strcmp(argv[i], "-Q")))
- continue;
-
-#endif /* __APPLE__ */
-
- as_params[as_par_cnt++] = argv[i];
-
- }
-
-#ifdef __APPLE__
-
- /* When calling clang as the upstream assembler, append -c -x assembler
- and hope for the best. */
-
- if (use_clang_as) {
-
- as_params[as_par_cnt++] = "-c";
- as_params[as_par_cnt++] = "-x";
- as_params[as_par_cnt++] = "assembler";
-
- }
-
-#endif /* __APPLE__ */
-
- input_file = argv[argc - 1];
-
- if (input_file[0] == '-') {
-
- if (!strcmp(input_file + 1, "-version")) {
- just_version = 1;
- modified_file = input_file;
- goto wrap_things_up;
- }
-
- if (input_file[1]) FATAL("Incorrect use (not called through afl-gcc?)");
- else input_file = NULL;
-
- } else {
-
- /* Check if this looks like a standard invocation as a part of an attempt
- to compile a program, rather than using gcc on an ad-hoc .s file in
- a format we may not understand. This works around an issue compiling
- NSS. */
-
- if (strncmp(input_file, tmp_dir, strlen(tmp_dir)) &&
- strncmp(input_file, "/var/tmp/", 9) &&
- strncmp(input_file, "/tmp/", 5)) pass_thru = 1;
-
- }
-
- modified_file = alloc_printf("%s/.afl-%u-%u.s", tmp_dir, getpid(),
- (u32)time(NULL));
-
-wrap_things_up:
-
- as_params[as_par_cnt++] = modified_file;
- as_params[as_par_cnt] = NULL;
-
-}
-
-
-/* Process input file, generate modified_file. Insert instrumentation in all
- the appropriate places. */
-
-static void add_instrumentation(void) {
-
- static u8 line[MAX_LINE];
-
- FILE* inf;
- FILE* outf;
- s32 outfd;
- u32 ins_lines = 0;
-
- u8 instr_ok = 0, skip_csect = 0, skip_next_label = 0,
- skip_intel = 0, skip_app = 0, instrument_next = 0;
-
-#ifdef __APPLE__
-
- u8* colon_pos;
-
-#endif /* __APPLE__ */
-
- if (input_file) {
-
- inf = fopen(input_file, "r");
- if (!inf) PFATAL("Unable to read '%s'", input_file);
-
- } else inf = stdin;
-
- outfd = open(modified_file, O_WRONLY | O_EXCL | O_CREAT, 0600);
-
- if (outfd < 0) PFATAL("Unable to write to '%s'", modified_file);
-
- outf = fdopen(outfd, "w");
-
- if (!outf) PFATAL("fdopen() failed");
-
- while (fgets(line, MAX_LINE, inf)) {
-
- /* In some cases, we want to defer writing the instrumentation trampoline
- until after all the labels, macros, comments, etc. If we're in this
- mode, and if the line starts with a tab followed by a character, dump
- the trampoline now. */
-
- if (!pass_thru && !skip_intel && !skip_app && !skip_csect && instr_ok &&
- instrument_next && line[0] == '\t' && isalpha(line[1])) {
-
- fprintf(outf, use_64bit ? trampoline_fmt_64 : trampoline_fmt_32,
- R(MAP_SIZE));
-
- instrument_next = 0;
- ins_lines++;
-
- }
-
- /* Output the actual line, call it a day in pass-thru mode. */
-
- fputs(line, outf);
-
- if (pass_thru) continue;
-
- /* All right, this is where the actual fun begins. For one, we only want to
- instrument the .text section. So, let's keep track of that in processed
- files - and let's set instr_ok accordingly. */
-
- if (line[0] == '\t' && line[1] == '.') {
-
- /* OpenBSD puts jump tables directly inline with the code, which is
- a bit annoying. They use a specific format of p2align directives
- around them, so we use that as a signal. */
-
- if (!clang_mode && instr_ok && !strncmp(line + 2, "p2align ", 8) &&
- isdigit(line[10]) && line[11] == '\n') skip_next_label = 1;
-
- if (!strncmp(line + 2, "text\n", 5) ||
- !strncmp(line + 2, "section\t.text", 13) ||
- !strncmp(line + 2, "section\t__TEXT,__text", 21) ||
- !strncmp(line + 2, "section __TEXT,__text", 21)) {
- instr_ok = 1;
- continue;
- }
-
- if (!strncmp(line + 2, "section\t", 8) ||
- !strncmp(line + 2, "section ", 8) ||
- !strncmp(line + 2, "bss\n", 4) ||
- !strncmp(line + 2, "data\n", 5)) {
- instr_ok = 0;
- continue;
- }
-
- }
-
- /* Detect off-flavor assembly (rare, happens in gdb). When this is
- encountered, we set skip_csect until the opposite directive is
- seen, and we do not instrument. */
-
- if (strstr(line, ".code")) {
-
- if (strstr(line, ".code32")) skip_csect = use_64bit;
- if (strstr(line, ".code64")) skip_csect = !use_64bit;
-
- }
-
- /* Detect syntax changes, as could happen with hand-written assembly.
- Skip Intel blocks, resume instrumentation when back to AT&T. */
-
- if (strstr(line, ".intel_syntax")) skip_intel = 1;
- if (strstr(line, ".att_syntax")) skip_intel = 0;
-
- /* Detect and skip ad-hoc __asm__ blocks, likewise skipping them. */
-
- if (line[0] == '#' || line[1] == '#') {
-
- if (strstr(line, "#APP")) skip_app = 1;
- if (strstr(line, "#NO_APP")) skip_app = 0;
-
- }
-
- /* If we're in the right mood for instrumenting, check for function
- names or conditional labels. This is a bit messy, but in essence,
- we want to catch:
-
- ^main: - function entry point (always instrumented)
- ^.L0: - GCC branch label
- ^.LBB0_0: - clang branch label (but only in clang mode)
- ^\tjnz foo - conditional branches
-
- ...but not:
-
- ^# BB#0: - clang comments
- ^ # BB#0: - ditto
- ^.Ltmp0: - clang non-branch labels
- ^.LC0 - GCC non-branch labels
- ^.LBB0_0: - ditto (when in GCC mode)
- ^\tjmp foo - non-conditional jumps
-
- Additionally, clang and GCC on MacOS X follow a different convention
- with no leading dots on labels, hence the weird maze of #ifdefs
- later on.
-
- */
-
- if (skip_intel || skip_app || skip_csect || !instr_ok ||
- line[0] == '#' || line[0] == ' ') continue;
-
- /* Conditional branch instruction (jnz, etc). We append the instrumentation
- right after the branch (to instrument the not-taken path) and at the
- branch destination label (handled later on). */
-
- if (line[0] == '\t') {
-
- if (line[1] == 'j' && line[2] != 'm' && R(100) < inst_ratio) {
-
- fprintf(outf, use_64bit ? trampoline_fmt_64 : trampoline_fmt_32,
- R(MAP_SIZE));
-
- ins_lines++;
-
- }
-
- continue;
-
- }
-
- /* Label of some sort. This may be a branch destination, but we need to
- tread carefully and account for several different formatting
- conventions. */
-
-#ifdef __APPLE__
-
- /* Apple: L<whatever><digit>: */
-
- if ((colon_pos = strstr(line, ":"))) {
-
- if (line[0] == 'L' && isdigit(*(colon_pos - 1))) {
-
-#else
-
- /* Everybody else: .L<whatever>: */
-
- if (strstr(line, ":")) {
-
- if (line[0] == '.') {
-
-#endif /* __APPLE__ */
-
- /* .L0: or LBB0_0: style jump destination */
-
-#ifdef __APPLE__
-
- /* Apple: L<num> / LBB<num> */
-
- if ((isdigit(line[1]) || (clang_mode && !strncmp(line, "LBB", 3)))
- && R(100) < inst_ratio) {
-
-#else
-
- /* Apple: .L<num> / .LBB<num> */
-
- if ((isdigit(line[2]) || (clang_mode && !strncmp(line + 1, "LBB", 3)))
- && R(100) < inst_ratio) {
-
-#endif /* __APPLE__ */
-
- /* An optimization is possible here by adding the code only if the
- label is mentioned in the code in contexts other than call / jmp.
- That said, this complicates the code by requiring two-pass
- processing (messy with stdin), and results in a speed gain
- typically under 10%, because compilers are generally pretty good
- about not generating spurious intra-function jumps.
-
- We use deferred output chiefly to avoid disrupting
- .Lfunc_begin0-style exception handling calculations (a problem on
- MacOS X). */
-
- if (!skip_next_label) instrument_next = 1; else skip_next_label = 0;
-
- }
-
- } else {
-
- /* Function label (always instrumented, deferred mode). */
-
- instrument_next = 1;
-
- }
-
- }
-
- }
-
- if (ins_lines)
- fputs(use_64bit ? main_payload_64 : main_payload_32, outf);
-
- if (input_file) fclose(inf);
- fclose(outf);
-
- if (!be_quiet) {
-
- if (!ins_lines) WARNF("No instrumentation targets found%s.",
- pass_thru ? " (pass-thru mode)" : "");
- else OKF("Instrumented %u locations (%s-bit, %s mode, ratio %u%%).",
- ins_lines, use_64bit ? "64" : "32",
- getenv("AFL_HARDEN") ? "hardened" : "non-hardened",
- inst_ratio);
-
- }
-
-}
-
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- s32 pid;
- u32 rand_seed;
- int status;
- u8* inst_ratio_str = getenv("AFL_INST_RATIO");
-
- struct timeval tv;
- struct timezone tz;
-
- clang_mode = !!getenv(CLANG_ENV_VAR);
-
- if (isatty(2) && !getenv("AFL_QUIET")) {
-
- SAYF(cCYA "afl-as " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- } else be_quiet = 1;
-
- if (argc < 2) {
-
- SAYF("\n"
- "This is a helper application for afl-fuzz. It is a wrapper around GNU 'as',\n"
- "executed by the toolchain whenever using afl-gcc or afl-clang. You probably\n"
- "don't want to run this program directly.\n\n"
-
- "Rarely, when dealing with extremely complex projects, it may be advisable to\n"
- "set AFL_INST_RATIO to a value less than 100 in order to reduce the odds of\n"
- "instrumenting every discovered branch.\n\n");
-
- exit(1);
-
- }
-
- gettimeofday(&tv, &tz);
-
- rand_seed = tv.tv_sec ^ tv.tv_usec ^ getpid();
-
- srandom(rand_seed);
-
- edit_params(argc, argv);
-
- if (inst_ratio_str) {
-
- if (sscanf(inst_ratio_str, "%u", &inst_ratio) != 1 || inst_ratio > 100)
- FATAL("Bad value of AFL_INST_RATIO (must be between 0 and 100)");
-
- }
-
- if (getenv(AS_LOOP_ENV_VAR))
- FATAL("Endless loop when calling 'as' (remove '.' from your PATH)");
-
- setenv(AS_LOOP_ENV_VAR, "1", 1);
-
- /* When compiling with ASAN, we don't have a particularly elegant way to skip
- ASAN-specific branches. But we can probabilistically compensate for
- that... */
-
- if (getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN")) inst_ratio /= 3;
-
- if (!just_version) add_instrumentation();
-
- if (!(pid = fork())) {
-
- execvp(as_params[0], (char**)as_params);
- FATAL("Oops, failed to execute '%s' - check your PATH", as_params[0]);
-
- }
-
- if (pid < 0) PFATAL("fork() failed");
-
- if (waitpid(pid, &status, 0) <= 0) PFATAL("waitpid() failed");
-
- if (!getenv("AFL_KEEP_ASSEMBLY")) unlink(modified_file);
-
- exit(WEXITSTATUS(status));
-
-}
-
diff --git a/chromium/third_party/afl/src/afl-as.h b/chromium/third_party/afl/src/afl-as.h
deleted file mode 100644
index ebd571095e5..00000000000
--- a/chromium/third_party/afl/src/afl-as.h
+++ /dev/null
@@ -1,719 +0,0 @@
-/*
- american fuzzy lop - injectable parts
- -------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Forkserver design by Jann Horn <jannhorn@googlemail.com>
-
- Copyright 2013, 2014, 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This file houses the assembly-level instrumentation injected into fuzzed
- programs. The instrumentation stores XORed pairs of data: identifiers of the
- currently executing branch and the one that executed immediately before.
-
- TL;DR: the instrumentation does shm_trace_map[cur_loc ^ prev_loc]++
-
- The code is designed for 32-bit and 64-bit x86 systems. Both modes should
- work everywhere except for Apple systems. Apple does relocations differently
- from everybody else, so since their OSes have been 64-bit for a longer while,
- I didn't go through the mental effort of porting the 32-bit code.
-
- In principle, similar code should be easy to inject into any well-behaved
- binary-only code (e.g., using DynamoRIO). Conditional jumps offer natural
- targets for instrumentation, and should offer comparable probe density.
-
- */
-
-#ifndef _HAVE_AFL_AS_H
-#define _HAVE_AFL_AS_H
-
-#include "config.h"
-#include "types.h"
-
-/*
- ------------------
- Performances notes
- ------------------
-
- Contributions to make this code faster are appreciated! Here are some
- rough notes that may help with the task:
-
- - Only the trampoline_fmt and the non-setup __afl_maybe_log code paths are
- really worth optimizing; the setup / fork server stuff matters a lot less
- and should be mostly just kept readable.
-
- - We're aiming for modern CPUs with out-of-order execution and large
- pipelines; the code is mostly follows intuitive, human-readable
- instruction ordering, because "textbook" manual reorderings make no
- substantial difference.
-
- - Interestingly, instrumented execution isn't a lot faster if we store a
- variable pointer to the setup, log, or return routine and then do a reg
- call from within trampoline_fmt. It does speed up non-instrumented
- execution quite a bit, though, since that path just becomes
- push-call-ret-pop.
-
- - There is also not a whole lot to be gained by doing SHM attach at a
- fixed address instead of retrieving __afl_area_ptr. Although it allows us
- to have a shorter log routine inserted for conditional jumps and jump
- labels (for a ~10% perf gain), there is a risk of bumping into other
- allocations created by the program or by tools such as ASAN.
-
- - popf is *awfully* slow, which is why we're doing the lahf / sahf +
- overflow test trick. Unfortunately, this forces us to taint eax / rax, but
- this dependency on a commonly-used register still beats the alternative of
- using pushf / popf.
-
- One possible optimization is to avoid touching flags by using a circular
- buffer that stores just a sequence of current locations, with the XOR stuff
- happening offline. Alas, this doesn't seem to have a huge impact:
-
- https://groups.google.com/d/msg/afl-users/MsajVf4fRLo/2u6t88ntUBIJ
-
- - Preforking one child a bit sooner, and then waiting for the "go" command
- from within the child, doesn't offer major performance gains; fork() seems
- to be relatively inexpensive these days. Preforking multiple children does
- help, but badly breaks the "~1 core per fuzzer" design, making it harder to
- scale up. Maybe there is some middle ground.
-
- Perhaps of note: in the 64-bit version for all platforms except for Apple,
- the instrumentation is done slightly differently than on 32-bit, with
- __afl_prev_loc and __afl_area_ptr being local to the object file (.lcomm),
- rather than global (.comm). This is to avoid GOTRELPC lookups in the critical
- code path, which AFAICT, are otherwise unavoidable if we want gcc -shared to
- work; simple relocations between .bss and .text won't work on most 64-bit
- platforms in such a case.
-
- (Fun fact: on Apple systems, .lcomm can segfault the linker.)
-
- The side effect is that state transitions are measured in a somewhat
- different way, with previous tuple being recorded separately within the scope
- of every .c file. This should have no impact in any practical sense.
-
- Another side effect of this design is that getenv() will be called once per
- every .o file when running in non-instrumented mode; and since getenv() tends
- to be optimized in funny ways, we need to be very careful to save every
- oddball register it may touch.
-
- */
-
-static const u8* trampoline_fmt_32 =
-
- "\n"
- "/* --- AFL TRAMPOLINE (32-BIT) --- */\n"
- "\n"
- ".align 4\n"
- "\n"
- "leal -16(%%esp), %%esp\n"
- "movl %%edi, 0(%%esp)\n"
- "movl %%edx, 4(%%esp)\n"
- "movl %%ecx, 8(%%esp)\n"
- "movl %%eax, 12(%%esp)\n"
- "movl $0x%08x, %%ecx\n"
- "call __afl_maybe_log\n"
- "movl 12(%%esp), %%eax\n"
- "movl 8(%%esp), %%ecx\n"
- "movl 4(%%esp), %%edx\n"
- "movl 0(%%esp), %%edi\n"
- "leal 16(%%esp), %%esp\n"
- "\n"
- "/* --- END --- */\n"
- "\n";
-
-static const u8* trampoline_fmt_64 =
-
- "\n"
- "/* --- AFL TRAMPOLINE (64-BIT) --- */\n"
- "\n"
- ".align 4\n"
- "\n"
- "leaq -(128+24)(%%rsp), %%rsp\n"
- "movq %%rdx, 0(%%rsp)\n"
- "movq %%rcx, 8(%%rsp)\n"
- "movq %%rax, 16(%%rsp)\n"
- "movq $0x%08x, %%rcx\n"
- "call __afl_maybe_log\n"
- "movq 16(%%rsp), %%rax\n"
- "movq 8(%%rsp), %%rcx\n"
- "movq 0(%%rsp), %%rdx\n"
- "leaq (128+24)(%%rsp), %%rsp\n"
- "\n"
- "/* --- END --- */\n"
- "\n";
-
-static const u8* main_payload_32 =
-
- "\n"
- "/* --- AFL MAIN PAYLOAD (32-BIT) --- */\n"
- "\n"
- ".text\n"
- ".att_syntax\n"
- ".code32\n"
- ".align 8\n"
- "\n"
-
- "__afl_maybe_log:\n"
- "\n"
- " lahf\n"
- " seto %al\n"
- "\n"
- " /* Check if SHM region is already mapped. */\n"
- "\n"
- " movl __afl_area_ptr, %edx\n"
- " testl %edx, %edx\n"
- " je __afl_setup\n"
- "\n"
- "__afl_store:\n"
- "\n"
- " /* Calculate and store hit for the code location specified in ecx. There\n"
- " is a double-XOR way of doing this without tainting another register,\n"
- " and we use it on 64-bit systems; but it's slower for 32-bit ones. */\n"
- "\n"
-#ifndef COVERAGE_ONLY
- " movl __afl_prev_loc, %edi\n"
- " xorl %ecx, %edi\n"
- " shrl $1, %ecx\n"
- " movl %ecx, __afl_prev_loc\n"
-#else
- " movl %ecx, %edi\n"
-#endif /* ^!COVERAGE_ONLY */
- "\n"
-#ifdef SKIP_COUNTS
- " orb $1, (%edx, %edi, 1)\n"
-#else
- " incb (%edx, %edi, 1)\n"
-#endif /* ^SKIP_COUNTS */
- "\n"
- "__afl_return:\n"
- "\n"
- " addb $127, %al\n"
- " sahf\n"
- " ret\n"
- "\n"
- ".align 8\n"
- "\n"
- "__afl_setup:\n"
- "\n"
- " /* Do not retry setup if we had previous failures. */\n"
- "\n"
- " cmpb $0, __afl_setup_failure\n"
- " jne __afl_return\n"
- "\n"
- " /* Map SHM, jumping to __afl_setup_abort if something goes wrong.\n"
- " We do not save FPU/MMX/SSE registers here, but hopefully, nobody\n"
- " will notice this early in the game. */\n"
- "\n"
- " pushl %eax\n"
- " pushl %ecx\n"
- "\n"
- " pushl $.AFL_SHM_ENV\n"
- " call getenv\n"
- " addl $4, %esp\n"
- "\n"
- " testl %eax, %eax\n"
- " je __afl_setup_abort\n"
- "\n"
- " pushl %eax\n"
- " call atoi\n"
- " addl $4, %esp\n"
- "\n"
- " pushl $0 /* shmat flags */\n"
- " pushl $0 /* requested addr */\n"
- " pushl %eax /* SHM ID */\n"
- " call shmat\n"
- " addl $12, %esp\n"
- "\n"
- " cmpl $-1, %eax\n"
- " je __afl_setup_abort\n"
- "\n"
- " /* Store the address of the SHM region. */\n"
- "\n"
- " movl %eax, __afl_area_ptr\n"
- " movl %eax, %edx\n"
- "\n"
- " popl %ecx\n"
- " popl %eax\n"
- "\n"
- "__afl_forkserver:\n"
- "\n"
- " /* Enter the fork server mode to avoid the overhead of execve() calls. */\n"
- "\n"
- " pushl %eax\n"
- " pushl %ecx\n"
- " pushl %edx\n"
- "\n"
- " /* Phone home and tell the parent that we're OK. (Note that signals with\n"
- " no SA_RESTART will mess it up). If this fails, assume that the fd is\n"
- " closed because we were execve()d from an instrumented binary, or because\n"
- " the parent doesn't want to use the fork server. */\n"
- "\n"
- " pushl $4 /* length */\n"
- " pushl $__afl_temp /* data */\n"
- " pushl $" STRINGIFY((FORKSRV_FD + 1)) " /* file desc */\n"
- " call write\n"
- " addl $12, %esp\n"
- "\n"
- " cmpl $4, %eax\n"
- " jne __afl_fork_resume\n"
- "\n"
- "__afl_fork_wait_loop:\n"
- "\n"
- " /* Wait for parent by reading from the pipe. Abort if read fails. */\n"
- "\n"
- " pushl $4 /* length */\n"
- " pushl $__afl_temp /* data */\n"
- " pushl $" STRINGIFY(FORKSRV_FD) " /* file desc */\n"
- " call read\n"
- " addl $12, %esp\n"
- "\n"
- " cmpl $4, %eax\n"
- " jne __afl_die\n"
- "\n"
- " /* Once woken up, create a clone of our process. This is an excellent use\n"
- " case for syscall(__NR_clone, 0, CLONE_PARENT), but glibc boneheadedly\n"
- " caches getpid() results and offers no way to update the value, breaking\n"
- " abort(), raise(), and a bunch of other things :-( */\n"
- "\n"
- " call fork\n"
- "\n"
- " cmpl $0, %eax\n"
- " jl __afl_die\n"
- " je __afl_fork_resume\n"
- "\n"
- " /* In parent process: write PID to pipe, then wait for child. */\n"
- "\n"
- " movl %eax, __afl_fork_pid\n"
- "\n"
- " pushl $4 /* length */\n"
- " pushl $__afl_fork_pid /* data */\n"
- " pushl $" STRINGIFY((FORKSRV_FD + 1)) " /* file desc */\n"
- " call write\n"
- " addl $12, %esp\n"
- "\n"
- " pushl $0 /* no flags */\n"
- " pushl $__afl_temp /* status */\n"
- " pushl __afl_fork_pid /* PID */\n"
- " call waitpid\n"
- " addl $12, %esp\n"
- "\n"
- " cmpl $0, %eax\n"
- " jle __afl_die\n"
- "\n"
- " /* Relay wait status to pipe, then loop back. */\n"
- "\n"
- " pushl $4 /* length */\n"
- " pushl $__afl_temp /* data */\n"
- " pushl $" STRINGIFY((FORKSRV_FD + 1)) " /* file desc */\n"
- " call write\n"
- " addl $12, %esp\n"
- "\n"
- " jmp __afl_fork_wait_loop\n"
- "\n"
- "__afl_fork_resume:\n"
- "\n"
- " /* In child process: close fds, resume execution. */\n"
- "\n"
- " pushl $" STRINGIFY(FORKSRV_FD) "\n"
- " call close\n"
- "\n"
- " pushl $" STRINGIFY((FORKSRV_FD + 1)) "\n"
- " call close\n"
- "\n"
- " addl $8, %esp\n"
- "\n"
- " popl %edx\n"
- " popl %ecx\n"
- " popl %eax\n"
- " jmp __afl_store\n"
- "\n"
- "__afl_die:\n"
- "\n"
- " xorl %eax, %eax\n"
- " call _exit\n"
- "\n"
- "__afl_setup_abort:\n"
- "\n"
- " /* Record setup failure so that we don't keep calling\n"
- " shmget() / shmat() over and over again. */\n"
- "\n"
- " incb __afl_setup_failure\n"
- " popl %ecx\n"
- " popl %eax\n"
- " jmp __afl_return\n"
- "\n"
- ".AFL_VARS:\n"
- "\n"
- " .comm __afl_area_ptr, 4, 32\n"
- " .comm __afl_setup_failure, 1, 32\n"
-#ifndef COVERAGE_ONLY
- " .comm __afl_prev_loc, 4, 32\n"
-#endif /* !COVERAGE_ONLY */
- " .comm __afl_fork_pid, 4, 32\n"
- " .comm __afl_temp, 4, 32\n"
- "\n"
- ".AFL_SHM_ENV:\n"
- " .asciz \"" SHM_ENV_VAR "\"\n"
- "\n"
- "/* --- END --- */\n"
- "\n";
-
-/* The OpenBSD hack is due to lahf and sahf not being recognized by some
- versions of binutils: http://marc.info/?l=openbsd-cvs&m=141636589924400
-
- The Apple code is a bit different when calling libc functions because
- they are doing relocations differently from everybody else. We also need
- to work around the crash issue with .lcomm and the fact that they don't
- recognize .string. */
-
-#ifdef __APPLE__
-# define CALL_L64(str) "call _" str "\n"
-#else
-# define CALL_L64(str) "call " str "@PLT\n"
-#endif /* ^__APPLE__ */
-
-static const u8* main_payload_64 =
-
- "\n"
- "/* --- AFL MAIN PAYLOAD (64-BIT) --- */\n"
- "\n"
- ".text\n"
- ".att_syntax\n"
- ".code64\n"
- ".align 8\n"
- "\n"
- "__afl_maybe_log:\n"
- "\n"
-#if defined(__OpenBSD__) || (defined(__FreeBSD__) && (__FreeBSD__ < 9))
- " .byte 0x9f /* lahf */\n"
-#else
- " lahf\n"
-#endif /* ^__OpenBSD__, etc */
- " seto %al\n"
- "\n"
- " /* Check if SHM region is already mapped. */\n"
- "\n"
- " movq __afl_area_ptr(%rip), %rdx\n"
- " testq %rdx, %rdx\n"
- " je __afl_setup\n"
- "\n"
- "__afl_store:\n"
- "\n"
- " /* Calculate and store hit for the code location specified in rcx. */\n"
- "\n"
-#ifndef COVERAGE_ONLY
- " xorq __afl_prev_loc(%rip), %rcx\n"
- " xorq %rcx, __afl_prev_loc(%rip)\n"
- " shrq $1, __afl_prev_loc(%rip)\n"
-#endif /* ^!COVERAGE_ONLY */
- "\n"
-#ifdef SKIP_COUNTS
- " orb $1, (%rdx, %rcx, 1)\n"
-#else
- " incb (%rdx, %rcx, 1)\n"
-#endif /* ^SKIP_COUNTS */
- "\n"
- "__afl_return:\n"
- "\n"
- " addb $127, %al\n"
-#if defined(__OpenBSD__) || (defined(__FreeBSD__) && (__FreeBSD__ < 9))
- " .byte 0x9e /* sahf */\n"
-#else
- " sahf\n"
-#endif /* ^__OpenBSD__, etc */
- " ret\n"
- "\n"
- ".align 8\n"
- "\n"
- "__afl_setup:\n"
- "\n"
- " /* Do not retry setup if we had previous failures. */\n"
- "\n"
- " cmpb $0, __afl_setup_failure(%rip)\n"
- " jne __afl_return\n"
- "\n"
- " /* Check out if we have a global pointer on file. */\n"
- "\n"
-#ifndef __APPLE__
- " movq __afl_global_area_ptr@GOTPCREL(%rip), %rdx\n"
- " movq (%rdx), %rdx\n"
-#else
- " movq __afl_global_area_ptr(%rip), %rdx\n"
-#endif /* !^__APPLE__ */
- " testq %rdx, %rdx\n"
- " je __afl_setup_first\n"
- "\n"
- " movq %rdx, __afl_area_ptr(%rip)\n"
- " jmp __afl_store\n"
- "\n"
- "__afl_setup_first:\n"
- "\n"
- " /* Save everything that is not yet saved and that may be touched by\n"
- " getenv() and several other libcalls we'll be relying on. */\n"
- "\n"
- " leaq -352(%rsp), %rsp\n"
- "\n"
- " movq %rax, 0(%rsp)\n"
- " movq %rcx, 8(%rsp)\n"
- " movq %rdi, 16(%rsp)\n"
- " movq %rsi, 32(%rsp)\n"
- " movq %r8, 40(%rsp)\n"
- " movq %r9, 48(%rsp)\n"
- " movq %r10, 56(%rsp)\n"
- " movq %r11, 64(%rsp)\n"
- "\n"
- " movq %xmm0, 96(%rsp)\n"
- " movq %xmm1, 112(%rsp)\n"
- " movq %xmm2, 128(%rsp)\n"
- " movq %xmm3, 144(%rsp)\n"
- " movq %xmm4, 160(%rsp)\n"
- " movq %xmm5, 176(%rsp)\n"
- " movq %xmm6, 192(%rsp)\n"
- " movq %xmm7, 208(%rsp)\n"
- " movq %xmm8, 224(%rsp)\n"
- " movq %xmm9, 240(%rsp)\n"
- " movq %xmm10, 256(%rsp)\n"
- " movq %xmm11, 272(%rsp)\n"
- " movq %xmm12, 288(%rsp)\n"
- " movq %xmm13, 304(%rsp)\n"
- " movq %xmm14, 320(%rsp)\n"
- " movq %xmm15, 336(%rsp)\n"
- "\n"
- " /* Map SHM, jumping to __afl_setup_abort if something goes wrong. */\n"
- "\n"
- " /* The 64-bit ABI requires 16-byte stack alignment. We'll keep the\n"
- " original stack ptr in the callee-saved r12. */\n"
- "\n"
- " pushq %r12\n"
- " movq %rsp, %r12\n"
- " subq $16, %rsp\n"
- " andq $0xfffffffffffffff0, %rsp\n"
- "\n"
- " leaq .AFL_SHM_ENV(%rip), %rdi\n"
- CALL_L64("getenv")
- "\n"
- " testq %rax, %rax\n"
- " je __afl_setup_abort\n"
- "\n"
- " movq %rax, %rdi\n"
- CALL_L64("atoi")
- "\n"
- " xorq %rdx, %rdx /* shmat flags */\n"
- " xorq %rsi, %rsi /* requested addr */\n"
- " movq %rax, %rdi /* SHM ID */\n"
- CALL_L64("shmat")
- "\n"
- " cmpq $-1, %rax\n"
- " je __afl_setup_abort\n"
- "\n"
- " /* Store the address of the SHM region. */\n"
- "\n"
- " movq %rax, %rdx\n"
- " movq %rax, __afl_area_ptr(%rip)\n"
- "\n"
-#ifdef __APPLE__
- " movq %rax, __afl_global_area_ptr(%rip)\n"
-#else
- " movq __afl_global_area_ptr@GOTPCREL(%rip), %rdx\n"
- " movq %rax, (%rdx)\n"
-#endif /* ^__APPLE__ */
- " movq %rax, %rdx\n"
- "\n"
- "__afl_forkserver:\n"
- "\n"
- " /* Enter the fork server mode to avoid the overhead of execve() calls. We\n"
- " push rdx (area ptr) twice to keep stack alignment neat. */\n"
- "\n"
- " pushq %rdx\n"
- " pushq %rdx\n"
- "\n"
- " /* Phone home and tell the parent that we're OK. (Note that signals with\n"
- " no SA_RESTART will mess it up). If this fails, assume that the fd is\n"
- " closed because we were execve()d from an instrumented binary, or because\n"
- " the parent doesn't want to use the fork server. */\n"
- "\n"
- " movq $4, %rdx /* length */\n"
- " leaq __afl_temp(%rip), %rsi /* data */\n"
- " movq $" STRINGIFY((FORKSRV_FD + 1)) ", %rdi /* file desc */\n"
- CALL_L64("write")
- "\n"
- " cmpq $4, %rax\n"
- " jne __afl_fork_resume\n"
- "\n"
- "__afl_fork_wait_loop:\n"
- "\n"
- " /* Wait for parent by reading from the pipe. Abort if read fails. */\n"
- "\n"
- " movq $4, %rdx /* length */\n"
- " leaq __afl_temp(%rip), %rsi /* data */\n"
- " movq $" STRINGIFY(FORKSRV_FD) ", %rdi /* file desc */\n"
- CALL_L64("read")
- " cmpq $4, %rax\n"
- " jne __afl_die\n"
- "\n"
- " /* Once woken up, create a clone of our process. This is an excellent use\n"
- " case for syscall(__NR_clone, 0, CLONE_PARENT), but glibc boneheadedly\n"
- " caches getpid() results and offers no way to update the value, breaking\n"
- " abort(), raise(), and a bunch of other things :-( */\n"
- "\n"
- CALL_L64("fork")
- " cmpq $0, %rax\n"
- " jl __afl_die\n"
- " je __afl_fork_resume\n"
- "\n"
- " /* In parent process: write PID to pipe, then wait for child. */\n"
- "\n"
- " movl %eax, __afl_fork_pid(%rip)\n"
- "\n"
- " movq $4, %rdx /* length */\n"
- " leaq __afl_fork_pid(%rip), %rsi /* data */\n"
- " movq $" STRINGIFY((FORKSRV_FD + 1)) ", %rdi /* file desc */\n"
- CALL_L64("write")
- "\n"
- " movq $0, %rdx /* no flags */\n"
- " leaq __afl_temp(%rip), %rsi /* status */\n"
- " movq __afl_fork_pid(%rip), %rdi /* PID */\n"
- CALL_L64("waitpid")
- " cmpq $0, %rax\n"
- " jle __afl_die\n"
- "\n"
- " /* Relay wait status to pipe, then loop back. */\n"
- "\n"
- " movq $4, %rdx /* length */\n"
- " leaq __afl_temp(%rip), %rsi /* data */\n"
- " movq $" STRINGIFY((FORKSRV_FD + 1)) ", %rdi /* file desc */\n"
- CALL_L64("write")
- "\n"
- " jmp __afl_fork_wait_loop\n"
- "\n"
- "__afl_fork_resume:\n"
- "\n"
- " /* In child process: close fds, resume execution. */\n"
- "\n"
- " movq $" STRINGIFY(FORKSRV_FD) ", %rdi\n"
- CALL_L64("close")
- "\n"
- " movq $" STRINGIFY((FORKSRV_FD + 1)) ", %rdi\n"
- CALL_L64("close")
- "\n"
- " popq %rdx\n"
- " popq %rdx\n"
- "\n"
- " movq %r12, %rsp\n"
- " popq %r12\n"
- "\n"
- " movq 0(%rsp), %rax\n"
- " movq 8(%rsp), %rcx\n"
- " movq 16(%rsp), %rdi\n"
- " movq 32(%rsp), %rsi\n"
- " movq 40(%rsp), %r8\n"
- " movq 48(%rsp), %r9\n"
- " movq 56(%rsp), %r10\n"
- " movq 64(%rsp), %r11\n"
- "\n"
- " movq 96(%rsp), %xmm0\n"
- " movq 112(%rsp), %xmm1\n"
- " movq 128(%rsp), %xmm2\n"
- " movq 144(%rsp), %xmm3\n"
- " movq 160(%rsp), %xmm4\n"
- " movq 176(%rsp), %xmm5\n"
- " movq 192(%rsp), %xmm6\n"
- " movq 208(%rsp), %xmm7\n"
- " movq 224(%rsp), %xmm8\n"
- " movq 240(%rsp), %xmm9\n"
- " movq 256(%rsp), %xmm10\n"
- " movq 272(%rsp), %xmm11\n"
- " movq 288(%rsp), %xmm12\n"
- " movq 304(%rsp), %xmm13\n"
- " movq 320(%rsp), %xmm14\n"
- " movq 336(%rsp), %xmm15\n"
- "\n"
- " leaq 352(%rsp), %rsp\n"
- "\n"
- " jmp __afl_store\n"
- "\n"
- "__afl_die:\n"
- "\n"
- " xorq %rax, %rax\n"
- CALL_L64("_exit")
- "\n"
- "__afl_setup_abort:\n"
- "\n"
- " /* Record setup failure so that we don't keep calling\n"
- " shmget() / shmat() over and over again. */\n"
- "\n"
- " incb __afl_setup_failure(%rip)\n"
- "\n"
- " movq %r12, %rsp\n"
- " popq %r12\n"
- "\n"
- " movq 0(%rsp), %rax\n"
- " movq 8(%rsp), %rcx\n"
- " movq 16(%rsp), %rdi\n"
- " movq 32(%rsp), %rsi\n"
- " movq 40(%rsp), %r8\n"
- " movq 48(%rsp), %r9\n"
- " movq 56(%rsp), %r10\n"
- " movq 64(%rsp), %r11\n"
- "\n"
- " movq 96(%rsp), %xmm0\n"
- " movq 112(%rsp), %xmm1\n"
- " movq 128(%rsp), %xmm2\n"
- " movq 144(%rsp), %xmm3\n"
- " movq 160(%rsp), %xmm4\n"
- " movq 176(%rsp), %xmm5\n"
- " movq 192(%rsp), %xmm6\n"
- " movq 208(%rsp), %xmm7\n"
- " movq 224(%rsp), %xmm8\n"
- " movq 240(%rsp), %xmm9\n"
- " movq 256(%rsp), %xmm10\n"
- " movq 272(%rsp), %xmm11\n"
- " movq 288(%rsp), %xmm12\n"
- " movq 304(%rsp), %xmm13\n"
- " movq 320(%rsp), %xmm14\n"
- " movq 336(%rsp), %xmm15\n"
- "\n"
- " leaq 352(%rsp), %rsp\n"
- "\n"
- " jmp __afl_return\n"
- "\n"
- ".AFL_VARS:\n"
- "\n"
-
-#ifdef __APPLE__
-
- " .comm __afl_area_ptr, 8\n"
-#ifndef COVERAGE_ONLY
- " .comm __afl_prev_loc, 8\n"
-#endif /* !COVERAGE_ONLY */
- " .comm __afl_fork_pid, 4\n"
- " .comm __afl_temp, 4\n"
- " .comm __afl_setup_failure, 1\n"
-
-#else
-
- " .lcomm __afl_area_ptr, 8\n"
-#ifndef COVERAGE_ONLY
- " .lcomm __afl_prev_loc, 8\n"
-#endif /* !COVERAGE_ONLY */
- " .lcomm __afl_fork_pid, 4\n"
- " .lcomm __afl_temp, 4\n"
- " .lcomm __afl_setup_failure, 1\n"
-
-#endif /* ^__APPLE__ */
-
- " .comm __afl_global_area_ptr, 8, 8\n"
- "\n"
- ".AFL_SHM_ENV:\n"
- " .asciz \"" SHM_ENV_VAR "\"\n"
- "\n"
- "/* --- END --- */\n"
- "\n";
-
-#endif /* !_HAVE_AFL_AS_H */
diff --git a/chromium/third_party/afl/src/afl-cmin b/chromium/third_party/afl/src/afl-cmin
deleted file mode 100755
index 5af4b7744c4..00000000000
--- a/chromium/third_party/afl/src/afl-cmin
+++ /dev/null
@@ -1,447 +0,0 @@
-#!/usr/bin/env bash
-#
-# american fuzzy lop - corpus minimization tool
-# ---------------------------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2014, 2015 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# This tool tries to find the smallest subset of files in the input directory
-# that still trigger the full range of instrumentation data points seen in
-# the starting corpus. This has two uses:
-#
-# - Screening large corpora of input files before using them as a seed for
-# afl-fuzz. The tool will remove functionally redundant files and likely
-# leave you with a much smaller set.
-#
-# (In this case, you probably also want to consider running afl-tmin on
-# the individual files later on to reduce their size.)
-#
-# - Minimizing the corpus generated organically by afl-fuzz, perhaps when
-# planning to feed it to more resource-intensive tools. The tool achieves
-# this by removing all entries that used to trigger unique behaviors in the
-# past, but have been made obsolete by later finds.
-#
-# Note that the tool doesn't modify the files themselves. For that, you want
-# afl-tmin.
-#
-# This script must use bash because other shells may have hardcoded limits on
-# array sizes.
-#
-
-echo "corpus minimization tool for afl-fuzz by <lcamtuf@google.com>"
-echo
-
-#########
-# SETUP #
-#########
-
-# Process command-line options...
-
-MEM_LIMIT=100
-TIMEOUT=none
-
-unset IN_DIR OUT_DIR STDIN_FILE EXTRA_PAR MEM_LIMIT_GIVEN \
- AFL_CMIN_CRASHES_ONLY AFL_CMIN_ALLOW_ANY QEMU_MODE
-
-while getopts "+i:o:f:m:t:eQC" opt; do
-
- case "$opt" in
-
- "i")
- IN_DIR="$OPTARG"
- ;;
-
- "o")
- OUT_DIR="$OPTARG"
- ;;
- "f")
- STDIN_FILE="$OPTARG"
- ;;
- "m")
- MEM_LIMIT="$OPTARG"
- MEM_LIMIT_GIVEN=1
- ;;
- "t")
- TIMEOUT="$OPTARG"
- ;;
- "e")
- EXTRA_PAR="$EXTRA_PAR -e"
- ;;
- "C")
- export AFL_CMIN_CRASHES_ONLY=1
- ;;
- "Q")
- EXTRA_PAR="$EXTRA_PAR -Q"
- test "$MEM_LIMIT_GIVEN" = "" && MEM_LIMIT=250
- QEMU_MODE=1
- ;;
- "?")
- exit 1
- ;;
-
- esac
-
-done
-
-shift $((OPTIND-1))
-
-TARGET_BIN="$1"
-
-if [ "$TARGET_BIN" = "" -o "$IN_DIR" = "" -o "$OUT_DIR" = "" ]; then
-
- cat 1>&2 <<_EOF_
-Usage: $0 [ options ] -- /path/to/target_app [ ... ]
-
-Required parameters:
-
- -i dir - input directory with the starting corpus
- -o dir - output directory for minimized files
-
-Execution control settings:
-
- -f file - location read by the fuzzed program (stdin)
- -m megs - memory limit for child process ($MEM_LIMIT MB)
- -t msec - run time limit for child process (none)
- -Q - use binary-only instrumentation (QEMU mode)
-
-Minimization settings:
-
- -C - keep crashing inputs, reject everything else
- -e - solve for edge coverage only, ignore hit counts
-
-For additional tips, please consult docs/README.
-
-_EOF_
- exit 1
-fi
-
-# Do a sanity check to discourage the use of /tmp, since we can't really
-# handle this safely from a shell script.
-
-echo "$IN_DIR" | grep -qE '^(/var)?/tmp/'
-T1="$?"
-
-echo "$TARGET_BIN" | grep -qE '^(/var)?/tmp/'
-T2="$?"
-
-echo "$OUT_DIR" | grep -qE '^(/var)?/tmp/'
-T3="$?"
-
-echo "$STDIN_FILE" | grep -qE '^(/var)?/tmp/'
-T4="$?"
-
-echo "$PWD" | grep -qE '^(/var)?/tmp/'
-T5="$?"
-
-if [ "$T1" = "0" -o "$T2" = "0" -o "$T3" = "0" -o "$T4" = "0" -o "$T5" = "0" ]; then
- echo "[-] Error: do not use this script in /tmp or /var/tmp." 1>&2
- exit 1
-fi
-
-# If @@ is specified, but there's no -f, let's come up with a temporary input
-# file name.
-
-TRACE_DIR="$OUT_DIR/.traces"
-
-if [ "$STDIN_FILE" = "" ]; then
-
- if echo "$*" | grep -qF '@@'; then
- STDIN_FILE="$TRACE_DIR/.cur_input"
- fi
-
-fi
-
-# Check for obvious errors.
-
-if [ ! "$MEM_LIMIT" = "none" ]; then
-
- if [ "$MEM_LIMIT" -lt "5" ]; then
- echo "[-] Error: dangerously low memory limit." 1>&2
- exit 1
- fi
-
-fi
-
-if [ ! "$TIMEOUT" = "none" ]; then
-
- if [ "$TIMEOUT" -lt "10" ]; then
- echo "[-] Error: dangerously low timeout." 1>&2
- exit 1
- fi
-
-fi
-
-if [ ! -f "$TARGET_BIN" -o ! -x "$TARGET_BIN" ]; then
-
- TNEW="`which "$TARGET_BIN" 2>/dev/null`"
-
- if [ ! -f "$TNEW" -o ! -x "$TNEW" ]; then
- echo "[-] Error: binary '$TARGET_BIN' not found or not executable." 1>&2
- exit 1
- fi
-
- TARGET_BIN="$TNEW"
-
-fi
-
-if [ "$AFL_SKIP_BIN_CHECK" = "" -a "$QEMU_MODE" = "" ]; then
-
- if ! grep -qF "__AFL_SHM_ID" "$TARGET_BIN"; then
- echo "[-] Error: binary '$TARGET_BIN' doesn't appear to be instrumented." 1>&2
- exit 1
- fi
-
-fi
-
-if [ ! -d "$IN_DIR" ]; then
- echo "[-] Error: directory '$IN_DIR' not found." 1>&2
- exit 1
-fi
-
-test -d "$IN_DIR/queue" && IN_DIR="$IN_DIR/queue"
-
-find "$OUT_DIR" -name 'id[:_]*' -maxdepth 1 -exec rm -- {} \; 2>/dev/null
-rm -rf "$TRACE_DIR" 2>/dev/null
-
-rmdir "$OUT_DIR" 2>/dev/null
-
-if [ -d "$OUT_DIR" ]; then
- echo "[-] Error: directory '$OUT_DIR' exists and is not empty - delete it first." 1>&2
- exit 1
-fi
-
-mkdir -m 700 -p "$TRACE_DIR" || exit 1
-
-if [ ! "$STDIN_FILE" = "" ]; then
- rm -f "$STDIN_FILE" || exit 1
- touch "$STDIN_FILE" || exit 1
-fi
-
-if [ "$AFL_PATH" = "" ]; then
- SHOWMAP="${0%/afl-cmin}/afl-showmap"
-else
- SHOWMAP="$AFL_PATH/afl-showmap"
-fi
-
-if [ ! -x "$SHOWMAP" ]; then
- echo "[-] Error: can't find 'afl-showmap' - please set AFL_PATH." 1>&2
- rm -rf "$TRACE_DIR"
- exit 1
-fi
-
-IN_COUNT=$((`ls -- "$IN_DIR" 2>/dev/null | wc -l`))
-
-if [ "$IN_COUNT" = "0" ]; then
- echo "No inputs in the target directory - nothing to be done."
- rm -rf "$TRACE_DIR"
- exit 1
-fi
-
-FIRST_FILE=`ls "$IN_DIR" | head -1`
-
-if ln "$IN_DIR/$FIRST_FILE" "$TRACE_DIR/.link_test" 2>/dev/null; then
- CP_TOOL=ln
-else
- CP_TOOL=cp
-fi
-
-# Make sure that we can actually get anything out of afl-showmap before we
-# waste too much time.
-
-echo "[*] Testing the target binary..."
-
-if [ "$STDIN_FILE" = "" ]; then
-
- AFL_CMIN_ALLOW_ANY=1 "$SHOWMAP" -m "$MEM_LIMIT" -t "$TIMEOUT" -o "$TRACE_DIR/.run_test" -Z $EXTRA_PAR -- "$@" <"$IN_DIR/$FIRST_FILE"
-
-else
-
- cp "$IN_DIR/$FIRST_FILE" "$STDIN_FILE"
- AFL_CMIN_ALLOW_ANY=1 "$SHOWMAP" -m "$MEM_LIMIT" -t "$TIMEOUT" -o "$TRACE_DIR/.run_test" -Z $EXTRA_PAR -A "$STDIN_FILE" -- "$@" </dev/null
-
-fi
-
-FIRST_COUNT=$((`grep -c . "$TRACE_DIR/.run_test"`))
-
-if [ "$FIRST_COUNT" -gt "0" ]; then
-
- echo "[+] OK, $FIRST_COUNT tuples recorded."
-
-else
-
- echo "[-] Error: no instrumentation output detected (perhaps crash or timeout)." 1>&2
- test "$AFL_KEEP_TRACES" = "" && rm -rf "$TRACE_DIR"
- exit 1
-
-fi
-
-# Let's roll!
-
-#############################
-# STEP 1: COLLECTING TRACES #
-#############################
-
-echo "[*] Obtaining traces for input files in '$IN_DIR'..."
-
-(
-
- CUR=0
-
- if [ "$STDIN_FILE" = "" ]; then
-
- while read -r fn; do
-
- CUR=$((CUR+1))
- printf "\\r Processing file $CUR/$IN_COUNT... "
-
- "$SHOWMAP" -m "$MEM_LIMIT" -t "$TIMEOUT" -o "$TRACE_DIR/$fn" -Z $EXTRA_PAR -- "$@" <"$IN_DIR/$fn"
-
- done < <(ls "$IN_DIR")
-
- else
-
- while read -r fn; do
-
- CUR=$((CUR+1))
- printf "\\r Processing file $CUR/$IN_COUNT... "
-
- cp "$IN_DIR/$fn" "$STDIN_FILE"
-
- "$SHOWMAP" -m "$MEM_LIMIT" -t "$TIMEOUT" -o "$TRACE_DIR/$fn" -Z $EXTRA_PAR -A "$STDIN_FILE" -- "$@" </dev/null
-
- done < <(ls "$IN_DIR")
-
-
- fi
-
-)
-
-echo
-
-##########################
-# STEP 2: SORTING TUPLES #
-##########################
-
-# With this out of the way, we sort all tuples by popularity across all
-# datasets. The reasoning here is that we won't be able to avoid the files
-# that trigger unique tuples anyway, so we will want to start with them and
-# see what's left.
-
-echo "[*] Sorting trace sets (this may take a while)..."
-
-ls "$IN_DIR" | sed "s#^#$TRACE_DIR/#" | tr '\n' '\0' | xargs -0 -n 1 cat | \
- sort | uniq -c | sort -n >"$TRACE_DIR/.all_uniq"
-
-TUPLE_COUNT=$((`grep -c . "$TRACE_DIR/.all_uniq"`))
-
-echo "[+] Found $TUPLE_COUNT unique tuples across $IN_COUNT files."
-
-#####################################
-# STEP 3: SELECTING CANDIDATE FILES #
-#####################################
-
-# The next step is to find the best candidate for each tuple. The "best"
-# part is understood simply as the smallest input that includes a particular
-# tuple in its trace. Empirical evidence suggests that this produces smaller
-# datasets than more involved algorithms that could be still pulled off in
-# a shell script.
-
-echo "[*] Finding best candidates for each tuple..."
-
-CUR=0
-
-while read -r fn; do
-
- CUR=$((CUR+1))
- printf "\\r Processing file $CUR/$IN_COUNT... "
-
- sed "s#\$# $fn#" "$TRACE_DIR/$fn" >>"$TRACE_DIR/.candidate_list"
-
-done < <(ls -rS "$IN_DIR")
-
-echo
-
-##############################
-# STEP 4: LOADING CANDIDATES #
-##############################
-
-# At this point, we have a file of tuple-file pairs, sorted by file size
-# in ascending order (as a consequence of ls -rS). By doing sort keyed
-# only by tuple (-k 1,1) and configured to output only the first line for
-# every key (-s -u), we end up with the smallest file for each tuple.
-
-echo "[*] Sorting candidate list (be patient)..."
-
-sort -k1,1 -s -u "$TRACE_DIR/.candidate_list" | \
- sed 's/^/BEST_FILE[/;s/ /]="/;s/$/"/' >"$TRACE_DIR/.candidate_script"
-
-if [ ! -s "$TRACE_DIR/.candidate_script" ]; then
- echo "[-] Error: no traces obtained from test cases, check syntax!"
- test "$AFL_KEEP_TRACES" = "" && rm -rf "$TRACE_DIR"
- exit 1
-fi
-
-# The sed command converted the sorted list to a shell script that populates
-# BEST_FILE[tuple]="fname". Let's load that!
-
-. "$TRACE_DIR/.candidate_script"
-
-##########################
-# STEP 5: WRITING OUTPUT #
-##########################
-
-# The final trick is to grab the top pick for each tuple, unless said tuple is
-# already set due to the inclusion of an earlier candidate; and then put all
-# tuples associated with the newly-added file to the "already have" list. The
-# loop works from least popular tuples and toward the most common ones.
-
-echo "[*] Processing candidates and writing output files..."
-
-CUR=0
-
-touch "$TRACE_DIR/.already_have"
-
-while read -r cnt tuple; do
-
- CUR=$((CUR+1))
- printf "\\r Processing tuple $CUR/$TUPLE_COUNT... "
-
- # If we already have this tuple, skip it.
-
- grep -q "^$tuple\$" "$TRACE_DIR/.already_have" && continue
-
- FN=${BEST_FILE[tuple]}
-
- $CP_TOOL "$IN_DIR/$FN" "$OUT_DIR/$FN"
-
- if [ "$((CUR % 5))" = "0" ]; then
- sort -u "$TRACE_DIR/$FN" "$TRACE_DIR/.already_have" >"$TRACE_DIR/.tmp"
- mv -f "$TRACE_DIR/.tmp" "$TRACE_DIR/.already_have"
- else
- cat "$TRACE_DIR/$FN" >>"$TRACE_DIR/.already_have"
- fi
-
-done <"$TRACE_DIR/.all_uniq"
-
-echo
-
-OUT_COUNT=`ls -- "$OUT_DIR" | wc -l`
-
-if [ "$OUT_COUNT" = "1" ]; then
- echo "[!] WARNING: All test cases had the same traces, check syntax!"
-fi
-
-echo "[+] Narrowed down to $OUT_COUNT files, saved in '$OUT_DIR'."
-echo
-
-test "$AFL_KEEP_TRACES" = "" && rm -rf "$TRACE_DIR"
-
-exit 0
diff --git a/chromium/third_party/afl/src/afl-fuzz.c b/chromium/third_party/afl/src/afl-fuzz.c
deleted file mode 100644
index e730cb29364..00000000000
--- a/chromium/third_party/afl/src/afl-fuzz.c
+++ /dev/null
@@ -1,8005 +0,0 @@
-/*
- american fuzzy lop - fuzzer code
- --------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Forkserver design by Jann Horn <jannhorn@googlemail.com>
-
- Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This is the real deal: the program takes an instrumented binary and
- attempts a variety of basic fuzzing tricks, paying close attention to
- how they affect the execution path.
-
- */
-
-#define AFL_MAIN
-#define MESSAGES_TO_STDOUT
-
-#define _GNU_SOURCE
-#define _FILE_OFFSET_BITS 64
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-#include "alloc-inl.h"
-#include "hash.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <dlfcn.h>
-#include <sched.h>
-
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__)
-# include <sys/sysctl.h>
-#endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */
-
-/* For systems that have sched_setaffinity; right now just Linux, but one
- can hope... */
-
-#ifdef __linux__
-# define HAVE_AFFINITY 1
-#endif /* __linux__ */
-
-/* A toggle to export some variables when building as a library. Not very
- useful for the general public. */
-
-#ifdef AFL_LIB
-# define EXP_ST
-#else
-# define EXP_ST static
-#endif /* ^AFL_LIB */
-
-/* Lots of globals, but mostly for the status UI and other things where it
- really makes no sense to haul them around as function parameters. */
-
-
-EXP_ST u8 *in_dir, /* Input directory with test cases */
- *out_file, /* File to fuzz, if any */
- *out_dir, /* Working & output directory */
- *sync_dir, /* Synchronization directory */
- *sync_id, /* Fuzzer ID */
- *use_banner, /* Display banner */
- *in_bitmap, /* Input bitmap */
- *doc_path, /* Path to documentation dir */
- *target_path, /* Path to target binary */
- *orig_cmdline; /* Original command line */
-
-EXP_ST u32 exec_tmout = EXEC_TIMEOUT; /* Configurable exec timeout (ms) */
-EXP_ST u64 mem_limit = MEM_LIMIT; /* Memory cap for child (MB) */
-
-static u32 stats_update_freq = 1; /* Stats update frequency (execs) */
-
-EXP_ST u8 skip_deterministic, /* Skip deterministic stages? */
- force_deterministic, /* Force deterministic stages? */
- use_splicing, /* Recombine input files? */
- dumb_mode, /* Run in non-instrumented mode? */
- score_changed, /* Scoring for favorites changed? */
- kill_signal, /* Signal that killed the child */
- resuming_fuzz, /* Resuming an older fuzzing job? */
- timeout_given, /* Specific timeout given? */
- not_on_tty, /* stdout is not a tty */
- term_too_small, /* terminal dimensions too small */
- uses_asan, /* Target uses ASAN? */
- no_forkserver, /* Disable forkserver? */
- crash_mode, /* Crash mode! Yeah! */
- in_place_resume, /* Attempt in-place resume? */
- auto_changed, /* Auto-generated tokens changed? */
- no_cpu_meter_red, /* Feng shui on the status screen */
- shuffle_queue, /* Shuffle input queue? */
- bitmap_changed = 1, /* Time to update bitmap? */
- qemu_mode, /* Running in QEMU mode? */
- skip_requested, /* Skip request, via SIGUSR1 */
- run_over10m, /* Run time over 10 minutes? */
- persistent_mode; /* Running in persistent mode? */
-
-static s32 out_fd, /* Persistent fd for out_file */
- dev_urandom_fd = -1, /* Persistent fd for /dev/urandom */
- dev_null_fd = -1, /* Persistent fd for /dev/null */
- fsrv_ctl_fd, /* Fork server control pipe (write) */
- fsrv_st_fd; /* Fork server status pipe (read) */
-
-static s32 forksrv_pid, /* PID of the fork server */
- child_pid = -1, /* PID of the fuzzed program */
- out_dir_fd = -1; /* FD of the lock file */
-
-EXP_ST u8* trace_bits; /* SHM with instrumentation bitmap */
-
-EXP_ST u8 virgin_bits[MAP_SIZE], /* Regions yet untouched by fuzzing */
- virgin_hang[MAP_SIZE], /* Bits we haven't seen in hangs */
- virgin_crash[MAP_SIZE]; /* Bits we haven't seen in crashes */
-
-static u8 var_bytes[MAP_SIZE]; /* Bytes that appear to be variable */
-
-static s32 shm_id; /* ID of the SHM region */
-
-static volatile u8 stop_soon, /* Ctrl-C pressed? */
- clear_screen = 1, /* Window resized? */
- child_timed_out; /* Traced process timed out? */
-
-EXP_ST u32 queued_paths, /* Total number of queued testcases */
- queued_variable, /* Testcases with variable behavior */
- queued_at_start, /* Total number of initial inputs */
- queued_discovered, /* Items discovered during this run */
- queued_imported, /* Items imported via -S */
- queued_favored, /* Paths deemed favorable */
- queued_with_cov, /* Paths with new coverage bytes */
- pending_not_fuzzed, /* Queued but not done yet */
- pending_favored, /* Pending favored paths */
- cur_skipped_paths, /* Abandoned inputs in cur cycle */
- cur_depth, /* Current path depth */
- max_depth, /* Max path depth */
- useless_at_start, /* Number of useless starting paths */
- var_byte_count, /* Bitmap bytes with var behavior */
- current_entry, /* Current queue entry ID */
- havoc_div = 1; /* Cycle count divisor for havoc */
-
-EXP_ST u64 total_crashes, /* Total number of crashes */
- unique_crashes, /* Crashes with unique signatures */
- total_hangs, /* Total number of hangs */
- unique_hangs, /* Hangs with unique signatures */
- total_execs, /* Total execve() calls */
- start_time, /* Unix start time (ms) */
- last_path_time, /* Time for most recent path (ms) */
- last_crash_time, /* Time for most recent crash (ms) */
- last_hang_time, /* Time for most recent hang (ms) */
- last_crash_execs, /* Exec counter at last crash */
- queue_cycle, /* Queue round counter */
- cycles_wo_finds, /* Cycles without any new paths */
- trim_execs, /* Execs done to trim input files */
- bytes_trim_in, /* Bytes coming into the trimmer */
- bytes_trim_out, /* Bytes coming outa the trimmer */
- blocks_eff_total, /* Blocks subject to effector maps */
- blocks_eff_select; /* Blocks selected as fuzzable */
-
-static u32 subseq_hangs; /* Number of hangs in a row */
-
-static u8 *stage_name = "init", /* Name of the current fuzz stage */
- *stage_short, /* Short stage name */
- *syncing_party; /* Currently syncing with... */
-
-static s32 stage_cur, stage_max; /* Stage progression */
-static s32 splicing_with = -1; /* Splicing with which test case? */
-
-static u32 master_id, master_max; /* Master instance job splitting */
-
-static u32 syncing_case; /* Syncing with case #... */
-
-static s32 stage_cur_byte, /* Byte offset of current stage op */
- stage_cur_val; /* Value used for stage op */
-
-static u8 stage_val_type; /* Value type (STAGE_VAL_*) */
-
-static u64 stage_finds[32], /* Patterns found per fuzz stage */
- stage_cycles[32]; /* Execs per fuzz stage */
-
-static u32 rand_cnt; /* Random number counter */
-
-static u64 total_cal_us, /* Total calibration time (us) */
- total_cal_cycles; /* Total calibration cycles */
-
-static u64 total_bitmap_size, /* Total bit count for all bitmaps */
- total_bitmap_entries; /* Number of bitmaps counted */
-
-static s32 cpu_core_count; /* CPU core count */
-
-#ifdef HAVE_AFFINITY
-
-static s32 cpu_aff = -1; /* Selected CPU core */
-
-#endif /* HAVE_AFFINITY */
-
-static FILE* plot_file; /* Gnuplot output file */
-
-struct queue_entry {
-
- u8* fname; /* File name for the test case */
- u32 len; /* Input length */
-
- u8 cal_failed, /* Calibration failed? */
- trim_done, /* Trimmed? */
- was_fuzzed, /* Had any fuzzing done yet? */
- passed_det, /* Deterministic stages passed? */
- has_new_cov, /* Triggers new coverage? */
- var_behavior, /* Variable behavior? */
- favored, /* Currently favored? */
- fs_redundant; /* Marked as redundant in the fs? */
-
- u32 bitmap_size, /* Number of bits set in bitmap */
- exec_cksum; /* Checksum of the execution trace */
-
- u64 exec_us, /* Execution time (us) */
- handicap, /* Number of queue cycles behind */
- depth; /* Path depth */
-
- u8* trace_mini; /* Trace bytes, if kept */
- u32 tc_ref; /* Trace bytes ref count */
-
- struct queue_entry *next, /* Next element, if any */
- *next_100; /* 100 elements ahead */
-
-};
-
-static struct queue_entry *queue, /* Fuzzing queue (linked list) */
- *queue_cur, /* Current offset within the queue */
- *queue_top, /* Top of the list */
- *q_prev100; /* Previous 100 marker */
-
-static struct queue_entry*
- top_rated[MAP_SIZE]; /* Top entries for bitmap bytes */
-
-struct extra_data {
- u8* data; /* Dictionary token data */
- u32 len; /* Dictionary token length */
- u32 hit_cnt; /* Use count in the corpus */
-};
-
-static struct extra_data* extras; /* Extra tokens to fuzz with */
-static u32 extras_cnt; /* Total number of tokens read */
-
-static struct extra_data* a_extras; /* Automatically selected extras */
-static u32 a_extras_cnt; /* Total number of tokens available */
-
-static u8* (*post_handler)(u8* buf, u32* len);
-
-/* Interesting values, as per config.h */
-
-static s8 interesting_8[] = { INTERESTING_8 };
-static s16 interesting_16[] = { INTERESTING_8, INTERESTING_16 };
-static s32 interesting_32[] = { INTERESTING_8, INTERESTING_16, INTERESTING_32 };
-
-/* Fuzzing stages */
-
-enum {
- /* 00 */ STAGE_FLIP1,
- /* 01 */ STAGE_FLIP2,
- /* 02 */ STAGE_FLIP4,
- /* 03 */ STAGE_FLIP8,
- /* 04 */ STAGE_FLIP16,
- /* 05 */ STAGE_FLIP32,
- /* 06 */ STAGE_ARITH8,
- /* 07 */ STAGE_ARITH16,
- /* 08 */ STAGE_ARITH32,
- /* 09 */ STAGE_INTEREST8,
- /* 10 */ STAGE_INTEREST16,
- /* 11 */ STAGE_INTEREST32,
- /* 12 */ STAGE_EXTRAS_UO,
- /* 13 */ STAGE_EXTRAS_UI,
- /* 14 */ STAGE_EXTRAS_AO,
- /* 15 */ STAGE_HAVOC,
- /* 16 */ STAGE_SPLICE
-};
-
-/* Stage value types */
-
-enum {
- /* 00 */ STAGE_VAL_NONE,
- /* 01 */ STAGE_VAL_LE,
- /* 02 */ STAGE_VAL_BE
-};
-
-/* Execution status fault codes */
-
-enum {
- /* 00 */ FAULT_NONE,
- /* 01 */ FAULT_HANG,
- /* 02 */ FAULT_CRASH,
- /* 03 */ FAULT_ERROR,
- /* 04 */ FAULT_NOINST,
- /* 05 */ FAULT_NOBITS
-};
-
-
-/* Get unix time in milliseconds */
-
-static u64 get_cur_time(void) {
-
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
-
- return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000);
-
-}
-
-
-/* Get unix time in microseconds */
-
-static u64 get_cur_time_us(void) {
-
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
-
- return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
-
-}
-
-
-/* Generate a random number (from 0 to limit - 1). This may
- have slight bias. */
-
-static inline u32 UR(u32 limit) {
-
- if (unlikely(!rand_cnt--)) {
-
- u32 seed[2];
-
- ck_read(dev_urandom_fd, &seed, sizeof(seed), "/dev/urandom");
-
- srandom(seed[0]);
- rand_cnt = (RESEED_RNG / 2) + (seed[1] % RESEED_RNG);
-
- }
-
- return random() % limit;
-
-}
-
-
-/* Shuffle an array of pointers. Might be slightly biased. */
-
-static void shuffle_ptrs(void** ptrs, u32 cnt) {
-
- u32 i;
-
- for (i = 0; i < cnt - 2; i++) {
-
- u32 j = i + UR(cnt - i);
- void *s = ptrs[i];
- ptrs[i] = ptrs[j];
- ptrs[j] = s;
-
- }
-
-}
-
-
-#ifdef HAVE_AFFINITY
-
-/* Build a list of processes bound to specific cores. Returns -1 if nothing
- can be found. Assumes an upper bound of 4k CPUs. */
-
-static void bind_to_free_cpu(void) {
-
- DIR* d;
- struct dirent* de;
- cpu_set_t c;
-
- u8 cpu_used[4096] = { 0 };
- u32 i;
-
- if (cpu_core_count < 2) return;
-
- if (getenv("AFL_NO_AFFINITY")) {
-
- WARNF("Not binding to a CPU core (AFL_NO_AFFINITY set).");
- return;
-
- }
-
- d = opendir("/proc");
-
- if (!d) {
-
- WARNF("Unable to access /proc - can't scan for free CPU cores.");
- return;
-
- }
-
- ACTF("Checking CPU core loadout...");
-
- /* Introduce some jitter, in case multiple AFL tasks are doing the same
- thing at the same time... */
-
- usleep(R(1000) * 250);
-
- /* Scan all /proc/<pid>/status entries, checking for Cpus_allowed_list.
- Flag all processes bound to a specific CPU using cpu_used[]. This will
- fail for some exotic binding setups, but is likely good enough in almost
- all real-world use cases. */
-
- while ((de = readdir(d))) {
-
- u8* fn;
- FILE* f;
- u8 tmp[MAX_LINE];
- u8 has_vmsize = 0;
-
- if (!isdigit(de->d_name[0])) continue;
-
- fn = alloc_printf("/proc/%s/status", de->d_name);
-
- if (!(f = fopen(fn, "r"))) {
- ck_free(fn);
- continue;
- }
-
- while (fgets(tmp, MAX_LINE, f)) {
-
- u32 hval;
-
- /* Processes without VmSize are probably kernel tasks. */
-
- if (!strncmp(tmp, "VmSize:\t", 8)) has_vmsize = 1;
-
- if (!strncmp(tmp, "Cpus_allowed_list:\t", 19) &&
- !strchr(tmp, '-') && !strchr(tmp, ',') &&
- sscanf(tmp + 19, "%u", &hval) == 1 && hval < sizeof(cpu_used) &&
- has_vmsize) {
-
- cpu_used[hval] = 1;
- break;
-
- }
-
- }
-
- ck_free(fn);
- fclose(f);
-
- }
-
- closedir(d);
-
- for (i = 0; i < cpu_core_count; i++) if (!cpu_used[i]) break;
-
- if (i == cpu_core_count) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Uh-oh, looks like all %u CPU cores on your system are allocated to\n"
- " other instances of afl-fuzz (or similar CPU-locked tasks). Starting\n"
- " another fuzzer on this machine is probably a bad plan, but if you are\n"
- " absolutely sure, you can set AFL_NO_AFFINITY and try again.\n",
- cpu_core_count);
-
- FATAL("No more free CPU cores");
-
- }
-
- OKF("Found a free CPU core, binding to #%u.", i);
-
- cpu_aff = i;
-
- CPU_ZERO(&c);
- CPU_SET(i, &c);
-
- if (sched_setaffinity(0, sizeof(c), &c))
- PFATAL("sched_setaffinity failed");
-
-}
-
-#endif /* HAVE_AFFINITY */
-
-#ifndef IGNORE_FINDS
-
-/* Helper function to compare buffers; returns first and last differing offset. We
- use this to find reasonable locations for splicing two files. */
-
-static void locate_diffs(u8* ptr1, u8* ptr2, u32 len, s32* first, s32* last) {
-
- s32 f_loc = -1;
- s32 l_loc = -1;
- u32 pos;
-
- for (pos = 0; pos < len; pos++) {
-
- if (*(ptr1++) != *(ptr2++)) {
-
- if (f_loc == -1) f_loc = pos;
- l_loc = pos;
-
- }
-
- }
-
- *first = f_loc;
- *last = l_loc;
-
- return;
-
-}
-
-#endif /* !IGNORE_FINDS */
-
-
-/* Describe integer. Uses 12 cyclic static buffers for return values. The value
- returned should be five characters or less for all the integers we reasonably
- expect to see. */
-
-static u8* DI(u64 val) {
-
- static u8 tmp[12][16];
- static u8 cur;
-
- cur = (cur + 1) % 12;
-
-#define CHK_FORMAT(_divisor, _limit_mult, _fmt, _cast) do { \
- if (val < (_divisor) * (_limit_mult)) { \
- sprintf(tmp[cur], _fmt, ((_cast)val) / (_divisor)); \
- return tmp[cur]; \
- } \
- } while (0)
-
- /* 0-9999 */
- CHK_FORMAT(1, 10000, "%llu", u64);
-
- /* 10.0k - 99.9k */
- CHK_FORMAT(1000, 99.95, "%0.01fk", double);
-
- /* 100k - 999k */
- CHK_FORMAT(1000, 1000, "%lluk", u64);
-
- /* 1.00M - 9.99M */
- CHK_FORMAT(1000 * 1000, 9.995, "%0.02fM", double);
-
- /* 10.0M - 99.9M */
- CHK_FORMAT(1000 * 1000, 99.95, "%0.01fM", double);
-
- /* 100M - 999M */
- CHK_FORMAT(1000 * 1000, 1000, "%lluM", u64);
-
- /* 1.00G - 9.99G */
- CHK_FORMAT(1000LL * 1000 * 1000, 9.995, "%0.02fG", double);
-
- /* 10.0G - 99.9G */
- CHK_FORMAT(1000LL * 1000 * 1000, 99.95, "%0.01fG", double);
-
- /* 100G - 999G */
- CHK_FORMAT(1000LL * 1000 * 1000, 1000, "%lluG", u64);
-
- /* 1.00T - 9.99G */
- CHK_FORMAT(1000LL * 1000 * 1000 * 1000, 9.995, "%0.02fT", double);
-
- /* 10.0T - 99.9T */
- CHK_FORMAT(1000LL * 1000 * 1000 * 1000, 99.95, "%0.01fT", double);
-
- /* 100T+ */
- strcpy(tmp[cur], "infty");
- return tmp[cur];
-
-}
-
-
-/* Describe float. Similar to the above, except with a single
- static buffer. */
-
-static u8* DF(double val) {
-
- static u8 tmp[16];
-
- if (val < 99.995) {
- sprintf(tmp, "%0.02f", val);
- return tmp;
- }
-
- if (val < 999.95) {
- sprintf(tmp, "%0.01f", val);
- return tmp;
- }
-
- return DI((u64)val);
-
-}
-
-
-/* Describe integer as memory size. */
-
-static u8* DMS(u64 val) {
-
- static u8 tmp[12][16];
- static u8 cur;
-
- cur = (cur + 1) % 12;
-
- /* 0-9999 */
- CHK_FORMAT(1, 10000, "%llu B", u64);
-
- /* 10.0k - 99.9k */
- CHK_FORMAT(1024, 99.95, "%0.01f kB", double);
-
- /* 100k - 999k */
- CHK_FORMAT(1024, 1000, "%llu kB", u64);
-
- /* 1.00M - 9.99M */
- CHK_FORMAT(1024 * 1024, 9.995, "%0.02f MB", double);
-
- /* 10.0M - 99.9M */
- CHK_FORMAT(1024 * 1024, 99.95, "%0.01f MB", double);
-
- /* 100M - 999M */
- CHK_FORMAT(1024 * 1024, 1000, "%llu MB", u64);
-
- /* 1.00G - 9.99G */
- CHK_FORMAT(1024LL * 1024 * 1024, 9.995, "%0.02f GB", double);
-
- /* 10.0G - 99.9G */
- CHK_FORMAT(1024LL * 1024 * 1024, 99.95, "%0.01f GB", double);
-
- /* 100G - 999G */
- CHK_FORMAT(1024LL * 1024 * 1024, 1000, "%llu GB", u64);
-
- /* 1.00T - 9.99G */
- CHK_FORMAT(1024LL * 1024 * 1024 * 1024, 9.995, "%0.02f TB", double);
-
- /* 10.0T - 99.9T */
- CHK_FORMAT(1024LL * 1024 * 1024 * 1024, 99.95, "%0.01f TB", double);
-
-#undef CHK_FORMAT
-
- /* 100T+ */
- strcpy(tmp[cur], "infty");
- return tmp[cur];
-
-}
-
-
-/* Describe time delta. Returns one static buffer, 34 chars of less. */
-
-static u8* DTD(u64 cur_ms, u64 event_ms) {
-
- static u8 tmp[64];
- u64 delta;
- s32 t_d, t_h, t_m, t_s;
-
- if (!event_ms) return "none seen yet";
-
- delta = cur_ms - event_ms;
-
- t_d = delta / 1000 / 60 / 60 / 24;
- t_h = (delta / 1000 / 60 / 60) % 24;
- t_m = (delta / 1000 / 60) % 60;
- t_s = (delta / 1000) % 60;
-
- sprintf(tmp, "%s days, %u hrs, %u min, %u sec", DI(t_d), t_h, t_m, t_s);
- return tmp;
-
-}
-
-
-/* Mark deterministic checks as done for a particular queue entry. We use the
- .state file to avoid repeating deterministic fuzzing when resuming aborted
- scans. */
-
-static void mark_as_det_done(struct queue_entry* q) {
-
- u8* fn = strrchr(q->fname, '/');
- s32 fd;
-
- fn = alloc_printf("%s/queue/.state/deterministic_done/%s", out_dir, fn + 1);
-
- fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
- close(fd);
-
- ck_free(fn);
-
- q->passed_det = 1;
-
-}
-
-
-/* Mark as variable. Create symlinks if possible to make it easier to examine
- the files. */
-
-static void mark_as_variable(struct queue_entry* q) {
-
- u8 *fn = strrchr(q->fname, '/') + 1, *ldest;
-
- ldest = alloc_printf("../../%s", fn);
- fn = alloc_printf("%s/queue/.state/variable_behavior/%s", out_dir, fn);
-
- if (symlink(ldest, fn)) {
-
- s32 fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
- close(fd);
-
- }
-
- ck_free(ldest);
- ck_free(fn);
-
- q->var_behavior = 1;
-
-}
-
-
-/* Mark / unmark as redundant (edge-only). This is not used for restoring state,
- but may be useful for post-processing datasets. */
-
-static void mark_as_redundant(struct queue_entry* q, u8 state) {
-
- u8* fn;
- s32 fd;
-
- if (state == q->fs_redundant) return;
-
- q->fs_redundant = state;
-
- fn = strrchr(q->fname, '/');
- fn = alloc_printf("%s/queue/.state/redundant_edges/%s", out_dir, fn + 1);
-
- if (state) {
-
- fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
- close(fd);
-
- } else {
-
- if (unlink(fn)) PFATAL("Unable to remove '%s'", fn);
-
- }
-
- ck_free(fn);
-
-}
-
-
-/* Append new test case to the queue. */
-
-static void add_to_queue(u8* fname, u32 len, u8 passed_det) {
-
- struct queue_entry* q = ck_alloc(sizeof(struct queue_entry));
-
- q->fname = fname;
- q->len = len;
- q->depth = cur_depth + 1;
- q->passed_det = passed_det;
-
- if (q->depth > max_depth) max_depth = q->depth;
-
- if (queue_top) {
-
- queue_top->next = q;
- queue_top = q;
-
- } else q_prev100 = queue = queue_top = q;
-
- queued_paths++;
- pending_not_fuzzed++;
-
- cycles_wo_finds = 0;
-
- if (!(queued_paths % 100)) {
-
- q_prev100->next_100 = q;
- q_prev100 = q;
-
- }
-
- last_path_time = get_cur_time();
-
-}
-
-
-/* Destroy the entire queue. */
-
-EXP_ST void destroy_queue(void) {
-
- struct queue_entry *q = queue, *n;
-
- while (q) {
-
- n = q->next;
- ck_free(q->fname);
- ck_free(q->trace_mini);
- ck_free(q);
- q = n;
-
- }
-
-}
-
-
-/* Write bitmap to file. The bitmap is useful mostly for the secret
- -B option, to focus a separate fuzzing session on a particular
- interesting input without rediscovering all the others. */
-
-EXP_ST void write_bitmap(void) {
-
- u8* fname;
- s32 fd;
-
- if (!bitmap_changed) return;
- bitmap_changed = 0;
-
- fname = alloc_printf("%s/fuzz_bitmap", out_dir);
- fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-
- if (fd < 0) PFATAL("Unable to open '%s'", fname);
-
- ck_write(fd, virgin_bits, MAP_SIZE, fname);
-
- close(fd);
- ck_free(fname);
-
-}
-
-
-/* Read bitmap from file. This is for the -B option again. */
-
-EXP_ST void read_bitmap(u8* fname) {
-
- s32 fd = open(fname, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", fname);
-
- ck_read(fd, virgin_bits, MAP_SIZE, fname);
-
- close(fd);
-
-}
-
-
-/* Check if the current execution path brings anything new to the table.
- Update virgin bits to reflect the finds. Returns 1 if the only change is
- the hit-count for a particular tuple; 2 if there are new tuples seen.
- Updates the map, so subsequent calls will always return 0.
-
- This function is called after every exec() on a fairly large buffer, so
- it needs to be fast. We do this in 32-bit and 64-bit flavors. */
-
-static inline u8 has_new_bits(u8* virgin_map) {
-
-#ifdef __x86_64__
-
- u64* current = (u64*)trace_bits;
- u64* virgin = (u64*)virgin_map;
-
- u32 i = (MAP_SIZE >> 3);
-
-#else
-
- u32* current = (u32*)trace_bits;
- u32* virgin = (u32*)virgin_map;
-
- u32 i = (MAP_SIZE >> 2);
-
-#endif /* ^__x86_64__ */
-
- u8 ret = 0;
-
- while (i--) {
-
- /* Optimize for (*current & *virgin) == 0 - i.e., no bits in current bitmap
- that have not been already cleared from the virgin map - since this will
- almost always be the case. */
-
- if (unlikely(*current) && unlikely(*current & *virgin)) {
-
- if (likely(ret < 2)) {
-
- u8* cur = (u8*)current;
- u8* vir = (u8*)virgin;
-
- /* Looks like we have not found any new bytes yet; see if any non-zero
- bytes in current[] are pristine in virgin[]. */
-
-#ifdef __x86_64__
-
- if ((cur[0] && vir[0] == 0xff) || (cur[1] && vir[1] == 0xff) ||
- (cur[2] && vir[2] == 0xff) || (cur[3] && vir[3] == 0xff) ||
- (cur[4] && vir[4] == 0xff) || (cur[5] && vir[5] == 0xff) ||
- (cur[6] && vir[6] == 0xff) || (cur[7] && vir[7] == 0xff)) ret = 2;
- else ret = 1;
-
-#else
-
- if ((cur[0] && vir[0] == 0xff) || (cur[1] && vir[1] == 0xff) ||
- (cur[2] && vir[2] == 0xff) || (cur[3] && vir[3] == 0xff)) ret = 2;
- else ret = 1;
-
-#endif /* ^__x86_64__ */
-
- }
-
- *virgin &= ~*current;
-
- }
-
- current++;
- virgin++;
-
- }
-
- if (ret && virgin_map == virgin_bits) bitmap_changed = 1;
-
- return ret;
-
-}
-
-
-/* Count the number of bits set in the provided bitmap. Used for the status
- screen several times every second, does not have to be fast. */
-
-static u32 count_bits(u8* mem) {
-
- u32* ptr = (u32*)mem;
- u32 i = (MAP_SIZE >> 2);
- u32 ret = 0;
-
- while (i--) {
-
- u32 v = *(ptr++);
-
- /* This gets called on the inverse, virgin bitmap; optimize for sparse
- data. */
-
- if (v == 0xffffffff) {
- ret += 32;
- continue;
- }
-
- v -= ((v >> 1) & 0x55555555);
- v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
- ret += (((v + (v >> 4)) & 0xF0F0F0F) * 0x01010101) >> 24;
-
- }
-
- return ret;
-
-}
-
-
-#define FF(_b) (0xff << ((_b) << 3))
-
-/* Count the number of bytes set in the bitmap. Called fairly sporadically,
- mostly to update the status screen or calibrate and examine confirmed
- new paths. */
-
-static u32 count_bytes(u8* mem) {
-
- u32* ptr = (u32*)mem;
- u32 i = (MAP_SIZE >> 2);
- u32 ret = 0;
-
- while (i--) {
-
- u32 v = *(ptr++);
-
- if (!v) continue;
- if (v & FF(0)) ret++;
- if (v & FF(1)) ret++;
- if (v & FF(2)) ret++;
- if (v & FF(3)) ret++;
-
- }
-
- return ret;
-
-}
-
-
-/* Count the number of non-255 bytes set in the bitmap. Used strictly for the
- status screen, several calls per second or so. */
-
-static u32 count_non_255_bytes(u8* mem) {
-
- u32* ptr = (u32*)mem;
- u32 i = (MAP_SIZE >> 2);
- u32 ret = 0;
-
- while (i--) {
-
- u32 v = *(ptr++);
-
- /* This is called on the virgin bitmap, so optimize for the most likely
- case. */
-
- if (v == 0xffffffff) continue;
- if ((v & FF(0)) != FF(0)) ret++;
- if ((v & FF(1)) != FF(1)) ret++;
- if ((v & FF(2)) != FF(2)) ret++;
- if ((v & FF(3)) != FF(3)) ret++;
-
- }
-
- return ret;
-
-}
-
-
-/* Destructively simplify trace by eliminating hit count information
- and replacing it with 0x80 or 0x01 depending on whether the tuple
- is hit or not. Called on every new crash or hang, should be
- reasonably fast. */
-
-static const u8 simplify_lookup[256] = {
-
- [0] = 1,
- [1 ... 255] = 128
-
-};
-
-#ifdef __x86_64__
-
-static void simplify_trace(u64* mem) {
-
- u32 i = MAP_SIZE >> 3;
-
- while (i--) {
-
- /* Optimize for sparse bitmaps. */
-
- if (unlikely(*mem)) {
-
- u8* mem8 = (u8*)mem;
-
- mem8[0] = simplify_lookup[mem8[0]];
- mem8[1] = simplify_lookup[mem8[1]];
- mem8[2] = simplify_lookup[mem8[2]];
- mem8[3] = simplify_lookup[mem8[3]];
- mem8[4] = simplify_lookup[mem8[4]];
- mem8[5] = simplify_lookup[mem8[5]];
- mem8[6] = simplify_lookup[mem8[6]];
- mem8[7] = simplify_lookup[mem8[7]];
-
- } else *mem = 0x0101010101010101ULL;
-
- mem++;
-
- }
-
-}
-
-#else
-
-static void simplify_trace(u32* mem) {
-
- u32 i = MAP_SIZE >> 2;
-
- while (i--) {
-
- /* Optimize for sparse bitmaps. */
-
- if (unlikely(*mem)) {
-
- u8* mem8 = (u8*)mem;
-
- mem8[0] = simplify_lookup[mem8[0]];
- mem8[1] = simplify_lookup[mem8[1]];
- mem8[2] = simplify_lookup[mem8[2]];
- mem8[3] = simplify_lookup[mem8[3]];
-
- } else *mem = 0x01010101;
-
- mem++;
- }
-
-}
-
-#endif /* ^__x86_64__ */
-
-
-/* Destructively classify execution counts in a trace. This is used as a
- preprocessing step for any newly acquired traces. Called on every exec,
- must be fast. */
-
-static const u8 count_class_lookup8[256] = {
-
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 4,
- [4 ... 7] = 8,
- [8 ... 15] = 16,
- [16 ... 31] = 32,
- [32 ... 127] = 64,
- [128 ... 255] = 128
-
-};
-
-static u16 count_class_lookup16[65536];
-
-
-static void init_count_class16(void) {
-
- u32 b1, b2;
-
- for (b1 = 0; b1 < 256; b1++)
- for (b2 = 0; b2 < 256; b2++)
- count_class_lookup16[(b1 << 8) + b2] =
- (count_class_lookup8[b1] << 8) |
- count_class_lookup8[b2];
-
-}
-
-
-#ifdef __x86_64__
-
-static inline void classify_counts(u64* mem) {
-
- u32 i = MAP_SIZE >> 3;
-
- while (i--) {
-
- /* Optimize for sparse bitmaps. */
-
- if (unlikely(*mem)) {
-
- u16* mem16 = (u16*)mem;
-
- mem16[0] = count_class_lookup16[mem16[0]];
- mem16[1] = count_class_lookup16[mem16[1]];
- mem16[2] = count_class_lookup16[mem16[2]];
- mem16[3] = count_class_lookup16[mem16[3]];
-
- }
-
- mem++;
-
- }
-
-}
-
-#else
-
-static inline void classify_counts(u32* mem) {
-
- u32 i = MAP_SIZE >> 2;
-
- while (i--) {
-
- /* Optimize for sparse bitmaps. */
-
- if (unlikely(*mem)) {
-
- u16* mem16 = (u16*)mem;
-
- mem16[0] = count_class_lookup16[mem16[0]];
- mem16[1] = count_class_lookup16[mem16[1]];
-
- }
-
- mem++;
-
- }
-
-}
-
-#endif /* ^__x86_64__ */
-
-
-/* Get rid of shared memory (atexit handler). */
-
-static void remove_shm(void) {
-
- shmctl(shm_id, IPC_RMID, NULL);
-
-}
-
-
-/* Compact trace bytes into a smaller bitmap. We effectively just drop the
- count information here. This is called only sporadically, for some
- new paths. */
-
-static void minimize_bits(u8* dst, u8* src) {
-
- u32 i = 0;
-
- while (i < MAP_SIZE) {
-
- if (*(src++)) dst[i >> 3] |= 1 << (i & 7);
- i++;
-
- }
-
-}
-
-
-/* When we bump into a new path, we call this to see if the path appears
- more "favorable" than any of the existing ones. The purpose of the
- "favorables" is to have a minimal set of paths that trigger all the bits
- seen in the bitmap so far, and focus on fuzzing them at the expense of
- the rest.
-
- The first step of the process is to maintain a list of top_rated[] entries
- for every byte in the bitmap. We win that slot if there is no previous
- contender, or if the contender has a more favorable speed x size factor. */
-
-static void update_bitmap_score(struct queue_entry* q) {
-
- u32 i;
- u64 fav_factor = q->exec_us * q->len;
-
- /* For every byte set in trace_bits[], see if there is a previous winner,
- and how it compares to us. */
-
- for (i = 0; i < MAP_SIZE; i++)
-
- if (trace_bits[i]) {
-
- if (top_rated[i]) {
-
- /* Faster-executing or smaller test cases are favored. */
-
- if (fav_factor > top_rated[i]->exec_us * top_rated[i]->len) continue;
-
- /* Looks like we're going to win. Decrease ref count for the
- previous winner, discard its trace_bits[] if necessary. */
-
- if (!--top_rated[i]->tc_ref) {
- ck_free(top_rated[i]->trace_mini);
- top_rated[i]->trace_mini = 0;
- }
-
- }
-
- /* Insert ourselves as the new winner. */
-
- top_rated[i] = q;
- q->tc_ref++;
-
- if (!q->trace_mini) {
- q->trace_mini = ck_alloc(MAP_SIZE >> 3);
- minimize_bits(q->trace_mini, trace_bits);
- }
-
- score_changed = 1;
-
- }
-
-}
-
-
-/* The second part of the mechanism discussed above is a routine that
- goes over top_rated[] entries, and then sequentially grabs winners for
- previously-unseen bytes (temp_v) and marks them as favored, at least
- until the next run. The favored entries are given more air time during
- all fuzzing steps. */
-
-static void cull_queue(void) {
-
- struct queue_entry* q;
- static u8 temp_v[MAP_SIZE >> 3];
- u32 i;
-
- if (dumb_mode || !score_changed) return;
-
- score_changed = 0;
-
- memset(temp_v, 255, MAP_SIZE >> 3);
-
- queued_favored = 0;
- pending_favored = 0;
-
- q = queue;
-
- while (q) {
- q->favored = 0;
- q = q->next;
- }
-
- /* Let's see if anything in the bitmap isn't captured in temp_v.
- If yes, and if it has a top_rated[] contender, let's use it. */
-
- for (i = 0; i < MAP_SIZE; i++)
- if (top_rated[i] && (temp_v[i >> 3] & (1 << (i & 7)))) {
-
- u32 j = MAP_SIZE >> 3;
-
- /* Remove all bits belonging to the current entry from temp_v. */
-
- while (j--)
- if (top_rated[i]->trace_mini[j])
- temp_v[j] &= ~top_rated[i]->trace_mini[j];
-
- top_rated[i]->favored = 1;
- queued_favored++;
-
- if (!top_rated[i]->was_fuzzed) pending_favored++;
-
- }
-
- q = queue;
-
- while (q) {
- mark_as_redundant(q, !q->favored);
- q = q->next;
- }
-
-}
-
-
-/* Configure shared memory and virgin_bits. This is called at startup. */
-
-EXP_ST void setup_shm(void) {
-
- u8* shm_str;
-
- if (!in_bitmap) memset(virgin_bits, 255, MAP_SIZE);
-
- memset(virgin_hang, 255, MAP_SIZE);
- memset(virgin_crash, 255, MAP_SIZE);
-
- shm_id = shmget(IPC_PRIVATE, MAP_SIZE, IPC_CREAT | IPC_EXCL | 0600);
-
- if (shm_id < 0) PFATAL("shmget() failed");
-
- atexit(remove_shm);
-
- shm_str = alloc_printf("%d", shm_id);
-
- /* If somebody is asking us to fuzz instrumented binaries in dumb mode,
- we don't want them to detect instrumentation, since we won't be sending
- fork server commands. This should be replaced with better auto-detection
- later on, perhaps? */
-
- if (!dumb_mode) setenv(SHM_ENV_VAR, shm_str, 1);
-
- ck_free(shm_str);
-
- trace_bits = shmat(shm_id, NULL, 0);
-
- if (!trace_bits) PFATAL("shmat() failed");
-
-}
-
-
-/* Load postprocessor, if available. */
-
-static void setup_post(void) {
-
- void* dh;
- u8* fn = getenv("AFL_POST_LIBRARY");
- u32 tlen = 6;
-
- if (!fn) return;
-
- ACTF("Loading postprocessor from '%s'...", fn);
-
- dh = dlopen(fn, RTLD_NOW);
- if (!dh) FATAL("%s", dlerror());
-
- post_handler = dlsym(dh, "afl_postprocess");
- if (!post_handler) FATAL("Symbol 'afl_postprocess' not found.");
-
- /* Do a quick test. It's better to segfault now than later =) */
-
- post_handler("hello", &tlen);
-
- OKF("Postprocessor installed successfully.");
-
-}
-
-
-/* Read all testcases from the input directory, then queue them for testing.
- Called at startup. */
-
-static void read_testcases(void) {
-
- struct dirent **nl;
- s32 nl_cnt;
- u32 i;
- u8* fn;
-
- /* Auto-detect non-in-place resumption attempts. */
-
- fn = alloc_printf("%s/queue", in_dir);
- if (!access(fn, F_OK)) in_dir = fn; else ck_free(fn);
-
- ACTF("Scanning '%s'...", in_dir);
-
- /* We use scandir() + alphasort() rather than readdir() because otherwise,
- the ordering of test cases would vary somewhat randomly and would be
- difficult to control. */
-
- nl_cnt = scandir(in_dir, &nl, NULL, alphasort);
-
- if (nl_cnt < 0) {
-
- if (errno == ENOENT || errno == ENOTDIR)
-
- SAYF("\n" cLRD "[-] " cRST
- "The input directory does not seem to be valid - try again. The fuzzer needs\n"
- " one or more test case to start with - ideally, a small file under 1 kB\n"
- " or so. The cases must be stored as regular files directly in the input\n"
- " directory.\n");
-
- PFATAL("Unable to open '%s'", in_dir);
-
- }
-
- if (shuffle_queue && nl_cnt > 1) {
-
- ACTF("Shuffling queue...");
- shuffle_ptrs((void**)nl, nl_cnt);
-
- }
-
- for (i = 0; i < nl_cnt; i++) {
-
- struct stat st;
-
- u8* fn = alloc_printf("%s/%s", in_dir, nl[i]->d_name);
- u8* dfn = alloc_printf("%s/.state/deterministic_done/%s", in_dir, nl[i]->d_name);
-
- u8 passed_det = 0;
-
- free(nl[i]); /* not tracked */
-
- if (lstat(fn, &st) || access(fn, R_OK))
- PFATAL("Unable to access '%s'", fn);
-
- /* This also takes care of . and .. */
-
- if (!S_ISREG(st.st_mode) || !st.st_size || strstr(fn, "/README.txt")) {
-
- ck_free(fn);
- ck_free(dfn);
- continue;
-
- }
-
- if (st.st_size > MAX_FILE)
- FATAL("Test case '%s' is too big (%s, limit is %s)", fn,
- DMS(st.st_size), DMS(MAX_FILE));
-
- /* Check for metadata that indicates that deterministic fuzzing
- is complete for this entry. We don't want to repeat deterministic
- fuzzing when resuming aborted scans, because it would be pointless
- and probably very time-consuming. */
-
- if (!access(dfn, F_OK)) passed_det = 1;
- ck_free(dfn);
-
- add_to_queue(fn, st.st_size, passed_det);
-
- }
-
- free(nl); /* not tracked */
-
- if (!queued_paths) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Looks like there are no valid test cases in the input directory! The fuzzer\n"
- " needs one or more test case to start with - ideally, a small file under\n"
- " 1 kB or so. The cases must be stored as regular files directly in the\n"
- " input directory.\n");
-
- FATAL("No usable test cases in '%s'", in_dir);
-
- }
-
- last_path_time = 0;
- queued_at_start = queued_paths;
-
-}
-
-
-/* Helper function for load_extras. */
-
-static int compare_extras_len(const void* p1, const void* p2) {
- struct extra_data *e1 = (struct extra_data*)p1,
- *e2 = (struct extra_data*)p2;
-
- return e1->len - e2->len;
-}
-
-static int compare_extras_use_d(const void* p1, const void* p2) {
- struct extra_data *e1 = (struct extra_data*)p1,
- *e2 = (struct extra_data*)p2;
-
- return e2->hit_cnt - e1->hit_cnt;
-}
-
-
-/* Read extras from a file, sort by size. */
-
-static void load_extras_file(u8* fname, u32* min_len, u32* max_len,
- u32 dict_level) {
-
- FILE* f;
- u8 buf[MAX_LINE];
- u8 *lptr;
- u32 cur_line = 0;
-
- f = fopen(fname, "r");
-
- if (!f) PFATAL("Unable to open '%s'", fname);
-
- while ((lptr = fgets(buf, MAX_LINE, f))) {
-
- u8 *rptr, *wptr;
- u32 klen = 0;
-
- cur_line++;
-
- /* Trim on left and right. */
-
- while (isspace(*lptr)) lptr++;
-
- rptr = lptr + strlen(lptr) - 1;
- while (rptr >= lptr && isspace(*rptr)) rptr--;
- rptr++;
- *rptr = 0;
-
- /* Skip empty lines and comments. */
-
- if (!*lptr || *lptr == '#') continue;
-
- /* All other lines must end with '"', which we can consume. */
-
- rptr--;
-
- if (rptr < lptr || *rptr != '"')
- FATAL("Malformed name=\"value\" pair in line %u.", cur_line);
-
- *rptr = 0;
-
- /* Skip alphanumerics and dashes (label). */
-
- while (isalnum(*lptr) || *lptr == '_') lptr++;
-
- /* If @number follows, parse that. */
-
- if (*lptr == '@') {
-
- lptr++;
- if (atoi(lptr) > dict_level) continue;
- while (isdigit(*lptr)) lptr++;
-
- }
-
- /* Skip whitespace and = signs. */
-
- while (isspace(*lptr) || *lptr == '=') lptr++;
-
- /* Consume opening '"'. */
-
- if (*lptr != '"')
- FATAL("Malformed name=\"keyword\" pair in line %u.", cur_line);
-
- lptr++;
-
- if (!*lptr) FATAL("Empty keyword in line %u.", cur_line);
-
- /* Okay, let's allocate memory and copy data between "...", handling
- \xNN escaping, \\, and \". */
-
- extras = ck_realloc_block(extras, (extras_cnt + 1) *
- sizeof(struct extra_data));
-
- wptr = extras[extras_cnt].data = ck_alloc(rptr - lptr);
-
- while (*lptr) {
-
- char* hexdigits = "0123456789abcdef";
-
- switch (*lptr) {
-
- case 1 ... 31:
- case 128 ... 255:
- FATAL("Non-printable characters in line %u.", cur_line);
-
- case '\\':
-
- lptr++;
-
- if (*lptr == '\\' || *lptr == '"') {
- *(wptr++) = *(lptr++);
- klen++;
- break;
- }
-
- if (*lptr != 'x' || !isxdigit(lptr[1]) || !isxdigit(lptr[2]))
- FATAL("Invalid escaping (not \\xNN) in line %u.", cur_line);
-
- *(wptr++) =
- ((strchr(hexdigits, tolower(lptr[1])) - hexdigits) << 4) |
- (strchr(hexdigits, tolower(lptr[2])) - hexdigits);
-
- lptr += 3;
- klen++;
-
- break;
-
- default:
-
- *(wptr++) = *(lptr++);
- klen++;
-
- }
-
- }
-
- extras[extras_cnt].len = klen;
-
- if (extras[extras_cnt].len > MAX_DICT_FILE)
- FATAL("Keyword too big in line %u (%s, limit is %s)", cur_line,
- DMS(klen), DMS(MAX_DICT_FILE));
-
- if (*min_len > klen) *min_len = klen;
- if (*max_len < klen) *max_len = klen;
-
- extras_cnt++;
-
- }
-
- fclose(f);
-
-}
-
-
-/* Read extras from the extras directory and sort them by size. */
-
-static void load_extras(u8* dir) {
-
- DIR* d;
- struct dirent* de;
- u32 min_len = MAX_DICT_FILE, max_len = 0, dict_level = 0;
- u8* x;
-
- /* If the name ends with @, extract level and continue. */
-
- if ((x = strchr(dir, '@'))) {
-
- *x = 0;
- dict_level = atoi(x + 1);
-
- }
-
- ACTF("Loading extra dictionary from '%s' (level %u)...", dir, dict_level);
-
- d = opendir(dir);
-
- if (!d) {
-
- if (errno == ENOTDIR) {
- load_extras_file(dir, &min_len, &max_len, dict_level);
- goto check_and_sort;
- }
-
- PFATAL("Unable to open '%s'", dir);
-
- }
-
- if (x) FATAL("Dictionary levels not supported for directories.");
-
- while ((de = readdir(d))) {
-
- struct stat st;
- u8* fn = alloc_printf("%s/%s", dir, de->d_name);
- s32 fd;
-
- if (lstat(fn, &st) || access(fn, R_OK))
- PFATAL("Unable to access '%s'", fn);
-
- /* This also takes care of . and .. */
- if (!S_ISREG(st.st_mode) || !st.st_size) {
-
- ck_free(fn);
- continue;
-
- }
-
- if (st.st_size > MAX_DICT_FILE)
- FATAL("Extra '%s' is too big (%s, limit is %s)", fn,
- DMS(st.st_size), DMS(MAX_DICT_FILE));
-
- if (min_len > st.st_size) min_len = st.st_size;
- if (max_len < st.st_size) max_len = st.st_size;
-
- extras = ck_realloc_block(extras, (extras_cnt + 1) *
- sizeof(struct extra_data));
-
- extras[extras_cnt].data = ck_alloc(st.st_size);
- extras[extras_cnt].len = st.st_size;
-
- fd = open(fn, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", fn);
-
- ck_read(fd, extras[extras_cnt].data, st.st_size, fn);
-
- close(fd);
- ck_free(fn);
-
- extras_cnt++;
-
- }
-
- closedir(d);
-
-check_and_sort:
-
- if (!extras_cnt) FATAL("No usable files in '%s'", dir);
-
- qsort(extras, extras_cnt, sizeof(struct extra_data), compare_extras_len);
-
- OKF("Loaded %u extra tokens, size range %s to %s.", extras_cnt,
- DMS(min_len), DMS(max_len));
-
- if (max_len > 32)
- WARNF("Some tokens are relatively large (%s) - consider trimming.",
- DMS(max_len));
-
- if (extras_cnt > MAX_DET_EXTRAS)
- WARNF("More than %u tokens - will use them probabilistically.",
- MAX_DET_EXTRAS);
-
-}
-
-
-
-
-/* Helper function for maybe_add_auto() */
-
-static inline u8 memcmp_nocase(u8* m1, u8* m2, u32 len) {
-
- while (len--) if (tolower(*(m1++)) ^ tolower(*(m2++))) return 1;
- return 0;
-
-}
-
-
-/* Maybe add automatic extra. */
-
-static void maybe_add_auto(u8* mem, u32 len) {
-
- u32 i;
-
- /* Allow users to specify that they don't want auto dictionaries. */
-
- if (!MAX_AUTO_EXTRAS || !USE_AUTO_EXTRAS) return;
-
- /* Skip runs of identical bytes. */
-
- for (i = 1; i < len; i++)
- if (mem[0] ^ mem[i]) break;
-
- if (i == len) return;
-
- /* Reject builtin interesting values. */
-
- if (len == 2) {
-
- i = sizeof(interesting_16) >> 1;
-
- while (i--)
- if (*((u16*)mem) == interesting_16[i] ||
- *((u16*)mem) == SWAP16(interesting_16[i])) return;
-
- }
-
- if (len == 4) {
-
- i = sizeof(interesting_32) >> 2;
-
- while (i--)
- if (*((u32*)mem) == interesting_32[i] ||
- *((u32*)mem) == SWAP32(interesting_32[i])) return;
-
- }
-
- /* Reject anything that matches existing extras. Do a case-insensitive
- match. We optimize by exploiting the fact that extras[] are sorted
- by size. */
-
- for (i = 0; i < extras_cnt; i++)
- if (extras[i].len >= len) break;
-
- for (; i < extras_cnt && extras[i].len == len; i++)
- if (!memcmp_nocase(extras[i].data, mem, len)) return;
-
- /* Last but not least, check a_extras[] for matches. There are no
- guarantees of a particular sort order. */
-
- auto_changed = 1;
-
- for (i = 0; i < a_extras_cnt; i++) {
-
- if (a_extras[i].len == len && !memcmp_nocase(a_extras[i].data, mem, len)) {
-
- a_extras[i].hit_cnt++;
- goto sort_a_extras;
-
- }
-
- }
-
- /* At this point, looks like we're dealing with a new entry. So, let's
- append it if we have room. Otherwise, let's randomly evict some other
- entry from the bottom half of the list. */
-
- if (a_extras_cnt < MAX_AUTO_EXTRAS) {
-
- a_extras = ck_realloc_block(a_extras, (a_extras_cnt + 1) *
- sizeof(struct extra_data));
-
- a_extras[a_extras_cnt].data = ck_memdup(mem, len);
- a_extras[a_extras_cnt].len = len;
- a_extras_cnt++;
-
- } else {
-
- i = MAX_AUTO_EXTRAS / 2 +
- UR((MAX_AUTO_EXTRAS + 1) / 2);
-
- ck_free(a_extras[i].data);
-
- a_extras[i].data = ck_memdup(mem, len);
- a_extras[i].len = len;
- a_extras[i].hit_cnt = 0;
-
- }
-
-sort_a_extras:
-
- /* First, sort all auto extras by use count, descending order. */
-
- qsort(a_extras, a_extras_cnt, sizeof(struct extra_data),
- compare_extras_use_d);
-
- /* Then, sort the top USE_AUTO_EXTRAS entries by size. */
-
- qsort(a_extras, MIN(USE_AUTO_EXTRAS, a_extras_cnt),
- sizeof(struct extra_data), compare_extras_len);
-
-}
-
-
-/* Save automatically generated extras. */
-
-static void save_auto(void) {
-
- u32 i;
-
- if (!auto_changed) return;
- auto_changed = 0;
-
- for (i = 0; i < MIN(USE_AUTO_EXTRAS, a_extras_cnt); i++) {
-
- u8* fn = alloc_printf("%s/queue/.state/auto_extras/auto_%06u", out_dir, i);
- s32 fd;
-
- fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
-
- ck_write(fd, a_extras[i].data, a_extras[i].len, fn);
-
- close(fd);
- ck_free(fn);
-
- }
-
-}
-
-
-/* Load automatically generated extras. */
-
-static void load_auto(void) {
-
- u32 i;
-
- for (i = 0; i < USE_AUTO_EXTRAS; i++) {
-
- u8 tmp[MAX_AUTO_EXTRA + 1];
- u8* fn = alloc_printf("%s/.state/auto_extras/auto_%06u", in_dir, i);
- s32 fd, len;
-
- fd = open(fn, O_RDONLY, 0600);
-
- if (fd < 0) {
-
- if (errno != ENOENT) PFATAL("Unable to open '%s'", fn);
- ck_free(fn);
- break;
-
- }
-
- /* We read one byte more to cheaply detect tokens that are too
- long (and skip them). */
-
- len = read(fd, tmp, MAX_AUTO_EXTRA + 1);
-
- if (len < 0) PFATAL("Unable to read from '%s'", fn);
-
- if (len >= MIN_AUTO_EXTRA && len <= MAX_AUTO_EXTRA)
- maybe_add_auto(tmp, len);
-
- close(fd);
- ck_free(fn);
-
- }
-
- if (i) OKF("Loaded %u auto-discovered dictionary tokens.", i);
- else OKF("No auto-generated dictionary tokens to reuse.");
-
-}
-
-
-/* Destroy extras. */
-
-static void destroy_extras(void) {
-
- u32 i;
-
- for (i = 0; i < extras_cnt; i++)
- ck_free(extras[i].data);
-
- ck_free(extras);
-
- for (i = 0; i < a_extras_cnt; i++)
- ck_free(a_extras[i].data);
-
- ck_free(a_extras);
-
-}
-
-
-/* Spin up fork server (instrumented mode only). The idea is explained here:
-
- http://lcamtuf.blogspot.com/2014/10/fuzzing-binaries-without-execve.html
-
- In essence, the instrumentation allows us to skip execve(), and just keep
- cloning a stopped child. So, we just execute once, and then send commands
- through a pipe. The other part of this logic is in afl-as.h. */
-
-EXP_ST void init_forkserver(char** argv) {
-
- static struct itimerval it;
- int st_pipe[2], ctl_pipe[2];
- int status;
- s32 rlen;
-
- ACTF("Spinning up the fork server...");
-
- if (pipe(st_pipe) || pipe(ctl_pipe)) PFATAL("pipe() failed");
-
- forksrv_pid = fork();
-
- if (forksrv_pid < 0) PFATAL("fork() failed");
-
- if (!forksrv_pid) {
-
- struct rlimit r;
-
- /* Umpf. On OpenBSD, the default fd limit for root users is set to
- soft 128. Let's try to fix that... */
-
- if (!getrlimit(RLIMIT_NOFILE, &r) && r.rlim_cur < FORKSRV_FD + 2) {
-
- r.rlim_cur = FORKSRV_FD + 2;
- setrlimit(RLIMIT_NOFILE, &r); /* Ignore errors */
-
- }
-
- if (mem_limit) {
-
- r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;
-
-#ifdef RLIMIT_AS
-
- setrlimit(RLIMIT_AS, &r); /* Ignore errors */
-
-#else
-
- /* This takes care of OpenBSD, which doesn't have RLIMIT_AS, but
- according to reliable sources, RLIMIT_DATA covers anonymous
- maps - so we should be getting good protection against OOM bugs. */
-
- setrlimit(RLIMIT_DATA, &r); /* Ignore errors */
-
-#endif /* ^RLIMIT_AS */
-
-
- }
-
- /* Dumping cores is slow and can lead to anomalies if SIGKILL is delivered
- before the dump is complete. */
-
- r.rlim_max = r.rlim_cur = 0;
-
- setrlimit(RLIMIT_CORE, &r); /* Ignore errors */
-
- /* Isolate the process and configure standard descriptors. If out_file is
- specified, stdin is /dev/null; otherwise, out_fd is cloned instead. */
-
- setsid();
-
- dup2(dev_null_fd, 1);
- dup2(dev_null_fd, 2);
-
- if (out_file) {
-
- dup2(dev_null_fd, 0);
-
- } else {
-
- dup2(out_fd, 0);
- close(out_fd);
-
- }
-
- /* Set up control and status pipes, close the unneeded original fds. */
-
- if (dup2(ctl_pipe[0], FORKSRV_FD) < 0) PFATAL("dup2() failed");
- if (dup2(st_pipe[1], FORKSRV_FD + 1) < 0) PFATAL("dup2() failed");
-
- close(ctl_pipe[0]);
- close(ctl_pipe[1]);
- close(st_pipe[0]);
- close(st_pipe[1]);
-
- close(out_dir_fd);
- close(dev_null_fd);
- close(dev_urandom_fd);
- close(fileno(plot_file));
-
- /* This should improve performance a bit, since it stops the linker from
- doing extra work post-fork(). */
-
- if (!getenv("LD_BIND_LAZY")) setenv("LD_BIND_NOW", "1", 0);
-
- /* Set sane defaults for ASAN if nothing else specified. */
-
- setenv("ASAN_OPTIONS", "abort_on_error=1:"
- "detect_leaks=0:"
- "symbolize=0:"
- "allocator_may_return_null=1", 0);
-
- /* MSAN is tricky, because it doesn't support abort_on_error=1 at this
- point. So, we do this in a very hacky way. */
-
- setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":"
- "symbolize=0:"
- "abort_on_error=1:"
- "allocator_may_return_null=1:"
- "msan_track_origins=0", 0);
-
- execv(target_path, argv);
-
- /* Use a distinctive bitmap signature to tell the parent about execv()
- falling through. */
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- exit(0);
-
- }
-
- /* Close the unneeded endpoints. */
-
- close(ctl_pipe[0]);
- close(st_pipe[1]);
-
- fsrv_ctl_fd = ctl_pipe[1];
- fsrv_st_fd = st_pipe[0];
-
- /* Wait for the fork server to come up, but don't wait too long. */
-
- it.it_value.tv_sec = ((exec_tmout * FORK_WAIT_MULT) / 1000);
- it.it_value.tv_usec = ((exec_tmout * FORK_WAIT_MULT) % 1000) * 1000;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- rlen = read(fsrv_st_fd, &status, 4);
-
- it.it_value.tv_sec = 0;
- it.it_value.tv_usec = 0;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- /* If we have a four-byte "hello" message from the server, we're all set.
- Otherwise, try to figure out what went wrong. */
-
- if (rlen == 4) {
- OKF("All right - fork server is up.");
- return;
- }
-
- if (child_timed_out)
- FATAL("Timeout while initializing fork server (adjusting -t may help)");
-
- if (waitpid(forksrv_pid, &status, 0) <= 0)
- PFATAL("waitpid() failed");
-
- if (WIFSIGNALED(status)) {
-
- if (mem_limit && mem_limit < 500 && uses_asan) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Whoops, the target binary crashed suddenly, before receiving any input\n"
- " from the fuzzer! Since it seems to be built with ASAN and you have a\n"
- " restrictive memory limit configured, this is expected; please read\n"
- " %s/notes_for_asan.txt for help.\n", doc_path);
-
- } else if (!mem_limit) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Whoops, the target binary crashed suddenly, before receiving any input\n"
- " from the fuzzer! There are several probable explanations:\n\n"
-
- " - The binary is just buggy and explodes entirely on its own. If so, you\n"
- " need to fix the underlying problem or find a better replacement.\n\n"
-
-#ifdef __APPLE__
-
- " - On MacOS X, the semantics of fork() syscalls are non-standard and may\n"
- " break afl-fuzz performance optimizations when running platform-specific\n"
- " targets. To fix this, set AFL_NO_FORKSRV=1 in the environment.\n\n"
-
-#endif /* __APPLE__ */
-
- " - Less likely, there is a horrible bug in the fuzzer. If other options\n"
- " fail, poke <lcamtuf@coredump.cx> for troubleshooting tips.\n");
-
- } else {
-
- SAYF("\n" cLRD "[-] " cRST
- "Whoops, the target binary crashed suddenly, before receiving any input\n"
- " from the fuzzer! There are several probable explanations:\n\n"
-
- " - The current memory limit (%s) is too restrictive, causing the\n"
- " target to hit an OOM condition in the dynamic linker. Try bumping up\n"
- " the limit with the -m setting in the command line. A simple way confirm\n"
- " this diagnosis would be:\n\n"
-
-#ifdef RLIMIT_AS
- " ( ulimit -Sv $[%llu << 10]; /path/to/fuzzed_app )\n\n"
-#else
- " ( ulimit -Sd $[%llu << 10]; /path/to/fuzzed_app )\n\n"
-#endif /* ^RLIMIT_AS */
-
- " Tip: you can use http://jwilk.net/software/recidivm to quickly\n"
- " estimate the required amount of virtual memory for the binary.\n\n"
-
- " - The binary is just buggy and explodes entirely on its own. If so, you\n"
- " need to fix the underlying problem or find a better replacement.\n\n"
-
-#ifdef __APPLE__
-
- " - On MacOS X, the semantics of fork() syscalls are non-standard and may\n"
- " break afl-fuzz performance optimizations when running platform-specific\n"
- " targets. To fix this, set AFL_NO_FORKSRV=1 in the environment.\n\n"
-
-#endif /* __APPLE__ */
-
- " - Less likely, there is a horrible bug in the fuzzer. If other options\n"
- " fail, poke <lcamtuf@coredump.cx> for troubleshooting tips.\n",
- DMS(mem_limit << 20), mem_limit - 1);
-
- }
-
- FATAL("Fork server crashed with signal %d", WTERMSIG(status));
-
- }
-
- if (*(u32*)trace_bits == EXEC_FAIL_SIG)
- FATAL("Unable to execute target application ('%s')", argv[0]);
-
- if (mem_limit && mem_limit < 500 && uses_asan) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Hmm, looks like the target binary terminated before we could complete a\n"
- " handshake with the injected code. Since it seems to be built with ASAN and\n"
- " you have a restrictive memory limit configured, this is expected; please\n"
- " read %s/notes_for_asan.txt for help.\n", doc_path);
-
- } else if (!mem_limit) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Hmm, looks like the target binary terminated before we could complete a\n"
- " handshake with the injected code. Perhaps there is a horrible bug in the\n"
- " fuzzer. Poke <lcamtuf@coredump.cx> for troubleshooting tips.\n");
-
- } else {
-
- SAYF("\n" cLRD "[-] " cRST
- "Hmm, looks like the target binary terminated before we could complete a\n"
- " handshake with the injected code. There are %s probable explanations:\n\n"
-
- "%s"
- " - The current memory limit (%s) is too restrictive, causing an OOM\n"
- " fault in the dynamic linker. This can be fixed with the -m option. A\n"
- " simple way to confirm the diagnosis may be:\n\n"
-
-#ifdef RLIMIT_AS
- " ( ulimit -Sv $[%llu << 10]; /path/to/fuzzed_app )\n\n"
-#else
- " ( ulimit -Sd $[%llu << 10]; /path/to/fuzzed_app )\n\n"
-#endif /* ^RLIMIT_AS */
-
- " Tip: you can use http://jwilk.net/software/recidivm to quickly\n"
- " estimate the required amount of virtual memory for the binary.\n\n"
-
- " - Less likely, there is a horrible bug in the fuzzer. If other options\n"
- " fail, poke <lcamtuf@coredump.cx> for troubleshooting tips.\n",
- getenv(DEFER_ENV_VAR) ? "three" : "two",
- getenv(DEFER_ENV_VAR) ?
- " - You are using deferred forkserver, but __AFL_INIT() is never\n"
- " reached before the program terminates.\n\n" : "",
- DMS(mem_limit << 20), mem_limit - 1);
-
- }
-
- FATAL("Fork server handshake failed");
-
-}
-
-
-/* Execute target application, monitoring for timeouts. Return status
- information. The called program will update trace_bits[]. */
-
-static u8 run_target(char** argv) {
-
- static struct itimerval it;
- static u32 prev_timed_out = 0;
-
- int status = 0;
- u32 tb4;
-
- child_timed_out = 0;
-
- /* After this memset, trace_bits[] are effectively volatile, so we
- must prevent any earlier operations from venturing into that
- territory. */
-
- memset(trace_bits, 0, MAP_SIZE);
- MEM_BARRIER();
-
- /* If we're running in "dumb" mode, we can't rely on the fork server
- logic compiled into the target program, so we will just keep calling
- execve(). There is a bit of code duplication between here and
- init_forkserver(), but c'est la vie. */
-
- if (dumb_mode == 1 || no_forkserver) {
-
- child_pid = fork();
-
- if (child_pid < 0) PFATAL("fork() failed");
-
- if (!child_pid) {
-
- struct rlimit r;
-
- if (mem_limit) {
-
- r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;
-
-#ifdef RLIMIT_AS
-
- setrlimit(RLIMIT_AS, &r); /* Ignore errors */
-
-#else
-
- setrlimit(RLIMIT_DATA, &r); /* Ignore errors */
-
-#endif /* ^RLIMIT_AS */
-
- }
-
- r.rlim_max = r.rlim_cur = 0;
-
- setrlimit(RLIMIT_CORE, &r); /* Ignore errors */
-
- /* Isolate the process and configure standard descriptors. If out_file is
- specified, stdin is /dev/null; otherwise, out_fd is cloned instead. */
-
- setsid();
-
- dup2(dev_null_fd, 1);
- dup2(dev_null_fd, 2);
-
- if (out_file) {
-
- dup2(dev_null_fd, 0);
-
- } else {
-
- dup2(out_fd, 0);
- close(out_fd);
-
- }
-
- /* On Linux, would be faster to use O_CLOEXEC. Maybe TODO. */
-
- close(dev_null_fd);
- close(out_dir_fd);
- close(dev_urandom_fd);
- close(fileno(plot_file));
-
- /* Set sane defaults for ASAN if nothing else specified. */
-
- setenv("ASAN_OPTIONS", "abort_on_error=1:"
- "detect_leaks=0:"
- "symbolize=0:"
- "allocator_may_return_null=1", 0);
-
- setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":"
- "symbolize=0:"
- "msan_track_origins=0", 0);
-
- execv(target_path, argv);
-
- /* Use a distinctive bitmap value to tell the parent about execv()
- falling through. */
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- exit(0);
-
- }
-
- } else {
-
- s32 res;
-
- /* In non-dumb mode, we have the fork server up and running, so simply
- tell it to have at it, and then read back PID. */
-
- if ((res = write(fsrv_ctl_fd, &prev_timed_out, 4)) != 4) {
-
- if (stop_soon) return 0;
- RPFATAL(res, "Unable to request new process from fork server (OOM?)");
-
- }
-
- if ((res = read(fsrv_st_fd, &child_pid, 4)) != 4) {
-
- if (stop_soon) return 0;
- RPFATAL(res, "Unable to request new process from fork server (OOM?)");
-
- }
-
- if (child_pid <= 0) FATAL("Fork server is misbehaving (OOM?)");
-
- }
-
- /* Configure timeout, as requested by user, then wait for child to terminate. */
-
- it.it_value.tv_sec = (exec_tmout / 1000);
- it.it_value.tv_usec = (exec_tmout % 1000) * 1000;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- /* The SIGALRM handler simply kills the child_pid and sets child_timed_out. */
-
- if (dumb_mode == 1 || no_forkserver) {
-
- if (waitpid(child_pid, &status, 0) <= 0) PFATAL("waitpid() failed");
-
- } else {
-
- s32 res;
-
- if ((res = read(fsrv_st_fd, &status, 4)) != 4) {
-
- if (stop_soon) return 0;
- RPFATAL(res, "Unable to communicate with fork server (OOM?)");
-
- }
-
- }
-
- if (!WIFSTOPPED(status)) child_pid = 0;
-
- it.it_value.tv_sec = 0;
- it.it_value.tv_usec = 0;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- total_execs++;
-
- /* Any subsequent operations on trace_bits must not be moved by the
- compiler below this point. Past this location, trace_bits[] behave
- very normally and do not have to be treated as volatile. */
-
- MEM_BARRIER();
-
- tb4 = *(u32*)trace_bits;
-
-#ifdef __x86_64__
- classify_counts((u64*)trace_bits);
-#else
- classify_counts((u32*)trace_bits);
-#endif /* ^__x86_64__ */
-
- prev_timed_out = child_timed_out;
-
- /* Report outcome to caller. */
-
- if (child_timed_out) return FAULT_HANG;
-
- if (WIFSIGNALED(status) && !stop_soon) {
- kill_signal = WTERMSIG(status);
- return FAULT_CRASH;
- }
-
- /* A somewhat nasty hack for MSAN, which doesn't support abort_on_error and
- must use a special exit code. */
-
- if (uses_asan && WEXITSTATUS(status) == MSAN_ERROR) {
- kill_signal = 0;
- return FAULT_CRASH;
- }
-
- if ((dumb_mode == 1 || no_forkserver) && tb4 == EXEC_FAIL_SIG)
- return FAULT_ERROR;
-
- return FAULT_NONE;
-
-}
-
-
-/* Write modified data to file for testing. If out_file is set, the old file
- is unlinked and a new one is created. Otherwise, out_fd is rewound and
- truncated. */
-
-static void write_to_testcase(void* mem, u32 len) {
-
- s32 fd = out_fd;
-
- if (out_file) {
-
- unlink(out_file); /* Ignore errors. */
-
- fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
-
- if (fd < 0) PFATAL("Unable to create '%s'", out_file);
-
- } else lseek(fd, 0, SEEK_SET);
-
- ck_write(fd, mem, len, out_file);
-
- if (!out_file) {
-
- if (ftruncate(fd, len)) PFATAL("ftruncate() failed");
- lseek(fd, 0, SEEK_SET);
-
- } else close(fd);
-
-}
-
-
-/* The same, but with an adjustable gap. Used for trimming. */
-
-static void write_with_gap(void* mem, u32 len, u32 skip_at, u32 skip_len) {
-
- s32 fd = out_fd;
- u32 tail_len = len - skip_at - skip_len;
-
- if (out_file) {
-
- unlink(out_file); /* Ignore errors. */
-
- fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
-
- if (fd < 0) PFATAL("Unable to create '%s'", out_file);
-
- } else lseek(fd, 0, SEEK_SET);
-
- if (skip_at) ck_write(fd, mem, skip_at, out_file);
-
- if (tail_len) ck_write(fd, mem + skip_at + skip_len, tail_len, out_file);
-
- if (!out_file) {
-
- if (ftruncate(fd, len - skip_len)) PFATAL("ftruncate() failed");
- lseek(fd, 0, SEEK_SET);
-
- } else close(fd);
-
-}
-
-
-static void show_stats(void);
-
-/* Calibrate a new test case. This is done when processing the input directory
- to warn about flaky or otherwise problematic test cases early on; and when
- new paths are discovered to detect variable behavior and so on. */
-
-static u8 calibrate_case(char** argv, struct queue_entry* q, u8* use_mem,
- u32 handicap, u8 from_queue) {
-
- static u8 first_trace[MAP_SIZE];
-
- u8 fault = 0, new_bits = 0, var_detected = 0,
- first_run = (q->exec_cksum == 0);
-
- u64 start_us, stop_us;
-
- s32 old_sc = stage_cur, old_sm = stage_max, old_tmout = exec_tmout;
- u8* old_sn = stage_name;
-
- /* Be a bit more generous about timeouts when resuming sessions, or when
- trying to calibrate already-added finds. This helps avoid trouble due
- to intermittent latency. */
-
- if (!from_queue || resuming_fuzz)
- exec_tmout = MAX(exec_tmout + CAL_TMOUT_ADD,
- exec_tmout * CAL_TMOUT_PERC / 100);
-
- q->cal_failed++;
-
- stage_name = "calibration";
- stage_max = CAL_CYCLES;
-
- /* Make sure the forkserver is up before we do anything, and let's not
- count its spin-up time toward binary calibration. */
-
- if (dumb_mode != 1 && !no_forkserver && !forksrv_pid)
- init_forkserver(argv);
-
- if (q->exec_cksum) memcpy(first_trace, trace_bits, MAP_SIZE);
-
- start_us = get_cur_time_us();
-
- for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {
-
- u32 cksum;
-
- if (!first_run && !(stage_cur % stats_update_freq)) show_stats();
-
- write_to_testcase(use_mem, q->len);
-
- fault = run_target(argv);
-
- /* stop_soon is set by the handler for Ctrl+C. When it's pressed,
- we want to bail out quickly. */
-
- if (stop_soon || fault != crash_mode) goto abort_calibration;
-
- if (!dumb_mode && !stage_cur && !count_bytes(trace_bits)) {
- fault = FAULT_NOINST;
- goto abort_calibration;
- }
-
- cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
-
- if (q->exec_cksum != cksum) {
-
- u8 hnb = has_new_bits(virgin_bits);
- if (hnb > new_bits) new_bits = hnb;
-
- if (q->exec_cksum) {
-
- u32 i;
-
- for (i = 0; i < MAP_SIZE; i++) {
-
- if (!var_bytes[i] && first_trace[i] != trace_bits[i]) {
-
- var_bytes[i] = 1;
- stage_max = CAL_CYCLES_LONG;
-
- }
-
- }
-
- var_detected = 1;
-
- } else {
-
- q->exec_cksum = cksum;
- memcpy(first_trace, trace_bits, MAP_SIZE);
-
- }
-
- }
-
- }
-
- stop_us = get_cur_time_us();
-
- total_cal_us += stop_us - start_us;
- total_cal_cycles += stage_max;
-
- /* OK, let's collect some stats about the performance of this test case.
- This is used for fuzzing air time calculations in calculate_score(). */
-
- q->exec_us = (stop_us - start_us) / stage_max;
- q->bitmap_size = count_bytes(trace_bits);
- q->handicap = handicap;
- q->cal_failed = 0;
-
- total_bitmap_size += q->bitmap_size;
- total_bitmap_entries++;
-
- update_bitmap_score(q);
-
- /* If this case didn't result in new output from the instrumentation, tell
- parent. This is a non-critical problem, but something to warn the user
- about. */
-
- if (!dumb_mode && first_run && !fault && !new_bits) fault = FAULT_NOBITS;
-
-abort_calibration:
-
- if (new_bits == 2 && !q->has_new_cov) {
- q->has_new_cov = 1;
- queued_with_cov++;
- }
-
- /* Mark variable paths. */
-
- if (var_detected) {
-
- var_byte_count = count_bytes(var_bytes);
-
- if (!q->var_behavior) {
- mark_as_variable(q);
- queued_variable++;
- }
-
- }
-
- stage_name = old_sn;
- stage_cur = old_sc;
- stage_max = old_sm;
- exec_tmout = old_tmout;
-
- if (!first_run) show_stats();
-
- return fault;
-
-}
-
-
-/* Examine map coverage. Called once, for first test case. */
-
-static void check_map_coverage(void) {
-
- u32 i;
-
- if (count_bytes(trace_bits) < 100) return;
-
- for (i = (1 << (MAP_SIZE_POW2 - 1)); i < MAP_SIZE; i++)
- if (trace_bits[i]) return;
-
- WARNF("Recompile binary with newer version of afl to improve coverage!");
-
-}
-
-
-/* Perform dry run of all test cases to confirm that the app is working as
- expected. This is done only for the initial inputs, and only once. */
-
-static void perform_dry_run(char** argv) {
-
- struct queue_entry* q = queue;
- u32 cal_failures = 0;
- u8* skip_crashes = getenv("AFL_SKIP_CRASHES");
-
- while (q) {
-
- u8* use_mem;
- u8 res;
- s32 fd;
-
- u8* fn = strrchr(q->fname, '/') + 1;
-
- ACTF("Attempting dry run with '%s'...", fn);
-
- fd = open(q->fname, O_RDONLY);
- if (fd < 0) PFATAL("Unable to open '%s'", q->fname);
-
- use_mem = ck_alloc_nozero(q->len);
-
- if (read(fd, use_mem, q->len) != q->len)
- FATAL("Short read from '%s'", q->fname);
-
- close(fd);
-
- res = calibrate_case(argv, q, use_mem, 0, 1);
- ck_free(use_mem);
-
- if (stop_soon) return;
-
- if (res == crash_mode || res == FAULT_NOBITS)
- SAYF(cGRA " len = %u, map size = %u, exec speed = %llu us\n" cRST,
- q->len, q->bitmap_size, q->exec_us);
-
- switch (res) {
-
- case FAULT_NONE:
-
- if (q == queue) check_map_coverage();
-
- if (crash_mode) FATAL("Test case '%s' does *NOT* crash", fn);
-
- break;
-
- case FAULT_HANG:
-
- if (timeout_given) {
-
- /* The -t nn+ syntax in the command line sets timeout_given to '2' and
- instructs afl-fuzz to tolerate but skip queue entries that time
- out. */
-
- if (timeout_given > 1) {
- WARNF("Test case results in a hang (skipping)");
- q->cal_failed = CAL_CHANCES;
- cal_failures++;
- break;
- }
-
- SAYF("\n" cLRD "[-] " cRST
- "The program took more than %u ms to process one of the initial test cases.\n"
- " Usually, the right thing to do is to relax the -t option - or to delete it\n"
- " altogether and allow the fuzzer to auto-calibrate. That said, if you know\n"
- " what you are doing and want to simply skip the unruly test cases, append\n"
- " '+' at the end of the value passed to -t ('-t %u+').\n", exec_tmout,
- exec_tmout);
-
- FATAL("Test case '%s' results in a hang", fn);
-
- } else {
-
- SAYF("\n" cLRD "[-] " cRST
- "The program took more than %u ms to process one of the initial test cases.\n"
- " This is bad news; raising the limit with the -t option is possible, but\n"
- " will probably make the fuzzing process extremely slow.\n\n"
-
- " If this test case is just a fluke, the other option is to just avoid it\n"
- " altogether, and find one that is less of a CPU hog.\n", exec_tmout);
-
- FATAL("Test case '%s' results in a hang", fn);
-
- }
-
- case FAULT_CRASH:
-
- if (crash_mode) break;
-
- if (skip_crashes) {
- WARNF("Test case results in a crash (skipping)");
- q->cal_failed = CAL_CHANCES;
- cal_failures++;
- break;
- }
-
- if (mem_limit) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Oops, the program crashed with one of the test cases provided. There are\n"
- " several possible explanations:\n\n"
-
- " - The test case causes known crashes under normal working conditions. If\n"
- " so, please remove it. The fuzzer should be seeded with interesting\n"
- " inputs - but not ones that cause an outright crash.\n\n"
-
- " - The current memory limit (%s) is too low for this program, causing\n"
- " it to die due to OOM when parsing valid files. To fix this, try\n"
- " bumping it up with the -m setting in the command line. If in doubt,\n"
- " try something along the lines of:\n\n"
-
-#ifdef RLIMIT_AS
- " ( ulimit -Sv $[%llu << 10]; /path/to/binary [...] <testcase )\n\n"
-#else
- " ( ulimit -Sd $[%llu << 10]; /path/to/binary [...] <testcase )\n\n"
-#endif /* ^RLIMIT_AS */
-
- " Tip: you can use http://jwilk.net/software/recidivm to quickly\n"
- " estimate the required amount of virtual memory for the binary. Also,\n"
- " if you are using ASAN, see %s/notes_for_asan.txt.\n\n"
-
-#ifdef __APPLE__
-
- " - On MacOS X, the semantics of fork() syscalls are non-standard and may\n"
- " break afl-fuzz performance optimizations when running platform-specific\n"
- " binaries. To fix this, set AFL_NO_FORKSRV=1 in the environment.\n\n"
-
-#endif /* __APPLE__ */
-
- " - Least likely, there is a horrible bug in the fuzzer. If other options\n"
- " fail, poke <lcamtuf@coredump.cx> for troubleshooting tips.\n",
- DMS(mem_limit << 20), mem_limit - 1, doc_path);
-
- } else {
-
- SAYF("\n" cLRD "[-] " cRST
- "Oops, the program crashed with one of the test cases provided. There are\n"
- " several possible explanations:\n\n"
-
- " - The test case causes known crashes under normal working conditions. If\n"
- " so, please remove it. The fuzzer should be seeded with interesting\n"
- " inputs - but not ones that cause an outright crash.\n\n"
-
-#ifdef __APPLE__
-
- " - On MacOS X, the semantics of fork() syscalls are non-standard and may\n"
- " break afl-fuzz performance optimizations when running platform-specific\n"
- " binaries. To fix this, set AFL_NO_FORKSRV=1 in the environment.\n\n"
-
-#endif /* __APPLE__ */
-
- " - Least likely, there is a horrible bug in the fuzzer. If other options\n"
- " fail, poke <lcamtuf@coredump.cx> for troubleshooting tips.\n");
-
- }
-
- FATAL("Test case '%s' results in a crash", fn);
-
- case FAULT_ERROR:
-
- FATAL("Unable to execute target application ('%s')", argv[0]);
-
- case FAULT_NOINST:
-
- FATAL("No instrumentation detected");
-
- case FAULT_NOBITS:
-
- useless_at_start++;
-
- if (!in_bitmap && !shuffle_queue)
- WARNF("No new instrumentation output, test case may be useless.");
-
- break;
-
- }
-
- if (q->var_behavior) WARNF("Instrumentation output varies across runs.");
-
- q = q->next;
-
- }
-
- if (cal_failures) {
-
- if (cal_failures == queued_paths)
- FATAL("All test cases time out%s, giving up!",
- skip_crashes ? " or crash" : "");
-
- WARNF("Skipped %u test cases (%0.02f%%) due to timeouts%s.", cal_failures,
- ((double)cal_failures) * 100 / queued_paths,
- skip_crashes ? " or crashes" : "");
-
- if (cal_failures * 5 > queued_paths)
- WARNF(cLRD "High percentage of rejected test cases, check settings!");
-
- }
-
- OKF("All test cases processed.");
-
-}
-
-
-/* Helper function: link() if possible, copy otherwise. */
-
-static void link_or_copy(u8* old_path, u8* new_path) {
-
- s32 i = link(old_path, new_path);
- s32 sfd, dfd;
- u8* tmp;
-
- if (!i) return;
-
- sfd = open(old_path, O_RDONLY);
- if (sfd < 0) PFATAL("Unable to open '%s'", old_path);
-
- dfd = open(new_path, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (dfd < 0) PFATAL("Unable to create '%s'", new_path);
-
- tmp = ck_alloc(64 * 1024);
-
- while ((i = read(sfd, tmp, 64 * 1024)) > 0)
- ck_write(dfd, tmp, i, new_path);
-
- if (i < 0) PFATAL("read() failed");
-
- ck_free(tmp);
- close(sfd);
- close(dfd);
-
-}
-
-
-static void nuke_resume_dir(void);
-
-/* Create hard links for input test cases in the output directory, choosing
- good names and pivoting accordingly. */
-
-static void pivot_inputs(void) {
-
- struct queue_entry* q = queue;
- u32 id = 0;
-
- ACTF("Creating hard links for all input files...");
-
- while (q) {
-
- u8 *nfn, *rsl = strrchr(q->fname, '/');
- u32 orig_id;
-
- if (!rsl) rsl = q->fname; else rsl++;
-
- /* If the original file name conforms to the syntax and the recorded
- ID matches the one we'd assign, just use the original file name.
- This is valuable for resuming fuzzing runs. */
-
-#ifndef SIMPLE_FILES
-# define CASE_PREFIX "id:"
-#else
-# define CASE_PREFIX "id_"
-#endif /* ^!SIMPLE_FILES */
-
- if (!strncmp(rsl, CASE_PREFIX, 3) &&
- sscanf(rsl + 3, "%06u", &orig_id) == 1 && orig_id == id) {
-
- u8* src_str;
- u32 src_id;
-
- resuming_fuzz = 1;
- nfn = alloc_printf("%s/queue/%s", out_dir, rsl);
-
- /* Since we're at it, let's also try to find parent and figure out the
- appropriate depth for this entry. */
-
- src_str = strchr(rsl + 3, ':');
-
- if (src_str && sscanf(src_str + 1, "%06u", &src_id) == 1) {
-
- struct queue_entry* s = queue;
- while (src_id-- && s) s = s->next;
- if (s) q->depth = s->depth + 1;
-
- if (max_depth < q->depth) max_depth = q->depth;
-
- }
-
- } else {
-
- /* No dice - invent a new name, capturing the original one as a
- substring. */
-
-#ifndef SIMPLE_FILES
-
- u8* use_name = strstr(rsl, ",orig:");
-
- if (use_name) use_name += 6; else use_name = rsl;
- nfn = alloc_printf("%s/queue/id:%06u,orig:%s", out_dir, id, use_name);
-
-#else
-
- nfn = alloc_printf("%s/queue/id_%06u", out_dir, id);
-
-#endif /* ^!SIMPLE_FILES */
-
- }
-
- /* Pivot to the new queue entry. */
-
- link_or_copy(q->fname, nfn);
- ck_free(q->fname);
- q->fname = nfn;
-
- /* Make sure that the passed_det value carries over, too. */
-
- if (q->passed_det) mark_as_det_done(q);
-
- q = q->next;
- id++;
-
- }
-
- if (in_place_resume) nuke_resume_dir();
-
-}
-
-
-#ifndef SIMPLE_FILES
-
-/* Construct a file name for a new test case, capturing the operation
- that led to its discovery. Uses a static buffer. */
-
-static u8* describe_op(u8 hnb) {
-
- static u8 ret[256];
-
- if (syncing_party) {
-
- sprintf(ret, "sync:%s,src:%06u", syncing_party, syncing_case);
-
- } else {
-
- sprintf(ret, "src:%06u", current_entry);
-
- if (splicing_with >= 0)
- sprintf(ret + strlen(ret), "+%06u", splicing_with);
-
- sprintf(ret + strlen(ret), ",op:%s", stage_short);
-
- if (stage_cur_byte >= 0) {
-
- sprintf(ret + strlen(ret), ",pos:%u", stage_cur_byte);
-
- if (stage_val_type != STAGE_VAL_NONE)
- sprintf(ret + strlen(ret), ",val:%s%+d",
- (stage_val_type == STAGE_VAL_BE) ? "be:" : "",
- stage_cur_val);
-
- } else sprintf(ret + strlen(ret), ",rep:%u", stage_cur_val);
-
- }
-
- if (hnb == 2) strcat(ret, ",+cov");
-
- return ret;
-
-}
-
-#endif /* !SIMPLE_FILES */
-
-
-/* Write a message accompanying the crash directory :-) */
-
-static void write_crash_readme(void) {
-
- u8* fn = alloc_printf("%s/crashes/README.txt", out_dir);
- s32 fd;
- FILE* f;
-
- fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- ck_free(fn);
-
- /* Do not die on errors here - that would be impolite. */
-
- if (fd < 0) return;
-
- f = fdopen(fd, "w");
-
- if (!f) {
- close(fd);
- return;
- }
-
- fprintf(f, "Command line used to find this crash:\n\n"
-
- "%s\n\n"
-
- "If you can't reproduce a bug outside of afl-fuzz, be sure to set the same\n"
- "memory limit. The limit used for this fuzzing session was %s.\n\n"
-
- "Need a tool to minimize test cases before investigating the crashes or sending\n"
- "them to a vendor? Check out the afl-tmin that comes with the fuzzer!\n\n"
-
- "Found any cool bugs in open-source tools using afl-fuzz? If yes, please drop\n"
- "me a mail at <lcamtuf@coredump.cx> once the issues are fixed - I'd love to\n"
- "add your finds to the gallery at:\n\n"
-
- " http://lcamtuf.coredump.cx/afl/\n\n"
-
- "Thanks :-)\n",
-
- orig_cmdline, DMS(mem_limit << 20)); /* ignore errors */
-
- fclose(f);
-
-}
-
-
-/* Check if the result of an execve() during routine fuzzing is interesting,
- save or queue the input test case for further analysis if so. Returns 1 if
- entry is saved, 0 otherwise. */
-
-static u8 save_if_interesting(char** argv, void* mem, u32 len, u8 fault) {
-
- u8 *fn = "";
- u8 hnb;
- s32 fd;
- u8 keeping = 0, res;
-
- if (fault == crash_mode) {
-
- /* Keep only if there are new bits in the map, add to queue for
- future fuzzing, etc. */
-
- if (!(hnb = has_new_bits(virgin_bits))) {
- if (crash_mode) total_crashes++;
- return 0;
- }
-
-#ifndef SIMPLE_FILES
-
- fn = alloc_printf("%s/queue/id:%06u,%s", out_dir, queued_paths,
- describe_op(hnb));
-
-#else
-
- fn = alloc_printf("%s/queue/id_%06u", out_dir, queued_paths);
-
-#endif /* ^!SIMPLE_FILES */
-
- add_to_queue(fn, len, 0);
-
- if (hnb == 2) {
- queue_top->has_new_cov = 1;
- queued_with_cov++;
- }
-
- queue_top->exec_cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
-
- /* Try to calibrate inline; this also calls update_bitmap_score() when
- successful. */
-
- res = calibrate_case(argv, queue_top, mem, queue_cycle - 1, 0);
-
- if (res == FAULT_ERROR)
- FATAL("Unable to execute target application");
-
- fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
- ck_write(fd, mem, len, fn);
- close(fd);
-
- keeping = 1;
-
- }
-
- switch (fault) {
-
- case FAULT_HANG:
-
- /* Hangs are not very interesting, but we're still obliged to keep
- a handful of samples. We use the presence of new bits in the
- hang-specific bitmap as a signal of uniqueness. In "dumb" mode, we
- just keep everything. */
-
- total_hangs++;
-
- if (unique_hangs >= KEEP_UNIQUE_HANG) return keeping;
-
- if (!dumb_mode) {
-
-#ifdef __x86_64__
- simplify_trace((u64*)trace_bits);
-#else
- simplify_trace((u32*)trace_bits);
-#endif /* ^__x86_64__ */
-
- if (!has_new_bits(virgin_hang)) return keeping;
-
- }
-
-#ifndef SIMPLE_FILES
-
- fn = alloc_printf("%s/hangs/id:%06llu,%s", out_dir,
- unique_hangs, describe_op(0));
-
-#else
-
- fn = alloc_printf("%s/hangs/id_%06llu", out_dir,
- unique_hangs);
-
-#endif /* ^!SIMPLE_FILES */
-
- unique_hangs++;
-
- last_hang_time = get_cur_time();
-
- break;
-
- case FAULT_CRASH:
-
- /* This is handled in a manner roughly similar to hangs,
- except for slightly different limits. */
-
- total_crashes++;
-
- if (unique_crashes >= KEEP_UNIQUE_CRASH) return keeping;
-
- if (!dumb_mode) {
-
-#ifdef __x86_64__
- simplify_trace((u64*)trace_bits);
-#else
- simplify_trace((u32*)trace_bits);
-#endif /* ^__x86_64__ */
-
- if (!has_new_bits(virgin_crash)) return keeping;
-
- }
-
- if (!unique_crashes) write_crash_readme();
-
-#ifndef SIMPLE_FILES
-
- fn = alloc_printf("%s/crashes/id:%06llu,sig:%02u,%s", out_dir,
- unique_crashes, kill_signal, describe_op(0));
-
-#else
-
- fn = alloc_printf("%s/crashes/id_%06llu_%02u", out_dir, unique_crashes,
- kill_signal);
-
-#endif /* ^!SIMPLE_FILES */
-
- unique_crashes++;
-
- last_crash_time = get_cur_time();
- last_crash_execs = total_execs;
-
- break;
-
- case FAULT_ERROR: FATAL("Unable to execute target application");
-
- default: return keeping;
-
- }
-
- /* If we're here, we apparently want to save the crash or hang
- test case, too. */
-
- fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
- ck_write(fd, mem, len, fn);
- close(fd);
-
- ck_free(fn);
-
- return keeping;
-
-}
-
-
-/* When resuming, try to find the queue position to start from. This makes sense
- only when resuming, and when we can find the original fuzzer_stats. */
-
-static u32 find_start_position(void) {
-
- static u8 tmp[4096]; /* Ought to be enough for anybody. */
-
- u8 *fn, *off;
- s32 fd, i;
- u32 ret;
-
- if (!resuming_fuzz) return 0;
-
- if (in_place_resume) fn = alloc_printf("%s/fuzzer_stats", out_dir);
- else fn = alloc_printf("%s/../fuzzer_stats", in_dir);
-
- fd = open(fn, O_RDONLY);
- ck_free(fn);
-
- if (fd < 0) return 0;
-
- i = read(fd, tmp, sizeof(tmp) - 1); (void)i; /* Ignore errors */
- close(fd);
-
- off = strstr(tmp, "cur_path : ");
- if (!off) return 0;
-
- ret = atoi(off + 17);
- if (ret >= queued_paths) ret = 0;
- return ret;
-
-}
-
-
-/* The same, but for timeouts. The idea is that when resuming sessions without
- -t given, we don't want to keep auto-scaling the timeout over and over
- again to prevent it from growing due to random flukes. */
-
-static void find_timeout(void) {
-
- static u8 tmp[4096]; /* Ought to be enough for anybody. */
-
- u8 *fn, *off;
- s32 fd, i;
- u32 ret;
-
- if (!resuming_fuzz) return;
-
- if (in_place_resume) fn = alloc_printf("%s/fuzzer_stats", out_dir);
- else fn = alloc_printf("%s/../fuzzer_stats", in_dir);
-
- fd = open(fn, O_RDONLY);
- ck_free(fn);
-
- if (fd < 0) return;
-
- i = read(fd, tmp, sizeof(tmp) - 1); (void)i; /* Ignore errors */
- close(fd);
-
- off = strstr(tmp, "exec_timeout : ");
- if (!off) return;
-
- ret = atoi(off + 17);
- if (ret <= 4) return;
-
- exec_tmout = ret;
- timeout_given = 3;
-
-}
-
-
-/* Update stats file for unattended monitoring. */
-
-static void write_stats_file(double bitmap_cvg, double stability, double eps) {
-
- static double last_bcvg, last_stab, last_eps;
-
- u8* fn = alloc_printf("%s/fuzzer_stats", out_dir);
- s32 fd;
- FILE* f;
-
- fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-
- if (fd < 0) PFATAL("Unable to create '%s'", fn);
-
- ck_free(fn);
-
- f = fdopen(fd, "w");
-
- if (!f) PFATAL("fdopen() failed");
-
- /* Keep last values in case we're called from another context
- where exec/sec stats and such are not readily available. */
-
- if (!bitmap_cvg && !stability && !eps) {
- bitmap_cvg = last_bcvg;
- stability = last_stab;
- eps = last_eps;
- } else {
- last_bcvg = bitmap_cvg;
- last_stab = stability;
- last_eps = eps;
- }
-
- fprintf(f, "start_time : %llu\n"
- "last_update : %llu\n"
- "fuzzer_pid : %u\n"
- "cycles_done : %llu\n"
- "execs_done : %llu\n"
- "execs_per_sec : %0.02f\n"
- "paths_total : %u\n"
- "paths_favored : %u\n"
- "paths_found : %u\n"
- "paths_imported : %u\n"
- "max_depth : %u\n"
- "cur_path : %u\n"
- "pending_favs : %u\n"
- "pending_total : %u\n"
- "variable_paths : %u\n"
- "stability : %0.02f%%\n"
- "bitmap_cvg : %0.02f%%\n"
- "unique_crashes : %llu\n"
- "unique_hangs : %llu\n"
- "last_path : %llu\n"
- "last_crash : %llu\n"
- "last_hang : %llu\n"
- "execs_since_crash : %llu\n"
- "exec_timeout : %u\n"
- "afl_banner : %s\n"
- "afl_version : " VERSION "\n"
- "command_line : %s\n",
- start_time / 1000, get_cur_time() / 1000, getpid(),
- queue_cycle ? (queue_cycle - 1) : 0, total_execs, eps,
- queued_paths, queued_favored, queued_discovered, queued_imported,
- max_depth, current_entry, pending_favored, pending_not_fuzzed,
- queued_variable, stability, bitmap_cvg, unique_crashes,
- unique_hangs, last_path_time / 1000, last_crash_time / 1000,
- last_hang_time / 1000, total_execs - last_crash_execs,
- exec_tmout, use_banner, orig_cmdline);
- /* ignore errors */
-
- fclose(f);
-
-}
-
-
-/* Update the plot file if there is a reason to. */
-
-static void maybe_update_plot_file(double bitmap_cvg, double eps) {
-
- static u32 prev_qp, prev_pf, prev_pnf, prev_ce, prev_md;
- static u64 prev_qc, prev_uc, prev_uh;
-
- if (prev_qp == queued_paths && prev_pf == pending_favored &&
- prev_pnf == pending_not_fuzzed && prev_ce == current_entry &&
- prev_qc == queue_cycle && prev_uc == unique_crashes &&
- prev_uh == unique_hangs && prev_md == max_depth) return;
-
- prev_qp = queued_paths;
- prev_pf = pending_favored;
- prev_pnf = pending_not_fuzzed;
- prev_ce = current_entry;
- prev_qc = queue_cycle;
- prev_uc = unique_crashes;
- prev_uh = unique_hangs;
- prev_md = max_depth;
-
- /* Fields in the file:
-
- unix_time, cycles_done, cur_path, paths_total, paths_not_fuzzed,
- favored_not_fuzzed, unique_crashes, unique_hangs, max_depth,
- execs_per_sec */
-
- fprintf(plot_file,
- "%llu, %llu, %u, %u, %u, %u, %0.02f%%, %llu, %llu, %u, %0.02f\n",
- get_cur_time() / 1000, queue_cycle - 1, current_entry, queued_paths,
- pending_not_fuzzed, pending_favored, bitmap_cvg, unique_crashes,
- unique_hangs, max_depth, eps); /* ignore errors */
-
- fflush(plot_file);
-
-}
-
-
-
-/* A helper function for maybe_delete_out_dir(), deleting all prefixed
- files in a directory. */
-
-static u8 delete_files(u8* path, u8* prefix) {
-
- DIR* d;
- struct dirent* d_ent;
-
- d = opendir(path);
-
- if (!d) return 0;
-
- while ((d_ent = readdir(d))) {
-
- if (d_ent->d_name[0] != '.' && (!prefix ||
- !strncmp(d_ent->d_name, prefix, strlen(prefix)))) {
-
- u8* fname = alloc_printf("%s/%s", path, d_ent->d_name);
- if (unlink(fname)) PFATAL("Unable to delete '%s'", fname);
- ck_free(fname);
-
- }
-
- }
-
- closedir(d);
-
- return !!rmdir(path);
-
-}
-
-
-/* Get the number of runnable processes, with some simple smoothing. */
-
-static double get_runnable_processes(void) {
-
- static double res;
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__)
-
- /* I don't see any portable sysctl or so that would quickly give us the
- number of runnable processes; the 1-minute load average can be a
- semi-decent approximation, though. */
-
- if (getloadavg(&res, 1) != 1) return 0;
-
-#else
-
- /* On Linux, /proc/stat is probably the best way; load averages are
- computed in funny ways and sometimes don't reflect extremely short-lived
- processes well. */
-
- FILE* f = fopen("/proc/stat", "r");
- u8 tmp[1024];
- u32 val = 0;
-
- if (!f) return 0;
-
- while (fgets(tmp, sizeof(tmp), f)) {
-
- if (!strncmp(tmp, "procs_running ", 14) ||
- !strncmp(tmp, "procs_blocked ", 14)) val += atoi(tmp + 14);
-
- }
-
- fclose(f);
-
- if (!res) {
-
- res = val;
-
- } else {
-
- res = res * (1.0 - 1.0 / AVG_SMOOTHING) +
- ((double)val) * (1.0 / AVG_SMOOTHING);
-
- }
-
-#endif /* ^(__APPLE__ || __FreeBSD__ || __OpenBSD__) */
-
- return res;
-
-}
-
-
-/* Delete the temporary directory used for in-place session resume. */
-
-static void nuke_resume_dir(void) {
-
- u8* fn;
-
- fn = alloc_printf("%s/_resume/.state/deterministic_done", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/_resume/.state/auto_extras", out_dir);
- if (delete_files(fn, "auto_")) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/_resume/.state/redundant_edges", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/_resume/.state/variable_behavior", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/_resume/.state", out_dir);
- if (rmdir(fn) && errno != ENOENT) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/_resume", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- return;
-
-dir_cleanup_failed:
-
- FATAL("_resume directory cleanup failed");
-
-}
-
-
-/* Delete fuzzer output directory if we recognize it as ours, if the fuzzer
- is not currently running, and if the last run time isn't too great. */
-
-static void maybe_delete_out_dir(void) {
-
- FILE* f;
- u8 *fn = alloc_printf("%s/fuzzer_stats", out_dir);
-
- /* See if the output directory is locked. If yes, bail out. If not,
- create a lock that will persist for the lifetime of the process
- (this requires leaving the descriptor open).*/
-
- out_dir_fd = open(out_dir, O_RDONLY);
- if (out_dir_fd < 0) PFATAL("Unable to open '%s'", out_dir);
-
-#ifndef __sun
-
- if (flock(out_dir_fd, LOCK_EX | LOCK_NB) && errno == EWOULDBLOCK) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Looks like the job output directory is being actively used by another\n"
- " instance of afl-fuzz. You will need to choose a different %s\n"
- " or stop the other process first.\n",
- sync_id ? "fuzzer ID" : "output location");
-
- FATAL("Directory '%s' is in use", out_dir);
-
- }
-
-#endif /* !__sun */
-
- f = fopen(fn, "r");
-
- if (f) {
-
- u64 start_time, last_update;
-
- if (fscanf(f, "start_time : %llu\n"
- "last_update : %llu\n", &start_time, &last_update) != 2)
- FATAL("Malformed data in '%s'", fn);
-
- fclose(f);
-
- /* Let's see how much work is at stake. */
-
- if (!in_place_resume && last_update - start_time > OUTPUT_GRACE * 60) {
-
- SAYF("\n" cLRD "[-] " cRST
- "The job output directory already exists and contains the results of more\n"
- " than %u minutes worth of fuzzing. To avoid data loss, afl-fuzz will *NOT*\n"
- " automatically delete this data for you.\n\n"
-
- " If you wish to start a new session, remove or rename the directory manually,\n"
- " or specify a different output location for this job. To resume the old\n"
- " session, put '-' as the input directory in the command line ('-i -') and\n"
- " try again.\n", OUTPUT_GRACE);
-
- FATAL("At-risk data found in '%s'", out_dir);
-
- }
-
- }
-
- ck_free(fn);
-
- /* The idea for in-place resume is pretty simple: we temporarily move the old
- queue/ to a new location that gets deleted once import to the new queue/
- is finished. If _resume/ already exists, the current queue/ may be
- incomplete due to an earlier abort, so we want to use the old _resume/
- dir instead, and we let rename() fail silently. */
-
- if (in_place_resume) {
-
- u8* orig_q = alloc_printf("%s/queue", out_dir);
-
- in_dir = alloc_printf("%s/_resume", out_dir);
-
- rename(orig_q, in_dir); /* Ignore errors */
-
- OKF("Output directory exists, will attempt session resume.");
-
- ck_free(orig_q);
-
- } else {
-
- OKF("Output directory exists but deemed OK to reuse.");
-
- }
-
- ACTF("Deleting old session data...");
-
- /* Okay, let's get the ball rolling! First, we need to get rid of the entries
- in <out_dir>/.synced/.../id:*, if any are present. */
-
- fn = alloc_printf("%s/.synced", out_dir);
- if (delete_files(fn, NULL)) goto dir_cleanup_failed;
- ck_free(fn);
-
- /* Next, we need to clean up <out_dir>/queue/.state/ subdirectories: */
-
- fn = alloc_printf("%s/queue/.state/deterministic_done", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/queue/.state/auto_extras", out_dir);
- if (delete_files(fn, "auto_")) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/queue/.state/redundant_edges", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/queue/.state/variable_behavior", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- /* Then, get rid of the .state subdirectory itself (should be empty by now)
- and everything matching <out_dir>/queue/id:*. */
-
- fn = alloc_printf("%s/queue/.state", out_dir);
- if (rmdir(fn) && errno != ENOENT) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/queue", out_dir);
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- /* All right, let's do <out_dir>/crashes/id:* and <out_dir>/hangs/id:*. */
-
- if (!in_place_resume) {
-
- fn = alloc_printf("%s/crashes/README.txt", out_dir);
- unlink(fn); /* Ignore errors */
- ck_free(fn);
-
- }
-
- fn = alloc_printf("%s/crashes", out_dir);
-
- /* Make backup of the crashes directory if it's not empty and if we're
- doing in-place resume. */
-
- if (in_place_resume && rmdir(fn)) {
-
- time_t cur_t = time(0);
- struct tm* t = localtime(&cur_t);
-
-#ifndef SIMPLE_FILES
-
- u8* nfn = alloc_printf("%s.%04u-%02u-%02u-%02u:%02u:%02u", fn,
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec);
-
-#else
-
- u8* nfn = alloc_printf("%s_%04u%02u%02u%02u%02u%02u", fn,
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec);
-
-#endif /* ^!SIMPLE_FILES */
-
- rename(fn, nfn); /* Ignore errors. */
- ck_free(nfn);
-
- }
-
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/hangs", out_dir);
-
- /* Backup hangs, too. */
-
- if (in_place_resume && rmdir(fn)) {
-
- time_t cur_t = time(0);
- struct tm* t = localtime(&cur_t);
-
-#ifndef SIMPLE_FILES
-
- u8* nfn = alloc_printf("%s.%04u-%02u-%02u-%02u:%02u:%02u", fn,
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec);
-
-#else
-
- u8* nfn = alloc_printf("%s_%04u%02u%02u%02u%02u%02u", fn,
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec);
-
-#endif /* ^!SIMPLE_FILES */
-
- rename(fn, nfn); /* Ignore errors. */
- ck_free(nfn);
-
- }
-
- if (delete_files(fn, CASE_PREFIX)) goto dir_cleanup_failed;
- ck_free(fn);
-
- /* And now, for some finishing touches. */
-
- fn = alloc_printf("%s/.cur_input", out_dir);
- if (unlink(fn) && errno != ENOENT) goto dir_cleanup_failed;
- ck_free(fn);
-
- fn = alloc_printf("%s/fuzz_bitmap", out_dir);
- if (unlink(fn) && errno != ENOENT) goto dir_cleanup_failed;
- ck_free(fn);
-
- if (!in_place_resume) {
- fn = alloc_printf("%s/fuzzer_stats", out_dir);
- if (unlink(fn) && errno != ENOENT) goto dir_cleanup_failed;
- ck_free(fn);
- }
-
- fn = alloc_printf("%s/plot_data", out_dir);
- if (unlink(fn) && errno != ENOENT) goto dir_cleanup_failed;
- ck_free(fn);
-
- OKF("Output dir cleanup successful.");
-
- /* Wow... is that all? If yes, celebrate! */
-
- return;
-
-dir_cleanup_failed:
-
- SAYF("\n" cLRD "[-] " cRST
- "Whoops, the fuzzer tried to reuse your output directory, but bumped into\n"
- " some files that shouldn't be there or that couldn't be removed - so it\n"
- " decided to abort! This happened while processing this path:\n\n"
-
- " %s\n\n"
- " Please examine and manually delete the files, or specify a different\n"
- " output location for the tool.\n", fn);
-
- FATAL("Output directory cleanup failed");
-
-}
-
-
-static void check_term_size(void);
-
-
-/* A spiffy retro stats screen! This is called every stats_update_freq
- execve() calls, plus in several other circumstances. */
-
-static void show_stats(void) {
-
- static u64 last_stats_ms, last_plot_ms, last_ms, last_execs;
- static double avg_exec;
- double t_byte_ratio, stab_ratio;
-
- u64 cur_ms;
- u32 t_bytes, t_bits;
-
- u32 banner_len, banner_pad;
- u8 tmp[256];
-
- cur_ms = get_cur_time();
-
- /* If not enough time has passed since last UI update, bail out. */
-
- if (cur_ms - last_ms < 1000 / UI_TARGET_HZ) return;
-
- /* Check if we're past the 10 minute mark. */
-
- if (cur_ms - start_time > 10 * 60 * 1000) run_over10m = 1;
-
- /* Calculate smoothed exec speed stats. */
-
- if (!last_execs) {
-
- avg_exec = ((double)total_execs) * 1000 / (cur_ms - start_time);
-
- } else {
-
- double cur_avg = ((double)(total_execs - last_execs)) * 1000 /
- (cur_ms - last_ms);
-
- /* If there is a dramatic (5x+) jump in speed, reset the indicator
- more quickly. */
-
- if (cur_avg * 5 < avg_exec || cur_avg / 5 > avg_exec)
- avg_exec = cur_avg;
-
- avg_exec = avg_exec * (1.0 - 1.0 / AVG_SMOOTHING) +
- cur_avg * (1.0 / AVG_SMOOTHING);
-
- }
-
- last_ms = cur_ms;
- last_execs = total_execs;
-
- /* Tell the callers when to contact us (as measured in execs). */
-
- stats_update_freq = avg_exec / (UI_TARGET_HZ * 10);
- if (!stats_update_freq) stats_update_freq = 1;
-
- /* Do some bitmap stats. */
-
- t_bytes = count_non_255_bytes(virgin_bits);
- t_byte_ratio = ((double)t_bytes * 100) / MAP_SIZE;
-
- if (t_bytes)
- stab_ratio = 100 - ((double)var_byte_count) * 100 / t_bytes;
- else
- stab_ratio = 100;
-
- /* Roughly every minute, update fuzzer stats and save auto tokens. */
-
- if (cur_ms - last_stats_ms > STATS_UPDATE_SEC * 1000) {
-
- last_stats_ms = cur_ms;
- write_stats_file(t_byte_ratio, stab_ratio, avg_exec);
- save_auto();
- write_bitmap();
-
- }
-
- /* Every now and then, write plot data. */
-
- if (cur_ms - last_plot_ms > PLOT_UPDATE_SEC * 1000) {
-
- last_plot_ms = cur_ms;
- maybe_update_plot_file(t_byte_ratio, avg_exec);
-
- }
-
- /* Honor AFL_EXIT_WHEN_DONE and AFL_BENCH_UNTIL_CRASH. */
-
- if (!dumb_mode && cycles_wo_finds > 100 && !pending_not_fuzzed &&
- getenv("AFL_EXIT_WHEN_DONE")) stop_soon = 2;
-
- if (total_crashes && getenv("AFL_BENCH_UNTIL_CRASH")) stop_soon = 2;
-
- /* If we're not on TTY, bail out. */
-
- if (not_on_tty) return;
-
- /* Compute some mildly useful bitmap stats. */
-
- t_bits = (MAP_SIZE << 3) - count_bits(virgin_bits);
-
- /* Now, for the visuals... */
-
- if (clear_screen) {
-
- SAYF(TERM_CLEAR CURSOR_HIDE);
- clear_screen = 0;
-
- check_term_size();
-
- }
-
- SAYF(TERM_HOME);
-
- if (term_too_small) {
-
- SAYF(cBRI "Your terminal is too small to display the UI.\n"
- "Please resize terminal window to at least 80x25.\n" cRST);
-
- return;
-
- }
-
- /* Let's start by drawing a centered banner. */
-
- banner_len = (crash_mode ? 24 : 22) + strlen(VERSION) + strlen(use_banner);
- banner_pad = (80 - banner_len) / 2;
- memset(tmp, ' ', banner_pad);
-
- sprintf(tmp + banner_pad, "%s " cLCY VERSION cLGN
- " (%s)", crash_mode ? cPIN "peruvian were-rabbit" :
- cYEL "american fuzzy lop", use_banner);
-
- SAYF("\n%s\n\n", tmp);
-
- /* "Handy" shortcuts for drawing boxes... */
-
-#define bSTG bSTART cGRA
-#define bH2 bH bH
-#define bH5 bH2 bH2 bH
-#define bH10 bH5 bH5
-#define bH20 bH10 bH10
-#define bH30 bH20 bH10
-#define SP5 " "
-#define SP10 SP5 SP5
-#define SP20 SP10 SP10
-
- /* Lord, forgive me this. */
-
- SAYF(SET_G1 bSTG bLT bH bSTOP cCYA " process timing " bSTG bH30 bH5 bH2 bHB
- bH bSTOP cCYA " overall results " bSTG bH5 bRT "\n");
-
- if (dumb_mode) {
-
- strcpy(tmp, cRST);
-
- } else {
-
- /* First queue cycle: don't stop now! */
- if (queue_cycle == 1) strcpy(tmp, cMGN); else
-
- /* Subsequent cycles, but we're still making finds. */
- if (cycles_wo_finds < 25) strcpy(tmp, cYEL); else
-
- /* No finds for a long time and no test cases to try. */
- if (cycles_wo_finds > 100 && !pending_not_fuzzed) strcpy(tmp, cLGN);
-
- /* Default: cautiously OK to stop? */
- else strcpy(tmp, cLBL);
-
- }
-
- SAYF(bV bSTOP " run time : " cRST "%-34s " bSTG bV bSTOP
- " cycles done : %s%-5s " bSTG bV "\n",
- DTD(cur_ms, start_time), tmp, DI(queue_cycle - 1));
-
- /* We want to warn people about not seeing new paths after a full cycle,
- except when resuming fuzzing or running in non-instrumented mode. */
-
- if (!dumb_mode && (last_path_time || resuming_fuzz || queue_cycle == 1 ||
- in_bitmap || crash_mode)) {
-
- SAYF(bV bSTOP " last new path : " cRST "%-34s ",
- DTD(cur_ms, last_path_time));
-
- } else {
-
- if (dumb_mode)
-
- SAYF(bV bSTOP " last new path : " cPIN "n/a" cRST
- " (non-instrumented mode) ");
-
- else
-
- SAYF(bV bSTOP " last new path : " cRST "none yet " cLRD
- "(odd, check syntax!) ");
-
- }
-
- SAYF(bSTG bV bSTOP " total paths : " cRST "%-5s " bSTG bV "\n",
- DI(queued_paths));
-
- /* Highlight crashes in red if found, denote going over the KEEP_UNIQUE_CRASH
- limit with a '+' appended to the count. */
-
- sprintf(tmp, "%s%s", DI(unique_crashes),
- (unique_crashes >= KEEP_UNIQUE_CRASH) ? "+" : "");
-
- SAYF(bV bSTOP " last uniq crash : " cRST "%-34s " bSTG bV bSTOP
- " uniq crashes : %s%-6s " bSTG bV "\n",
- DTD(cur_ms, last_crash_time), unique_crashes ? cLRD : cRST,
- tmp);
-
- sprintf(tmp, "%s%s", DI(unique_hangs),
- (unique_hangs >= KEEP_UNIQUE_HANG) ? "+" : "");
-
- SAYF(bV bSTOP " last uniq hang : " cRST "%-34s " bSTG bV bSTOP
- " uniq hangs : " cRST "%-6s " bSTG bV "\n",
- DTD(cur_ms, last_hang_time), tmp);
-
- SAYF(bVR bH bSTOP cCYA " cycle progress " bSTG bH20 bHB bH bSTOP cCYA
- " map coverage " bSTG bH bHT bH20 bH2 bH bVL "\n");
-
- /* This gets funny because we want to print several variable-length variables
- together, but then cram them into a fixed-width field - so we need to
- put them in a temporary buffer first. */
-
- sprintf(tmp, "%s%s (%0.02f%%)", DI(current_entry),
- queue_cur->favored ? "" : "*",
- ((double)current_entry * 100) / queued_paths);
-
- SAYF(bV bSTOP " now processing : " cRST "%-17s " bSTG bV bSTOP, tmp);
-
- sprintf(tmp, "%0.02f%% / %0.02f%%", ((double)queue_cur->bitmap_size) *
- 100 / MAP_SIZE, t_byte_ratio);
-
- SAYF(" map density : %s%-21s " bSTG bV "\n", t_byte_ratio > 70 ? cLRD :
- ((t_bytes < 200 && !dumb_mode) ? cPIN : cRST), tmp);
-
- sprintf(tmp, "%s (%0.02f%%)", DI(cur_skipped_paths),
- ((double)cur_skipped_paths * 100) / queued_paths);
-
- SAYF(bV bSTOP " paths timed out : " cRST "%-17s " bSTG bV, tmp);
-
- sprintf(tmp, "%0.02f bits/tuple",
- t_bytes ? (((double)t_bits) / t_bytes) : 0);
-
- SAYF(bSTOP " count coverage : " cRST "%-21s " bSTG bV "\n", tmp);
-
- SAYF(bVR bH bSTOP cCYA " stage progress " bSTG bH20 bX bH bSTOP cCYA
- " findings in depth " bSTG bH20 bVL "\n");
-
- sprintf(tmp, "%s (%0.02f%%)", DI(queued_favored),
- ((double)queued_favored) * 100 / queued_paths);
-
- /* Yeah... it's still going on... halp? */
-
- SAYF(bV bSTOP " now trying : " cRST "%-21s " bSTG bV bSTOP
- " favored paths : " cRST "%-22s " bSTG bV "\n", stage_name, tmp);
-
- if (!stage_max) {
-
- sprintf(tmp, "%s/-", DI(stage_cur));
-
- } else {
-
- sprintf(tmp, "%s/%s (%0.02f%%)", DI(stage_cur), DI(stage_max),
- ((double)stage_cur) * 100 / stage_max);
-
- }
-
- SAYF(bV bSTOP " stage execs : " cRST "%-21s " bSTG bV bSTOP, tmp);
-
- sprintf(tmp, "%s (%0.02f%%)", DI(queued_with_cov),
- ((double)queued_with_cov) * 100 / queued_paths);
-
- SAYF(" new edges on : " cRST "%-22s " bSTG bV "\n", tmp);
-
- sprintf(tmp, "%s (%s%s unique)", DI(total_crashes), DI(unique_crashes),
- (unique_crashes >= KEEP_UNIQUE_CRASH) ? "+" : "");
-
- if (crash_mode) {
-
- SAYF(bV bSTOP " total execs : " cRST "%-21s " bSTG bV bSTOP
- " new crashes : %s%-22s " bSTG bV "\n", DI(total_execs),
- unique_crashes ? cLRD : cRST, tmp);
-
- } else {
-
- SAYF(bV bSTOP " total execs : " cRST "%-21s " bSTG bV bSTOP
- " total crashes : %s%-22s " bSTG bV "\n", DI(total_execs),
- unique_crashes ? cLRD : cRST, tmp);
-
- }
-
- /* Show a warning about slow execution. */
-
- if (avg_exec < 100) {
-
- sprintf(tmp, "%s/sec (%s)", DF(avg_exec), avg_exec < 20 ?
- "zzzz..." : "slow!");
-
- SAYF(bV bSTOP " exec speed : " cLRD "%-21s ", tmp);
-
- } else {
-
- sprintf(tmp, "%s/sec", DF(avg_exec));
- SAYF(bV bSTOP " exec speed : " cRST "%-21s ", tmp);
-
- }
-
- sprintf(tmp, "%s (%s%s unique)", DI(total_hangs), DI(unique_hangs),
- (unique_hangs >= KEEP_UNIQUE_HANG) ? "+" : "");
-
- SAYF (bSTG bV bSTOP " total hangs : " cRST "%-22s " bSTG bV "\n", tmp);
-
- /* Aaaalmost there... hold on! */
-
- SAYF(bVR bH cCYA bSTOP " fuzzing strategy yields " bSTG bH10 bH bHT bH10
- bH5 bHB bH bSTOP cCYA " path geometry " bSTG bH5 bH2 bH bVL "\n");
-
- if (skip_deterministic) {
-
- strcpy(tmp, "n/a, n/a, n/a");
-
- } else {
-
- sprintf(tmp, "%s/%s, %s/%s, %s/%s",
- DI(stage_finds[STAGE_FLIP1]), DI(stage_cycles[STAGE_FLIP1]),
- DI(stage_finds[STAGE_FLIP2]), DI(stage_cycles[STAGE_FLIP2]),
- DI(stage_finds[STAGE_FLIP4]), DI(stage_cycles[STAGE_FLIP4]));
-
- }
-
- SAYF(bV bSTOP " bit flips : " cRST "%-37s " bSTG bV bSTOP " levels : "
- cRST "%-10s " bSTG bV "\n", tmp, DI(max_depth));
-
- if (!skip_deterministic)
- sprintf(tmp, "%s/%s, %s/%s, %s/%s",
- DI(stage_finds[STAGE_FLIP8]), DI(stage_cycles[STAGE_FLIP8]),
- DI(stage_finds[STAGE_FLIP16]), DI(stage_cycles[STAGE_FLIP16]),
- DI(stage_finds[STAGE_FLIP32]), DI(stage_cycles[STAGE_FLIP32]));
-
- SAYF(bV bSTOP " byte flips : " cRST "%-37s " bSTG bV bSTOP " pending : "
- cRST "%-10s " bSTG bV "\n", tmp, DI(pending_not_fuzzed));
-
- if (!skip_deterministic)
- sprintf(tmp, "%s/%s, %s/%s, %s/%s",
- DI(stage_finds[STAGE_ARITH8]), DI(stage_cycles[STAGE_ARITH8]),
- DI(stage_finds[STAGE_ARITH16]), DI(stage_cycles[STAGE_ARITH16]),
- DI(stage_finds[STAGE_ARITH32]), DI(stage_cycles[STAGE_ARITH32]));
-
- SAYF(bV bSTOP " arithmetics : " cRST "%-37s " bSTG bV bSTOP " pend fav : "
- cRST "%-10s " bSTG bV "\n", tmp, DI(pending_favored));
-
- if (!skip_deterministic)
- sprintf(tmp, "%s/%s, %s/%s, %s/%s",
- DI(stage_finds[STAGE_INTEREST8]), DI(stage_cycles[STAGE_INTEREST8]),
- DI(stage_finds[STAGE_INTEREST16]), DI(stage_cycles[STAGE_INTEREST16]),
- DI(stage_finds[STAGE_INTEREST32]), DI(stage_cycles[STAGE_INTEREST32]));
-
- SAYF(bV bSTOP " known ints : " cRST "%-37s " bSTG bV bSTOP " own finds : "
- cRST "%-10s " bSTG bV "\n", tmp, DI(queued_discovered));
-
- if (!skip_deterministic)
- sprintf(tmp, "%s/%s, %s/%s, %s/%s",
- DI(stage_finds[STAGE_EXTRAS_UO]), DI(stage_cycles[STAGE_EXTRAS_UO]),
- DI(stage_finds[STAGE_EXTRAS_UI]), DI(stage_cycles[STAGE_EXTRAS_UI]),
- DI(stage_finds[STAGE_EXTRAS_AO]), DI(stage_cycles[STAGE_EXTRAS_AO]));
-
- SAYF(bV bSTOP " dictionary : " cRST "%-37s " bSTG bV bSTOP
- " imported : " cRST "%-10s " bSTG bV "\n", tmp,
- sync_id ? DI(queued_imported) : (u8*)"n/a");
-
- sprintf(tmp, "%s/%s, %s/%s",
- DI(stage_finds[STAGE_HAVOC]), DI(stage_cycles[STAGE_HAVOC]),
- DI(stage_finds[STAGE_SPLICE]), DI(stage_cycles[STAGE_SPLICE]));
-
- SAYF(bV bSTOP " havoc : " cRST "%-37s " bSTG bV bSTOP, tmp);
-
- if (t_bytes) sprintf(tmp, "%0.02f%%", stab_ratio);
- else strcpy(tmp, "n/a");
-
- SAYF(" stability : %s%-10s " bSTG bV "\n", (stab_ratio < 85 && var_byte_count > 40)
- ? cLRD : ((queued_variable && (!persistent_mode || var_byte_count > 20))
- ? cMGN : cRST), tmp);
-
- if (!bytes_trim_out) {
-
- sprintf(tmp, "n/a, ");
-
- } else {
-
- sprintf(tmp, "%0.02f%%/%s, ",
- ((double)(bytes_trim_in - bytes_trim_out)) * 100 / bytes_trim_in,
- DI(trim_execs));
-
- }
-
- if (!blocks_eff_total) {
-
- u8 tmp2[128];
-
- sprintf(tmp2, "n/a");
- strcat(tmp, tmp2);
-
- } else {
-
- u8 tmp2[128];
-
- sprintf(tmp2, "%0.02f%%",
- ((double)(blocks_eff_total - blocks_eff_select)) * 100 /
- blocks_eff_total);
-
- strcat(tmp, tmp2);
-
- }
-
- SAYF(bV bSTOP " trim : " cRST "%-37s " bSTG bVR bH20 bH2 bH2 bRB "\n"
- bLB bH30 bH20 bH2 bH bRB bSTOP cRST RESET_G1, tmp);
-
- /* Provide some CPU utilization stats. */
-
- if (cpu_core_count) {
-
- double cur_runnable = get_runnable_processes();
- u32 cur_utilization = cur_runnable * 100 / cpu_core_count;
-
- u8* cpu_color = cCYA;
-
- /* If we could still run one or more processes, use green. */
-
- if (cpu_core_count > 1 && cur_runnable + 1 <= cpu_core_count)
- cpu_color = cLGN;
-
- /* If we're clearly oversubscribed, use red. */
-
- if (!no_cpu_meter_red && cur_utilization >= 150) cpu_color = cLRD;
-
-#ifdef HAVE_AFFINITY
-
- if (cpu_aff >= 0) {
-
- SAYF(SP10 cGRA "[cpu%03u:%s%3u%%" cGRA "]\r" cRST,
- MIN(cpu_aff, 999), cpu_color,
- MIN(cur_utilization, 999));
-
- } else {
-
- SAYF(SP10 cGRA " [cpu:%s%3u%%" cGRA "]\r" cRST,
- cpu_color, MIN(cur_utilization, 999));
-
- }
-
-#else
-
- SAYF(SP10 cGRA " [cpu:%s%3u%%" cGRA "]\r" cRST,
- cpu_color, MIN(cur_utilization, 999));
-
-#endif /* ^HAVE_AFFINITY */
-
- } else SAYF("\r");
-
- /* Hallelujah! */
-
- fflush(0);
-
-}
-
-
-/* Display quick statistics at the end of processing the input directory,
- plus a bunch of warnings. Some calibration stuff also ended up here,
- along with several hardcoded constants. Maybe clean up eventually. */
-
-static void show_init_stats(void) {
-
- struct queue_entry* q = queue;
- u32 min_bits = 0, max_bits = 0;
- u64 min_us = 0, max_us = 0;
- u64 avg_us = 0;
- u32 max_len = 0;
-
- if (total_cal_cycles) avg_us = total_cal_us / total_cal_cycles;
-
- while (q) {
-
- if (!min_us || q->exec_us < min_us) min_us = q->exec_us;
- if (q->exec_us > max_us) max_us = q->exec_us;
-
- if (!min_bits || q->bitmap_size < min_bits) min_bits = q->bitmap_size;
- if (q->bitmap_size > max_bits) max_bits = q->bitmap_size;
-
- if (q->len > max_len) max_len = q->len;
-
- q = q->next;
-
- }
-
- SAYF("\n");
-
- if (avg_us > (qemu_mode ? 50000 : 10000))
- WARNF(cLRD "The target binary is pretty slow! See %s/perf_tips.txt.",
- doc_path);
-
- /* Let's keep things moving with slow binaries. */
-
- if (avg_us > 50000) havoc_div = 10; /* 0-19 execs/sec */
- else if (avg_us > 20000) havoc_div = 5; /* 20-49 execs/sec */
- else if (avg_us > 10000) havoc_div = 2; /* 50-100 execs/sec */
-
- if (!resuming_fuzz) {
-
- if (max_len > 50 * 1024)
- WARNF(cLRD "Some test cases are huge (%s) - see %s/perf_tips.txt!",
- DMS(max_len), doc_path);
- else if (max_len > 10 * 1024)
- WARNF("Some test cases are big (%s) - see %s/perf_tips.txt.",
- DMS(max_len), doc_path);
-
- if (useless_at_start && !in_bitmap)
- WARNF(cLRD "Some test cases look useless. Consider using a smaller set.");
-
- if (queued_paths > 100)
- WARNF(cLRD "You probably have far too many input files! Consider trimming down.");
- else if (queued_paths > 20)
- WARNF("You have lots of input files; try starting small.");
-
- }
-
- OKF("Here are some useful stats:\n\n"
-
- cGRA " Test case count : " cRST "%u favored, %u variable, %u total\n"
- cGRA " Bitmap range : " cRST "%u to %u bits (average: %0.02f bits)\n"
- cGRA " Exec timing : " cRST "%s to %s us (average: %s us)\n",
- queued_favored, queued_variable, queued_paths, min_bits, max_bits,
- ((double)total_bitmap_size) / (total_bitmap_entries ? total_bitmap_entries : 1),
- DI(min_us), DI(max_us), DI(avg_us));
-
- if (!timeout_given) {
-
- /* Figure out the appropriate timeout. The basic idea is: 5x average or
- 1x max, rounded up to EXEC_TM_ROUND ms and capped at 1 second.
-
- If the program is slow, the multiplier is lowered to 2x or 3x, because
- random scheduler jitter is less likely to have any impact, and because
- our patience is wearing thin =) */
-
- if (avg_us > 50000) exec_tmout = avg_us * 2 / 1000;
- else if (avg_us > 10000) exec_tmout = avg_us * 3 / 1000;
- else exec_tmout = avg_us * 5 / 1000;
-
- exec_tmout = MAX(exec_tmout, max_us / 1000);
- exec_tmout = (exec_tmout + EXEC_TM_ROUND) / EXEC_TM_ROUND * EXEC_TM_ROUND;
-
- if (exec_tmout > EXEC_TIMEOUT) exec_tmout = EXEC_TIMEOUT;
-
- ACTF("No -t option specified, so I'll use exec timeout of %u ms.",
- exec_tmout);
-
- timeout_given = 1;
-
- } else if (timeout_given == 3) {
-
- ACTF("Applying timeout settings from resumed session (%u ms).", exec_tmout);
-
- }
-
- OKF("All set and ready to roll!");
-
-}
-
-
-/* Find first power of two greater or equal to val. */
-
-static u32 next_p2(u32 val) {
-
- u32 ret = 1;
- while (val > ret) ret <<= 1;
- return ret;
-
-}
-
-
-/* Trim all new test cases to save cycles when doing deterministic checks. The
- trimmer uses power-of-two increments somewhere between 1/16 and 1/1024 of
- file size, to keep the stage short and sweet. */
-
-static u8 trim_case(char** argv, struct queue_entry* q, u8* in_buf) {
-
- static u8 tmp[64];
- static u8 clean_trace[MAP_SIZE];
-
- u8 needs_write = 0, fault = 0;
- u32 trim_exec = 0;
- u32 remove_len;
- u32 len_p2;
-
- /* Although the trimmer will be less useful when variable behavior is
- detected, it will still work to some extent, so we don't check for
- this. */
-
- if (q->len < 5) return 0;
-
- stage_name = tmp;
- bytes_trim_in += q->len;
-
- /* Select initial chunk len, starting with large steps. */
-
- len_p2 = next_p2(q->len);
-
- remove_len = MAX(len_p2 / TRIM_START_STEPS, TRIM_MIN_BYTES);
-
- /* Continue until the number of steps gets too high or the stepover
- gets too small. */
-
- while (remove_len >= MAX(len_p2 / TRIM_END_STEPS, TRIM_MIN_BYTES)) {
-
- u32 remove_pos = remove_len;
-
- sprintf(tmp, "trim %s/%s", DI(remove_len), DI(remove_len));
-
- stage_cur = 0;
- stage_max = q->len / remove_len;
-
- while (remove_pos < q->len) {
-
- u32 trim_avail = MIN(remove_len, q->len - remove_pos);
- u32 cksum;
-
- write_with_gap(in_buf, q->len, remove_pos, trim_avail);
-
- fault = run_target(argv);
- trim_execs++;
-
- if (stop_soon || fault == FAULT_ERROR) goto abort_trimming;
-
- /* Note that we don't keep track of crashes or hangs here; maybe TODO? */
-
- cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
-
- /* If the deletion had no impact on the trace, make it permanent. This
- isn't perfect for variable-path inputs, but we're just making a
- best-effort pass, so it's not a big deal if we end up with false
- negatives every now and then. */
-
- if (cksum == q->exec_cksum) {
-
- u32 move_tail = q->len - remove_pos - trim_avail;
-
- q->len -= trim_avail;
- len_p2 = next_p2(q->len);
-
- memmove(in_buf + remove_pos, in_buf + remove_pos + trim_avail,
- move_tail);
-
- /* Let's save a clean trace, which will be needed by
- update_bitmap_score once we're done with the trimming stuff. */
-
- if (!needs_write) {
-
- needs_write = 1;
- memcpy(clean_trace, trace_bits, MAP_SIZE);
-
- }
-
- } else remove_pos += remove_len;
-
- /* Since this can be slow, update the screen every now and then. */
-
- if (!(trim_exec++ % stats_update_freq)) show_stats();
- stage_cur++;
-
- }
-
- remove_len >>= 1;
-
- }
-
- /* If we have made changes to in_buf, we also need to update the on-disk
- version of the test case. */
-
- if (needs_write) {
-
- s32 fd;
-
- unlink(q->fname); /* ignore errors */
-
- fd = open(q->fname, O_WRONLY | O_CREAT | O_EXCL, 0600);
-
- if (fd < 0) PFATAL("Unable to create '%s'", q->fname);
-
- ck_write(fd, in_buf, q->len, q->fname);
- close(fd);
-
- memcpy(trace_bits, clean_trace, MAP_SIZE);
- update_bitmap_score(q);
-
- }
-
-
-
-abort_trimming:
-
- bytes_trim_out += q->len;
- return fault;
-
-}
-
-
-/* Write a modified test case, run program, process results. Handle
- error conditions, returning 1 if it's time to bail out. This is
- a helper function for fuzz_one(). */
-
-EXP_ST u8 common_fuzz_stuff(char** argv, u8* out_buf, u32 len) {
-
- u8 fault;
-
- if (post_handler) {
-
- out_buf = post_handler(out_buf, &len);
- if (!out_buf || !len) return 0;
-
- }
-
- write_to_testcase(out_buf, len);
-
- fault = run_target(argv);
-
- if (stop_soon) return 1;
-
- if (fault == FAULT_HANG) {
-
- if (subseq_hangs++ > HANG_LIMIT) {
- cur_skipped_paths++;
- return 1;
- }
-
- } else subseq_hangs = 0;
-
- /* Users can hit us with SIGUSR1 to request the current input
- to be abandoned. */
-
- if (skip_requested) {
-
- skip_requested = 0;
- cur_skipped_paths++;
- return 1;
-
- }
-
- /* This handles FAULT_ERROR for us: */
-
- queued_discovered += save_if_interesting(argv, out_buf, len, fault);
-
- if (!(stage_cur % stats_update_freq) || stage_cur + 1 == stage_max)
- show_stats();
-
- return 0;
-
-}
-
-
-/* Helper to choose random block len for block operations in fuzz_one().
- Doesn't return zero, provided that max_len is > 0. */
-
-static u32 choose_block_len(u32 limit) {
-
- u32 min_value, max_value;
- u32 rlim = MIN(queue_cycle, 3);
-
- if (!run_over10m) rlim = 1;
-
- switch (UR(rlim)) {
-
- case 0: min_value = 1;
- max_value = HAVOC_BLK_SMALL;
- break;
-
- case 1: min_value = HAVOC_BLK_SMALL;
- max_value = HAVOC_BLK_MEDIUM;
- break;
-
- default: min_value = HAVOC_BLK_MEDIUM;
- max_value = HAVOC_BLK_LARGE;
-
-
- }
-
- if (min_value >= limit) min_value = 1;
-
- return min_value + UR(MIN(max_value, limit) - min_value + 1);
-
-}
-
-
-/* Calculate case desirability score to adjust the length of havoc fuzzing.
- A helper function for fuzz_one(). Maybe some of these constants should
- go into config.h. */
-
-static u32 calculate_score(struct queue_entry* q) {
-
- u32 avg_exec_us = total_cal_us / total_cal_cycles;
- u32 avg_bitmap_size = total_bitmap_size / total_bitmap_entries;
- u32 perf_score = 100;
-
- /* Adjust score based on execution speed of this path, compared to the
- global average. Multiplier ranges from 0.1x to 3x. Fast inputs are
- less expensive to fuzz, so we're giving them more air time. */
-
- if (q->exec_us * 0.1 > avg_exec_us) perf_score = 10;
- else if (q->exec_us * 0.25 > avg_exec_us) perf_score = 25;
- else if (q->exec_us * 0.5 > avg_exec_us) perf_score = 50;
- else if (q->exec_us * 0.75 > avg_exec_us) perf_score = 75;
- else if (q->exec_us * 4 < avg_exec_us) perf_score = 300;
- else if (q->exec_us * 3 < avg_exec_us) perf_score = 200;
- else if (q->exec_us * 2 < avg_exec_us) perf_score = 150;
-
- /* Adjust score based on bitmap size. The working theory is that better
- coverage translates to better targets. Multiplier from 0.25x to 3x. */
-
- if (q->bitmap_size * 0.3 > avg_bitmap_size) perf_score *= 3;
- else if (q->bitmap_size * 0.5 > avg_bitmap_size) perf_score *= 2;
- else if (q->bitmap_size * 0.75 > avg_bitmap_size) perf_score *= 1.5;
- else if (q->bitmap_size * 3 < avg_bitmap_size) perf_score *= 0.25;
- else if (q->bitmap_size * 2 < avg_bitmap_size) perf_score *= 0.5;
- else if (q->bitmap_size * 1.5 < avg_bitmap_size) perf_score *= 0.75;
-
- /* Adjust score based on handicap. Handicap is proportional to how late
- in the game we learned about this path. Latecomers are allowed to run
- for a bit longer until they catch up with the rest. */
-
- if (q->handicap >= 4) {
-
- perf_score *= 4;
- q->handicap -= 4;
-
- } else if (q->handicap) {
-
- perf_score *= 2;
- q->handicap--;
-
- }
-
- /* Final adjustment based on input depth, under the assumption that fuzzing
- deeper test cases is more likely to reveal stuff that can't be
- discovered with traditional fuzzers. */
-
- switch (q->depth) {
-
- case 0 ... 3: break;
- case 4 ... 7: perf_score *= 2; break;
- case 8 ... 13: perf_score *= 3; break;
- case 14 ... 25: perf_score *= 4; break;
- default: perf_score *= 5;
-
- }
-
- /* Make sure that we don't go over limit. */
-
- if (perf_score > HAVOC_MAX_MULT * 100) perf_score = HAVOC_MAX_MULT * 100;
-
- return perf_score;
-
-}
-
-
-/* Helper function to see if a particular change (xor_val = old ^ new) could
- be a product of deterministic bit flips with the lengths and stepovers
- attempted by afl-fuzz. This is used to avoid dupes in some of the
- deterministic fuzzing operations that follow bit flips. We also
- return 1 if xor_val is zero, which implies that the old and attempted new
- values are identical and the exec would be a waste of time. */
-
-static u8 could_be_bitflip(u32 xor_val) {
-
- u32 sh = 0;
-
- if (!xor_val) return 1;
-
- /* Shift left until first bit set. */
-
- while (!(xor_val & 1)) { sh++; xor_val >>= 1; }
-
- /* 1-, 2-, and 4-bit patterns are OK anywhere. */
-
- if (xor_val == 1 || xor_val == 3 || xor_val == 15) return 1;
-
- /* 8-, 16-, and 32-bit patterns are OK only if shift factor is
- divisible by 8, since that's the stepover for these ops. */
-
- if (sh & 7) return 0;
-
- if (xor_val == 0xff || xor_val == 0xffff || xor_val == 0xffffffff)
- return 1;
-
- return 0;
-
-}
-
-
-/* Helper function to see if a particular value is reachable through
- arithmetic operations. Used for similar purposes. */
-
-static u8 could_be_arith(u32 old_val, u32 new_val, u8 blen) {
-
- u32 i, ov = 0, nv = 0, diffs = 0;
-
- if (old_val == new_val) return 1;
-
- /* See if one-byte adjustments to any byte could produce this result. */
-
- for (i = 0; i < blen; i++) {
-
- u8 a = old_val >> (8 * i),
- b = new_val >> (8 * i);
-
- if (a != b) { diffs++; ov = a; nv = b; }
-
- }
-
- /* If only one byte differs and the values are within range, return 1. */
-
- if (diffs == 1) {
-
- if ((u8)(ov - nv) <= ARITH_MAX ||
- (u8)(nv - ov) <= ARITH_MAX) return 1;
-
- }
-
- if (blen == 1) return 0;
-
- /* See if two-byte adjustments to any byte would produce this result. */
-
- diffs = 0;
-
- for (i = 0; i < blen / 2; i++) {
-
- u16 a = old_val >> (16 * i),
- b = new_val >> (16 * i);
-
- if (a != b) { diffs++; ov = a; nv = b; }
-
- }
-
- /* If only one word differs and the values are within range, return 1. */
-
- if (diffs == 1) {
-
- if ((u16)(ov - nv) <= ARITH_MAX ||
- (u16)(nv - ov) <= ARITH_MAX) return 1;
-
- ov = SWAP16(ov); nv = SWAP16(nv);
-
- if ((u16)(ov - nv) <= ARITH_MAX ||
- (u16)(nv - ov) <= ARITH_MAX) return 1;
-
- }
-
- /* Finally, let's do the same thing for dwords. */
-
- if (blen == 4) {
-
- if ((u32)(old_val - new_val) <= ARITH_MAX ||
- (u32)(new_val - old_val) <= ARITH_MAX) return 1;
-
- new_val = SWAP32(new_val);
- old_val = SWAP32(old_val);
-
- if ((u32)(old_val - new_val) <= ARITH_MAX ||
- (u32)(new_val - old_val) <= ARITH_MAX) return 1;
-
- }
-
- return 0;
-
-}
-
-
-/* Last but not least, a similar helper to see if insertion of an
- interesting integer is redundant given the insertions done for
- shorter blen. The last param (check_le) is set if the caller
- already executed LE insertion for current blen and wants to see
- if BE variant passed in new_val is unique. */
-
-static u8 could_be_interest(u32 old_val, u32 new_val, u8 blen, u8 check_le) {
-
- u32 i, j;
-
- if (old_val == new_val) return 1;
-
- /* See if one-byte insertions from interesting_8 over old_val could
- produce new_val. */
-
- for (i = 0; i < blen; i++) {
-
- for (j = 0; j < sizeof(interesting_8); j++) {
-
- u32 tval = (old_val & ~(0xff << (i * 8))) |
- (((u8)interesting_8[j]) << (i * 8));
-
- if (new_val == tval) return 1;
-
- }
-
- }
-
- /* Bail out unless we're also asked to examine two-byte LE insertions
- as a preparation for BE attempts. */
-
- if (blen == 2 && !check_le) return 0;
-
- /* See if two-byte insertions over old_val could give us new_val. */
-
- for (i = 0; i < blen - 1; i++) {
-
- for (j = 0; j < sizeof(interesting_16) / 2; j++) {
-
- u32 tval = (old_val & ~(0xffff << (i * 8))) |
- (((u16)interesting_16[j]) << (i * 8));
-
- if (new_val == tval) return 1;
-
- /* Continue here only if blen > 2. */
-
- if (blen > 2) {
-
- tval = (old_val & ~(0xffff << (i * 8))) |
- (SWAP16(interesting_16[j]) << (i * 8));
-
- if (new_val == tval) return 1;
-
- }
-
- }
-
- }
-
- if (blen == 4 && check_le) {
-
- /* See if four-byte insertions could produce the same result
- (LE only). */
-
- for (j = 0; j < sizeof(interesting_32) / 4; j++)
- if (new_val == (u32)interesting_32[j]) return 1;
-
- }
-
- return 0;
-
-}
-
-
-/* Take the current entry from the queue, fuzz it for a while. This
- function is a tad too long... returns 0 if fuzzed successfully, 1 if
- skipped or bailed out. */
-
-static u8 fuzz_one(char** argv) {
-
- s32 len, fd, temp_len, i, j;
- u8 *in_buf, *out_buf, *orig_in, *ex_tmp, *eff_map = 0;
- u64 havoc_queued, orig_hit_cnt, new_hit_cnt;
- u32 splice_cycle = 0, perf_score = 100, orig_perf, prev_cksum, eff_cnt = 1;
-
- u8 ret_val = 1, doing_det = 0;
-
- u8 a_collect[MAX_AUTO_EXTRA];
- u32 a_len = 0;
-
-#ifdef IGNORE_FINDS
-
- /* In IGNORE_FINDS mode, skip any entries that weren't in the
- initial data set. */
-
- if (queue_cur->depth > 1) return 1;
-
-#else
-
- if (pending_favored) {
-
- /* If we have any favored, non-fuzzed new arrivals in the queue,
- possibly skip to them at the expense of already-fuzzed or non-favored
- cases. */
-
- if ((queue_cur->was_fuzzed || !queue_cur->favored) &&
- UR(100) < SKIP_TO_NEW_PROB) return 1;
-
- } else if (!dumb_mode && !queue_cur->favored && queued_paths > 10) {
-
- /* Otherwise, still possibly skip non-favored cases, albeit less often.
- The odds of skipping stuff are higher for already-fuzzed inputs and
- lower for never-fuzzed entries. */
-
- if (queue_cycle > 1 && !queue_cur->was_fuzzed) {
-
- if (UR(100) < SKIP_NFAV_NEW_PROB) return 1;
-
- } else {
-
- if (UR(100) < SKIP_NFAV_OLD_PROB) return 1;
-
- }
-
- }
-
-#endif /* ^IGNORE_FINDS */
-
- if (not_on_tty) {
- ACTF("Fuzzing test case #%u (%u total, %llu uniq crashes found)...",
- current_entry, queued_paths, unique_crashes);
- fflush(stdout);
- }
-
- /* Map the test case into memory. */
-
- fd = open(queue_cur->fname, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", queue_cur->fname);
-
- len = queue_cur->len;
-
- orig_in = in_buf = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
-
- if (orig_in == MAP_FAILED) PFATAL("Unable to mmap '%s'", queue_cur->fname);
-
- close(fd);
-
- /* We could mmap() out_buf as MAP_PRIVATE, but we end up clobbering every
- single byte anyway, so it wouldn't give us any performance or memory usage
- benefits. */
-
- out_buf = ck_alloc_nozero(len);
-
- subseq_hangs = 0;
-
- cur_depth = queue_cur->depth;
-
- /*******************************************
- * CALIBRATION (only if failed earlier on) *
- *******************************************/
-
- if (queue_cur->cal_failed) {
-
- u8 res = FAULT_HANG;
-
- if (queue_cur->cal_failed < CAL_CHANCES) {
-
- res = calibrate_case(argv, queue_cur, in_buf, queue_cycle - 1, 0);
-
- if (res == FAULT_ERROR)
- FATAL("Unable to execute target application");
-
- }
-
- if (stop_soon || res != crash_mode) {
- cur_skipped_paths++;
- goto abandon_entry;
- }
-
- }
-
- /************
- * TRIMMING *
- ************/
-
- if (!dumb_mode && !queue_cur->trim_done) {
-
- u8 res = trim_case(argv, queue_cur, in_buf);
-
- if (res == FAULT_ERROR)
- FATAL("Unable to execute target application");
-
- if (stop_soon) {
- cur_skipped_paths++;
- goto abandon_entry;
- }
-
- /* Don't retry trimming, even if it failed. */
-
- queue_cur->trim_done = 1;
-
- if (len != queue_cur->len) len = queue_cur->len;
-
- }
-
- memcpy(out_buf, in_buf, len);
-
- /*********************
- * PERFORMANCE SCORE *
- *********************/
-
- orig_perf = perf_score = calculate_score(queue_cur);
-
- /* Skip right away if -d is given, if we have done deterministic fuzzing on
- this entry ourselves (was_fuzzed), or if it has gone through deterministic
- testing in earlier, resumed runs (passed_det). */
-
- if (skip_deterministic || queue_cur->was_fuzzed || queue_cur->passed_det)
- goto havoc_stage;
-
- /* Skip deterministic fuzzing if exec path checksum puts this out of scope
- for this master instance. */
-
- if (master_max && (queue_cur->exec_cksum % master_max) != master_id - 1)
- goto havoc_stage;
-
- doing_det = 1;
-
- /*********************************************
- * SIMPLE BITFLIP (+dictionary construction) *
- *********************************************/
-
-#define FLIP_BIT(_ar, _b) do { \
- u8* _arf = (u8*)(_ar); \
- u32 _bf = (_b); \
- _arf[(_bf) >> 3] ^= (128 >> ((_bf) & 7)); \
- } while (0)
-
- /* Single walking bit. */
-
- stage_short = "flip1";
- stage_max = len << 3;
- stage_name = "bitflip 1/1";
-
- stage_val_type = STAGE_VAL_NONE;
-
- orig_hit_cnt = queued_paths + unique_crashes;
-
- prev_cksum = queue_cur->exec_cksum;
-
- for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {
-
- stage_cur_byte = stage_cur >> 3;
-
- FLIP_BIT(out_buf, stage_cur);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- FLIP_BIT(out_buf, stage_cur);
-
- /* While flipping the least significant bit in every byte, pull of an extra
- trick to detect possible syntax tokens. In essence, the idea is that if
- you have a binary blob like this:
-
- xxxxxxxxIHDRxxxxxxxx
-
- ...and changing the leading and trailing bytes causes variable or no
- changes in program flow, but touching any character in the "IHDR" string
- always produces the same, distinctive path, it's highly likely that
- "IHDR" is an atomically-checked magic value of special significance to
- the fuzzed format.
-
- We do this here, rather than as a separate stage, because it's a nice
- way to keep the operation approximately "free" (i.e., no extra execs).
-
- Empirically, performing the check when flipping the least significant bit
- is advantageous, compared to doing it at the time of more disruptive
- changes, where the program flow may be affected in more violent ways.
-
- The caveat is that we won't generate dictionaries in the -d mode or -S
- mode - but that's probably a fair trade-off.
-
- This won't work particularly well with paths that exhibit variable
- behavior, but fails gracefully, so we'll carry out the checks anyway.
-
- */
-
- if (!dumb_mode && (stage_cur & 7) == 7) {
-
- u32 cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
-
- if (stage_cur == stage_max - 1 && cksum == prev_cksum) {
-
- /* If at end of file and we are still collecting a string, grab the
- final character and force output. */
-
- if (a_len < MAX_AUTO_EXTRA) a_collect[a_len] = out_buf[stage_cur >> 3];
- a_len++;
-
- if (a_len >= MIN_AUTO_EXTRA && a_len <= MAX_AUTO_EXTRA)
- maybe_add_auto(a_collect, a_len);
-
- } else if (cksum != prev_cksum) {
-
- /* Otherwise, if the checksum has changed, see if we have something
- worthwhile queued up, and collect that if the answer is yes. */
-
- if (a_len >= MIN_AUTO_EXTRA && a_len <= MAX_AUTO_EXTRA)
- maybe_add_auto(a_collect, a_len);
-
- a_len = 0;
- prev_cksum = cksum;
-
- }
-
- /* Continue collecting string, but only if the bit flip actually made
- any difference - we don't want no-op tokens. */
-
- if (cksum != queue_cur->exec_cksum) {
-
- if (a_len < MAX_AUTO_EXTRA) a_collect[a_len] = out_buf[stage_cur >> 3];
- a_len++;
-
- }
-
- }
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_FLIP1] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_FLIP1] += stage_max;
-
- /* Two walking bits. */
-
- stage_name = "bitflip 2/1";
- stage_short = "flip2";
- stage_max = (len << 3) - 1;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {
-
- stage_cur_byte = stage_cur >> 3;
-
- FLIP_BIT(out_buf, stage_cur);
- FLIP_BIT(out_buf, stage_cur + 1);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- FLIP_BIT(out_buf, stage_cur);
- FLIP_BIT(out_buf, stage_cur + 1);
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_FLIP2] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_FLIP2] += stage_max;
-
- /* Four walking bits. */
-
- stage_name = "bitflip 4/1";
- stage_short = "flip4";
- stage_max = (len << 3) - 3;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {
-
- stage_cur_byte = stage_cur >> 3;
-
- FLIP_BIT(out_buf, stage_cur);
- FLIP_BIT(out_buf, stage_cur + 1);
- FLIP_BIT(out_buf, stage_cur + 2);
- FLIP_BIT(out_buf, stage_cur + 3);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- FLIP_BIT(out_buf, stage_cur);
- FLIP_BIT(out_buf, stage_cur + 1);
- FLIP_BIT(out_buf, stage_cur + 2);
- FLIP_BIT(out_buf, stage_cur + 3);
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_FLIP4] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_FLIP4] += stage_max;
-
- /* Effector map setup. These macros calculate:
-
- EFF_APOS - position of a particular file offset in the map.
- EFF_ALEN - length of a map with a particular number of bytes.
- EFF_SPAN_ALEN - map span for a sequence of bytes.
-
- */
-
-#define EFF_APOS(_p) ((_p) >> EFF_MAP_SCALE2)
-#define EFF_REM(_x) ((_x) & ((1 << EFF_MAP_SCALE2) - 1))
-#define EFF_ALEN(_l) (EFF_APOS(_l) + !!EFF_REM(_l))
-#define EFF_SPAN_ALEN(_p, _l) (EFF_APOS((_p) + (_l) - 1) - EFF_APOS(_p) + 1)
-
- /* Initialize effector map for the next step (see comments below). Always
- flag first and last byte as doing something. */
-
- eff_map = ck_alloc(EFF_ALEN(len));
- eff_map[0] = 1;
-
- if (EFF_APOS(len - 1) != 0) {
- eff_map[EFF_APOS(len - 1)] = 1;
- eff_cnt++;
- }
-
- /* Walking byte. */
-
- stage_name = "bitflip 8/8";
- stage_short = "flip8";
- stage_max = len;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {
-
- stage_cur_byte = stage_cur;
-
- out_buf[stage_cur] ^= 0xFF;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- /* We also use this stage to pull off a simple trick: we identify
- bytes that seem to have no effect on the current execution path
- even when fully flipped - and we skip them during more expensive
- deterministic stages, such as arithmetics or known ints. */
-
- if (!eff_map[EFF_APOS(stage_cur)]) {
-
- u32 cksum;
-
- /* If in dumb mode or if the file is very short, just flag everything
- without wasting time on checksums. */
-
- if (!dumb_mode && len >= EFF_MIN_LEN)
- cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
- else
- cksum = ~queue_cur->exec_cksum;
-
- if (cksum != queue_cur->exec_cksum) {
- eff_map[EFF_APOS(stage_cur)] = 1;
- eff_cnt++;
- }
-
- }
-
- out_buf[stage_cur] ^= 0xFF;
-
- }
-
- /* If the effector map is more than EFF_MAX_PERC dense, just flag the
- whole thing as worth fuzzing, since we wouldn't be saving much time
- anyway. */
-
- if (eff_cnt != EFF_ALEN(len) &&
- eff_cnt * 100 / EFF_ALEN(len) > EFF_MAX_PERC) {
-
- memset(eff_map, 1, EFF_ALEN(len));
-
- blocks_eff_select += EFF_ALEN(len);
-
- } else {
-
- blocks_eff_select += eff_cnt;
-
- }
-
- blocks_eff_total += EFF_ALEN(len);
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_FLIP8] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_FLIP8] += stage_max;
-
- /* Two walking bytes. */
-
- if (len < 2) goto skip_bitflip;
-
- stage_name = "bitflip 16/8";
- stage_short = "flip16";
- stage_cur = 0;
- stage_max = len - 1;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len - 1; i++) {
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)]) {
- stage_max--;
- continue;
- }
-
- stage_cur_byte = i;
-
- *(u16*)(out_buf + i) ^= 0xFFFF;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- *(u16*)(out_buf + i) ^= 0xFFFF;
-
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_FLIP16] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_FLIP16] += stage_max;
-
- if (len < 4) goto skip_bitflip;
-
- /* Four walking bytes. */
-
- stage_name = "bitflip 32/8";
- stage_short = "flip32";
- stage_cur = 0;
- stage_max = len - 3;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len - 3; i++) {
-
- /* Let's consult the effector map... */
- if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)] &&
- !eff_map[EFF_APOS(i + 2)] && !eff_map[EFF_APOS(i + 3)]) {
- stage_max--;
- continue;
- }
-
- stage_cur_byte = i;
-
- *(u32*)(out_buf + i) ^= 0xFFFFFFFF;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- *(u32*)(out_buf + i) ^= 0xFFFFFFFF;
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_FLIP32] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_FLIP32] += stage_max;
-
-skip_bitflip:
-
- /**********************
- * ARITHMETIC INC/DEC *
- **********************/
-
- /* 8-bit arithmetics. */
-
- stage_name = "arith 8/8";
- stage_short = "arith8";
- stage_cur = 0;
- stage_max = 2 * len * ARITH_MAX;
-
- stage_val_type = STAGE_VAL_LE;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len; i++) {
-
- u8 orig = out_buf[i];
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)]) {
- stage_max -= 2 * ARITH_MAX;
- continue;
- }
-
- stage_cur_byte = i;
-
- for (j = 1; j <= ARITH_MAX; j++) {
-
- u8 r = orig ^ (orig + j);
-
- /* Do arithmetic operations only if the result couldn't be a product
- of a bitflip. */
-
- if (!could_be_bitflip(r)) {
-
- stage_cur_val = j;
- out_buf[i] = orig + j;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- r = orig ^ (orig - j);
-
- if (!could_be_bitflip(r)) {
-
- stage_cur_val = -j;
- out_buf[i] = orig - j;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- out_buf[i] = orig;
-
- }
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_ARITH8] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_ARITH8] += stage_max;
-
- /* 16-bit arithmetics, both endians. */
-
- if (len < 2) goto skip_arith;
-
- stage_name = "arith 16/8";
- stage_short = "arith16";
- stage_cur = 0;
- stage_max = 4 * (len - 1) * ARITH_MAX;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len - 1; i++) {
-
- u16 orig = *(u16*)(out_buf + i);
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)]) {
- stage_max -= 4 * ARITH_MAX;
- continue;
- }
-
- stage_cur_byte = i;
-
- for (j = 1; j <= ARITH_MAX; j++) {
-
- u16 r1 = orig ^ (orig + j),
- r2 = orig ^ (orig - j),
- r3 = orig ^ SWAP16(SWAP16(orig) + j),
- r4 = orig ^ SWAP16(SWAP16(orig) - j);
-
- /* Try little endian addition and subtraction first. Do it only
- if the operation would affect more than one byte (hence the
- & 0xff overflow checks) and if it couldn't be a product of
- a bitflip. */
-
- stage_val_type = STAGE_VAL_LE;
-
- if ((orig & 0xff) + j > 0xff && !could_be_bitflip(r1)) {
-
- stage_cur_val = j;
- *(u16*)(out_buf + i) = orig + j;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- if ((orig & 0xff) < j && !could_be_bitflip(r2)) {
-
- stage_cur_val = -j;
- *(u16*)(out_buf + i) = orig - j;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- /* Big endian comes next. Same deal. */
-
- stage_val_type = STAGE_VAL_BE;
-
-
- if ((orig >> 8) + j > 0xff && !could_be_bitflip(r3)) {
-
- stage_cur_val = j;
- *(u16*)(out_buf + i) = SWAP16(SWAP16(orig) + j);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- if ((orig >> 8) < j && !could_be_bitflip(r4)) {
-
- stage_cur_val = -j;
- *(u16*)(out_buf + i) = SWAP16(SWAP16(orig) - j);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- *(u16*)(out_buf + i) = orig;
-
- }
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_ARITH16] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_ARITH16] += stage_max;
-
- /* 32-bit arithmetics, both endians. */
-
- if (len < 4) goto skip_arith;
-
- stage_name = "arith 32/8";
- stage_short = "arith32";
- stage_cur = 0;
- stage_max = 4 * (len - 3) * ARITH_MAX;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len - 3; i++) {
-
- u32 orig = *(u32*)(out_buf + i);
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)] &&
- !eff_map[EFF_APOS(i + 2)] && !eff_map[EFF_APOS(i + 3)]) {
- stage_max -= 4 * ARITH_MAX;
- continue;
- }
-
- stage_cur_byte = i;
-
- for (j = 1; j <= ARITH_MAX; j++) {
-
- u32 r1 = orig ^ (orig + j),
- r2 = orig ^ (orig - j),
- r3 = orig ^ SWAP32(SWAP32(orig) + j),
- r4 = orig ^ SWAP32(SWAP32(orig) - j);
-
- /* Little endian first. Same deal as with 16-bit: we only want to
- try if the operation would have effect on more than two bytes. */
-
- stage_val_type = STAGE_VAL_LE;
-
- if ((orig & 0xffff) + j > 0xffff && !could_be_bitflip(r1)) {
-
- stage_cur_val = j;
- *(u32*)(out_buf + i) = orig + j;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- if ((orig & 0xffff) < j && !could_be_bitflip(r2)) {
-
- stage_cur_val = -j;
- *(u32*)(out_buf + i) = orig - j;
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- /* Big endian next. */
-
- stage_val_type = STAGE_VAL_BE;
-
- if ((SWAP32(orig) & 0xffff) + j > 0xffff && !could_be_bitflip(r3)) {
-
- stage_cur_val = j;
- *(u32*)(out_buf + i) = SWAP32(SWAP32(orig) + j);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- if ((SWAP32(orig) & 0xffff) < j && !could_be_bitflip(r4)) {
-
- stage_cur_val = -j;
- *(u32*)(out_buf + i) = SWAP32(SWAP32(orig) - j);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- *(u32*)(out_buf + i) = orig;
-
- }
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_ARITH32] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_ARITH32] += stage_max;
-
-skip_arith:
-
- /**********************
- * INTERESTING VALUES *
- **********************/
-
- stage_name = "interest 8/8";
- stage_short = "int8";
- stage_cur = 0;
- stage_max = len * sizeof(interesting_8);
-
- stage_val_type = STAGE_VAL_LE;
-
- orig_hit_cnt = new_hit_cnt;
-
- /* Setting 8-bit integers. */
-
- for (i = 0; i < len; i++) {
-
- u8 orig = out_buf[i];
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)]) {
- stage_max -= sizeof(interesting_8);
- continue;
- }
-
- stage_cur_byte = i;
-
- for (j = 0; j < sizeof(interesting_8); j++) {
-
- /* Skip if the value could be a product of bitflips or arithmetics. */
-
- if (could_be_bitflip(orig ^ (u8)interesting_8[j]) ||
- could_be_arith(orig, (u8)interesting_8[j], 1)) {
- stage_max--;
- continue;
- }
-
- stage_cur_val = interesting_8[j];
- out_buf[i] = interesting_8[j];
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- out_buf[i] = orig;
- stage_cur++;
-
- }
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_INTEREST8] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_INTEREST8] += stage_max;
-
- /* Setting 16-bit integers, both endians. */
-
- if (len < 2) goto skip_interest;
-
- stage_name = "interest 16/8";
- stage_short = "int16";
- stage_cur = 0;
- stage_max = 2 * (len - 1) * (sizeof(interesting_16) >> 1);
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len - 1; i++) {
-
- u16 orig = *(u16*)(out_buf + i);
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)]) {
- stage_max -= sizeof(interesting_16);
- continue;
- }
-
- stage_cur_byte = i;
-
- for (j = 0; j < sizeof(interesting_16) / 2; j++) {
-
- stage_cur_val = interesting_16[j];
-
- /* Skip if this could be a product of a bitflip, arithmetics,
- or single-byte interesting value insertion. */
-
- if (!could_be_bitflip(orig ^ (u16)interesting_16[j]) &&
- !could_be_arith(orig, (u16)interesting_16[j], 2) &&
- !could_be_interest(orig, (u16)interesting_16[j], 2, 0)) {
-
- stage_val_type = STAGE_VAL_LE;
-
- *(u16*)(out_buf + i) = interesting_16[j];
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- if ((u16)interesting_16[j] != SWAP16(interesting_16[j]) &&
- !could_be_bitflip(orig ^ SWAP16(interesting_16[j])) &&
- !could_be_arith(orig, SWAP16(interesting_16[j]), 2) &&
- !could_be_interest(orig, SWAP16(interesting_16[j]), 2, 1)) {
-
- stage_val_type = STAGE_VAL_BE;
-
- *(u16*)(out_buf + i) = SWAP16(interesting_16[j]);
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- }
-
- *(u16*)(out_buf + i) = orig;
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_INTEREST16] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_INTEREST16] += stage_max;
-
- if (len < 4) goto skip_interest;
-
- /* Setting 32-bit integers, both endians. */
-
- stage_name = "interest 32/8";
- stage_short = "int32";
- stage_cur = 0;
- stage_max = 2 * (len - 3) * (sizeof(interesting_32) >> 2);
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len - 3; i++) {
-
- u32 orig = *(u32*)(out_buf + i);
-
- /* Let's consult the effector map... */
-
- if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)] &&
- !eff_map[EFF_APOS(i + 2)] && !eff_map[EFF_APOS(i + 3)]) {
- stage_max -= sizeof(interesting_32) >> 1;
- continue;
- }
-
- stage_cur_byte = i;
-
- for (j = 0; j < sizeof(interesting_32) / 4; j++) {
-
- stage_cur_val = interesting_32[j];
-
- /* Skip if this could be a product of a bitflip, arithmetics,
- or word interesting value insertion. */
-
- if (!could_be_bitflip(orig ^ (u32)interesting_32[j]) &&
- !could_be_arith(orig, interesting_32[j], 4) &&
- !could_be_interest(orig, interesting_32[j], 4, 0)) {
-
- stage_val_type = STAGE_VAL_LE;
-
- *(u32*)(out_buf + i) = interesting_32[j];
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- if ((u32)interesting_32[j] != SWAP32(interesting_32[j]) &&
- !could_be_bitflip(orig ^ SWAP32(interesting_32[j])) &&
- !could_be_arith(orig, SWAP32(interesting_32[j]), 4) &&
- !could_be_interest(orig, SWAP32(interesting_32[j]), 4, 1)) {
-
- stage_val_type = STAGE_VAL_BE;
-
- *(u32*)(out_buf + i) = SWAP32(interesting_32[j]);
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
- stage_cur++;
-
- } else stage_max--;
-
- }
-
- *(u32*)(out_buf + i) = orig;
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_INTEREST32] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_INTEREST32] += stage_max;
-
-skip_interest:
-
- /********************
- * DICTIONARY STUFF *
- ********************/
-
- if (!extras_cnt) goto skip_user_extras;
-
- /* Overwrite with user-supplied extras. */
-
- stage_name = "user extras (over)";
- stage_short = "ext_UO";
- stage_cur = 0;
- stage_max = extras_cnt * len;
-
- stage_val_type = STAGE_VAL_NONE;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len; i++) {
-
- u32 last_len = 0;
-
- stage_cur_byte = i;
-
- /* Extras are sorted by size, from smallest to largest. This means
- that we don't have to worry about restoring the buffer in
- between writes at a particular offset determined by the outer
- loop. */
-
- for (j = 0; j < extras_cnt; j++) {
-
- /* Skip extras probabilistically if extras_cnt > MAX_DET_EXTRAS. Also
- skip them if there's no room to insert the payload, if the token
- is redundant, or if its entire span has no bytes set in the effector
- map. */
-
- if ((extras_cnt > MAX_DET_EXTRAS && UR(extras_cnt) >= MAX_DET_EXTRAS) ||
- extras[j].len > len - i ||
- !memcmp(extras[j].data, out_buf + i, extras[j].len) ||
- !memchr(eff_map + EFF_APOS(i), 1, EFF_SPAN_ALEN(i, extras[j].len))) {
-
- stage_max--;
- continue;
-
- }
-
- last_len = extras[j].len;
- memcpy(out_buf + i, extras[j].data, last_len);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- stage_cur++;
-
- }
-
- /* Restore all the clobbered memory. */
- memcpy(out_buf + i, in_buf + i, last_len);
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_EXTRAS_UO] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_EXTRAS_UO] += stage_max;
-
- /* Insertion of user-supplied extras. */
-
- stage_name = "user extras (insert)";
- stage_short = "ext_UI";
- stage_cur = 0;
- stage_max = extras_cnt * len;
-
- orig_hit_cnt = new_hit_cnt;
-
- ex_tmp = ck_alloc(len + MAX_DICT_FILE);
-
- for (i = 0; i < len; i++) {
-
- stage_cur_byte = i;
-
- for (j = 0; j < extras_cnt; j++) {
-
- if (len + extras[j].len > MAX_FILE) {
- stage_max--;
- continue;
- }
-
- /* Insert token */
- memcpy(ex_tmp + i, extras[j].data, extras[j].len);
-
- /* Copy tail */
- memcpy(ex_tmp + i + extras[j].len, out_buf + i, len - i);
-
- if (common_fuzz_stuff(argv, ex_tmp, len + extras[j].len)) {
- ck_free(ex_tmp);
- goto abandon_entry;
- }
-
- stage_cur++;
-
- }
-
- /* Copy head */
- ex_tmp[i] = out_buf[i];
-
- }
-
- ck_free(ex_tmp);
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_EXTRAS_UI] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_EXTRAS_UI] += stage_max;
-
-skip_user_extras:
-
- if (!a_extras_cnt) goto skip_extras;
-
- stage_name = "auto extras (over)";
- stage_short = "ext_AO";
- stage_cur = 0;
- stage_max = MIN(a_extras_cnt, USE_AUTO_EXTRAS) * len;
-
- stage_val_type = STAGE_VAL_NONE;
-
- orig_hit_cnt = new_hit_cnt;
-
- for (i = 0; i < len; i++) {
-
- u32 last_len = 0;
-
- stage_cur_byte = i;
-
- for (j = 0; j < MIN(a_extras_cnt, USE_AUTO_EXTRAS); j++) {
-
- /* See the comment in the earlier code; extras are sorted by size. */
-
- if (a_extras[j].len > len - i ||
- !memcmp(a_extras[j].data, out_buf + i, a_extras[j].len) ||
- !memchr(eff_map + EFF_APOS(i), 1, EFF_SPAN_ALEN(i, a_extras[j].len))) {
-
- stage_max--;
- continue;
-
- }
-
- last_len = a_extras[j].len;
- memcpy(out_buf + i, a_extras[j].data, last_len);
-
- if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
-
- stage_cur++;
-
- }
-
- /* Restore all the clobbered memory. */
- memcpy(out_buf + i, in_buf + i, last_len);
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- stage_finds[STAGE_EXTRAS_AO] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_EXTRAS_AO] += stage_max;
-
-skip_extras:
-
- /* If we made this to here without jumping to havoc_stage or abandon_entry,
- we're properly done with deterministic steps and can mark it as such
- in the .state/ directory. */
-
- if (!queue_cur->passed_det) mark_as_det_done(queue_cur);
-
- /****************
- * RANDOM HAVOC *
- ****************/
-
-havoc_stage:
-
- stage_cur_byte = -1;
-
- /* The havoc stage mutation code is also invoked when splicing files; if the
- splice_cycle variable is set, generate different descriptions and such. */
-
- if (!splice_cycle) {
-
- stage_name = "havoc";
- stage_short = "havoc";
- stage_max = (doing_det ? HAVOC_CYCLES_INIT : HAVOC_CYCLES) *
- perf_score / havoc_div / 100;
-
- } else {
-
- static u8 tmp[32];
-
- perf_score = orig_perf;
-
- sprintf(tmp, "splice %u", splice_cycle);
- stage_name = tmp;
- stage_short = "splice";
- stage_max = SPLICE_HAVOC * perf_score / havoc_div / 100;
-
- }
-
- if (stage_max < HAVOC_MIN) stage_max = HAVOC_MIN;
-
- temp_len = len;
-
- orig_hit_cnt = queued_paths + unique_crashes;
-
- havoc_queued = queued_paths;
-
- /* We essentially just do several thousand runs (depending on perf_score)
- where we take the input file and make random stacked tweaks. */
-
- for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {
-
- u32 use_stacking = 1 << (1 + UR(HAVOC_STACK_POW2));
-
- stage_cur_val = use_stacking;
-
- for (i = 0; i < use_stacking; i++) {
-
- switch (UR(15 + ((extras_cnt + a_extras_cnt) ? 2 : 0))) {
-
- case 0:
-
- /* Flip a single bit somewhere. Spooky! */
-
- FLIP_BIT(out_buf, UR(temp_len << 3));
- break;
-
- case 1:
-
- /* Set byte to interesting value. */
-
- out_buf[UR(temp_len)] = interesting_8[UR(sizeof(interesting_8))];
- break;
-
- case 2:
-
- /* Set word to interesting value, randomly choosing endian. */
-
- if (temp_len < 2) break;
-
- if (UR(2)) {
-
- *(u16*)(out_buf + UR(temp_len - 1)) =
- interesting_16[UR(sizeof(interesting_16) >> 1)];
-
- } else {
-
- *(u16*)(out_buf + UR(temp_len - 1)) = SWAP16(
- interesting_16[UR(sizeof(interesting_16) >> 1)]);
-
- }
-
- break;
-
- case 3:
-
- /* Set dword to interesting value, randomly choosing endian. */
-
- if (temp_len < 4) break;
-
- if (UR(2)) {
-
- *(u32*)(out_buf + UR(temp_len - 3)) =
- interesting_32[UR(sizeof(interesting_32) >> 2)];
-
- } else {
-
- *(u32*)(out_buf + UR(temp_len - 3)) = SWAP32(
- interesting_32[UR(sizeof(interesting_32) >> 2)]);
-
- }
-
- break;
-
- case 4:
-
- /* Randomly subtract from byte. */
-
- out_buf[UR(temp_len)] -= 1 + UR(ARITH_MAX);
- break;
-
- case 5:
-
- /* Randomly add to byte. */
-
- out_buf[UR(temp_len)] += 1 + UR(ARITH_MAX);
- break;
-
- case 6:
-
- /* Randomly subtract from word, random endian. */
-
- if (temp_len < 2) break;
-
- if (UR(2)) {
-
- u32 pos = UR(temp_len - 1);
-
- *(u16*)(out_buf + pos) -= 1 + UR(ARITH_MAX);
-
- } else {
-
- u32 pos = UR(temp_len - 1);
- u16 num = 1 + UR(ARITH_MAX);
-
- *(u16*)(out_buf + pos) =
- SWAP16(SWAP16(*(u16*)(out_buf + pos)) - num);
-
- }
-
- break;
-
- case 7:
-
- /* Randomly add to word, random endian. */
-
- if (temp_len < 2) break;
-
- if (UR(2)) {
-
- u32 pos = UR(temp_len - 1);
-
- *(u16*)(out_buf + pos) += 1 + UR(ARITH_MAX);
-
- } else {
-
- u32 pos = UR(temp_len - 1);
- u16 num = 1 + UR(ARITH_MAX);
-
- *(u16*)(out_buf + pos) =
- SWAP16(SWAP16(*(u16*)(out_buf + pos)) + num);
-
- }
-
- break;
-
- case 8:
-
- /* Randomly subtract from dword, random endian. */
-
- if (temp_len < 4) break;
-
- if (UR(2)) {
-
- u32 pos = UR(temp_len - 3);
-
- *(u32*)(out_buf + pos) -= 1 + UR(ARITH_MAX);
-
- } else {
-
- u32 pos = UR(temp_len - 3);
- u32 num = 1 + UR(ARITH_MAX);
-
- *(u32*)(out_buf + pos) =
- SWAP32(SWAP32(*(u32*)(out_buf + pos)) - num);
-
- }
-
- break;
-
- case 9:
-
- /* Randomly add to dword, random endian. */
-
- if (temp_len < 4) break;
-
- if (UR(2)) {
-
- u32 pos = UR(temp_len - 3);
-
- *(u32*)(out_buf + pos) += 1 + UR(ARITH_MAX);
-
- } else {
-
- u32 pos = UR(temp_len - 3);
- u32 num = 1 + UR(ARITH_MAX);
-
- *(u32*)(out_buf + pos) =
- SWAP32(SWAP32(*(u32*)(out_buf + pos)) + num);
-
- }
-
- break;
-
- case 10:
-
- /* Just set a random byte to a random value. Because,
- why not. We use XOR with 1-255 to eliminate the
- possibility of a no-op. */
-
- out_buf[UR(temp_len)] ^= 1 + UR(255);
- break;
-
- case 11 ... 12: {
-
- /* Delete bytes. We're making this a bit more likely
- than insertion (the next option) in hopes of keeping
- files reasonably small. */
-
- u32 del_from, del_len;
-
- if (temp_len < 2) break;
-
- /* Don't delete too much. */
-
- del_len = choose_block_len(temp_len - 1);
-
- del_from = UR(temp_len - del_len + 1);
-
- memmove(out_buf + del_from, out_buf + del_from + del_len,
- temp_len - del_from - del_len);
-
- temp_len -= del_len;
-
- break;
-
- }
-
- case 13:
-
- if (temp_len + HAVOC_BLK_LARGE < MAX_FILE) {
-
- /* Clone bytes (75%) or insert a block of constant bytes (25%). */
-
- u32 clone_from, clone_to, clone_len;
- u8* new_buf;
-
- clone_len = choose_block_len(temp_len);
-
- clone_from = UR(temp_len - clone_len + 1);
- clone_to = UR(temp_len);
-
- new_buf = ck_alloc_nozero(temp_len + clone_len);
-
- /* Head */
-
- memcpy(new_buf, out_buf, clone_to);
-
- /* Inserted part */
-
- if (UR(4))
- memcpy(new_buf + clone_to, out_buf + clone_from, clone_len);
- else
- memset(new_buf + clone_to, UR(256), clone_len);
-
- /* Tail */
- memcpy(new_buf + clone_to + clone_len, out_buf + clone_to,
- temp_len - clone_to);
-
- ck_free(out_buf);
- out_buf = new_buf;
- temp_len += clone_len;
-
- }
-
- break;
-
- case 14: {
-
- /* Overwrite bytes with a randomly selected chunk (75%) or fixed
- bytes (25%). */
-
- u32 copy_from, copy_to, copy_len;
-
- if (temp_len < 2) break;
-
- copy_len = choose_block_len(temp_len - 1);
-
- copy_from = UR(temp_len - copy_len + 1);
- copy_to = UR(temp_len - copy_len + 1);
-
- if (UR(4)) {
-
- if (copy_from != copy_to)
- memmove(out_buf + copy_to, out_buf + copy_from, copy_len);
-
- } else memset(out_buf + copy_to, UR(256), copy_len);
-
- break;
-
- }
-
- /* Values 15 and 16 can be selected only if there are any extras
- present in the dictionaries. */
-
- case 15: {
-
- /* Overwrite bytes with an extra. */
-
- if (!extras_cnt || (a_extras_cnt && UR(2))) {
-
- /* No user-specified extras or odds in our favor. Let's use an
- auto-detected one. */
-
- u32 use_extra = UR(a_extras_cnt);
- u32 extra_len = a_extras[use_extra].len;
- u32 insert_at;
-
- if (extra_len > temp_len) break;
-
- insert_at = UR(temp_len - extra_len + 1);
- memcpy(out_buf + insert_at, a_extras[use_extra].data, extra_len);
-
- } else {
-
- /* No auto extras or odds in our favor. Use the dictionary. */
-
- u32 use_extra = UR(extras_cnt);
- u32 extra_len = extras[use_extra].len;
- u32 insert_at;
-
- if (extra_len > temp_len) break;
-
- insert_at = UR(temp_len - extra_len + 1);
- memcpy(out_buf + insert_at, extras[use_extra].data, extra_len);
-
- }
-
- break;
-
- }
-
- case 16: {
-
- u32 use_extra, extra_len, insert_at = UR(temp_len);
- u8* new_buf;
-
- /* Insert an extra. Do the same dice-rolling stuff as for the
- previous case. */
-
- if (!extras_cnt || (a_extras_cnt && UR(2))) {
-
- use_extra = UR(a_extras_cnt);
- extra_len = a_extras[use_extra].len;
-
- if (temp_len + extra_len >= MAX_FILE) break;
-
- new_buf = ck_alloc_nozero(temp_len + extra_len);
-
- /* Head */
- memcpy(new_buf, out_buf, insert_at);
-
- /* Inserted part */
- memcpy(new_buf + insert_at, a_extras[use_extra].data, extra_len);
-
- } else {
-
- use_extra = UR(extras_cnt);
- extra_len = extras[use_extra].len;
-
- if (temp_len + extra_len >= MAX_FILE) break;
-
- new_buf = ck_alloc_nozero(temp_len + extra_len);
-
- /* Head */
- memcpy(new_buf, out_buf, insert_at);
-
- /* Inserted part */
- memcpy(new_buf + insert_at, extras[use_extra].data, extra_len);
-
- }
-
- /* Tail */
- memcpy(new_buf + insert_at + extra_len, out_buf + insert_at,
- temp_len - insert_at);
-
- ck_free(out_buf);
- out_buf = new_buf;
- temp_len += extra_len;
-
- break;
-
- }
-
- }
-
- }
-
- if (common_fuzz_stuff(argv, out_buf, temp_len))
- goto abandon_entry;
-
- /* out_buf might have been mangled a bit, so let's restore it to its
- original size and shape. */
-
- if (temp_len < len) out_buf = ck_realloc(out_buf, len);
- temp_len = len;
- memcpy(out_buf, in_buf, len);
-
- /* If we're finding new stuff, let's run for a bit longer, limits
- permitting. */
-
- if (queued_paths != havoc_queued) {
-
- if (perf_score <= HAVOC_MAX_MULT * 100) {
- stage_max *= 2;
- perf_score *= 2;
- }
-
- havoc_queued = queued_paths;
-
- }
-
- }
-
- new_hit_cnt = queued_paths + unique_crashes;
-
- if (!splice_cycle) {
- stage_finds[STAGE_HAVOC] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_HAVOC] += stage_max;
- } else {
- stage_finds[STAGE_SPLICE] += new_hit_cnt - orig_hit_cnt;
- stage_cycles[STAGE_SPLICE] += stage_max;
- }
-
-#ifndef IGNORE_FINDS
-
- /************
- * SPLICING *
- ************/
-
- /* This is a last-resort strategy triggered by a full round with no findings.
- It takes the current input file, randomly selects another input, and
- splices them together at some offset, then relies on the havoc
- code to mutate that blob. */
-
-retry_splicing:
-
- if (use_splicing && splice_cycle++ < SPLICE_CYCLES &&
- queued_paths > 1 && queue_cur->len > 1) {
-
- struct queue_entry* target;
- u32 tid, split_at;
- u8* new_buf;
- s32 f_diff, l_diff;
-
- /* First of all, if we've modified in_buf for havoc, let's clean that
- up... */
-
- if (in_buf != orig_in) {
- ck_free(in_buf);
- in_buf = orig_in;
- len = queue_cur->len;
- }
-
- /* Pick a random queue entry and seek to it. Don't splice with yourself. */
-
- do { tid = UR(queued_paths); } while (tid == current_entry);
-
- splicing_with = tid;
- target = queue;
-
- while (tid >= 100) { target = target->next_100; tid -= 100; }
- while (tid--) target = target->next;
-
- /* Make sure that the target has a reasonable length. */
-
- while (target && (target->len < 2 || target == queue_cur)) {
- target = target->next;
- splicing_with++;
- }
-
- if (!target) goto retry_splicing;
-
- /* Read the testcase into a new buffer. */
-
- fd = open(target->fname, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", target->fname);
-
- new_buf = ck_alloc_nozero(target->len);
-
- ck_read(fd, new_buf, target->len, target->fname);
-
- close(fd);
-
- /* Find a suitable splicing location, somewhere between the first and
- the last differing byte. Bail out if the difference is just a single
- byte or so. */
-
- locate_diffs(in_buf, new_buf, MIN(len, target->len), &f_diff, &l_diff);
-
- if (f_diff < 0 || l_diff < 2 || f_diff == l_diff) {
- ck_free(new_buf);
- goto retry_splicing;
- }
-
- /* Split somewhere between the first and last differing byte. */
-
- split_at = f_diff + UR(l_diff - f_diff);
-
- /* Do the thing. */
-
- len = target->len;
- memcpy(new_buf, in_buf, split_at);
- in_buf = new_buf;
-
- ck_free(out_buf);
- out_buf = ck_alloc_nozero(len);
- memcpy(out_buf, in_buf, len);
-
- goto havoc_stage;
-
- }
-
-#endif /* !IGNORE_FINDS */
-
- ret_val = 0;
-
-abandon_entry:
-
- splicing_with = -1;
-
- /* Update pending_not_fuzzed count if we made it through the calibration
- cycle and have not seen this entry before. */
-
- if (!stop_soon && !queue_cur->cal_failed && !queue_cur->was_fuzzed) {
- queue_cur->was_fuzzed = 1;
- pending_not_fuzzed--;
- if (queue_cur->favored) pending_favored--;
- }
-
- munmap(orig_in, queue_cur->len);
-
- if (in_buf != orig_in) ck_free(in_buf);
- ck_free(out_buf);
- ck_free(eff_map);
-
- return ret_val;
-
-#undef FLIP_BIT
-
-}
-
-
-/* Grab interesting test cases from other fuzzers. */
-
-static void sync_fuzzers(char** argv) {
-
- DIR* sd;
- struct dirent* sd_ent;
- u32 sync_cnt = 0;
-
- sd = opendir(sync_dir);
- if (!sd) PFATAL("Unable to open '%s'", sync_dir);
-
- stage_max = stage_cur = 0;
- cur_depth = 0;
-
- /* Look at the entries created for every other fuzzer in the sync directory. */
-
- while ((sd_ent = readdir(sd))) {
-
- static u8 stage_tmp[128];
-
- DIR* qd;
- struct dirent* qd_ent;
- u8 *qd_path, *qd_synced_path;
- u32 min_accept = 0, next_min_accept;
-
- s32 id_fd;
-
- /* Skip dot files and our own output directory. */
-
- if (sd_ent->d_name[0] == '.' || !strcmp(sync_id, sd_ent->d_name)) continue;
-
- /* Skip anything that doesn't have a queue/ subdirectory. */
-
- qd_path = alloc_printf("%s/%s/queue", sync_dir, sd_ent->d_name);
-
- if (!(qd = opendir(qd_path))) {
- ck_free(qd_path);
- continue;
- }
-
- /* Retrieve the ID of the last seen test case. */
-
- qd_synced_path = alloc_printf("%s/.synced/%s", out_dir, sd_ent->d_name);
-
- id_fd = open(qd_synced_path, O_RDWR | O_CREAT, 0600);
-
- if (id_fd < 0) PFATAL("Unable to create '%s'", qd_synced_path);
-
- if (read(id_fd, &min_accept, sizeof(u32)) > 0)
- lseek(id_fd, 0, SEEK_SET);
-
- next_min_accept = min_accept;
-
- /* Show stats */
-
- sprintf(stage_tmp, "sync %u", ++sync_cnt);
- stage_name = stage_tmp;
- stage_cur = 0;
- stage_max = 0;
-
- /* For every file queued by this fuzzer, parse ID and see if we have looked at
- it before; exec a test case if not. */
-
- while ((qd_ent = readdir(qd))) {
-
- u8* path;
- s32 fd;
- struct stat st;
-
- if (qd_ent->d_name[0] == '.' ||
- sscanf(qd_ent->d_name, CASE_PREFIX "%06u", &syncing_case) != 1 ||
- syncing_case < min_accept) continue;
-
- /* OK, sounds like a new one. Let's give it a try. */
-
- if (syncing_case >= next_min_accept)
- next_min_accept = syncing_case + 1;
-
- path = alloc_printf("%s/%s", qd_path, qd_ent->d_name);
-
- /* Allow this to fail in case the other fuzzer is resuming or so... */
-
- fd = open(path, O_RDONLY);
-
- if (fd < 0) {
- ck_free(path);
- continue;
- }
-
- if (fstat(fd, &st)) PFATAL("fstat() failed");
-
- /* Ignore zero-sized or oversized files. */
-
- if (st.st_size && st.st_size <= MAX_FILE) {
-
- u8 fault;
- u8* mem = mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
-
- if (mem == MAP_FAILED) PFATAL("Unable to mmap '%s'", path);
-
- /* See what happens. We rely on save_if_interesting() to catch major
- errors and save the test case. */
-
- write_to_testcase(mem, st.st_size);
-
- fault = run_target(argv);
-
- if (stop_soon) return;
-
- syncing_party = sd_ent->d_name;
- queued_imported += save_if_interesting(argv, mem, st.st_size, fault);
- syncing_party = 0;
-
- munmap(mem, st.st_size);
-
- if (!(stage_cur++ % stats_update_freq)) show_stats();
-
- }
-
- ck_free(path);
- close(fd);
-
- }
-
- ck_write(id_fd, &next_min_accept, sizeof(u32), qd_synced_path);
-
- close(id_fd);
- closedir(qd);
- ck_free(qd_path);
- ck_free(qd_synced_path);
-
- }
-
- closedir(sd);
-
-}
-
-
-/* Handle stop signal (Ctrl-C, etc). */
-
-static void handle_stop_sig(int sig) {
-
- stop_soon = 1;
-
- if (child_pid > 0) kill(child_pid, SIGKILL);
- if (forksrv_pid > 0) kill(forksrv_pid, SIGKILL);
-
-}
-
-
-/* Handle skip request (SIGUSR1). */
-
-static void handle_skipreq(int sig) {
-
- skip_requested = 1;
-
-}
-
-/* Handle timeout (SIGALRM). */
-
-static void handle_timeout(int sig) {
-
- if (child_pid > 0) {
-
- child_timed_out = 1;
- kill(child_pid, SIGKILL);
-
- } else if (child_pid == -1 && forksrv_pid > 0) {
-
- child_timed_out = 1;
- kill(forksrv_pid, SIGKILL);
-
- }
-
-}
-
-
-/* Do a PATH search and find target binary to see that it exists and
- isn't a shell script - a common and painful mistake. We also check for
- a valid ELF header and for evidence of AFL instrumentation. */
-
-EXP_ST void check_binary(u8* fname) {
-
- u8* env_path = 0;
- struct stat st;
-
- s32 fd;
- u8* f_data;
- u32 f_len = 0;
-
- ACTF("Validating target binary...");
-
- if (strchr(fname, '/') || !(env_path = getenv("PATH"))) {
-
- target_path = ck_strdup(fname);
- if (stat(target_path, &st) || !S_ISREG(st.st_mode) ||
- !(st.st_mode & 0111) || (f_len = st.st_size) < 4)
- FATAL("Program '%s' not found or not executable", fname);
-
- } else {
-
- while (env_path) {
-
- u8 *cur_elem, *delim = strchr(env_path, ':');
-
- if (delim) {
-
- cur_elem = ck_alloc(delim - env_path + 1);
- memcpy(cur_elem, env_path, delim - env_path);
- delim++;
-
- } else cur_elem = ck_strdup(env_path);
-
- env_path = delim;
-
- if (cur_elem[0])
- target_path = alloc_printf("%s/%s", cur_elem, fname);
- else
- target_path = ck_strdup(fname);
-
- ck_free(cur_elem);
-
- if (!stat(target_path, &st) && S_ISREG(st.st_mode) &&
- (st.st_mode & 0111) && (f_len = st.st_size) >= 4) break;
-
- ck_free(target_path);
- target_path = 0;
-
- }
-
- if (!target_path) FATAL("Program '%s' not found or not executable", fname);
-
- }
-
- if (getenv("AFL_SKIP_BIN_CHECK")) return;
-
- /* Check for blatant user errors. */
-
- if ((!strncmp(target_path, "/tmp/", 5) && !strchr(target_path + 5, '/')) ||
- (!strncmp(target_path, "/var/tmp/", 9) && !strchr(target_path + 9, '/')))
- FATAL("Please don't keep binaries in /tmp or /var/tmp");
-
- fd = open(target_path, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", target_path);
-
- f_data = mmap(0, f_len, PROT_READ, MAP_PRIVATE, fd, 0);
-
- if (f_data == MAP_FAILED) PFATAL("Unable to mmap file '%s'", target_path);
-
- close(fd);
-
- if (f_data[0] == '#' && f_data[1] == '!') {
-
- SAYF("\n" cLRD "[-] " cRST
- "Oops, the target binary looks like a shell script. Some build systems will\n"
- " sometimes generate shell stubs for dynamically linked programs; try static\n"
- " library mode (./configure --disable-shared) if that's the case.\n\n"
-
- " Another possible cause is that you are actually trying to use a shell\n"
- " wrapper around the fuzzed component. Invoking shell can slow down the\n"
- " fuzzing process by a factor of 20x or more; it's best to write the wrapper\n"
- " in a compiled language instead.\n");
-
- FATAL("Program '%s' is a shell script", target_path);
-
- }
-
-#ifndef __APPLE__
-
- if (f_data[0] != 0x7f || memcmp(f_data + 1, "ELF", 3))
- FATAL("Program '%s' is not an ELF binary", target_path);
-
-#else
-
- if (f_data[0] != 0xCF || f_data[1] != 0xFA || f_data[2] != 0xED)
- FATAL("Program '%s' is not a 64-bit Mach-O binary", target_path);
-
-#endif /* ^!__APPLE__ */
-
- if (!qemu_mode && !dumb_mode &&
- !memmem(f_data, f_len, SHM_ENV_VAR, strlen(SHM_ENV_VAR) + 1)) {
-
- SAYF("\n" cLRD "[-] " cRST
- "Looks like the target binary is not instrumented! The fuzzer depends on\n"
- " compile-time instrumentation to isolate interesting test cases while\n"
- " mutating the input data. For more information, and for tips on how to\n"
- " instrument binaries, please see %s/README.\n\n"
-
- " When source code is not available, you may be able to leverage QEMU\n"
- " mode support. Consult the README for tips on how to enable this.\n"
-
- " (It is also possible to use afl-fuzz as a traditional, \"dumb\" fuzzer.\n"
- " For that, you can use the -n option - but expect much worse results.)\n",
- doc_path);
-
- FATAL("No instrumentation detected");
-
- }
-
- if (qemu_mode &&
- memmem(f_data, f_len, SHM_ENV_VAR, strlen(SHM_ENV_VAR) + 1)) {
-
- SAYF("\n" cLRD "[-] " cRST
- "This program appears to be instrumented with afl-gcc, but is being run in\n"
- " QEMU mode (-Q). This is probably not what you want - this setup will be\n"
- " slow and offer no practical benefits.\n");
-
- FATAL("Instrumentation found in -Q mode");
-
- }
-
- if (memmem(f_data, f_len, "libasan.so", 10) ||
- memmem(f_data, f_len, "__msan_init", 11)) uses_asan = 1;
-
- /* Detect persistent & deferred init signatures in the binary. */
-
- if (memmem(f_data, f_len, PERSIST_SIG, strlen(PERSIST_SIG) + 1)) {
-
- OKF(cPIN "Persistent mode binary detected.");
- setenv(PERSIST_ENV_VAR, "1", 1);
- persistent_mode = 1;
-
- } else if (getenv("AFL_PERSISTENT")) {
-
- WARNF("AFL_PERSISTENT is no longer supported and may misbehave!");
-
- }
-
- if (memmem(f_data, f_len, DEFER_SIG, strlen(DEFER_SIG) + 1)) {
-
- OKF(cPIN "Deferred forkserver binary detected.");
- setenv(DEFER_ENV_VAR, "1", 1);
-
- } else if (getenv("AFL_DEFER_FORKSRV")) {
-
- WARNF("AFL_DEFER_FORKSRV is no longer supported and may misbehave!");
-
- }
-
- if (munmap(f_data, f_len)) PFATAL("unmap() failed");
-
-}
-
-
-/* Trim and possibly create a banner for the run. */
-
-static void fix_up_banner(u8* name) {
-
- if (!use_banner) {
-
- if (sync_id) {
-
- use_banner = sync_id;
-
- } else {
-
- u8* trim = strrchr(name, '/');
- if (!trim) use_banner = name; else use_banner = trim + 1;
-
- }
-
- }
-
- if (strlen(use_banner) > 40) {
-
- u8* tmp = ck_alloc(44);
- sprintf(tmp, "%.40s...", use_banner);
- use_banner = tmp;
-
- }
-
-}
-
-
-/* Check if we're on TTY. */
-
-static void check_if_tty(void) {
-
- struct winsize ws;
-
- if (getenv("AFL_NO_UI")) {
- OKF("Disabling the UI because AFL_NO_UI is set.");
- not_on_tty = 1;
- return;
- }
-
- if (ioctl(1, TIOCGWINSZ, &ws)) {
-
- if (errno == ENOTTY) {
- OKF("Looks like we're not running on a tty, so I'll be a bit less verbose.");
- not_on_tty = 1;
- }
-
- return;
- }
-
-}
-
-
-/* Check terminal dimensions after resize. */
-
-static void check_term_size(void) {
-
- struct winsize ws;
-
- term_too_small = 0;
-
- if (ioctl(1, TIOCGWINSZ, &ws)) return;
-
- if (ws.ws_row < 25 || ws.ws_col < 80) term_too_small = 1;
-
-}
-
-
-
-/* Display usage hints. */
-
-static void usage(u8* argv0) {
-
- SAYF("\n%s [ options ] -- /path/to/fuzzed_app [ ... ]\n\n"
-
- "Required parameters:\n\n"
-
- " -i dir - input directory with test cases\n"
- " -o dir - output directory for fuzzer findings\n\n"
-
- "Execution control settings:\n\n"
-
- " -f file - location read by the fuzzed program (stdin)\n"
- " -t msec - timeout for each run (auto-scaled, 50-%u ms)\n"
- " -m megs - memory limit for child process (%u MB)\n"
- " -Q - use binary-only instrumentation (QEMU mode)\n\n"
-
- "Fuzzing behavior settings:\n\n"
-
- " -d - quick & dirty mode (skips deterministic steps)\n"
- " -n - fuzz without instrumentation (dumb mode)\n"
- " -x dir - optional fuzzer dictionary (see README)\n\n"
-
- "Other stuff:\n\n"
-
- " -T text - text banner to show on the screen\n"
- " -M / -S id - distributed mode (see parallel_fuzzing.txt)\n"
- " -C - crash exploration mode (the peruvian rabbit thing)\n\n"
-
- "For additional tips, please consult %s/README.\n\n",
-
- argv0, EXEC_TIMEOUT, MEM_LIMIT, doc_path);
-
- exit(1);
-
-}
-
-
-/* Prepare output directories and fds. */
-
-EXP_ST void setup_dirs_fds(void) {
-
- u8* tmp;
- s32 fd;
-
- ACTF("Setting up output directories...");
-
- if (sync_id && mkdir(sync_dir, 0700) && errno != EEXIST)
- PFATAL("Unable to create '%s'", sync_dir);
-
- if (mkdir(out_dir, 0700)) {
-
- if (errno != EEXIST) PFATAL("Unable to create '%s'", out_dir);
-
- maybe_delete_out_dir();
-
- } else {
-
- if (in_place_resume)
- FATAL("Resume attempted but old output directory not found");
-
- out_dir_fd = open(out_dir, O_RDONLY);
-
-#ifndef __sun
-
- if (out_dir_fd < 0 || flock(out_dir_fd, LOCK_EX | LOCK_NB))
- PFATAL("Unable to flock() output directory.");
-
-#endif /* !__sun */
-
- }
-
- /* Queue directory for any starting & discovered paths. */
-
- tmp = alloc_printf("%s/queue", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* Top-level directory for queue metadata used for session
- resume and related tasks. */
-
- tmp = alloc_printf("%s/queue/.state/", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* Directory for flagging queue entries that went through
- deterministic fuzzing in the past. */
-
- tmp = alloc_printf("%s/queue/.state/deterministic_done/", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* Directory with the auto-selected dictionary entries. */
-
- tmp = alloc_printf("%s/queue/.state/auto_extras/", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* The set of paths currently deemed redundant. */
-
- tmp = alloc_printf("%s/queue/.state/redundant_edges/", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* The set of paths showing variable behavior. */
-
- tmp = alloc_printf("%s/queue/.state/variable_behavior/", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* Sync directory for keeping track of cooperating fuzzers. */
-
- if (sync_id) {
-
- tmp = alloc_printf("%s/.synced/", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- }
-
- /* All recorded crashes. */
-
- tmp = alloc_printf("%s/crashes", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* All recorded hangs. */
-
- tmp = alloc_printf("%s/hangs", out_dir);
- if (mkdir(tmp, 0700)) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- /* Generally useful file descriptors. */
-
- dev_null_fd = open("/dev/null", O_RDWR);
- if (dev_null_fd < 0) PFATAL("Unable to open /dev/null");
-
- dev_urandom_fd = open("/dev/urandom", O_RDONLY);
- if (dev_urandom_fd < 0) PFATAL("Unable to open /dev/urandom");
-
- /* Gnuplot output file. */
-
- tmp = alloc_printf("%s/plot_data", out_dir);
- fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", tmp);
- ck_free(tmp);
-
- plot_file = fdopen(fd, "w");
- if (!plot_file) PFATAL("fdopen() failed");
-
- fprintf(plot_file, "# unix_time, cycles_done, cur_path, paths_total, "
- "pending_total, pending_favs, map_size, unique_crashes, "
- "unique_hangs, max_depth, execs_per_sec\n");
- /* ignore errors */
-
-}
-
-
-/* Setup the output file for fuzzed data, if not using -f. */
-
-EXP_ST void setup_stdio_file(void) {
-
- u8* fn = alloc_printf("%s/.cur_input", out_dir);
-
- unlink(fn); /* Ignore errors */
-
- out_fd = open(fn, O_RDWR | O_CREAT | O_EXCL, 0600);
-
- if (out_fd < 0) PFATAL("Unable to create '%s'", fn);
-
- ck_free(fn);
-
-}
-
-
-/* Make sure that core dumps don't go to a program. */
-
-static void check_crash_handling(void) {
-
-#ifdef __APPLE__
-
- /* Yuck! There appears to be no simple C API to query for the state of
- loaded daemons on MacOS X, and I'm a bit hesitant to do something
- more sophisticated, such as disabling crash reporting via Mach ports,
- until I get a box to test the code. So, for now, we check for crash
- reporting the awful way. */
-
- if (system("launchctl list 2>/dev/null | grep -q '\\.ReportCrash$'")) return;
-
- SAYF("\n" cLRD "[-] " cRST
- "Whoops, your system is configured to forward crash notifications to an\n"
- " external crash reporting utility. This will cause issues due to the\n"
- " extended delay between the fuzzed binary malfunctioning and this fact\n"
- " being relayed to the fuzzer via the standard waitpid() API.\n\n"
- " To avoid having crashes misinterpreted as hangs, please run the\n"
- " following commands:\n\n"
-
- " SL=/System/Library; PL=com.apple.ReportCrash\n"
- " launchctl unload -w ${SL}/LaunchAgents/${PL}.plist\n"
- " sudo launchctl unload -w ${SL}/LaunchDaemons/${PL}.Root.plist\n");
-
- if (!getenv("AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES"))
- FATAL("Crash reporter detected");
-
-#else
-
- /* This is Linux specific, but I don't think there's anything equivalent on
- *BSD, so we can just let it slide for now. */
-
- s32 fd = open("/proc/sys/kernel/core_pattern", O_RDONLY);
- u8 fchar;
-
- if (fd < 0) return;
-
- ACTF("Checking core_pattern...");
-
- if (read(fd, &fchar, 1) == 1 && fchar == '|') {
-
- SAYF("\n" cLRD "[-] " cRST
- "Hmm, your system is configured to send core dump notifications to an\n"
- " external utility. This will cause issues: there will be an extended delay\n"
- " between stumbling upon a crash and having this information relayed to the\n"
- " fuzzer via the standard waitpid() API.\n\n"
-
- " To avoid having crashes misinterpreted as hangs, please log in as root\n"
- " and temporarily modify /proc/sys/kernel/core_pattern, like so:\n\n"
-
- " echo core >/proc/sys/kernel/core_pattern\n");
-
- if (!getenv("AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES"))
- FATAL("Pipe at the beginning of 'core_pattern'");
-
- }
-
- close(fd);
-
-#endif /* ^__APPLE__ */
-
-}
-
-
-/* Check CPU governor. */
-
-static void check_cpu_governor(void) {
-
- FILE* f;
- u8 tmp[128];
- u64 min = 0, max = 0;
-
- if (getenv("AFL_SKIP_CPUFREQ")) return;
-
- f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "r");
- if (!f) return;
-
- ACTF("Checking CPU scaling governor...");
-
- if (!fgets(tmp, 128, f)) PFATAL("fgets() failed");
-
- fclose(f);
-
- if (!strncmp(tmp, "perf", 4)) return;
-
- f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", "r");
-
- if (f) {
- if (fscanf(f, "%llu", &min) != 1) min = 0;
- fclose(f);
- }
-
- f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r");
-
- if (f) {
- if (fscanf(f, "%llu", &max) != 1) max = 0;
- fclose(f);
- }
-
- if (min == max) return;
-
- SAYF("\n" cLRD "[-] " cRST
- "Whoops, your system uses on-demand CPU frequency scaling, adjusted\n"
- " between %llu and %llu MHz. Unfortunately, the scaling algorithm in the\n"
- " kernel is imperfect and can miss the short-lived processes spawned by\n"
- " afl-fuzz. To keep things moving, run these commands as root:\n\n"
-
- " cd /sys/devices/system/cpu\n"
- " echo performance | tee cpu*/cpufreq/scaling_governor\n\n"
-
- " You can later go back to the original state by replacing 'performance' with\n"
- " 'ondemand'. If you don't want to change the settings, set AFL_SKIP_CPUFREQ\n"
- " to make afl-fuzz skip this check - but expect some performance drop.\n",
- min / 1024, max / 1024);
-
- FATAL("Suboptimal CPU scaling governor");
-
-}
-
-
-/* Count the number of logical CPU cores. */
-
-static void get_core_count(void) {
-
- u32 cur_runnable = 0;
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__)
-
- size_t s = sizeof(cpu_core_count);
-
- /* On *BSD systems, we can just use a sysctl to get the number of CPUs. */
-
-#ifdef __APPLE__
-
- if (sysctlbyname("hw.logicalcpu", &cpu_core_count, &s, NULL, 0) < 0)
- return;
-
-#else
-
- int s_name[2] = { CTL_HW, HW_NCPU };
-
- if (sysctl(s_name, 2, &cpu_core_count, &s, NULL, 0) < 0) return;
-
-#endif /* ^__APPLE__ */
-
-#else
-
-#ifdef HAVE_AFFINITY
-
- cpu_core_count = sysconf(_SC_NPROCESSORS_ONLN);
-
-#else
-
- FILE* f = fopen("/proc/stat", "r");
- u8 tmp[1024];
-
- if (!f) return;
-
- while (fgets(tmp, sizeof(tmp), f))
- if (!strncmp(tmp, "cpu", 3) && isdigit(tmp[3])) cpu_core_count++;
-
- fclose(f);
-
-#endif /* ^HAVE_AFFINITY */
-
-#endif /* ^(__APPLE__ || __FreeBSD__ || __OpenBSD__) */
-
- if (cpu_core_count > 0) {
-
- cur_runnable = (u32)get_runnable_processes();
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__)
-
- /* Add ourselves, since the 1-minute average doesn't include that yet. */
-
- cur_runnable++;
-
-#endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */
-
- OKF("You have %u CPU core%s and %u runnable tasks (utilization: %0.0f%%).",
- cpu_core_count, cpu_core_count > 1 ? "s" : "",
- cur_runnable, cur_runnable * 100.0 / cpu_core_count);
-
- if (cpu_core_count > 1) {
-
- if (cur_runnable > cpu_core_count * 1.5) {
-
- WARNF("System under apparent load, performance may be spotty.");
-
- } else if (cur_runnable + 1 <= cpu_core_count) {
-
- OKF("Try parallel jobs - see %s/parallel_fuzzing.txt.", doc_path);
-
- }
-
- }
-
- } else {
-
- cpu_core_count = 0;
- WARNF("Unable to figure out the number of CPU cores.");
-
- }
-
-}
-
-
-/* Validate and fix up out_dir and sync_dir when using -S. */
-
-static void fix_up_sync(void) {
-
- u8* x = sync_id;
-
- if (dumb_mode)
- FATAL("-S / -M and -n are mutually exclusive");
-
- if (skip_deterministic) {
-
- if (force_deterministic)
- FATAL("use -S instead of -M -d");
- else
- FATAL("-S already implies -d");
-
- }
-
- while (*x) {
-
- if (!isalnum(*x) && *x != '_' && *x != '-')
- FATAL("Non-alphanumeric fuzzer ID specified via -S or -M");
-
- x++;
-
- }
-
- if (strlen(sync_id) > 32) FATAL("Fuzzer ID too long");
-
- x = alloc_printf("%s/%s", out_dir, sync_id);
-
- sync_dir = out_dir;
- out_dir = x;
-
- if (!force_deterministic) {
- skip_deterministic = 1;
- use_splicing = 1;
- }
-
-}
-
-
-/* Handle screen resize (SIGWINCH). */
-
-static void handle_resize(int sig) {
- clear_screen = 1;
-}
-
-
-/* Check ASAN options. */
-
-static void check_asan_opts(void) {
- u8* x = getenv("ASAN_OPTIONS");
-
- if (x) {
-
- if (!strstr(x, "abort_on_error=1"))
- FATAL("Custom ASAN_OPTIONS set without abort_on_error=1 - please fix!");
-
- if (!strstr(x, "symbolize=0"))
- FATAL("Custom ASAN_OPTIONS set without symbolize=0 - please fix!");
-
- }
-
- x = getenv("MSAN_OPTIONS");
-
- if (x) {
-
- if (!strstr(x, "exit_code=" STRINGIFY(MSAN_ERROR)))
- FATAL("Custom MSAN_OPTIONS set without exit_code="
- STRINGIFY(MSAN_ERROR) " - please fix!");
-
- if (!strstr(x, "symbolize=0"))
- FATAL("Custom MSAN_OPTIONS set without symbolize=0 - please fix!");
-
- }
-
-}
-
-
-/* Detect @@ in args. */
-
-EXP_ST void detect_file_args(char** argv) {
-
- u32 i = 0;
- u8* cwd = getcwd(NULL, 0);
-
- if (!cwd) PFATAL("getcwd() failed");
-
- while (argv[i]) {
-
- u8* aa_loc = strstr(argv[i], "@@");
-
- if (aa_loc) {
-
- u8 *aa_subst, *n_arg;
-
- /* If we don't have a file name chosen yet, use a safe default. */
-
- if (!out_file)
- out_file = alloc_printf("%s/.cur_input", out_dir);
-
- /* Be sure that we're always using fully-qualified paths. */
-
- if (out_file[0] == '/') aa_subst = out_file;
- else aa_subst = alloc_printf("%s/%s", cwd, out_file);
-
- /* Construct a replacement argv value. */
-
- *aa_loc = 0;
- n_arg = alloc_printf("%s%s%s", argv[i], aa_subst, aa_loc + 2);
- argv[i] = n_arg;
- *aa_loc = '@';
-
- if (out_file[0] != '/') ck_free(aa_subst);
-
- }
-
- i++;
-
- }
-
- free(cwd); /* not tracked */
-
-}
-
-
-/* Set up signal handlers. More complicated that needs to be, because libc on
- Solaris doesn't resume interrupted reads(), sets SA_RESETHAND when you call
- siginterrupt(), and does other stupid things. */
-
-EXP_ST void setup_signal_handlers(void) {
-
- struct sigaction sa;
-
- sa.sa_handler = NULL;
- sa.sa_flags = SA_RESTART;
- sa.sa_sigaction = NULL;
-
- sigemptyset(&sa.sa_mask);
-
- /* Various ways of saying "stop". */
-
- sa.sa_handler = handle_stop_sig;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-
- /* Exec timeout notifications. */
-
- sa.sa_handler = handle_timeout;
- sigaction(SIGALRM, &sa, NULL);
-
- /* Window resize */
-
- sa.sa_handler = handle_resize;
- sigaction(SIGWINCH, &sa, NULL);
-
- /* SIGUSR1: skip entry */
-
- sa.sa_handler = handle_skipreq;
- sigaction(SIGUSR1, &sa, NULL);
-
- /* Things we don't care about. */
-
- sa.sa_handler = SIG_IGN;
- sigaction(SIGTSTP, &sa, NULL);
- sigaction(SIGPIPE, &sa, NULL);
-
-}
-
-
-/* Rewrite argv for QEMU. */
-
-static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
-
- char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
- u8 *tmp, *cp, *rsl, *own_copy;
-
- memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
-
- new_argv[2] = target_path;
- new_argv[1] = "--";
-
- /* Now we need to actually find the QEMU binary to put in argv[0]. */
-
- tmp = getenv("AFL_PATH");
-
- if (tmp) {
-
- cp = alloc_printf("%s/afl-qemu-trace", tmp);
-
- if (access(cp, X_OK))
- FATAL("Unable to find '%s'", tmp);
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- own_copy = ck_strdup(own_loc);
- rsl = strrchr(own_copy, '/');
-
- if (rsl) {
-
- *rsl = 0;
-
- cp = alloc_printf("%s/afl-qemu-trace", own_copy);
- ck_free(own_copy);
-
- if (!access(cp, X_OK)) {
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- } else ck_free(own_copy);
-
- if (!access(BIN_PATH "/afl-qemu-trace", X_OK)) {
-
- target_path = new_argv[0] = ck_strdup(BIN_PATH "/afl-qemu-trace");
- return new_argv;
-
- }
-
- SAYF("\n" cLRD "[-] " cRST
- "Oops, unable to find the 'afl-qemu-trace' binary. The binary must be built\n"
- " separately by following the instructions in qemu_mode/README.qemu. If you\n"
- " already have the binary installed, you may need to specify AFL_PATH in the\n"
- " environment.\n\n"
-
- " Of course, even without QEMU, afl-fuzz can still work with binaries that are\n"
- " instrumented at compile time with afl-gcc. It is also possible to use it as a\n"
- " traditional \"dumb\" fuzzer by specifying '-n' in the command line.\n");
-
- FATAL("Failed to locate 'afl-qemu-trace'.");
-
-}
-
-
-/* Make a copy of the current command line. */
-
-static void save_cmdline(u32 argc, char** argv) {
-
- u32 len = 1, i;
- u8* buf;
-
- for (i = 0; i < argc; i++)
- len += strlen(argv[i]) + 1;
-
- buf = orig_cmdline = ck_alloc(len);
-
- for (i = 0; i < argc; i++) {
-
- u32 l = strlen(argv[i]);
-
- memcpy(buf, argv[i], l);
- buf += l;
-
- if (i != argc - 1) *(buf++) = ' ';
-
- }
-
- *buf = 0;
-
-}
-
-
-#ifndef AFL_LIB
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- s32 opt;
- u64 prev_queued = 0;
- u32 sync_interval_cnt = 0, seek_to;
- u8 *extras_dir = 0;
- u8 mem_limit_given = 0;
- u8 exit_1 = !!getenv("AFL_BENCH_JUST_ONE");
- char** use_argv;
-
- struct timeval tv;
- struct timezone tz;
-
- SAYF(cCYA "afl-fuzz " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
-
- gettimeofday(&tv, &tz);
- srandom(tv.tv_sec ^ tv.tv_usec ^ getpid());
-
- while ((opt = getopt(argc, argv, "+i:o:f:m:t:T:dnCB:S:M:x:Q")) > 0)
-
- switch (opt) {
-
- case 'i': /* input dir */
-
- if (in_dir) FATAL("Multiple -i options not supported");
- in_dir = optarg;
-
- if (!strcmp(in_dir, "-")) in_place_resume = 1;
-
- break;
-
- case 'o': /* output dir */
-
- if (out_dir) FATAL("Multiple -o options not supported");
- out_dir = optarg;
- break;
-
- case 'M': { /* master sync ID */
-
- u8* c;
-
- if (sync_id) FATAL("Multiple -S or -M options not supported");
- sync_id = ck_strdup(optarg);
-
- if ((c = strchr(sync_id, ':'))) {
-
- *c = 0;
-
- if (sscanf(c + 1, "%u/%u", &master_id, &master_max) != 2 ||
- !master_id || !master_max || master_id > master_max ||
- master_max > 1000000) FATAL("Bogus master ID passed to -M");
-
- }
-
- force_deterministic = 1;
-
- }
-
- break;
-
- case 'S':
-
- if (sync_id) FATAL("Multiple -S or -M options not supported");
- sync_id = ck_strdup(optarg);
- break;
-
- case 'f': /* target file */
-
- if (out_file) FATAL("Multiple -f options not supported");
- out_file = optarg;
- break;
-
- case 'x': /* dictionary */
-
- if (extras_dir) FATAL("Multiple -x options not supported");
- extras_dir = optarg;
- break;
-
- case 't': { /* timeout */
-
- u8 suffix = 0;
-
- if (timeout_given) FATAL("Multiple -t options not supported");
-
- if (sscanf(optarg, "%u%c", &exec_tmout, &suffix) < 1 ||
- optarg[0] == '-') FATAL("Bad syntax used for -t");
-
- if (exec_tmout < 5) FATAL("Dangerously low value of -t");
-
- if (suffix == '+') timeout_given = 2; else timeout_given = 1;
-
- break;
-
- }
-
- case 'm': { /* mem limit */
-
- u8 suffix = 'M';
-
- if (mem_limit_given) FATAL("Multiple -m options not supported");
- mem_limit_given = 1;
-
- if (!strcmp(optarg, "none")) {
-
- mem_limit = 0;
- break;
-
- }
-
- if (sscanf(optarg, "%llu%c", &mem_limit, &suffix) < 1 ||
- optarg[0] == '-') FATAL("Bad syntax used for -m");
-
- switch (suffix) {
-
- case 'T': mem_limit *= 1024 * 1024; break;
- case 'G': mem_limit *= 1024; break;
- case 'k': mem_limit /= 1024; break;
- case 'M': break;
-
- default: FATAL("Unsupported suffix or bad syntax for -m");
-
- }
-
- if (mem_limit < 5) FATAL("Dangerously low value of -m");
-
- if (sizeof(rlim_t) == 4 && mem_limit > 2000)
- FATAL("Value of -m out of range on 32-bit systems");
-
- }
-
- break;
-
- case 'd': /* skip deterministic */
-
- if (skip_deterministic) FATAL("Multiple -d options not supported");
- skip_deterministic = 1;
- use_splicing = 1;
- break;
-
- case 'B': /* load bitmap */
-
- /* This is a secret undocumented option! It is useful if you find
- an interesting test case during a normal fuzzing process, and want
- to mutate it without rediscovering any of the test cases already
- found during an earlier run.
-
- To use this mode, you need to point -B to the fuzz_bitmap produced
- by an earlier run for the exact same binary... and that's it.
-
- I only used this once or twice to get variants of a particular
- file, so I'm not making this an official setting. */
-
- if (in_bitmap) FATAL("Multiple -B options not supported");
-
- in_bitmap = optarg;
- read_bitmap(in_bitmap);
- break;
-
- case 'C': /* crash mode */
-
- if (crash_mode) FATAL("Multiple -C options not supported");
- crash_mode = FAULT_CRASH;
- break;
-
- case 'n': /* dumb mode */
-
- if (dumb_mode) FATAL("Multiple -n options not supported");
- if (getenv("AFL_DUMB_FORKSRV")) dumb_mode = 2; else dumb_mode = 1;
-
- break;
-
- case 'T': /* banner */
-
- if (use_banner) FATAL("Multiple -T options not supported");
- use_banner = optarg;
- break;
-
- case 'Q': /* QEMU mode */
-
- if (qemu_mode) FATAL("Multiple -Q options not supported");
- qemu_mode = 1;
-
- if (!mem_limit_given) mem_limit = MEM_LIMIT_QEMU;
-
- break;
-
- default:
-
- usage(argv[0]);
-
- }
-
- if (optind == argc || !in_dir || !out_dir) usage(argv[0]);
-
- setup_signal_handlers();
- check_asan_opts();
-
- if (sync_id) fix_up_sync();
-
- if (!strcmp(in_dir, out_dir))
- FATAL("Input and output directories can't be the same");
-
- if (dumb_mode) {
-
- if (crash_mode) FATAL("-C and -n are mutually exclusive");
- if (qemu_mode) FATAL("-Q and -n are mutually exclusive");
-
- }
-
- if (getenv("AFL_NO_FORKSRV")) no_forkserver = 1;
- if (getenv("AFL_NO_CPU_RED")) no_cpu_meter_red = 1;
- if (getenv("AFL_SHUFFLE_QUEUE")) shuffle_queue = 1;
-
- if (dumb_mode == 2 && no_forkserver)
- FATAL("AFL_DUMB_FORKSRV and AFL_NO_FORKSRV are mutually exclusive");
-
- if (getenv("AFL_PRELOAD")) {
- setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
- setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
- }
-
- if (getenv("AFL_LD_PRELOAD"))
- FATAL("Use AFL_PRELOAD instead of AFL_LD_PRELOAD");
-
- save_cmdline(argc, argv);
-
- fix_up_banner(argv[optind]);
-
- check_if_tty();
-
- get_core_count();
-
-#ifdef HAVE_AFFINITY
- bind_to_free_cpu();
-#endif /* HAVE_AFFINITY */
-
- check_crash_handling();
- check_cpu_governor();
-
- setup_post();
- setup_shm();
- init_count_class16();
-
- setup_dirs_fds();
- read_testcases();
- load_auto();
-
- pivot_inputs();
-
- if (extras_dir) load_extras(extras_dir);
-
- if (!timeout_given) find_timeout();
-
- detect_file_args(argv + optind + 1);
-
- if (!out_file) setup_stdio_file();
-
- check_binary(argv[optind]);
-
- start_time = get_cur_time();
-
- if (qemu_mode)
- use_argv = get_qemu_argv(argv[0], argv + optind, argc - optind);
- else
- use_argv = argv + optind;
-
- perform_dry_run(use_argv);
-
- cull_queue();
-
- show_init_stats();
-
- seek_to = find_start_position();
-
- write_stats_file(0, 0, 0);
- save_auto();
-
- if (stop_soon) goto stop_fuzzing;
-
- /* Woop woop woop */
-
- if (!not_on_tty) {
- sleep(4);
- start_time += 4000;
- if (stop_soon) goto stop_fuzzing;
- }
-
- while (1) {
-
- u8 skipped_fuzz;
-
- cull_queue();
-
- if (!queue_cur) {
-
- queue_cycle++;
- current_entry = 0;
- cur_skipped_paths = 0;
- queue_cur = queue;
-
- while (seek_to) {
- current_entry++;
- seek_to--;
- queue_cur = queue_cur->next;
- }
-
- show_stats();
-
- if (not_on_tty) {
- ACTF("Entering queue cycle %llu.", queue_cycle);
- fflush(stdout);
- }
-
- /* If we had a full queue cycle with no new finds, try
- recombination strategies next. */
-
- if (queued_paths == prev_queued) {
-
- if (use_splicing) cycles_wo_finds++; else use_splicing = 1;
-
- } else cycles_wo_finds = 0;
-
- prev_queued = queued_paths;
-
- if (sync_id && queue_cycle == 1 && getenv("AFL_IMPORT_FIRST"))
- sync_fuzzers(use_argv);
-
- }
-
- skipped_fuzz = fuzz_one(use_argv);
-
- if (!stop_soon && sync_id && !skipped_fuzz) {
-
- if (!(sync_interval_cnt++ % SYNC_INTERVAL))
- sync_fuzzers(use_argv);
-
- }
-
- if (!stop_soon && exit_1) stop_soon = 2;
-
- if (stop_soon) break;
-
- queue_cur = queue_cur->next;
- current_entry++;
-
- }
-
- if (queue_cur) show_stats();
-
- write_bitmap();
- write_stats_file(0, 0, 0);
- save_auto();
-
-stop_fuzzing:
-
- SAYF(CURSOR_SHOW cLRD "\n\n+++ Testing aborted %s +++\n" cRST,
- stop_soon == 2 ? "programmatically" : "by user");
-
- /* Running for more than 30 minutes but still doing first cycle? */
-
- if (queue_cycle == 1 && get_cur_time() - start_time > 30 * 60 * 1000) {
-
- SAYF("\n" cYEL "[!] " cRST
- "Stopped during the first cycle, results may be incomplete.\n"
- " (For info on resuming, see %s/README.)\n", doc_path);
-
- }
-
- fclose(plot_file);
- destroy_queue();
- destroy_extras();
- ck_free(target_path);
- ck_free(sync_id);
-
- alloc_report();
-
- OKF("We're done here. Have a nice day!\n");
-
- exit(0);
-
-}
-
-#endif /* !AFL_LIB */
diff --git a/chromium/third_party/afl/src/afl-gcc.c b/chromium/third_party/afl/src/afl-gcc.c
deleted file mode 100644
index fa3dec1aaeb..00000000000
--- a/chromium/third_party/afl/src/afl-gcc.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- american fuzzy lop - wrapper for GCC and clang
- ----------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This program is a drop-in replacement for GCC or clang. The most common way
- of using it is to pass the path to afl-gcc or afl-clang via CC when invoking
- ./configure.
-
- (Of course, use CXX and point it to afl-g++ / afl-clang++ for C++ code.)
-
- The wrapper needs to know the path to afl-as (renamed to 'as'). The default
- is /usr/local/lib/afl/. A convenient way to specify alternative directories
- would be to set AFL_PATH.
-
- If AFL_HARDEN is set, the wrapper will compile the target app with various
- hardening options that may help detect memory management issues more
- reliably. You can also specify AFL_USE_ASAN to enable ASAN.
-
- If you want to call a non-default compiler as a next step of the chain,
- specify its location via AFL_CC or AFL_CXX.
-
- */
-
-#define AFL_MAIN
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-#include "alloc-inl.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-static u8* as_path; /* Path to the AFL 'as' wrapper */
-static u8** cc_params; /* Parameters passed to the real CC */
-static u32 cc_par_cnt = 1; /* Param count, including argv0 */
-static u8 be_quiet, /* Quiet mode */
- clang_mode; /* Invoked as afl-clang*? */
-
-
-/* Try to find our "fake" GNU assembler in AFL_PATH or at the location derived
- from argv[0]. If that fails, abort. */
-
-static void find_as(u8* argv0) {
-
- u8 *afl_path = getenv("AFL_PATH");
- u8 *slash, *tmp;
-
- if (afl_path) {
-
- tmp = alloc_printf("%s/as", afl_path);
-
- if (!access(tmp, X_OK)) {
- as_path = afl_path;
- ck_free(tmp);
- return;
- }
-
- ck_free(tmp);
-
- }
-
- slash = strrchr(argv0, '/');
-
- if (slash) {
-
- u8 *dir;
-
- *slash = 0;
- dir = ck_strdup(argv0);
- *slash = '/';
-
- tmp = alloc_printf("%s/afl-as", dir);
-
- if (!access(tmp, X_OK)) {
- as_path = dir;
- ck_free(tmp);
- return;
- }
-
- ck_free(tmp);
- ck_free(dir);
-
- }
-
- if (!access(AFL_PATH "/as", X_OK)) {
- as_path = AFL_PATH;
- return;
- }
-
- FATAL("Unable to find AFL wrapper binary for 'as'. Please set AFL_PATH");
-
-}
-
-
-/* Copy argv to cc_params, making the necessary edits. */
-
-static void edit_params(u32 argc, char** argv) {
-
- u8 fortify_set = 0, asan_set = 0;
- u8 *name;
-
-#if defined(__FreeBSD__) && defined(__x86_64__)
- u8 m32_set = 0;
-#endif
-
- cc_params = ck_alloc((argc + 128) * sizeof(u8*));
-
- name = strrchr(argv[0], '/');
- if (!name) name = argv[0]; else name++;
-
- if (!strncmp(name, "afl-clang", 9)) {
-
- clang_mode = 1;
-
- setenv(CLANG_ENV_VAR, "1", 1);
-
- if (!strcmp(name, "afl-clang++")) {
- u8* alt_cxx = getenv("AFL_CXX");
- cc_params[0] = alt_cxx ? alt_cxx : (u8*)"clang++";
- } else {
- u8* alt_cc = getenv("AFL_CC");
- cc_params[0] = alt_cc ? alt_cc : (u8*)"clang";
- }
-
- } else {
-
- /* With GCJ and Eclipse installed, you can actually compile Java! The
- instrumentation will work (amazingly). Alas, unhandled exceptions do
- not call abort(), so afl-fuzz would need to be modified to equate
- non-zero exit codes with crash conditions when working with Java
- binaries. Meh. */
-
-#ifdef __APPLE__
-
- if (!strcmp(name, "afl-g++")) cc_params[0] = getenv("AFL_CXX");
- else if (!strcmp(name, "afl-gcj")) cc_params[0] = getenv("AFL_GCJ");
- else cc_params[0] = getenv("AFL_CC");
-
- if (!cc_params[0]) {
-
- SAYF("\n" cLRD "[-] " cRST
- "On Apple systems, 'gcc' is usually just a wrapper for clang. Please use the\n"
- " 'afl-clang' utility instead of 'afl-gcc'. If you really have GCC installed,\n"
- " set AFL_CC or AFL_CXX to specify the correct path to that compiler.\n");
-
- FATAL("AFL_CC or AFL_CXX required on MacOS X");
-
- }
-
-#else
-
- if (!strcmp(name, "afl-g++")) {
- u8* alt_cxx = getenv("AFL_CXX");
- cc_params[0] = alt_cxx ? alt_cxx : (u8*)"g++";
- } else if (!strcmp(name, "afl-gcj")) {
- u8* alt_cc = getenv("AFL_GCJ");
- cc_params[0] = alt_cc ? alt_cc : (u8*)"gcj";
- } else {
- u8* alt_cc = getenv("AFL_CC");
- cc_params[0] = alt_cc ? alt_cc : (u8*)"gcc";
- }
-
-#endif /* __APPLE__ */
-
- }
-
- while (--argc) {
- u8* cur = *(++argv);
-
- if (!strncmp(cur, "-B", 2)) {
-
- if (!be_quiet) WARNF("-B is already set, overriding");
-
- if (!cur[2] && argc > 1) { argc--; argv++; }
- continue;
-
- }
-
- if (!strcmp(cur, "-integrated-as")) continue;
-
- if (!strcmp(cur, "-pipe")) continue;
-
-#if defined(__FreeBSD__) && defined(__x86_64__)
- if (!strcmp(cur, "-m32")) m32_set = 1;
-#endif
-
- if (!strcmp(cur, "-fsanitize=address") ||
- !strcmp(cur, "-fsanitize=memory")) asan_set = 1;
-
- if (strstr(cur, "FORTIFY_SOURCE")) fortify_set = 1;
-
- cc_params[cc_par_cnt++] = cur;
-
- }
-
- cc_params[cc_par_cnt++] = "-B";
- cc_params[cc_par_cnt++] = as_path;
-
- if (clang_mode)
- cc_params[cc_par_cnt++] = "-no-integrated-as";
-
- if (getenv("AFL_HARDEN")) {
-
- cc_params[cc_par_cnt++] = "-fstack-protector-all";
-
- if (!fortify_set)
- cc_params[cc_par_cnt++] = "-D_FORTIFY_SOURCE=2";
-
- }
-
- if (asan_set) {
-
- /* Pass this on to afl-as to adjust map density. */
-
- setenv("AFL_USE_ASAN", "1", 1);
-
- } else if (getenv("AFL_USE_ASAN")) {
-
- if (getenv("AFL_USE_MSAN"))
- FATAL("ASAN and MSAN are mutually exclusive");
-
- if (getenv("AFL_HARDEN"))
- FATAL("ASAN and AFL_HARDEN are mutually exclusive");
-
- cc_params[cc_par_cnt++] = "-U_FORTIFY_SOURCE";
- cc_params[cc_par_cnt++] = "-fsanitize=address";
-
- } else if (getenv("AFL_USE_MSAN")) {
-
- if (getenv("AFL_USE_ASAN"))
- FATAL("ASAN and MSAN are mutually exclusive");
-
- if (getenv("AFL_HARDEN"))
- FATAL("MSAN and AFL_HARDEN are mutually exclusive");
-
- cc_params[cc_par_cnt++] = "-U_FORTIFY_SOURCE";
- cc_params[cc_par_cnt++] = "-fsanitize=memory";
-
-
- }
-
- if (!getenv("AFL_DONT_OPTIMIZE")) {
-
-#if defined(__FreeBSD__) && defined(__x86_64__)
-
- /* On 64-bit FreeBSD systems, clang -g -m32 is broken, but -m32 itself
- works OK. This has nothing to do with us, but let's avoid triggering
- that bug. */
-
- if (!clang_mode || !m32_set)
- cc_params[cc_par_cnt++] = "-g";
-
-#else
-
- cc_params[cc_par_cnt++] = "-g";
-
-#endif
-
- cc_params[cc_par_cnt++] = "-O3";
- cc_params[cc_par_cnt++] = "-funroll-loops";
-
- /* Two indicators that you're building for fuzzing; one of them is
- AFL-specific, the other is shared with libfuzzer. */
-
- cc_params[cc_par_cnt++] = "-D__AFL_COMPILER=1";
- cc_params[cc_par_cnt++] = "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1";
-
- }
-
- if (getenv("AFL_NO_BUILTIN")) {
-
- cc_params[cc_par_cnt++] = "-fno-builtin-strcmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-strncmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-memcmp";
-
- }
-
- cc_params[cc_par_cnt] = NULL;
-
-}
-
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- if (isatty(2) && !getenv("AFL_QUIET")) {
-
- SAYF(cCYA "afl-cc " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- } else be_quiet = 1;
-
- if (argc < 2) {
-
- SAYF("\n"
- "This is a helper application for afl-fuzz. It serves as a drop-in replacement\n"
- "for gcc or clang, letting you recompile third-party code with the required\n"
- "runtime instrumentation. A common use pattern would be one of the following:\n\n"
-
- " CC=%s/afl-gcc ./configure\n"
- " CXX=%s/afl-g++ ./configure\n\n"
-
- "You can specify custom next-stage toolchain via AFL_CC, AFL_CXX, and AFL_AS.\n"
- "Setting AFL_HARDEN enables hardening optimizations in the compiled code.\n\n",
- BIN_PATH, BIN_PATH);
-
- exit(1);
-
- }
-
- find_as(argv[0]);
-
- edit_params(argc, argv);
-
- execvp(cc_params[0], (char**)cc_params);
-
- FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]);
-
- return 0;
-
-}
diff --git a/chromium/third_party/afl/src/afl-gotcpu.c b/chromium/third_party/afl/src/afl-gotcpu.c
deleted file mode 100644
index c296993bf50..00000000000
--- a/chromium/third_party/afl/src/afl-gotcpu.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- american fuzzy lop - free CPU gizmo
- -----------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This tool provides a fairly accurate measurement of CPU preemption rate.
- It is meant to complement the quick-and-dirty load average widget shown
- in the afl-fuzz UI. See docs/parallel_fuzzing.txt for more info.
-
- For some work loads, the tool may actually suggest running more instances
- than you have CPU cores. This can happen if the tested program is spending
- a portion of its run time waiting for I/O, rather than being 100%
- CPU-bound.
-
- The idea for the getrusage()-based approach comes from Jakub Wilk.
-
- */
-
-#define AFL_MAIN
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sched.h>
-
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-#include "types.h"
-#include "debug.h"
-
-#ifdef __linux__
-# define HAVE_AFFINITY 1
-#endif /* __linux__ */
-
-
-/* Get unix time in microseconds. */
-
-static u64 get_cur_time_us(void) {
-
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
-
- return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
-
-}
-
-
-/* Get CPU usage in microseconds. */
-
-static u64 get_cpu_usage_us(void) {
-
- struct rusage u;
-
- getrusage(RUSAGE_SELF, &u);
-
- return (u.ru_utime.tv_sec * 1000000ULL) + u.ru_utime.tv_usec +
- (u.ru_stime.tv_sec * 1000000ULL) + u.ru_stime.tv_usec;
-
-}
-
-
-/* Measure preemption rate. */
-
-static u32 measure_preemption(u32 target_ms) {
-
- static volatile u32 v1, v2;
-
- u64 st_t, en_t, st_c, en_c, real_delta, slice_delta;
- s32 loop_repeats = 0;
-
- st_t = get_cur_time_us();
- st_c = get_cpu_usage_us();
-
-repeat_loop:
-
- v1 = CTEST_BUSY_CYCLES;
-
- while (v1--) v2++;
- sched_yield();
-
- en_t = get_cur_time_us();
-
- if (en_t - st_t < target_ms * 1000) {
- loop_repeats++;
- goto repeat_loop;
- }
-
- /* Let's see what percentage of this time we actually had a chance to
- run, and how much time was spent in the penalty box. */
-
- en_c = get_cpu_usage_us();
-
- real_delta = (en_t - st_t) / 1000;
- slice_delta = (en_c - st_c) / 1000;
-
- return real_delta * 100 / slice_delta;
-
-}
-
-
-/* Do the benchmark thing. */
-
-int main(int argc, char** argv) {
-
-#ifdef HAVE_AFFINITY
-
- u32 cpu_cnt = sysconf(_SC_NPROCESSORS_ONLN),
- idle_cpus = 0, maybe_cpus = 0, i;
-
- SAYF(cCYA "afl-gotcpu " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- ACTF("Measuring per-core preemption rate (this will take %0.02f sec)...",
- ((double)CTEST_CORE_TRG_MS) / 1000);
-
- for (i = 0; i < cpu_cnt; i++) {
-
- s32 fr = fork();
-
- if (fr < 0) PFATAL("fork failed");
-
- if (!fr) {
-
- cpu_set_t c;
- u32 util_perc;
-
- CPU_ZERO(&c);
- CPU_SET(i, &c);
-
- if (sched_setaffinity(0, sizeof(c), &c))
- PFATAL("sched_setaffinity failed");
-
- util_perc = measure_preemption(CTEST_CORE_TRG_MS);
-
- if (util_perc < 110) {
-
- SAYF(" Core #%u: " cLGN "AVAILABLE\n" cRST, i);
- exit(0);
-
- } else if (util_perc < 250) {
-
- SAYF(" Core #%u: " cYEL "CAUTION " cRST "(%u%%)\n", i, util_perc);
- exit(1);
-
- }
-
- SAYF(" Core #%u: " cLRD "OVERBOOKED " cRST "(%u%%)\n" cRST, i,
- util_perc);
- exit(2);
-
- }
-
- }
-
- for (i = 0; i < cpu_cnt; i++) {
-
- int ret;
- if (waitpid(-1, &ret, 0) < 0) PFATAL("waitpid failed");
-
- if (WEXITSTATUS(ret) == 0) idle_cpus++;
- if (WEXITSTATUS(ret) <= 1) maybe_cpus++;
-
- }
-
- SAYF(cGRA "\n>>> ");
-
- if (idle_cpus) {
-
- if (maybe_cpus == idle_cpus) {
-
- SAYF(cLGN "PASS: " cRST "You can run more processes on %u core%s.",
- idle_cpus, idle_cpus > 1 ? "s" : "");
-
- } else {
-
- SAYF(cLGN "PASS: " cRST "You can run more processes on %u to %u core%s.",
- idle_cpus, maybe_cpus, maybe_cpus > 1 ? "s" : "");
-
- }
-
- SAYF(cGRA " <<<" cRST "\n\n");
- return 0;
-
- }
-
- if (maybe_cpus) {
-
- SAYF(cYEL "CAUTION: " cRST "You may still have %u core%s available.",
- maybe_cpus, maybe_cpus > 1 ? "s" : "");
- SAYF(cGRA " <<<" cRST "\n\n");
- return 1;
-
- }
-
- SAYF(cLRD "FAIL: " cRST "All cores are overbooked.");
- SAYF(cGRA " <<<" cRST "\n\n");
- return 2;
-
-#else
-
- u32 util_perc;
-
- SAYF(cCYA "afl-gotcpu " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- /* Run a busy loop for CTEST_TARGET_MS. */
-
- ACTF("Measuring gross preemption rate (this will take %0.02f sec)...",
- ((double)CTEST_TARGET_MS) / 1000);
-
- util_perc = measure_preemption(CTEST_TARGET_MS);
-
- /* Deliver the final verdict. */
-
- SAYF(cGRA "\n>>> ");
-
- if (util_perc < 105) {
-
- SAYF(cLGN "PASS: " cRST "You can probably run additional processes.");
-
- } else if (util_perc < 130) {
-
- SAYF(cYEL "CAUTION: " cRST "Your CPU may be somewhat overbooked (%u%%).",
- util_perc);
-
- } else {
-
- SAYF(cLRD "FAIL: " cRST "Your CPU is overbooked (%u%%).", util_perc);
-
- }
-
- SAYF(cGRA " <<<" cRST "\n\n");
-
- return (util_perc > 105) + (util_perc > 130);
-
-#endif /* ^HAVE_AFFINITY */
-
-}
diff --git a/chromium/third_party/afl/src/afl-plot b/chromium/third_party/afl/src/afl-plot
deleted file mode 100755
index 3bd93590acd..00000000000
--- a/chromium/third_party/afl/src/afl-plot
+++ /dev/null
@@ -1,166 +0,0 @@
-#!/bin/sh
-#
-# american fuzzy lop - Advanced Persistent Graphing
-# -------------------------------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-# Based on a design & prototype by Michael Rash.
-#
-# Copyright 2014, 2015 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-
-echo "progress plotting utility for afl-fuzz by <lcamtuf@google.com>"
-echo
-
-if [ ! "$#" = "2" ]; then
-
- cat 1>&2 <<_EOF_
-This program generates gnuplot images from afl-fuzz output data. Usage:
-
-$0 afl_state_dir graph_output_dir
-
-The afl_state_dir parameter should point to an existing state directory for any
-active or stopped instance of afl-fuzz; while graph_output_dir should point to
-an empty directory where this tool can write the resulting plots to.
-
-The program will put index.html and three PNG images in the output directory;
-you should be able to view it with any web browser of your choice.
-
-_EOF_
-
- exit 1
-
-fi
-
-echo "$1" | grep -qE '^(/var)?/tmp/'
-T1="$?"
-
-echo "$2" | grep -qE '^(/var)?/tmp/'
-T2="$?"
-
-if [ "$T1" = "0" -o "$T2" = "0" ]; then
-
- echo "[-] Error: this script shouldn't be used with shared /tmp directories." 1>&2
- exit 1
-
-fi
-
-if [ ! -f "$1/plot_data" ]; then
-
- echo "[-] Error: input directory is not valid (missing 'plot_data')." 1>&2
- exit 1
-
-fi
-
-BANNER="`cat "$1/fuzzer_stats" | grep '^afl_banner ' | cut -d: -f2- | cut -b2-`"
-
-test "$BANNER" = "" && BANNER="(none)"
-
-GNUPLOT=`which gnuplot 2>/dev/null`
-
-if [ "$GNUPLOT" = "" ]; then
-
- echo "[-] Error: can't find 'gnuplot' in your \$PATH." 1>&2
- exit 1
-
-fi
-
-mkdir "$2" 2>/dev/null
-
-if [ ! -d "$2" ]; then
-
- echo "[-] Error: unable to create the output directory - pick another location." 1>&2
- exit 1
-
-fi
-
-rm -f "$2/high_freq.png" "$2/low_freq.png" "$2/exec_speed.png"
-mv -f "$2/index.html" "$2/index.html.orig" 2>/dev/null
-
-echo "[*] Generating plots..."
-
-(
-
-cat <<_EOF_
-set terminal png truecolor enhanced size 1000,300 butt
-
-set output '$2/high_freq.png'
-
-set xdata time
-set timefmt '%s'
-set format x "%b %d\n%H:%M"
-set tics font 'small'
-unset mxtics
-unset mytics
-
-set grid xtics linetype 0 linecolor rgb '#e0e0e0'
-set grid ytics linetype 0 linecolor rgb '#e0e0e0'
-set border linecolor rgb '#50c0f0'
-set tics textcolor rgb '#000000'
-set key outside
-
-set autoscale xfixmin
-set autoscale xfixmax
-
-plot '$1/plot_data' using 1:4 with filledcurve x1 title 'total paths' linecolor rgb '#000000' fillstyle transparent solid 0.2 noborder, \\
- '' using 1:3 with filledcurve x1 title 'current path' linecolor rgb '#f0f0f0' fillstyle transparent solid 0.5 noborder, \\
- '' using 1:5 with lines title 'pending paths' linecolor rgb '#0090ff' linewidth 3, \\
- '' using 1:6 with lines title 'pending favs' linecolor rgb '#c00080' linewidth 3, \\
- '' using 1:2 with lines title 'cycles done' linecolor rgb '#c000f0' linewidth 3
-
-set terminal png truecolor enhanced size 1000,200 butt
-set output '$2/low_freq.png'
-
-plot '$1/plot_data' using 1:8 with filledcurve x1 title '' linecolor rgb '#c00080' fillstyle transparent solid 0.2 noborder, \\
- '' using 1:8 with lines title ' uniq crashes' linecolor rgb '#c00080' linewidth 3, \\
- '' using 1:9 with lines title 'uniq hangs' linecolor rgb '#c000f0' linewidth 3, \\
- '' using 1:10 with lines title 'levels' linecolor rgb '#0090ff' linewidth 3
-
-set terminal png truecolor enhanced size 1000,200 butt
-set output '$2/exec_speed.png'
-
-plot '$1/plot_data' using 1:11 with filledcurve x1 title '' linecolor rgb '#0090ff' fillstyle transparent solid 0.2 noborder, \\
- '$1/plot_data' using 1:11 with lines title ' execs/sec' linecolor rgb '#0090ff' linewidth 3 smooth bezier;
-
-_EOF_
-
-) | gnuplot
-
-if [ ! -s "$2/exec_speed.png" ]; then
-
- echo "[-] Error: something went wrong! Perhaps you have an ancient version of gnuplot?" 1>&2
- exit 1
-
-fi
-
-echo "[*] Generating index.html..."
-
-cat >"$2/index.html" <<_EOF_
-<table style="font-family: 'Trebuchet MS', 'Tahoma', 'Arial', 'Helvetica'">
-<tr><td style="width: 18ex"><b>Banner:</b></td><td>$BANNER</td></tr>
-<tr><td><b>Directory:</b></td><td>$1</td></tr>
-<tr><td><b>Generated on:</b></td><td>`date`</td></tr>
-</table>
-<p>
-<img src="high_freq.png" width=1000 height=300><p>
-<img src="low_freq.png" width=1000 height=200><p>
-<img src="exec_speed.png" width=1000 height=200>
-
-_EOF_
-
-# Make it easy to remotely view results when outputting directly to a directory
-# served by Apache or other HTTP daemon. Since the plots aren't horribly
-# sensitive, this seems like a reasonable trade-off.
-
-chmod 755 "$2"
-chmod 644 "$2/high_freq.png" "$2/low_freq.png" "$2/exec_speed.png" "$2/index.html"
-
-echo "[+] All done - enjoy your charts!"
-
-exit 0
diff --git a/chromium/third_party/afl/src/afl-showmap.c b/chromium/third_party/afl/src/afl-showmap.c
deleted file mode 100644
index 4b81862a27e..00000000000
--- a/chromium/third_party/afl/src/afl-showmap.c
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
- american fuzzy lop - map display utility
- ----------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- A very simple tool that runs the targeted binary and displays
- the contents of the trace bitmap in a human-readable form. Useful in
- scripts to eliminate redundant inputs and perform other checks.
-
- Exit code is 2 if the target program crashes; 1 if it times out or
- there is a problem executing it; or 0 if execution is successful.
-
- */
-
-#define AFL_MAIN
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-#include "alloc-inl.h"
-#include "hash.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-#include <dirent.h>
-#include <fcntl.h>
-
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-
-static s32 child_pid; /* PID of the tested program */
-
-static u8* trace_bits; /* SHM with instrumentation bitmap */
-
-static u8 *out_file, /* Trace output file */
- *doc_path, /* Path to docs */
- *target_path, /* Path to target binary */
- *at_file; /* Substitution string for @@ */
-
-static u32 exec_tmout; /* Exec timeout (ms) */
-
-static u64 mem_limit = MEM_LIMIT; /* Memory limit (MB) */
-
-static s32 shm_id; /* ID of the SHM region */
-
-static u8 quiet_mode, /* Hide non-essential messages? */
- edges_only, /* Ignore hit counts? */
- cmin_mode, /* Generate output in afl-cmin mode? */
- binary_mode; /* Write output as a binary map */
-
-static volatile u8
- stop_soon, /* Ctrl-C pressed? */
- child_timed_out, /* Child timed out? */
- child_crashed; /* Child crashed? */
-
-/* Classify tuple counts. Instead of mapping to individual bits, as in
- afl-fuzz.c, we map to more user-friendly numbers between 1 and 8. */
-
-static const u8 count_class_human[256] = {
-
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 3,
- [4 ... 7] = 4,
- [8 ... 15] = 5,
- [16 ... 31] = 6,
- [32 ... 127] = 7,
- [128 ... 255] = 8
-
-};
-
-static const u8 count_class_binary[256] = {
-
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 4,
- [4 ... 7] = 8,
- [8 ... 15] = 16,
- [16 ... 31] = 32,
- [32 ... 127] = 64,
- [128 ... 255] = 128
-
-};
-
-static void classify_counts(u8* mem, const u8* map) {
-
- u32 i = MAP_SIZE;
-
- if (edges_only) {
-
- while (i--) {
- if (*mem) *mem = 1;
- mem++;
- }
-
- } else {
-
- while (i--) {
- *mem = map[*mem];
- mem++;
- }
-
- }
-
-}
-
-
-/* Get rid of shared memory (atexit handler). */
-
-static void remove_shm(void) {
-
- shmctl(shm_id, IPC_RMID, NULL);
-
-}
-
-
-/* Configure shared memory. */
-
-static void setup_shm(void) {
-
- u8* shm_str;
-
- shm_id = shmget(IPC_PRIVATE, MAP_SIZE, IPC_CREAT | IPC_EXCL | 0600);
-
- if (shm_id < 0) PFATAL("shmget() failed");
-
- atexit(remove_shm);
-
- shm_str = alloc_printf("%d", shm_id);
-
- setenv(SHM_ENV_VAR, shm_str, 1);
-
- ck_free(shm_str);
-
- trace_bits = shmat(shm_id, NULL, 0);
-
- if (!trace_bits) PFATAL("shmat() failed");
-
-}
-
-/* Write results. */
-
-static u32 write_results(void) {
-
- s32 fd;
- u32 i, ret = 0;
-
- u8 cco = !!getenv("AFL_CMIN_CRASHES_ONLY"),
- caa = !!getenv("AFL_CMIN_ALLOW_ANY");
-
- if (!strncmp(out_file, "/dev/", 5)) {
-
- fd = open(out_file, O_WRONLY, 0600);
- if (fd < 0) PFATAL("Unable to open '%s'", out_file);
-
- } else if (!strcmp(out_file, "-")) {
-
- fd = dup(1);
- if (fd < 0) PFATAL("Unable to open stdout");
-
- } else {
-
- unlink(out_file); /* Ignore errors */
- fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd < 0) PFATAL("Unable to create '%s'", out_file);
-
- }
-
-
- if (binary_mode) {
-
- for (i = 0; i < MAP_SIZE; i++)
- if (trace_bits[i]) ret++;
-
- ck_write(fd, trace_bits, MAP_SIZE, out_file);
- close(fd);
-
- } else {
-
- FILE* f = fdopen(fd, "w");
-
- if (!f) PFATAL("fdopen() failed");
-
- for (i = 0; i < MAP_SIZE; i++) {
-
- if (!trace_bits[i]) continue;
- ret++;
-
- if (cmin_mode) {
-
- if (child_timed_out) break;
- if (!caa && child_crashed != cco) break;
-
- fprintf(f, "%u%u\n", trace_bits[i], i);
-
- } else fprintf(f, "%06u:%u\n", i, trace_bits[i]);
-
- }
-
- fclose(f);
-
- }
-
- return ret;
-
-}
-
-
-/* Handle timeout signal. */
-
-static void handle_timeout(int sig) {
-
- child_timed_out = 1;
- if (child_pid > 0) kill(child_pid, SIGKILL);
-
-}
-
-
-/* Execute target application. */
-
-static void run_target(char** argv) {
-
- static struct itimerval it;
- int status = 0;
-
- if (!quiet_mode)
- SAYF("-- Program output begins --\n" cRST);
-
- MEM_BARRIER();
-
- child_pid = fork();
-
- if (child_pid < 0) PFATAL("fork() failed");
-
- if (!child_pid) {
-
- struct rlimit r;
-
- if (quiet_mode) {
-
- s32 fd = open("/dev/null", O_RDWR);
-
- if (fd < 0 || dup2(fd, 1) < 0 || dup2(fd, 2) < 0) {
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- PFATAL("Descriptor initialization failed");
- }
-
- close(fd);
-
- }
-
- if (mem_limit) {
-
- r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;
-
-#ifdef RLIMIT_AS
-
- setrlimit(RLIMIT_AS, &r); /* Ignore errors */
-
-#else
-
- setrlimit(RLIMIT_DATA, &r); /* Ignore errors */
-
-#endif /* ^RLIMIT_AS */
-
- }
-
- r.rlim_max = r.rlim_cur = 0;
- setrlimit(RLIMIT_CORE, &r); /* Ignore errors */
-
- execv(target_path, argv);
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- exit(0);
-
- }
-
- /* Configure timeout, wait for child, cancel timeout. */
-
- if (exec_tmout) {
-
- child_timed_out = 0;
- it.it_value.tv_sec = (exec_tmout / 1000);
- it.it_value.tv_usec = (exec_tmout % 1000) * 1000;
-
- }
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- if (waitpid(child_pid, &status, 0) <= 0) FATAL("waitpid() failed");
-
- child_pid = 0;
- it.it_value.tv_sec = 0;
- it.it_value.tv_usec = 0;
- setitimer(ITIMER_REAL, &it, NULL);
-
- MEM_BARRIER();
-
- /* Clean up bitmap, analyze exit condition, etc. */
-
- if (*(u32*)trace_bits == EXEC_FAIL_SIG)
- FATAL("Unable to execute '%s'", argv[0]);
-
- classify_counts(trace_bits, binary_mode ?
- count_class_binary : count_class_human);
-
- if (!quiet_mode)
- SAYF(cRST "-- Program output ends --\n");
-
- if (!child_timed_out && !stop_soon && WIFSIGNALED(status))
- child_crashed = 1;
-
- if (!quiet_mode) {
-
- if (child_timed_out)
- SAYF(cLRD "\n+++ Program timed off +++\n" cRST);
- else if (stop_soon)
- SAYF(cLRD "\n+++ Program aborted by user +++\n" cRST);
- else if (child_crashed)
- SAYF(cLRD "\n+++ Program killed by signal %u +++\n" cRST, WTERMSIG(status));
-
- }
-
-
-}
-
-
-/* Handle Ctrl-C and the like. */
-
-static void handle_stop_sig(int sig) {
-
- stop_soon = 1;
-
- if (child_pid > 0) kill(child_pid, SIGKILL);
-
-}
-
-
-/* Do basic preparations - persistent fds, filenames, etc. */
-
-static void set_up_environment(void) {
-
- setenv("ASAN_OPTIONS", "abort_on_error=1:"
- "detect_leaks=0:"
- "symbolize=0:"
- "allocator_may_return_null=1", 0);
-
- setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":"
- "symbolize=0:"
- "abort_on_error=1:"
- "allocator_may_return_null=1:"
- "msan_track_origins=0", 0);
-
- if (getenv("AFL_PRELOAD")) {
- setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
- setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
- }
-
-}
-
-
-/* Setup signal handlers, duh. */
-
-static void setup_signal_handlers(void) {
-
- struct sigaction sa;
-
- sa.sa_handler = NULL;
- sa.sa_flags = SA_RESTART;
- sa.sa_sigaction = NULL;
-
- sigemptyset(&sa.sa_mask);
-
- /* Various ways of saying "stop". */
-
- sa.sa_handler = handle_stop_sig;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-
- /* Exec timeout notifications. */
-
- sa.sa_handler = handle_timeout;
- sigaction(SIGALRM, &sa, NULL);
-
-}
-
-
-/* Detect @@ in args. */
-
-static void detect_file_args(char** argv) {
-
- u32 i = 0;
- u8* cwd = getcwd(NULL, 0);
-
- if (!cwd) PFATAL("getcwd() failed");
-
- while (argv[i]) {
-
- u8* aa_loc = strstr(argv[i], "@@");
-
- if (aa_loc) {
-
- u8 *aa_subst, *n_arg;
-
- if (!at_file) FATAL("@@ syntax is not supported by this tool.");
-
- /* Be sure that we're always using fully-qualified paths. */
-
- if (at_file[0] == '/') aa_subst = at_file;
- else aa_subst = alloc_printf("%s/%s", cwd, at_file);
-
- /* Construct a replacement argv value. */
-
- *aa_loc = 0;
- n_arg = alloc_printf("%s%s%s", argv[i], aa_subst, aa_loc + 2);
- argv[i] = n_arg;
- *aa_loc = '@';
-
- if (at_file[0] != '/') ck_free(aa_subst);
-
- }
-
- i++;
-
- }
-
- free(cwd); /* not tracked */
-
-}
-
-
-/* Show banner. */
-
-static void show_banner(void) {
-
- SAYF(cCYA "afl-showmap " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
-}
-
-/* Display usage hints. */
-
-static void usage(u8* argv0) {
-
- show_banner();
-
- SAYF("\n%s [ options ] -- /path/to/target_app [ ... ]\n\n"
-
- "Required parameters:\n\n"
-
- " -o file - file to write the trace data to\n\n"
-
- "Execution control settings:\n\n"
-
- " -t msec - timeout for each run (none)\n"
- " -m megs - memory limit for child process (%u MB)\n"
- " -Q - use binary-only instrumentation (QEMU mode)\n\n"
-
- "Other settings:\n\n"
-
- " -q - sink program's output and don't show messages\n"
- " -e - show edge coverage only, ignore hit counts\n\n"
-
- "This tool displays raw tuple data captured by AFL instrumentation.\n"
- "For additional help, consult %s/README.\n\n" cRST,
-
- argv0, MEM_LIMIT, doc_path);
-
- exit(1);
-
-}
-
-
-/* Find binary. */
-
-static void find_binary(u8* fname) {
-
- u8* env_path = 0;
- struct stat st;
-
- if (strchr(fname, '/') || !(env_path = getenv("PATH"))) {
-
- target_path = ck_strdup(fname);
-
- if (stat(target_path, &st) || !S_ISREG(st.st_mode) ||
- !(st.st_mode & 0111) || st.st_size < 4)
- FATAL("Program '%s' not found or not executable", fname);
-
- } else {
-
- while (env_path) {
-
- u8 *cur_elem, *delim = strchr(env_path, ':');
-
- if (delim) {
-
- cur_elem = ck_alloc(delim - env_path + 1);
- memcpy(cur_elem, env_path, delim - env_path);
- delim++;
-
- } else cur_elem = ck_strdup(env_path);
-
- env_path = delim;
-
- if (cur_elem[0])
- target_path = alloc_printf("%s/%s", cur_elem, fname);
- else
- target_path = ck_strdup(fname);
-
- ck_free(cur_elem);
-
- if (!stat(target_path, &st) && S_ISREG(st.st_mode) &&
- (st.st_mode & 0111) && st.st_size >= 4) break;
-
- ck_free(target_path);
- target_path = 0;
-
- }
-
- if (!target_path) FATAL("Program '%s' not found or not executable", fname);
-
- }
-
-}
-
-
-/* Fix up argv for QEMU. */
-
-static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
-
- char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
- u8 *tmp, *cp, *rsl, *own_copy;
-
- memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
-
- new_argv[2] = target_path;
- new_argv[1] = "--";
-
- /* Now we need to actually find qemu for argv[0]. */
-
- tmp = getenv("AFL_PATH");
-
- if (tmp) {
-
- cp = alloc_printf("%s/afl-qemu-trace", tmp);
-
- if (access(cp, X_OK))
- FATAL("Unable to find '%s'", tmp);
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- own_copy = ck_strdup(own_loc);
- rsl = strrchr(own_copy, '/');
-
- if (rsl) {
-
- *rsl = 0;
-
- cp = alloc_printf("%s/afl-qemu-trace", own_copy);
- ck_free(own_copy);
-
- if (!access(cp, X_OK)) {
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- } else ck_free(own_copy);
-
- if (!access(BIN_PATH "/afl-qemu-trace", X_OK)) {
-
- target_path = new_argv[0] = BIN_PATH "/afl-qemu-trace";
- return new_argv;
-
- }
-
- FATAL("Unable to find 'afl-qemu-trace'.");
-
-}
-
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- s32 opt;
- u8 mem_limit_given = 0, timeout_given = 0, qemu_mode = 0;
- u32 tcnt;
- char** use_argv;
-
- doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
-
- while ((opt = getopt(argc,argv,"+o:m:t:A:eqZQb")) > 0)
-
- switch (opt) {
-
- case 'o':
-
- if (out_file) FATAL("Multiple -o options not supported");
- out_file = optarg;
- break;
-
- case 'm': {
-
- u8 suffix = 'M';
-
- if (mem_limit_given) FATAL("Multiple -m options not supported");
- mem_limit_given = 1;
-
- if (!strcmp(optarg, "none")) {
-
- mem_limit = 0;
- break;
-
- }
-
- if (sscanf(optarg, "%llu%c", &mem_limit, &suffix) < 1 ||
- optarg[0] == '-') FATAL("Bad syntax used for -m");
-
- switch (suffix) {
-
- case 'T': mem_limit *= 1024 * 1024; break;
- case 'G': mem_limit *= 1024; break;
- case 'k': mem_limit /= 1024; break;
- case 'M': break;
-
- default: FATAL("Unsupported suffix or bad syntax for -m");
-
- }
-
- if (mem_limit < 5) FATAL("Dangerously low value of -m");
-
- if (sizeof(rlim_t) == 4 && mem_limit > 2000)
- FATAL("Value of -m out of range on 32-bit systems");
-
- }
-
- break;
-
- case 't':
-
- if (timeout_given) FATAL("Multiple -t options not supported");
- timeout_given = 1;
-
- if (strcmp(optarg, "none")) {
- exec_tmout = atoi(optarg);
-
- if (exec_tmout < 20 || optarg[0] == '-')
- FATAL("Dangerously low value of -t");
-
- }
-
- break;
-
- case 'e':
-
- if (edges_only) FATAL("Multiple -e options not supported");
- edges_only = 1;
- break;
-
- case 'q':
-
- if (quiet_mode) FATAL("Multiple -q options not supported");
- quiet_mode = 1;
- break;
-
- case 'Z':
-
- /* This is an undocumented option to write data in the syntax expected
- by afl-cmin. Nobody else should have any use for this. */
-
- cmin_mode = 1;
- quiet_mode = 1;
- break;
-
- case 'A':
-
- /* Another afl-cmin specific feature. */
- at_file = optarg;
- break;
-
- case 'Q':
-
- if (qemu_mode) FATAL("Multiple -Q options not supported");
- if (!mem_limit_given) mem_limit = MEM_LIMIT_QEMU;
-
- qemu_mode = 1;
- break;
-
- case 'b':
-
- /* Secret undocumented mode. Writes output in raw binary format
- similar to that dumped by afl-fuzz in <out_dir/queue/fuzz_bitmap. */
-
- binary_mode = 1;
- break;
-
- default:
-
- usage(argv[0]);
-
- }
-
- if (optind == argc || !out_file) usage(argv[0]);
-
- setup_shm();
- setup_signal_handlers();
-
- set_up_environment();
-
- find_binary(argv[optind]);
-
- if (!quiet_mode) {
- show_banner();
- ACTF("Executing '%s'...\n", target_path);
- }
-
- detect_file_args(argv + optind);
-
- if (qemu_mode)
- use_argv = get_qemu_argv(argv[0], argv + optind, argc - optind);
- else
- use_argv = argv + optind;
-
- run_target(use_argv);
-
- tcnt = write_results();
-
- if (!quiet_mode) {
-
- if (!tcnt) FATAL("No instrumentation detected" cRST);
- OKF("Captured %u tuples in '%s'." cRST, tcnt, out_file);
-
- }
-
- exit(child_crashed * 2 + child_timed_out);
-
-}
-
diff --git a/chromium/third_party/afl/src/afl-tmin.c b/chromium/third_party/afl/src/afl-tmin.c
deleted file mode 100644
index c1abbe7c708..00000000000
--- a/chromium/third_party/afl/src/afl-tmin.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-/*
- american fuzzy lop - test case minimizer
- ----------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- A simple test case minimizer that takes an input file and tries to remove
- as much data as possible while keeping the binary in a crashing state
- *or* producing consistent instrumentation output (the mode is auto-selected
- based on the initially observed behavior).
-
- */
-
-#define AFL_MAIN
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-#include "alloc-inl.h"
-#include "hash.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-#include <dirent.h>
-#include <fcntl.h>
-
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-
-static s32 child_pid; /* PID of the tested program */
-
-static u8 *trace_bits, /* SHM with instrumentation bitmap */
- *mask_bitmap; /* Mask for trace bits (-B) */
-
-static u8 *in_file, /* Minimizer input test case */
- *out_file, /* Minimizer output file */
- *prog_in, /* Targeted program input file */
- *target_path, /* Path to target binary */
- *doc_path; /* Path to docs */
-
-static u8* in_data; /* Input data for trimming */
-
-static u32 in_len, /* Input data length */
- orig_cksum, /* Original checksum */
- total_execs, /* Total number of execs */
- missed_hangs, /* Misses due to hangs */
- missed_crashes, /* Misses due to crashes */
- missed_paths, /* Misses due to exec path diffs */
- exec_tmout = EXEC_TIMEOUT; /* Exec timeout (ms) */
-
-static u64 mem_limit = MEM_LIMIT; /* Memory limit (MB) */
-
-static s32 shm_id, /* ID of the SHM region */
- dev_null_fd = -1; /* FD to /dev/null */
-
-static u8 crash_mode, /* Crash-centric mode? */
- exit_crash, /* Treat non-zero exit as crash? */
- edges_only, /* Ignore hit counts? */
- use_stdin = 1; /* Use stdin for program input? */
-
-static volatile u8
- stop_soon, /* Ctrl-C pressed? */
- child_timed_out; /* Child timed out? */
-
-
-/* Classify tuple counts. This is a slow & naive version, but good enough here. */
-
-static const u8 count_class_lookup[256] = {
-
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 4,
- [4 ... 7] = 8,
- [8 ... 15] = 16,
- [16 ... 31] = 32,
- [32 ... 127] = 64,
- [128 ... 255] = 128
-
-};
-
-static void classify_counts(u8* mem) {
-
- u32 i = MAP_SIZE;
-
- if (edges_only) {
-
- while (i--) {
- if (*mem) *mem = 1;
- mem++;
- }
-
- } else {
-
- while (i--) {
- *mem = count_class_lookup[*mem];
- mem++;
- }
-
- }
-
-}
-
-
-/* Apply mask to classified bitmap (if set). */
-
-static void apply_mask(u32* mem, u32* mask) {
-
- u32 i = (MAP_SIZE >> 2);
-
- if (!mask) return;
-
- while (i--) {
-
- *mem &= ~*mask;
- mem++;
- mask++;
-
- }
-
-}
-
-
-/* See if any bytes are set in the bitmap. */
-
-static inline u8 anything_set(void) {
-
- u32* ptr = (u32*)trace_bits;
- u32 i = (MAP_SIZE >> 2);
-
- while (i--) if (*(ptr++)) return 1;
-
- return 0;
-
-}
-
-
-
-/* Get rid of shared memory and temp files (atexit handler). */
-
-static void remove_shm(void) {
-
- unlink(prog_in); /* Ignore errors */
- shmctl(shm_id, IPC_RMID, NULL);
-
-}
-
-
-/* Configure shared memory. */
-
-static void setup_shm(void) {
-
- u8* shm_str;
-
- shm_id = shmget(IPC_PRIVATE, MAP_SIZE, IPC_CREAT | IPC_EXCL | 0600);
-
- if (shm_id < 0) PFATAL("shmget() failed");
-
- atexit(remove_shm);
-
- shm_str = alloc_printf("%d", shm_id);
-
- setenv(SHM_ENV_VAR, shm_str, 1);
-
- ck_free(shm_str);
-
- trace_bits = shmat(shm_id, NULL, 0);
-
- if (!trace_bits) PFATAL("shmat() failed");
-
-}
-
-
-/* Read initial file. */
-
-static void read_initial_file(void) {
-
- struct stat st;
- s32 fd = open(in_file, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", in_file);
-
- if (fstat(fd, &st) || !st.st_size)
- FATAL("Zero-sized input file.");
-
- if (st.st_size >= TMIN_MAX_FILE)
- FATAL("Input file is too large (%u MB max)", TMIN_MAX_FILE / 1024 / 1024);
-
- in_len = st.st_size;
- in_data = ck_alloc_nozero(in_len);
-
- ck_read(fd, in_data, in_len, in_file);
-
- close(fd);
-
- OKF("Read %u byte%s from '%s'.", in_len, in_len == 1 ? "" : "s", in_file);
-
-}
-
-
-/* Write output file. */
-
-static s32 write_to_file(u8* path, u8* mem, u32 len) {
-
- s32 ret;
-
- unlink(path); /* Ignore errors */
-
- ret = open(path, O_RDWR | O_CREAT | O_EXCL, 0600);
-
- if (ret < 0) PFATAL("Unable to create '%s'", path);
-
- ck_write(ret, mem, len, path);
-
- lseek(ret, 0, SEEK_SET);
-
- return ret;
-
-}
-
-
-/* Handle timeout signal. */
-
-static void handle_timeout(int sig) {
-
- child_timed_out = 1;
- if (child_pid > 0) kill(child_pid, SIGKILL);
-
-}
-
-
-/* Execute target application. Returns 0 if the changes are a dud, or
- 1 if they should be kept. */
-
-static u8 run_target(char** argv, u8* mem, u32 len, u8 first_run) {
-
- static struct itimerval it;
- int status = 0;
-
- s32 prog_in_fd;
- u32 cksum;
-
- memset(trace_bits, 0, MAP_SIZE);
- MEM_BARRIER();
-
- prog_in_fd = write_to_file(prog_in, mem, len);
-
- child_pid = fork();
-
- if (child_pid < 0) PFATAL("fork() failed");
-
- if (!child_pid) {
-
- struct rlimit r;
-
- if (dup2(use_stdin ? prog_in_fd : dev_null_fd, 0) < 0 ||
- dup2(dev_null_fd, 1) < 0 ||
- dup2(dev_null_fd, 2) < 0) {
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- PFATAL("dup2() failed");
-
- }
-
- close(dev_null_fd);
- close(prog_in_fd);
-
- if (mem_limit) {
-
- r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;
-
-#ifdef RLIMIT_AS
-
- setrlimit(RLIMIT_AS, &r); /* Ignore errors */
-
-#else
-
- setrlimit(RLIMIT_DATA, &r); /* Ignore errors */
-
-#endif /* ^RLIMIT_AS */
-
- }
-
- r.rlim_max = r.rlim_cur = 0;
- setrlimit(RLIMIT_CORE, &r); /* Ignore errors */
-
- execv(target_path, argv);
-
- *(u32*)trace_bits = EXEC_FAIL_SIG;
- exit(0);
-
- }
-
- close(prog_in_fd);
-
- /* Configure timeout, wait for child, cancel timeout. */
-
- child_timed_out = 0;
- it.it_value.tv_sec = (exec_tmout / 1000);
- it.it_value.tv_usec = (exec_tmout % 1000) * 1000;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- if (waitpid(child_pid, &status, 0) <= 0) FATAL("waitpid() failed");
-
- child_pid = 0;
- it.it_value.tv_sec = 0;
- it.it_value.tv_usec = 0;
-
- setitimer(ITIMER_REAL, &it, NULL);
-
- MEM_BARRIER();
-
- /* Clean up bitmap, analyze exit condition, etc. */
-
- if (*(u32*)trace_bits == EXEC_FAIL_SIG)
- FATAL("Unable to execute '%s'", argv[0]);
-
- classify_counts(trace_bits);
- apply_mask((u32*)trace_bits, (u32*)mask_bitmap);
- total_execs++;
-
- if (stop_soon) {
- SAYF(cRST cLRD "\n+++ Minimization aborted by user +++\n" cRST);
- exit(1);
- }
-
- /* Always discard inputs that time out. */
-
- if (child_timed_out) {
-
- missed_hangs++;
- return 0;
-
- }
-
- /* Handle crashing inputs depending on current mode. */
-
- if (WIFSIGNALED(status) ||
- (WIFEXITED(status) && WEXITSTATUS(status) == MSAN_ERROR) ||
- (WIFEXITED(status) && WEXITSTATUS(status) && exit_crash)) {
-
- if (first_run) crash_mode = 1;
-
- if (crash_mode) {
-
- return 1;
-
- } else {
-
- missed_crashes++;
- return 0;
-
- }
-
- }
-
- /* Handle non-crashing inputs appropriately. */
-
- if (crash_mode) {
-
- missed_paths++;
- return 0;
-
- }
-
- cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
-
- if (first_run) orig_cksum = cksum;
-
- if (orig_cksum == cksum) return 1;
-
- missed_paths++;
- return 0;
-
-}
-
-
-/* Find first power of two greater or equal to val. */
-
-static u32 next_p2(u32 val) {
-
- u32 ret = 1;
- while (val > ret) ret <<= 1;
- return ret;
-
-}
-
-
-/* Actually minimize! */
-
-static void minimize(char** argv) {
-
- static u32 alpha_map[256];
-
- u8* tmp_buf = ck_alloc_nozero(in_len);
- u32 orig_len = in_len, stage_o_len;
-
- u32 del_len, set_len, del_pos, set_pos, i, alpha_size, cur_pass = 0;
- u32 syms_removed, alpha_del0 = 0, alpha_del1, alpha_del2, alpha_d_total = 0;
- u8 changed_any, prev_del;
-
- /***********************
- * BLOCK NORMALIZATION *
- ***********************/
-
- set_len = next_p2(in_len / TMIN_SET_STEPS);
- set_pos = 0;
-
- if (set_len < TMIN_SET_MIN_SIZE) set_len = TMIN_SET_MIN_SIZE;
-
- ACTF(cBRI "Stage #0: " cRST "One-time block normalization...");
-
- while (set_pos < in_len) {
-
- u8 res;
- u32 use_len = MIN(set_len, in_len - set_pos);
-
- for (i = 0; i < use_len; i++)
- if (in_data[set_pos + i] != '0') break;
-
- if (i != use_len) {
-
- memcpy(tmp_buf, in_data, in_len);
- memset(tmp_buf + set_pos, '0', use_len);
-
- res = run_target(argv, tmp_buf, in_len, 0);
-
- if (res) {
-
- memset(in_data + set_pos, '0', use_len);
- changed_any = 1;
- alpha_del0 += use_len;
-
- }
-
- }
-
- set_pos += set_len;
-
- }
-
- alpha_d_total += alpha_del0;
-
- OKF("Block normalization complete, %u byte%s replaced.", alpha_del0,
- alpha_del0 == 1 ? "" : "s");
-
-next_pass:
-
- ACTF(cYEL "--- " cBRI "Pass #%u " cYEL "---", ++cur_pass);
- changed_any = 0;
-
- /******************
- * BLOCK DELETION *
- ******************/
-
- del_len = next_p2(in_len / TRIM_START_STEPS);
- stage_o_len = in_len;
-
- ACTF(cBRI "Stage #1: " cRST "Removing blocks of data...");
-
-next_del_blksize:
-
- if (!del_len) del_len = 1;
- del_pos = 0;
- prev_del = 1;
-
- SAYF(cGRA " Block length = %u, remaining size = %u\n" cRST,
- del_len, in_len);
-
- while (del_pos < in_len) {
-
- u8 res;
- s32 tail_len;
-
- tail_len = in_len - del_pos - del_len;
- if (tail_len < 0) tail_len = 0;
-
- /* If we have processed at least one full block (initially, prev_del == 1),
- and we did so without deleting the previous one, and we aren't at the
- very end of the buffer (tail_len > 0), and the current block is the same
- as the previous one... skip this step as a no-op. */
-
- if (!prev_del && tail_len && !memcmp(in_data + del_pos - del_len,
- in_data + del_pos, del_len)) {
-
- del_pos += del_len;
- continue;
-
- }
-
- prev_del = 0;
-
- /* Head */
- memcpy(tmp_buf, in_data, del_pos);
-
- /* Tail */
- memcpy(tmp_buf + del_pos, in_data + del_pos + del_len, tail_len);
-
- res = run_target(argv, tmp_buf, del_pos + tail_len, 0);
-
- if (res) {
-
- memcpy(in_data, tmp_buf, del_pos + tail_len);
- prev_del = 1;
- in_len = del_pos + tail_len;
-
- changed_any = 1;
-
- } else del_pos += del_len;
-
- }
-
- if (del_len > 1 && in_len >= 1) {
-
- del_len /= 2;
- goto next_del_blksize;
-
- }
-
- OKF("Block removal complete, %u bytes deleted.", stage_o_len - in_len);
-
- if (!in_len && changed_any)
- WARNF(cLRD "Down to zero bytes - check the command line and mem limit!" cRST);
-
- if (cur_pass > 1 && !changed_any) goto finalize_all;
-
- /*************************
- * ALPHABET MINIMIZATION *
- *************************/
-
- alpha_size = 0;
- alpha_del1 = 0;
- syms_removed = 0;
-
- memset(alpha_map, 0, 256 * sizeof(u32));
-
- for (i = 0; i < in_len; i++) {
- if (!alpha_map[in_data[i]]) alpha_size++;
- alpha_map[in_data[i]]++;
- }
-
- ACTF(cBRI "Stage #2: " cRST "Minimizing symbols (%u code point%s)...",
- alpha_size, alpha_size == 1 ? "" : "s");
-
- for (i = 0; i < 256; i++) {
-
- u32 r;
- u8 res;
-
- if (i == '0' || !alpha_map[i]) continue;
-
- memcpy(tmp_buf, in_data, in_len);
-
- for (r = 0; r < in_len; r++)
- if (tmp_buf[r] == i) tmp_buf[r] = '0';
-
- res = run_target(argv, tmp_buf, in_len, 0);
-
- if (res) {
-
- memcpy(in_data, tmp_buf, in_len);
- syms_removed++;
- alpha_del1 += alpha_map[i];
- changed_any = 1;
-
- }
-
- }
-
- alpha_d_total += alpha_del1;
-
- OKF("Symbol minimization finished, %u symbol%s (%u byte%s) replaced.",
- syms_removed, syms_removed == 1 ? "" : "s",
- alpha_del1, alpha_del1 == 1 ? "" : "s");
-
- /**************************
- * CHARACTER MINIMIZATION *
- **************************/
-
- alpha_del2 = 0;
-
- ACTF(cBRI "Stage #3: " cRST "Character minimization...");
-
- memcpy(tmp_buf, in_data, in_len);
-
- for (i = 0; i < in_len; i++) {
-
- u8 res, orig = tmp_buf[i];
-
- if (orig == '0') continue;
- tmp_buf[i] = '0';
-
- res = run_target(argv, tmp_buf, in_len, 0);
-
- if (res) {
-
- in_data[i] = '0';
- alpha_del2++;
- changed_any = 1;
-
- } else tmp_buf[i] = orig;
-
- }
-
- alpha_d_total += alpha_del2;
-
- OKF("Character minimization done, %u byte%s replaced.",
- alpha_del2, alpha_del2 == 1 ? "" : "s");
-
- if (changed_any) goto next_pass;
-
-finalize_all:
-
- SAYF("\n"
- cGRA " File size reduced by : " cRST "%0.02f%% (to %u byte%s)\n"
- cGRA " Characters simplified : " cRST "%0.02f%%\n"
- cGRA " Number of execs done : " cRST "%u\n"
- cGRA " Fruitless execs : " cRST "path=%u crash=%u hang=%s%u\n\n",
- 100 - ((double)in_len) * 100 / orig_len, in_len, in_len == 1 ? "" : "s",
- ((double)(alpha_d_total)) * 100 / (in_len ? in_len : 1),
- total_execs, missed_paths, missed_crashes, missed_hangs ? cLRD : "",
- missed_hangs);
-
- if (total_execs > 50 && missed_hangs * 10 > total_execs)
- WARNF(cLRD "Frequent timeouts - results may be skewed." cRST);
-
-}
-
-
-
-/* Handle Ctrl-C and the like. */
-
-static void handle_stop_sig(int sig) {
-
- stop_soon = 1;
-
- if (child_pid > 0) kill(child_pid, SIGKILL);
-
-}
-
-
-/* Do basic preparations - persistent fds, filenames, etc. */
-
-static void set_up_environment(void) {
-
- u8* x;
-
- dev_null_fd = open("/dev/null", O_RDWR);
- if (dev_null_fd < 0) PFATAL("Unable to open /dev/null");
-
- if (!prog_in) {
-
- u8* use_dir = ".";
-
- if (!access(use_dir, R_OK | W_OK | X_OK)) {
-
- use_dir = getenv("TMPDIR");
- if (!use_dir) use_dir = "/tmp";
-
- prog_in = alloc_printf("%s/.afl-tmin-temp-%u", use_dir, getpid());
-
- }
-
- }
-
- /* Set sane defaults... */
-
- x = getenv("ASAN_OPTIONS");
-
- if (x) {
-
- if (!strstr(x, "abort_on_error=1"))
- FATAL("Custom ASAN_OPTIONS set without abort_on_error=1 - please fix!");
-
- if (!strstr(x, "symbolize=0"))
- FATAL("Custom ASAN_OPTIONS set without symbolize=0 - please fix!");
-
- }
-
- x = getenv("MSAN_OPTIONS");
-
- if (x) {
-
- if (!strstr(x, "exit_code=" STRINGIFY(MSAN_ERROR)))
- FATAL("Custom MSAN_OPTIONS set without exit_code="
- STRINGIFY(MSAN_ERROR) " - please fix!");
-
- if (!strstr(x, "symbolize=0"))
- FATAL("Custom MSAN_OPTIONS set without symbolize=0 - please fix!");
-
- }
-
- setenv("ASAN_OPTIONS", "abort_on_error=1:"
- "detect_leaks=0:"
- "symbolize=0:"
- "allocator_may_return_null=1", 0);
-
- setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":"
- "symbolize=0:"
- "abort_on_error=1:"
- "allocator_may_return_null=1:"
- "msan_track_origins=0", 0);
-
- if (getenv("AFL_PRELOAD")) {
- setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
- setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
- }
-
-}
-
-
-/* Setup signal handlers, duh. */
-
-static void setup_signal_handlers(void) {
-
- struct sigaction sa;
-
- sa.sa_handler = NULL;
- sa.sa_flags = SA_RESTART;
- sa.sa_sigaction = NULL;
-
- sigemptyset(&sa.sa_mask);
-
- /* Various ways of saying "stop". */
-
- sa.sa_handler = handle_stop_sig;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-
- /* Exec timeout notifications. */
-
- sa.sa_handler = handle_timeout;
- sigaction(SIGALRM, &sa, NULL);
-
-}
-
-
-/* Detect @@ in args. */
-
-static void detect_file_args(char** argv) {
-
- u32 i = 0;
- u8* cwd = getcwd(NULL, 0);
-
- if (!cwd) PFATAL("getcwd() failed");
-
- while (argv[i]) {
-
- u8* aa_loc = strstr(argv[i], "@@");
-
- if (aa_loc) {
-
- u8 *aa_subst, *n_arg;
-
- /* Be sure that we're always using fully-qualified paths. */
-
- if (prog_in[0] == '/') aa_subst = prog_in;
- else aa_subst = alloc_printf("%s/%s", cwd, prog_in);
-
- /* Construct a replacement argv value. */
-
- *aa_loc = 0;
- n_arg = alloc_printf("%s%s%s", argv[i], aa_subst, aa_loc + 2);
- argv[i] = n_arg;
- *aa_loc = '@';
-
- if (prog_in[0] != '/') ck_free(aa_subst);
-
- }
-
- i++;
-
- }
-
- free(cwd); /* not tracked */
-
-}
-
-
-/* Display usage hints. */
-
-static void usage(u8* argv0) {
-
- SAYF("\n%s [ options ] -- /path/to/target_app [ ... ]\n\n"
-
- "Required parameters:\n\n"
-
- " -i file - input test case to be shrunk by the tool\n"
- " -o file - final output location for the minimized data\n\n"
-
- "Execution control settings:\n\n"
-
- " -f file - input file read by the tested program (stdin)\n"
- " -t msec - timeout for each run (%u ms)\n"
- " -m megs - memory limit for child process (%u MB)\n"
- " -Q - use binary-only instrumentation (QEMU mode)\n\n"
-
- "Minimization settings:\n\n"
-
- " -e - solve for edge coverage only, ignore hit counts\n"
- " -x - treat non-zero exit codes as crashes\n\n"
-
- "For additional tips, please consult %s/README.\n\n",
-
- argv0, EXEC_TIMEOUT, MEM_LIMIT, doc_path);
-
- exit(1);
-
-}
-
-
-/* Find binary. */
-
-static void find_binary(u8* fname) {
-
- u8* env_path = 0;
- struct stat st;
-
- if (strchr(fname, '/') || !(env_path = getenv("PATH"))) {
-
- target_path = ck_strdup(fname);
-
- if (stat(target_path, &st) || !S_ISREG(st.st_mode) ||
- !(st.st_mode & 0111) || st.st_size < 4)
- FATAL("Program '%s' not found or not executable", fname);
-
- } else {
-
- while (env_path) {
-
- u8 *cur_elem, *delim = strchr(env_path, ':');
-
- if (delim) {
-
- cur_elem = ck_alloc(delim - env_path + 1);
- memcpy(cur_elem, env_path, delim - env_path);
- delim++;
-
- } else cur_elem = ck_strdup(env_path);
-
- env_path = delim;
-
- if (cur_elem[0])
- target_path = alloc_printf("%s/%s", cur_elem, fname);
- else
- target_path = ck_strdup(fname);
-
- ck_free(cur_elem);
-
- if (!stat(target_path, &st) && S_ISREG(st.st_mode) &&
- (st.st_mode & 0111) && st.st_size >= 4) break;
-
- ck_free(target_path);
- target_path = 0;
-
- }
-
- if (!target_path) FATAL("Program '%s' not found or not executable", fname);
-
- }
-
-}
-
-
-/* Fix up argv for QEMU. */
-
-static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
-
- char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
- u8 *tmp, *cp, *rsl, *own_copy;
-
- memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
-
- /* Now we need to actually find qemu for argv[0]. */
-
- new_argv[2] = target_path;
- new_argv[1] = "--";
-
- tmp = getenv("AFL_PATH");
-
- if (tmp) {
-
- cp = alloc_printf("%s/afl-qemu-trace", tmp);
-
- if (access(cp, X_OK))
- FATAL("Unable to find '%s'", tmp);
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- own_copy = ck_strdup(own_loc);
- rsl = strrchr(own_copy, '/');
-
- if (rsl) {
-
- *rsl = 0;
-
- cp = alloc_printf("%s/afl-qemu-trace", own_copy);
- ck_free(own_copy);
-
- if (!access(cp, X_OK)) {
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- } else ck_free(own_copy);
-
- if (!access(BIN_PATH "/afl-qemu-trace", X_OK)) {
-
- target_path = new_argv[0] = BIN_PATH "/afl-qemu-trace";
- return new_argv;
-
- }
-
- FATAL("Unable to find 'afl-qemu-trace'.");
-
-}
-
-
-/* Read mask bitmap from file. This is for the -B option. */
-
-static void read_bitmap(u8* fname) {
-
- s32 fd = open(fname, O_RDONLY);
-
- if (fd < 0) PFATAL("Unable to open '%s'", fname);
-
- ck_read(fd, mask_bitmap, MAP_SIZE, fname);
-
- close(fd);
-
-}
-
-
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- s32 opt;
- u8 mem_limit_given = 0, timeout_given = 0, qemu_mode = 0;
- char** use_argv;
-
- doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
-
- SAYF(cCYA "afl-tmin " cBRI VERSION cRST " by <lcamtuf@google.com>\n");
-
- while ((opt = getopt(argc,argv,"+i:o:f:m:t:B:xeQ")) > 0)
-
- switch (opt) {
-
- case 'i':
-
- if (in_file) FATAL("Multiple -i options not supported");
- in_file = optarg;
- break;
-
- case 'o':
-
- if (out_file) FATAL("Multiple -o options not supported");
- out_file = optarg;
- break;
-
- case 'f':
-
- if (prog_in) FATAL("Multiple -f options not supported");
- use_stdin = 0;
- prog_in = optarg;
- break;
-
- case 'e':
-
- if (edges_only) FATAL("Multiple -e options not supported");
- edges_only = 1;
- break;
-
- case 'x':
-
- if (exit_crash) FATAL("Multiple -x options not supported");
- exit_crash = 1;
- break;
-
- case 'm': {
-
- u8 suffix = 'M';
-
- if (mem_limit_given) FATAL("Multiple -m options not supported");
- mem_limit_given = 1;
-
- if (!strcmp(optarg, "none")) {
-
- mem_limit = 0;
- break;
-
- }
-
- if (sscanf(optarg, "%llu%c", &mem_limit, &suffix) < 1 ||
- optarg[0] == '-') FATAL("Bad syntax used for -m");
-
- switch (suffix) {
-
- case 'T': mem_limit *= 1024 * 1024; break;
- case 'G': mem_limit *= 1024; break;
- case 'k': mem_limit /= 1024; break;
- case 'M': break;
-
- default: FATAL("Unsupported suffix or bad syntax for -m");
-
- }
-
- if (mem_limit < 5) FATAL("Dangerously low value of -m");
-
- if (sizeof(rlim_t) == 4 && mem_limit > 2000)
- FATAL("Value of -m out of range on 32-bit systems");
-
- }
-
- break;
-
- case 't':
-
- if (timeout_given) FATAL("Multiple -t options not supported");
- timeout_given = 1;
-
- exec_tmout = atoi(optarg);
-
- if (exec_tmout < 10 || optarg[0] == '-')
- FATAL("Dangerously low value of -t");
-
- break;
-
- case 'Q':
-
- if (qemu_mode) FATAL("Multiple -Q options not supported");
- if (!mem_limit_given) mem_limit = MEM_LIMIT_QEMU;
-
- qemu_mode = 1;
- break;
-
- case 'B': /* load bitmap */
-
- /* This is a secret undocumented option! It is speculated to be useful
- if you have a baseline "boring" input file and another "interesting"
- file you want to minimize.
-
- You can dump a binary bitmap for the boring file using
- afl-showmap -b, and then load it into afl-tmin via -B. The minimizer
- will then minimize to preserve only the edges that are unique to
- the interesting input file, but ignoring everything from the
- original map.
-
- The option may be extended and made more official if it proves
- to be useful. */
-
- if (mask_bitmap) FATAL("Multiple -B options not supported");
- mask_bitmap = ck_alloc(MAP_SIZE);
- read_bitmap(optarg);
- break;
-
- default:
-
- usage(argv[0]);
-
- }
-
- if (optind == argc || !in_file || !out_file) usage(argv[0]);
-
- setup_shm();
- setup_signal_handlers();
-
- set_up_environment();
-
- find_binary(argv[optind]);
- detect_file_args(argv + optind);
-
- if (qemu_mode)
- use_argv = get_qemu_argv(argv[0], argv + optind, argc - optind);
- else
- use_argv = argv + optind;
-
- SAYF("\n");
-
- read_initial_file();
-
- ACTF("Performing dry run (mem limit = %llu MB, timeout = %u ms%s)...",
- mem_limit, exec_tmout, edges_only ? ", edges only" : "");
-
- run_target(use_argv, in_data, in_len, 1);
-
- if (child_timed_out)
- FATAL("Target binary times out (adjusting -t may help).");
-
- if (!crash_mode) {
-
- OKF("Program terminates normally, minimizing in "
- cCYA "instrumented" cRST " mode.");
-
- if (!anything_set()) FATAL("No instrumentation detected.");
-
- } else {
-
- OKF("Program exits with a signal, minimizing in " cMGN "crash" cRST
- " mode.");
-
- }
-
- minimize(use_argv);
-
- ACTF("Writing output to '%s'...", out_file);
-
- close(write_to_file(out_file, in_data, in_len));
-
- OKF("We're done here. Have a nice day!\n");
-
- exit(0);
-
-}
-
diff --git a/chromium/third_party/afl/src/afl-whatsup b/chromium/third_party/afl/src/afl-whatsup
deleted file mode 100755
index a4d30418792..00000000000
--- a/chromium/third_party/afl/src/afl-whatsup
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/bin/sh
-#
-# american fuzzy lop - status check tool
-# --------------------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2015 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# This tool summarizes the status of any locally-running synchronized
-# instances of afl-fuzz.
-#
-
-echo "status check tool for afl-fuzz by <lcamtuf@google.com>"
-echo
-
-if [ "$1" = "-s" ]; then
-
- SUMMARY_ONLY=1
- DIR="$2"
-
-else
-
- unset SUMMARY_ONLY
- DIR="$1"
-
-fi
-
-if [ "$DIR" = "" ]; then
-
- echo "Usage: $0 [ -s ] afl_sync_dir" 1>&2
- echo 1>&2
- echo "The -s option causes the tool to skip all the per-fuzzer trivia and show" 1>&2
- echo "just the summary results. See docs/parallel_fuzzing.txt for additional tips." 1>&2
- echo 1>&2
- exit 1
-
-fi
-
-cd "$DIR" || exit 1
-
-if [ -d queue ]; then
-
- echo "[-] Error: parameter is an individual output directory, not a sync dir." 1>&2
- exit 1
-
-fi
-
-CUR_TIME=`date +%s`
-
-TMP=`mktemp -t .afl-whatsup-XXXXXXXX` || exit 1
-
-ALIVE_CNT=0
-DEAD_CNT=0
-
-TOTAL_TIME=0
-TOTAL_EXECS=0
-TOTAL_EPS=0
-TOTAL_CRASHES=0
-TOTAL_PFAV=0
-TOTAL_PENDING=0
-
-if [ "$SUMMARY_ONLY" = "" ]; then
-
- echo "Individual fuzzers"
- echo "=================="
- echo
-
-fi
-
-for i in `find . -maxdepth 2 -iname fuzzer_stats | sort`; do
-
- sed 's/^command_line.*$/_skip:1/;s/[ ]*:[ ]*/="/;s/$/"/' "$i" >"$TMP"
- . "$TMP"
-
- RUN_UNIX=$((CUR_TIME - start_time))
- RUN_DAYS=$((RUN_UNIX / 60 / 60 / 24))
- RUN_HRS=$(((RUN_UNIX / 60 / 60) % 24))
-
- if [ "$SUMMARY_ONLY" = "" ]; then
-
- echo ">>> $afl_banner ($RUN_DAYS days, $RUN_HRS hrs) <<<"
- echo
-
- fi
-
- if ! kill -0 "$fuzzer_pid" 2>/dev/null; then
-
- if [ "$SUMMARY_ONLY" = "" ]; then
-
- echo " Instance is dead or running remotely, skipping."
- echo
-
- fi
-
- DEAD_CNT=$((DEAD_CNT + 1))
- continue
-
- fi
-
- ALIVE_CNT=$((ALIVE_CNT + 1))
-
- EXEC_SEC=$((execs_done / RUN_UNIX))
- PATH_PERC=$((cur_path * 100 / paths_total))
-
- TOTAL_TIME=$((TOTAL_TIME + RUN_UNIX))
- TOTAL_EPS=$((TOTAL_EPS + EXEC_SEC))
- TOTAL_EXECS=$((TOTAL_EXECS + execs_done))
- TOTAL_CRASHES=$((TOTAL_CRASHES + unique_crashes))
- TOTAL_PENDING=$((TOTAL_PENDING + pending_total))
- TOTAL_PFAV=$((TOTAL_PFAV + pending_favs))
-
- if [ "$SUMMARY_ONLY" = "" ]; then
-
- echo " cycle $((cycles_done + 1)), lifetime speed $EXEC_SEC execs/sec, path $cur_path/$paths_total (${PATH_PERC}%)"
-
- if [ "$unique_crashes" = "0" ]; then
- echo " pending $pending_favs/$pending_total, coverage $bitmap_cvg, no crashes yet"
- else
- echo " pending $pending_favs/$pending_total, coverage $bitmap_cvg, crash count $unique_crashes (!)"
- fi
-
- echo
-
- fi
-
-done
-
-rm -f "$TMP"
-
-TOTAL_DAYS=$((TOTAL_TIME / 60 / 60 / 24))
-TOTAL_HRS=$(((TOTAL_TIME / 60 / 60) % 24))
-
-test "$TOTAL_TIME" = "0" && TOTAL_TIME=1
-
-echo "Summary stats"
-echo "============="
-echo
-echo " Fuzzers alive : $ALIVE_CNT"
-
-if [ ! "$DEAD_CNT" = "0" ]; then
- echo " Dead or remote : $DEAD_CNT (excluded from stats)"
-fi
-
-echo " Total run time : $TOTAL_DAYS days, $TOTAL_HRS hours"
-echo " Total execs : $((TOTAL_EXECS / 1000 / 1000)) million"
-echo " Cumulative speed : $TOTAL_EPS execs/sec"
-echo " Pending paths : $TOTAL_PFAV faves, $TOTAL_PENDING total"
-
-if [ "$ALIVE_CNT" -gt "1" ]; then
- echo " Pending per fuzzer : $((TOTAL_PFAV/ALIVE_CNT)) faves, $((TOTAL_PENDING/ALIVE_CNT)) total (on average)"
-fi
-
-echo " Crashes found : $TOTAL_CRASHES locally unique"
-echo
-
-exit 0
diff --git a/chromium/third_party/afl/src/alloc-inl.h b/chromium/third_party/afl/src/alloc-inl.h
deleted file mode 100644
index d3c125fbb4c..00000000000
--- a/chromium/third_party/afl/src/alloc-inl.h
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- american fuzzy lop - error-checking, memory-zeroing alloc routines
- ------------------------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This allocator is not designed to resist malicious attackers (the canaries
- are small and predictable), but provides a robust and portable way to detect
- use-after-free, off-by-one writes, stale pointers, and so on.
-
- */
-
-#ifndef _HAVE_ALLOC_INL_H
-#define _HAVE_ALLOC_INL_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-#include "types.h"
-#include "debug.h"
-
-/* User-facing macro to sprintf() to a dynamically allocated buffer. */
-
-#define alloc_printf(_str...) ({ \
- u8* _tmp; \
- s32 _len = snprintf(NULL, 0, _str); \
- if (_len < 0) FATAL("Whoa, snprintf() fails?!"); \
- _tmp = ck_alloc(_len + 1); \
- snprintf((char*)_tmp, _len + 1, _str); \
- _tmp; \
- })
-
-/* Macro to enforce allocation limits as a last-resort defense against
- integer overflows. */
-
-#define ALLOC_CHECK_SIZE(_s) do { \
- if ((_s) > MAX_ALLOC) \
- ABORT("Bad alloc request: %u bytes", (_s)); \
- } while (0)
-
-/* Macro to check malloc() failures and the like. */
-
-#define ALLOC_CHECK_RESULT(_r, _s) do { \
- if (!(_r)) \
- ABORT("Out of memory: can't allocate %u bytes", (_s)); \
- } while (0)
-
-/* Magic tokens used to mark used / freed chunks. */
-
-#define ALLOC_MAGIC_C1 0xFF00FF00 /* Used head (dword) */
-#define ALLOC_MAGIC_F 0xFE00FE00 /* Freed head (dword) */
-#define ALLOC_MAGIC_C2 0xF0 /* Used tail (byte) */
-
-/* Positions of guard tokens in relation to the user-visible pointer. */
-
-#define ALLOC_C1(_ptr) (((u32*)(_ptr))[-2])
-#define ALLOC_S(_ptr) (((u32*)(_ptr))[-1])
-#define ALLOC_C2(_ptr) (((u8*)(_ptr))[ALLOC_S(_ptr)])
-
-#define ALLOC_OFF_HEAD 8
-#define ALLOC_OFF_TOTAL (ALLOC_OFF_HEAD + 1)
-
-/* Allocator increments for ck_realloc_block(). */
-
-#define ALLOC_BLK_INC 256
-
-/* Sanity-checking macros for pointers. */
-
-#define CHECK_PTR(_p) do { \
- if (_p) { \
- if (ALLOC_C1(_p) ^ ALLOC_MAGIC_C1) {\
- if (ALLOC_C1(_p) == ALLOC_MAGIC_F) \
- ABORT("Use after free."); \
- else ABORT("Corrupted head alloc canary."); \
- } \
- if (ALLOC_C2(_p) ^ ALLOC_MAGIC_C2) \
- ABORT("Corrupted tail alloc canary."); \
- } \
- } while (0)
-
-#define CHECK_PTR_EXPR(_p) ({ \
- typeof (_p) _tmp = (_p); \
- CHECK_PTR(_tmp); \
- _tmp; \
- })
-
-
-/* Allocate a buffer, explicitly not zeroing it. Returns NULL for zero-sized
- requests. */
-
-static inline void* DFL_ck_alloc_nozero(u32 size) {
-
- void* ret;
-
- if (!size) return NULL;
-
- ALLOC_CHECK_SIZE(size);
- ret = malloc(size + ALLOC_OFF_TOTAL);
- ALLOC_CHECK_RESULT(ret, size);
-
- ret += ALLOC_OFF_HEAD;
-
- ALLOC_C1(ret) = ALLOC_MAGIC_C1;
- ALLOC_S(ret) = size;
- ALLOC_C2(ret) = ALLOC_MAGIC_C2;
-
- return ret;
-
-}
-
-
-/* Allocate a buffer, returning zeroed memory. */
-
-static inline void* DFL_ck_alloc(u32 size) {
-
- void* mem;
-
- if (!size) return NULL;
- mem = DFL_ck_alloc_nozero(size);
-
- return memset(mem, 0, size);
-
-}
-
-
-/* Free memory, checking for double free and corrupted heap. When DEBUG_BUILD
- is set, the old memory will be also clobbered with 0xFF. */
-
-static inline void DFL_ck_free(void* mem) {
-
- if (!mem) return;
-
- CHECK_PTR(mem);
-
-#ifdef DEBUG_BUILD
-
- /* Catch pointer issues sooner. */
- memset(mem, 0xFF, ALLOC_S(mem));
-
-#endif /* DEBUG_BUILD */
-
- ALLOC_C1(mem) = ALLOC_MAGIC_F;
-
- free(mem - ALLOC_OFF_HEAD);
-
-}
-
-
-/* Re-allocate a buffer, checking for issues and zeroing any newly-added tail.
- With DEBUG_BUILD, the buffer is always reallocated to a new addresses and the
- old memory is clobbered with 0xFF. */
-
-static inline void* DFL_ck_realloc(void* orig, u32 size) {
-
- void* ret;
- u32 old_size = 0;
-
- if (!size) {
-
- DFL_ck_free(orig);
- return NULL;
-
- }
-
- if (orig) {
-
- CHECK_PTR(orig);
-
-#ifndef DEBUG_BUILD
- ALLOC_C1(orig) = ALLOC_MAGIC_F;
-#endif /* !DEBUG_BUILD */
-
- old_size = ALLOC_S(orig);
- orig -= ALLOC_OFF_HEAD;
-
- ALLOC_CHECK_SIZE(old_size);
-
- }
-
- ALLOC_CHECK_SIZE(size);
-
-#ifndef DEBUG_BUILD
-
- ret = realloc(orig, size + ALLOC_OFF_TOTAL);
- ALLOC_CHECK_RESULT(ret, size);
-
-#else
-
- /* Catch pointer issues sooner: force relocation and make sure that the
- original buffer is wiped. */
-
- ret = malloc(size + ALLOC_OFF_TOTAL);
- ALLOC_CHECK_RESULT(ret, size);
-
- if (orig) {
-
- memcpy(ret + ALLOC_OFF_HEAD, orig + ALLOC_OFF_HEAD, MIN(size, old_size));
- memset(orig + ALLOC_OFF_HEAD, 0xFF, old_size);
-
- ALLOC_C1(orig + ALLOC_OFF_HEAD) = ALLOC_MAGIC_F;
-
- free(orig);
-
- }
-
-#endif /* ^!DEBUG_BUILD */
-
- ret += ALLOC_OFF_HEAD;
-
- ALLOC_C1(ret) = ALLOC_MAGIC_C1;
- ALLOC_S(ret) = size;
- ALLOC_C2(ret) = ALLOC_MAGIC_C2;
-
- if (size > old_size)
- memset(ret + old_size, 0, size - old_size);
-
- return ret;
-
-}
-
-
-/* Re-allocate a buffer with ALLOC_BLK_INC increments (used to speed up
- repeated small reallocs without complicating the user code). */
-
-static inline void* DFL_ck_realloc_block(void* orig, u32 size) {
-
-#ifndef DEBUG_BUILD
-
- if (orig) {
-
- CHECK_PTR(orig);
-
- if (ALLOC_S(orig) >= size) return orig;
-
- size += ALLOC_BLK_INC;
-
- }
-
-#endif /* !DEBUG_BUILD */
-
- return DFL_ck_realloc(orig, size);
-
-}
-
-
-/* Create a buffer with a copy of a string. Returns NULL for NULL inputs. */
-
-static inline u8* DFL_ck_strdup(u8* str) {
-
- void* ret;
- u32 size;
-
- if (!str) return NULL;
-
- size = strlen((char*)str) + 1;
-
- ALLOC_CHECK_SIZE(size);
- ret = malloc(size + ALLOC_OFF_TOTAL);
- ALLOC_CHECK_RESULT(ret, size);
-
- ret += ALLOC_OFF_HEAD;
-
- ALLOC_C1(ret) = ALLOC_MAGIC_C1;
- ALLOC_S(ret) = size;
- ALLOC_C2(ret) = ALLOC_MAGIC_C2;
-
- return memcpy(ret, str, size);
-
-}
-
-
-/* Create a buffer with a copy of a memory block. Returns NULL for zero-sized
- or NULL inputs. */
-
-static inline void* DFL_ck_memdup(void* mem, u32 size) {
-
- void* ret;
-
- if (!mem || !size) return NULL;
-
- ALLOC_CHECK_SIZE(size);
- ret = malloc(size + ALLOC_OFF_TOTAL);
- ALLOC_CHECK_RESULT(ret, size);
-
- ret += ALLOC_OFF_HEAD;
-
- ALLOC_C1(ret) = ALLOC_MAGIC_C1;
- ALLOC_S(ret) = size;
- ALLOC_C2(ret) = ALLOC_MAGIC_C2;
-
- return memcpy(ret, mem, size);
-
-}
-
-
-/* Create a buffer with a block of text, appending a NUL terminator at the end.
- Returns NULL for zero-sized or NULL inputs. */
-
-static inline u8* DFL_ck_memdup_str(u8* mem, u32 size) {
-
- u8* ret;
-
- if (!mem || !size) return NULL;
-
- ALLOC_CHECK_SIZE(size);
- ret = malloc(size + ALLOC_OFF_TOTAL + 1);
- ALLOC_CHECK_RESULT(ret, size);
-
- ret += ALLOC_OFF_HEAD;
-
- ALLOC_C1(ret) = ALLOC_MAGIC_C1;
- ALLOC_S(ret) = size;
- ALLOC_C2(ret) = ALLOC_MAGIC_C2;
-
- memcpy(ret, mem, size);
- ret[size] = 0;
-
- return ret;
-
-}
-
-
-#ifndef DEBUG_BUILD
-
-/* In non-debug mode, we just do straightforward aliasing of the above functions
- to user-visible names such as ck_alloc(). */
-
-#define ck_alloc DFL_ck_alloc
-#define ck_alloc_nozero DFL_ck_alloc_nozero
-#define ck_realloc DFL_ck_realloc
-#define ck_realloc_block DFL_ck_realloc_block
-#define ck_strdup DFL_ck_strdup
-#define ck_memdup DFL_ck_memdup
-#define ck_memdup_str DFL_ck_memdup_str
-#define ck_free DFL_ck_free
-
-#define alloc_report()
-
-#else
-
-/* In debugging mode, we also track allocations to detect memory leaks, and the
- flow goes through one more layer of indirection. */
-
-/* Alloc tracking data structures: */
-
-#define ALLOC_BUCKETS 4096
-
-struct TRK_obj {
- void *ptr;
- char *file, *func;
- u32 line;
-};
-
-#ifdef AFL_MAIN
-
-struct TRK_obj* TRK[ALLOC_BUCKETS];
-u32 TRK_cnt[ALLOC_BUCKETS];
-
-# define alloc_report() TRK_report()
-
-#else
-
-extern struct TRK_obj* TRK[ALLOC_BUCKETS];
-extern u32 TRK_cnt[ALLOC_BUCKETS];
-
-# define alloc_report()
-
-#endif /* ^AFL_MAIN */
-
-/* Bucket-assigning function for a given pointer: */
-
-#define TRKH(_ptr) (((((u32)(_ptr)) >> 16) ^ ((u32)(_ptr))) % ALLOC_BUCKETS)
-
-
-/* Add a new entry to the list of allocated objects. */
-
-static inline void TRK_alloc_buf(void* ptr, const char* file, const char* func,
- u32 line) {
-
- u32 i, bucket;
-
- if (!ptr) return;
-
- bucket = TRKH(ptr);
-
- /* Find a free slot in the list of entries for that bucket. */
-
- for (i = 0; i < TRK_cnt[bucket]; i++)
-
- if (!TRK[bucket][i].ptr) {
-
- TRK[bucket][i].ptr = ptr;
- TRK[bucket][i].file = (char*)file;
- TRK[bucket][i].func = (char*)func;
- TRK[bucket][i].line = line;
- return;
-
- }
-
- /* No space available - allocate more. */
-
- TRK[bucket] = DFL_ck_realloc_block(TRK[bucket],
- (TRK_cnt[bucket] + 1) * sizeof(struct TRK_obj));
-
- TRK[bucket][i].ptr = ptr;
- TRK[bucket][i].file = (char*)file;
- TRK[bucket][i].func = (char*)func;
- TRK[bucket][i].line = line;
-
- TRK_cnt[bucket]++;
-
-}
-
-
-/* Remove entry from the list of allocated objects. */
-
-static inline void TRK_free_buf(void* ptr, const char* file, const char* func,
- u32 line) {
-
- u32 i, bucket;
-
- if (!ptr) return;
-
- bucket = TRKH(ptr);
-
- /* Find the element on the list... */
-
- for (i = 0; i < TRK_cnt[bucket]; i++)
-
- if (TRK[bucket][i].ptr == ptr) {
-
- TRK[bucket][i].ptr = 0;
- return;
-
- }
-
- WARNF("ALLOC: Attempt to free non-allocated memory in %s (%s:%u)",
- func, file, line);
-
-}
-
-
-/* Do a final report on all non-deallocated objects. */
-
-static inline void TRK_report(void) {
-
- u32 i, bucket;
-
- fflush(0);
-
- for (bucket = 0; bucket < ALLOC_BUCKETS; bucket++)
- for (i = 0; i < TRK_cnt[bucket]; i++)
- if (TRK[bucket][i].ptr)
- WARNF("ALLOC: Memory never freed, created in %s (%s:%u)",
- TRK[bucket][i].func, TRK[bucket][i].file, TRK[bucket][i].line);
-
-}
-
-
-/* Simple wrappers for non-debugging functions: */
-
-static inline void* TRK_ck_alloc(u32 size, const char* file, const char* func,
- u32 line) {
-
- void* ret = DFL_ck_alloc(size);
- TRK_alloc_buf(ret, file, func, line);
- return ret;
-
-}
-
-
-static inline void* TRK_ck_realloc(void* orig, u32 size, const char* file,
- const char* func, u32 line) {
-
- void* ret = DFL_ck_realloc(orig, size);
- TRK_free_buf(orig, file, func, line);
- TRK_alloc_buf(ret, file, func, line);
- return ret;
-
-}
-
-
-static inline void* TRK_ck_realloc_block(void* orig, u32 size, const char* file,
- const char* func, u32 line) {
-
- void* ret = DFL_ck_realloc_block(orig, size);
- TRK_free_buf(orig, file, func, line);
- TRK_alloc_buf(ret, file, func, line);
- return ret;
-
-}
-
-
-static inline void* TRK_ck_strdup(u8* str, const char* file, const char* func,
- u32 line) {
-
- void* ret = DFL_ck_strdup(str);
- TRK_alloc_buf(ret, file, func, line);
- return ret;
-
-}
-
-
-static inline void* TRK_ck_memdup(void* mem, u32 size, const char* file,
- const char* func, u32 line) {
-
- void* ret = DFL_ck_memdup(mem, size);
- TRK_alloc_buf(ret, file, func, line);
- return ret;
-
-}
-
-
-static inline void* TRK_ck_memdup_str(void* mem, u32 size, const char* file,
- const char* func, u32 line) {
-
- void* ret = DFL_ck_memdup_str(mem, size);
- TRK_alloc_buf(ret, file, func, line);
- return ret;
-
-}
-
-
-static inline void TRK_ck_free(void* ptr, const char* file,
- const char* func, u32 line) {
-
- TRK_free_buf(ptr, file, func, line);
- DFL_ck_free(ptr);
-
-}
-
-/* Aliasing user-facing names to tracking functions: */
-
-#define ck_alloc(_p1) \
- TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_alloc_nozero(_p1) \
- TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_realloc(_p1, _p2) \
- TRK_ck_realloc(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_realloc_block(_p1, _p2) \
- TRK_ck_realloc_block(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_strdup(_p1) \
- TRK_ck_strdup(_p1, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_memdup(_p1, _p2) \
- TRK_ck_memdup(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_memdup_str(_p1, _p2) \
- TRK_ck_memdup_str(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
-
-#define ck_free(_p1) \
- TRK_ck_free(_p1, __FILE__, __FUNCTION__, __LINE__)
-
-#endif /* ^!DEBUG_BUILD */
-
-#endif /* ! _HAVE_ALLOC_INL_H */
diff --git a/chromium/third_party/afl/src/config.h b/chromium/third_party/afl/src/config.h
deleted file mode 100644
index 2fdef50020c..00000000000
--- a/chromium/third_party/afl/src/config.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- american fuzzy lop - vaguely configurable bits
- ----------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- */
-
-#ifndef _HAVE_CONFIG_H
-#define _HAVE_CONFIG_H
-
-#include "types.h"
-
-/* Version string: */
-
-#define VERSION "2.38b"
-
-/******************************************************
- * *
- * Settings that may be of interest to power users: *
- * *
- ******************************************************/
-
-/* Comment out to disable terminal colors (note that this makes afl-analyze
- a lot less nice): */
-
-#define USE_COLOR
-
-/* Comment out to disable fancy ANSI boxes and use poor man's 7-bit UI: */
-
-#define FANCY_BOXES
-
-/* Default timeout for fuzzed code (milliseconds): */
-
-#define EXEC_TIMEOUT 1000
-
-/* Timeout rounding factor when auto-scaling (milliseconds): */
-
-#define EXEC_TM_ROUND 20
-
-/* Default memory limit for child process (MB): */
-
-#ifndef __x86_64__
-# define MEM_LIMIT 25
-#else
-# define MEM_LIMIT 50
-#endif /* ^!__x86_64__ */
-
-/* Default memory limit when running in QEMU mode (MB): */
-
-#define MEM_LIMIT_QEMU 200
-
-/* Number of calibration cycles per every new test case (and for test
- cases that show variable behavior): */
-
-#define CAL_CYCLES 8
-#define CAL_CYCLES_LONG 40
-
-/* Number of subsequent hangs before abandoning an input file: */
-
-#define HANG_LIMIT 250
-
-/* Maximum number of unique hangs or crashes to record: */
-
-#define KEEP_UNIQUE_HANG 500
-#define KEEP_UNIQUE_CRASH 5000
-
-/* Baseline number of random tweaks during a single 'havoc' stage: */
-
-#define HAVOC_CYCLES 256
-#define HAVOC_CYCLES_INIT 1024
-
-/* Maximum multiplier for the above (should be a power of two, beware
- of 32-bit int overflows): */
-
-#define HAVOC_MAX_MULT 16
-
-/* Absolute minimum number of havoc cycles (after all adjustments): */
-
-#define HAVOC_MIN 16
-
-/* Maximum stacking for havoc-stage tweaks. The actual value is calculated
- like this:
-
- n = random between 1 and HAVOC_STACK_POW2
- stacking = 2^n
-
- In other words, the default (n = 7) produces 2, 4, 8, 16, 32, 64, or
- 128 stacked tweaks: */
-
-#define HAVOC_STACK_POW2 7
-
-/* Caps on block sizes for cloning and deletion operations. Each of these
- ranges has a 33% probability of getting picked, except for the first
- two cycles where smaller blocks are favored: */
-
-#define HAVOC_BLK_SMALL 32
-#define HAVOC_BLK_MEDIUM 128
-#define HAVOC_BLK_LARGE 1500
-
-/* Probabilities of skipping non-favored entries in the queue, expressed as
- percentages: */
-
-#define SKIP_TO_NEW_PROB 99 /* ...when there are new, pending favorites */
-#define SKIP_NFAV_OLD_PROB 95 /* ...no new favs, cur entry already fuzzed */
-#define SKIP_NFAV_NEW_PROB 75 /* ...no new favs, cur entry not fuzzed yet */
-
-/* Splicing cycle count: */
-
-#define SPLICE_CYCLES 15
-
-/* Nominal per-splice havoc cycle length: */
-
-#define SPLICE_HAVOC 32
-
-/* Maximum offset for integer addition / subtraction stages: */
-
-#define ARITH_MAX 35
-
-/* Limits for the test case trimmer. The absolute minimum chunk size; and
- the starting and ending divisors for chopping up the input file: */
-
-#define TRIM_MIN_BYTES 4
-#define TRIM_START_STEPS 16
-#define TRIM_END_STEPS 1024
-
-/* Maximum size of input file, in bytes (keep under 100MB): */
-
-#define MAX_FILE (1 * 1024 * 1024)
-
-/* The same, for the test case minimizer: */
-
-#define TMIN_MAX_FILE (10 * 1024 * 1024)
-
-/* Block normalization steps for afl-tmin: */
-
-#define TMIN_SET_MIN_SIZE 4
-#define TMIN_SET_STEPS 128
-
-/* Maximum dictionary token size (-x), in bytes: */
-
-#define MAX_DICT_FILE 128
-
-/* Length limits for auto-detected dictionary tokens: */
-
-#define MIN_AUTO_EXTRA 3
-#define MAX_AUTO_EXTRA 32
-
-/* Maximum number of user-specified dictionary tokens to use in deterministic
- steps; past this point, the "extras/user" step will be still carried out,
- but with proportionally lower odds: */
-
-#define MAX_DET_EXTRAS 200
-
-/* Maximum number of auto-extracted dictionary tokens to actually use in fuzzing
- (first value), and to keep in memory as candidates. The latter should be much
- higher than the former. */
-
-#define USE_AUTO_EXTRAS 50
-#define MAX_AUTO_EXTRAS (USE_AUTO_EXTRAS * 10)
-
-/* Scaling factor for the effector map used to skip some of the more
- expensive deterministic steps. The actual divisor is set to
- 2^EFF_MAP_SCALE2 bytes: */
-
-#define EFF_MAP_SCALE2 3
-
-/* Minimum input file length at which the effector logic kicks in: */
-
-#define EFF_MIN_LEN 128
-
-/* Maximum effector density past which everything is just fuzzed
- unconditionally (%): */
-
-#define EFF_MAX_PERC 90
-
-/* UI refresh frequency (Hz): */
-
-#define UI_TARGET_HZ 5
-
-/* Fuzzer stats file and plot update intervals (sec): */
-
-#define STATS_UPDATE_SEC 60
-#define PLOT_UPDATE_SEC 5
-
-/* Smoothing divisor for CPU load and exec speed stats (1 - no smoothing). */
-
-#define AVG_SMOOTHING 16
-
-/* Sync interval (every n havoc cycles): */
-
-#define SYNC_INTERVAL 5
-
-/* Output directory reuse grace period (minutes): */
-
-#define OUTPUT_GRACE 25
-
-/* Uncomment to use simple file names (id_NNNNNN): */
-
-// #define SIMPLE_FILES
-
-/* List of interesting values to use in fuzzing. */
-
-#define INTERESTING_8 \
- -128, /* Overflow signed 8-bit when decremented */ \
- -1, /* */ \
- 0, /* */ \
- 1, /* */ \
- 16, /* One-off with common buffer size */ \
- 32, /* One-off with common buffer size */ \
- 64, /* One-off with common buffer size */ \
- 100, /* One-off with common buffer size */ \
- 127 /* Overflow signed 8-bit when incremented */
-
-#define INTERESTING_16 \
- -32768, /* Overflow signed 16-bit when decremented */ \
- -129, /* Overflow signed 8-bit */ \
- 128, /* Overflow signed 8-bit */ \
- 255, /* Overflow unsig 8-bit when incremented */ \
- 256, /* Overflow unsig 8-bit */ \
- 512, /* One-off with common buffer size */ \
- 1000, /* One-off with common buffer size */ \
- 1024, /* One-off with common buffer size */ \
- 4096, /* One-off with common buffer size */ \
- 32767 /* Overflow signed 16-bit when incremented */
-
-#define INTERESTING_32 \
- -2147483648LL, /* Overflow signed 32-bit when decremented */ \
- -100663046, /* Large negative number (endian-agnostic) */ \
- -32769, /* Overflow signed 16-bit */ \
- 32768, /* Overflow signed 16-bit */ \
- 65535, /* Overflow unsig 16-bit when incremented */ \
- 65536, /* Overflow unsig 16 bit */ \
- 100663045, /* Large positive number (endian-agnostic) */ \
- 2147483647 /* Overflow signed 32-bit when incremented */
-
-/***********************************************************
- * *
- * Really exotic stuff you probably don't want to touch: *
- * *
- ***********************************************************/
-
-/* Call count interval between reseeding the libc PRNG from /dev/urandom: */
-
-#define RESEED_RNG 10000
-
-/* Maximum line length passed from GCC to 'as' and used for parsing
- configuration files: */
-
-#define MAX_LINE 8192
-
-/* Environment variable used to pass SHM ID to the called program. */
-
-#define SHM_ENV_VAR "__AFL_SHM_ID"
-
-/* Other less interesting, internal-only variables. */
-
-#define CLANG_ENV_VAR "__AFL_CLANG_MODE"
-#define AS_LOOP_ENV_VAR "__AFL_AS_LOOPCHECK"
-#define PERSIST_ENV_VAR "__AFL_PERSISTENT"
-#define DEFER_ENV_VAR "__AFL_DEFER_FORKSRV"
-
-/* In-code signatures for deferred and persistent mode. */
-
-#define PERSIST_SIG "##SIG_AFL_PERSISTENT##"
-#define DEFER_SIG "##SIG_AFL_DEFER_FORKSRV##"
-
-/* Distinctive bitmap signature used to indicate failed execution: */
-
-#define EXEC_FAIL_SIG 0xfee1dead
-
-/* Distinctive exit code used to indicate MSAN trip condition: */
-
-#define MSAN_ERROR 86
-
-/* Designated file descriptors for forkserver commands (the application will
- use FORKSRV_FD and FORKSRV_FD + 1): */
-
-#define FORKSRV_FD 198
-
-/* Fork server init timeout multiplier: we'll wait the user-selected
- timeout plus this much for the fork server to spin up. */
-
-#define FORK_WAIT_MULT 10
-
-/* Calibration timeout adjustments, to be a bit more generous when resuming
- fuzzing sessions or trying to calibrate already-added internal finds.
- The first value is a percentage, the other is in milliseconds: */
-
-#define CAL_TMOUT_PERC 125
-#define CAL_TMOUT_ADD 50
-
-/* Number of chances to calibrate a case before giving up: */
-
-#define CAL_CHANCES 3
-
-/* Map size for the traced binary (2^MAP_SIZE_POW2). Must be greater than
- 2; you probably want to keep it under 18 or so for performance reasons
- (adjusting AFL_INST_RATIO when compiling is probably a better way to solve
- problems with complex programs). You need to recompile the target binary
- after changing this - otherwise, SEGVs may ensue. */
-
-#define MAP_SIZE_POW2 16
-#define MAP_SIZE (1 << MAP_SIZE_POW2)
-
-/* Maximum allocator request size (keep well under INT_MAX): */
-
-#define MAX_ALLOC 0x40000000
-
-/* A made-up hashing seed: */
-
-#define HASH_CONST 0xa5b35705
-
-/* Constants for afl-gotcpu to control busy loop timing: */
-
-#define CTEST_TARGET_MS 5000
-#define CTEST_CORE_TRG_MS 1000
-#define CTEST_BUSY_CYCLES (10 * 1000 * 1000)
-
-/* Uncomment this to use inferior block-coverage-based instrumentation. Note
- that you need to recompile the target binary for this to have any effect: */
-
-// #define COVERAGE_ONLY
-
-/* Uncomment this to ignore hit counts and output just one bit per tuple.
- As with the previous setting, you will need to recompile the target
- binary: */
-
-// #define SKIP_COUNTS
-
-/* Uncomment this to use instrumentation data to record newly discovered paths,
- but do not use them as seeds for fuzzing. This is useful for conveniently
- measuring coverage that could be attained by a "dumb" fuzzing algorithm: */
-
-// #define IGNORE_FINDS
-
-#endif /* ! _HAVE_CONFIG_H */
diff --git a/chromium/third_party/afl/src/debug.h b/chromium/third_party/afl/src/debug.h
deleted file mode 100644
index a943a573bdb..00000000000
--- a/chromium/third_party/afl/src/debug.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- american fuzzy lop - debug / error handling macros
- --------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- */
-
-#ifndef _HAVE_DEBUG_H
-#define _HAVE_DEBUG_H
-
-#include <errno.h>
-
-#include "types.h"
-#include "config.h"
-
-/*******************
- * Terminal colors *
- *******************/
-
-#ifdef USE_COLOR
-
-# define cBLK "\x1b[0;30m"
-# define cRED "\x1b[0;31m"
-# define cGRN "\x1b[0;32m"
-# define cBRN "\x1b[0;33m"
-# define cBLU "\x1b[0;34m"
-# define cMGN "\x1b[0;35m"
-# define cCYA "\x1b[0;36m"
-# define cLGR "\x1b[0;37m"
-# define cGRA "\x1b[1;90m"
-# define cLRD "\x1b[1;91m"
-# define cLGN "\x1b[1;92m"
-# define cYEL "\x1b[1;93m"
-# define cLBL "\x1b[1;94m"
-# define cPIN "\x1b[1;95m"
-# define cLCY "\x1b[1;96m"
-# define cBRI "\x1b[1;97m"
-# define cRST "\x1b[0m"
-
-# define bgBLK "\x1b[40m"
-# define bgRED "\x1b[41m"
-# define bgGRN "\x1b[42m"
-# define bgBRN "\x1b[43m"
-# define bgBLU "\x1b[44m"
-# define bgMGN "\x1b[45m"
-# define bgCYA "\x1b[46m"
-# define bgLGR "\x1b[47m"
-# define bgGRA "\x1b[100m"
-# define bgLRD "\x1b[101m"
-# define bgLGN "\x1b[102m"
-# define bgYEL "\x1b[103m"
-# define bgLBL "\x1b[104m"
-# define bgPIN "\x1b[105m"
-# define bgLCY "\x1b[106m"
-# define bgBRI "\x1b[107m"
-
-#else
-
-# define cBLK ""
-# define cRED ""
-# define cGRN ""
-# define cBRN ""
-# define cBLU ""
-# define cMGN ""
-# define cCYA ""
-# define cLGR ""
-# define cGRA ""
-# define cLRD ""
-# define cLGN ""
-# define cYEL ""
-# define cLBL ""
-# define cPIN ""
-# define cLCY ""
-# define cBRI ""
-# define cRST ""
-
-# define bgBLK ""
-# define bgRED ""
-# define bgGRN ""
-# define bgBRN ""
-# define bgBLU ""
-# define bgMGN ""
-# define bgCYA ""
-# define bgLGR ""
-# define bgGRA ""
-# define bgLRD ""
-# define bgLGN ""
-# define bgYEL ""
-# define bgLBL ""
-# define bgPIN ""
-# define bgLCY ""
-# define bgBRI ""
-
-#endif /* ^USE_COLOR */
-
-/*************************
- * Box drawing sequences *
- *************************/
-
-#ifdef FANCY_BOXES
-
-# define SET_G1 "\x1b)0" /* Set G1 for box drawing */
-# define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */
-# define bSTART "\x0e" /* Enter G1 drawing mode */
-# define bSTOP "\x0f" /* Leave G1 drawing mode */
-# define bH "q" /* Horizontal line */
-# define bV "x" /* Vertical line */
-# define bLT "l" /* Left top corner */
-# define bRT "k" /* Right top corner */
-# define bLB "m" /* Left bottom corner */
-# define bRB "j" /* Right bottom corner */
-# define bX "n" /* Cross */
-# define bVR "t" /* Vertical, branch right */
-# define bVL "u" /* Vertical, branch left */
-# define bHT "v" /* Horizontal, branch top */
-# define bHB "w" /* Horizontal, branch bottom */
-
-#else
-
-# define SET_G1 ""
-# define RESET_G1 ""
-# define bSTART ""
-# define bSTOP ""
-# define bH "-"
-# define bV "|"
-# define bLT "+"
-# define bRT "+"
-# define bLB "+"
-# define bRB "+"
-# define bX "+"
-# define bVR "+"
-# define bVL "+"
-# define bHT "+"
-# define bHB "+"
-
-#endif /* ^FANCY_BOXES */
-
-/***********************
- * Misc terminal codes *
- ***********************/
-
-#define TERM_HOME "\x1b[H"
-#define TERM_CLEAR TERM_HOME "\x1b[2J"
-#define cEOL "\x1b[0K"
-#define CURSOR_HIDE "\x1b[?25l"
-#define CURSOR_SHOW "\x1b[?25h"
-
-/************************
- * Debug & error macros *
- ************************/
-
-/* Just print stuff to the appropriate stream. */
-
-#ifdef MESSAGES_TO_STDOUT
-# define SAYF(x...) printf(x)
-#else
-# define SAYF(x...) fprintf(stderr, x)
-#endif /* ^MESSAGES_TO_STDOUT */
-
-/* Show a prefixed warning. */
-
-#define WARNF(x...) do { \
- SAYF(cYEL "[!] " cBRI "WARNING: " cRST x); \
- SAYF(cRST "\n"); \
- } while (0)
-
-/* Show a prefixed "doing something" message. */
-
-#define ACTF(x...) do { \
- SAYF(cLBL "[*] " cRST x); \
- SAYF(cRST "\n"); \
- } while (0)
-
-/* Show a prefixed "success" message. */
-
-#define OKF(x...) do { \
- SAYF(cLGN "[+] " cRST x); \
- SAYF(cRST "\n"); \
- } while (0)
-
-/* Show a prefixed fatal error message (not used in afl). */
-
-#define BADF(x...) do { \
- SAYF(cLRD "\n[-] " cRST x); \
- SAYF(cRST "\n"); \
- } while (0)
-
-/* Die with a verbose non-OS fatal error message. */
-
-#define FATAL(x...) do { \
- SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \
- cBRI x); \
- SAYF(cLRD "\n Location : " cRST "%s(), %s:%u\n\n", \
- __FUNCTION__, __FILE__, __LINE__); \
- exit(1); \
- } while (0)
-
-/* Die by calling abort() to provide a core dump. */
-
-#define ABORT(x...) do { \
- SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \
- cBRI x); \
- SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n\n", \
- __FUNCTION__, __FILE__, __LINE__); \
- abort(); \
- } while (0)
-
-/* Die while also including the output of perror(). */
-
-#define PFATAL(x...) do { \
- fflush(stdout); \
- SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] SYSTEM ERROR : " \
- cBRI x); \
- SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n", \
- __FUNCTION__, __FILE__, __LINE__); \
- SAYF(cLRD " OS message : " cRST "%s\n", strerror(errno)); \
- exit(1); \
- } while (0)
-
-/* Die with FAULT() or PFAULT() depending on the value of res (used to
- interpret different failure modes for read(), write(), etc). */
-
-#define RPFATAL(res, x...) do { \
- if (res < 0) PFATAL(x); else FATAL(x); \
- } while (0)
-
-/* Error-checking versions of read() and write() that call RPFATAL() as
- appropriate. */
-
-#define ck_write(fd, buf, len, fn) do { \
- u32 _len = (len); \
- s32 _res = write(fd, buf, _len); \
- if (_res != _len) RPFATAL(_res, "Short write to %s", fn); \
- } while (0)
-
-#define ck_read(fd, buf, len, fn) do { \
- u32 _len = (len); \
- s32 _res = read(fd, buf, _len); \
- if (_res != _len) RPFATAL(_res, "Short read from %s", fn); \
- } while (0)
-
-#endif /* ! _HAVE_DEBUG_H */
diff --git a/chromium/third_party/afl/src/docs/COPYING b/chromium/third_party/afl/src/docs/COPYING
deleted file mode 100644
index d6456956733..00000000000
--- a/chromium/third_party/afl/src/docs/COPYING
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/chromium/third_party/afl/src/docs/ChangeLog b/chromium/third_party/afl/src/docs/ChangeLog
deleted file mode 100644
index 3eb01a731a7..00000000000
--- a/chromium/third_party/afl/src/docs/ChangeLog
+++ /dev/null
@@ -1,2541 +0,0 @@
-=========
-ChangeLog
-=========
-
- This is the list of all noteworthy changes made in every public release of
- the tool. See README for the general instruction manual.
-
-----------------
-Staying informed
-----------------
-
-Want to stay in the loop on major new features? Join our mailing list by
-sending a mail to <afl-users+subscribe@googlegroups.com>.
-
-Not sure if you should upgrade? The lowest currently recommended version
-is 2.31b. If you're stuck on an earlier release, it's strongly advisable
-to get on with the times.
-
---------------
-Version 2.38b:
---------------
-
- - Added -mllvm -sanitizer-coverage-block-threshold=0 to trace-pc-guard
- mode, as suggested by Kostya Serebryany.
-
---------------
-Version 2.37b:
---------------
-
- - Fixed a typo. Spotted by Jakub Wilk.
-
- - Fixed support for make install when using trace-pc. Spotted by
- Kurt Roeckx.
-
- - Switched trace-pc to trace-pc-guard, which should be considerably
- faster and is less quirky. Kudos to Konstantin Serebryany (and sorry
- for dragging my feet).
-
- Note that for some reason, this mode doesn't perform as well as
- "vanilla" afl-clang-fast / afl-clang.
-
---------------
-Version 2.36b:
---------------
-
- - Fixed a cosmetic bad free() bug when aborting -S sessions. Spotted
- by Johannes S.
-
- - Made a small change to afl-whatsup to sort fuzzers by name.
-
- - Fixed a minor issue with malloc(0) in libdislocator. Spotted by
- Rene Freingruber.
-
- - Changed the clobber pattern in libdislocator to a slightly more
- reliable one. Suggested by Rene Freingruber.
-
- - Added a note about THP performance. Suggested by Sergey Davidoff.
-
- - Added a somewhat unofficial support for running afl-tmin with a
- baseline "mask" that causes it to minimize only for edges that
- are unique to the input file, but not to the "boring" baseline.
- Suggested by Sami Liedes.
-
- - "Fixed" a getPassName() problem with never versions of clang.
- Reported by Craig Young and several other folks.
-
- Yep, I know I have a backlog on several other feature requests.
- Stay tuned!
-
---------------
-Version 2.35b:
---------------
-
- - Fixed a minor cmdline reporting glitch, spotted by Leo Barnes.
-
- - Fixed a silly bug in libdislocator. Spotted by Johannes Schultz.
-
---------------
-Version 2.34b:
---------------
-
- - Added a note about afl-tmin to technical_details.txt.
-
- - Added support for AFL_NO_UI, as suggested by Leo Barnes.
-
---------------
-Version 2.33b:
---------------
-
- - Added code to strip -Wl,-z,defs and -Wl,--no-undefined for afl-clang-fast,
- since they interfere with -shared. Spotted and diagnosed by Toby Hutton.
-
- - Added some fuzzing tips for Android.
-
---------------
-Version 2.32b:
---------------
-
- - Added a check for AFL_HARDEN combined with AFL_USE_*SAN. Suggested by
- Hanno Boeck.
-
- - Made several other cosmetic adjustments to cycle timing in the wake of the
- big tweak made in 2.31b.
-
---------------
-Version 2.31b:
---------------
-
- - Changed havoc cycle counts for a marked performance boost, especially
- with -S / -d. See the discussion of FidgetyAFL in:
-
- https://groups.google.com/forum/#!topic/afl-users/fOPeb62FZUg
-
- While this does not implement the approach proposed by the authors of
- the CCS paper, the solution is a result of digging into that research;
- more improvements may follow as I do more experiments and get more
- definitive data.
-
---------------
-Version 2.30b:
---------------
-
- - Made minor improvements to persistent mode to avoid the remote
- possibility of "no instrumentation detected" issues with very low
- instrumentation densities.
-
- - Fixed a minor glitch with a leftover process in persistent mode.
- Reported by Jakub Wilk and Daniel Stender.
-
- - Made persistent mode bitmaps a bit more consistent and adjusted the way
- this is shown in the UI, especially in persistent mode.
-
---------------
-Version 2.29b:
---------------
-
- - Made a minor #include fix to llvm_mode. Suggested by Jonathan Metzman.
-
- - Made cosmetic updates to the docs.
-
---------------
-Version 2.28b:
---------------
-
- - Added "life pro tips" to docs/.
-
- - Moved testcases/_extras/ to dictionaries/ for visibility.
-
- - Made minor improvements to install scripts.
-
- - Added an important safety tip.
-
---------------
-Version 2.27b:
---------------
-
- - Added libtokencap, a simple feature to intercept strcmp / memcmp and
- generate dictionary entries that can help extend coverage.
-
- - Moved libdislocator to its own dir, added README.
-
- - The demo in experimental/instrumented_cmp is no more.
-
---------------
-Version 2.26b:
---------------
-
- - Made a fix for libdislocator.so to compile on MacOS X.
-
- - Added support for DYLD_INSERT_LIBRARIES.
-
- - Renamed AFL_LD_PRELOAD to AFL_PRELOAD.
-
---------------
-Version 2.25b:
---------------
-
- - Made some cosmetic updates to libdislocator.so, renamed one env
- variable.
-
---------------
-Version 2.24b:
---------------
-
- - Added libdislocator.so, an experimental, abusive allocator. Try
- it out with AFL_LD_PRELOAD=/path/to/libdislocator.so when running
- afl-fuzz.
-
---------------
-Version 2.23b:
---------------
-
- - Improved the stability metric for persistent mode binaries. Problem
- spotted by Kurt Roeckx.
-
- - Made a related improvement that may bring the metric to 100% for those
- targets.
-
---------------
-Version 2.22b:
---------------
-
- - Mentioned the potential conflicts between MSAN / ASAN and FORTIFY_SOURCE.
- There is no automated check for this, since some distros may implicitly
- set FORTIFY_SOURCE outside of the compiler's argv[].
-
- - Populated the support for AFL_LD_PRELOAD to all companion tools.
-
- - Made a change to the handling of ./afl-clang-fast -v. Spotted by
- Jan Kneschke.
-
---------------
-Version 2.21b:
---------------
-
- - Added some crash reporting notes for Solaris in docs/INSTALL, as
- investigated by Martin Carpenter.
-
- - Fixed a minor UI mix-up with havoc strategy stats.
-
---------------
-Version 2.20b:
---------------
-
- - Revamped the handling of variable paths, replacing path count with a
- "stability" score to give users a much better signal. Based on the
- feedback from Vegard Nossum.
-
- - Made a stability improvement to the syncing behavior with resuming
- fuzzers. Based on the feedback from Vegard.
-
- - Changed the UI to include current input bitmap density along with
- total density. Ditto.
-
- - Added experimental support for parallelizing -M.
-
---------------
-Version 2.19b:
---------------
-
- - Made a fix to make sure that auto CPU binding happens at non-overlapping
- times.
-
---------------
-Version 2.18b:
---------------
-
- - Made several performance improvements to has_new_bits() and
- classify_counts(). This should offer a robust performance bump with
- fast targets.
-
---------------
-Version 2.17b:
---------------
-
- - Killed the error-prone and manual -Z option. On Linux, AFL will now
- automatically bind to the first free core (or complain if there are no
- free cores left).
-
- - Made some doc updates along these lines.
-
---------------
-Version 2.16b:
---------------
-
- - Improved support for older versions of clang (hopefully without
- breaking anything).
-
- - Moved version data from Makefile to config.h. Suggested by
- Jonathan Metzman.
-
---------------
-Version 2.15b:
---------------
-
- - Added a README section on looking for non-crashing bugs.
-
- - Added license data to several boring files. Contributed by
- Jonathan Metzman.
-
---------------
-Version 2.14b:
---------------
-
- - Added FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION as a macro defined when
- compiling with afl-gcc and friends. Suggested by Kostya Serebryany.
-
- - Refreshed some of the non-x86 docs.
-
---------------
-Version 2.13b:
---------------
-
- - Fixed a spurious build test error with trace-pc and llvm_mode/Makefile.
- Spotted by Markus Teufelberger.
-
- - Fixed a cosmetic issue with afl-whatsup. Spotted by Brandon Perry.
-
---------------
-Version 2.12b:
---------------
-
- - Fixed a minor issue in afl-tmin that can make alphabet minimization less
- efficient during passes > 1. Spotted by Daniel Binderman.
-
---------------
-Version 2.11b:
---------------
-
- - Fixed a minor typo in instrumented_cmp, spotted by Hanno Eissfeldt.
-
- - Added a missing size check for deterministic insertion steps.
-
- - Made an improvement to afl-gotcpu when -Z not used.
-
- - Fixed a typo in post_library_png.so.c in experimental/. Spotted by Kostya
- Serebryany.
-
---------------
-Version 2.10b:
---------------
-
- - Fixed a minor core counting glitch, reported by Tyler Nighswander.
-
---------------
-Version 2.09b:
---------------
-
- - Made several documentation updates.
-
- - Added some visual indicators to promote and simplify the use of -Z.
-
---------------
-Version 2.08b:
---------------
-
- - Added explicit support for -m32 and -m64 for llvm_mode. Inspired by
- a request from Christian Holler.
-
- - Added a new benchmarking option, as requested by Kostya Serebryany.
-
---------------
-Version 2.07b:
---------------
-
- - Added CPU affinity option (-Z) on Linux. With some caution, this can
- offer a significant (10%+) performance bump and reduce jitter.
- Proposed by Austin Seipp.
-
- - Updated afl-gotcpu to use CPU affinity where supported.
-
- - Fixed confusing CPU_TARGET error messages with QEMU build. Spotted by
- Daniel Komaromy and others.
-
---------------
-Version 2.06b:
---------------
-
- - Worked around LLVM persistent mode hiccups with -shared code.
- Contributed by Christian Holler.
-
- - Added __AFL_COMPILER as a convenient way to detect that something is
- built under afl-gcc / afl-clang / afl-clang-fast and enable custom
- optimizations in your code. Suggested by Pedro Corte-Real.
-
- - Upstreamed several minor changes developed by Franjo Ivancic to
- allow AFL to be built as a library. This is fairly use-specific and
- may have relatively little appeal to general audiences.
-
---------------
-Version 2.05b:
---------------
-
- - Put __sanitizer_cov_module_init & co behind #ifdef to avoid problems
- with ASAN. Spotted by Christian Holler.
-
---------------
-Version 2.04b:
---------------
-
- - Removed indirect-calls coverage from -fsanitize-coverage (since it's
- redundant). Spotted by Kostya Serebryany.
-
---------------
-Version 2.03b:
---------------
-
- - Added experimental -fsanitize-coverage=trace-pc support that goes with
- some recent additions to LLVM, as implemented by Kostya Serebryany.
- Right now, this is cumbersome to use with common build systems, so
- the mode remains undocumented.
-
- - Made several substantial improvements to better support non-standard
- map sizes in LLVM mode.
-
- - Switched LLVM mode to thread-local execution tracing, which may offer
- better results in some multithreaded apps.
-
- - Fixed a minor typo, reported by Heiko Eissfeldt.
-
- - Force-disabled symbolization for ASAN, as suggested by Christian Holler.
-
- - AFL_NOX86 renamed to AFL_NO_X86 for consistency.
-
- - Added AFL_LD_PRELOAD to allow LD_PRELOAD to be set for targets without
- affecting AFL itself. Suggested by Daniel Godas-Lopez.
-
---------------
-Version 2.02b:
---------------
-
- - Fixed a "lcamtuf can't count to 16" bug in the havoc stage. Reported
- by Guillaume Endignoux.
-
---------------
-Version 2.01b:
---------------
-
- - Made an improvement to cycle counter color coding, based on feedback
- from Shai Sarfaty.
-
- - Added a mention of aflize to sister_projects.txt.
-
- - Fixed an installation issue with afl-as, as spotted by ilovezfs.
-
---------------
-Version 2.00b:
---------------
-
- - Cleaned up color handling after a minor snafu in 1.99b (affecting some
- terminals).
-
- - Made minor updates to the documentation.
-
---------------
-Version 1.99b:
---------------
-
- - Substantially revamped the output and the internal logic of afl-analyze.
-
- - Cleaned up some of the color handling code and added support for
- background colors.
-
- - Removed some stray files (oops).
-
- - Updated docs to better explain afl-analyze.
-
---------------
-Version 1.98b:
---------------
-
- - Improved to "boring string" detection in afl-analyze.
-
- - Added technical_details.txt for afl-analyze.
-
---------------
-Version 1.97b:
---------------
-
- - Added afl-analyze, a nifty tool to analyze the structure of a file
- based on the feedback from AFL instrumentation. This is kinda experimental,
- so field reports welcome.
-
- - Added a mention of afl-cygwin.
-
- - Fixed a couple of typos, as reported by Jakub Wilk and others.
-
---------------
-Version 1.96b:
---------------
-
- - Added -fpic to CFLAGS for the clang plugin, as suggested by Hanno Boeck.
-
- - Made another clang change (IRBuilder) suggested by Jeff Trull.
-
- - Fixed several typos, spotted by Jakub Wilk.
-
- - Added support for AFL_SHUFFLE_QUEUE, based on discussions with
- Christian Holler.
-
---------------
-Version 1.95b:
---------------
-
- - Fixed a harmless bug when handling -B. Spotted by Jacek Wielemborek.
-
- - Made the exit message a bit more accurate when AFL_EXIT_WHEN_DONE is set.
-
- - Added some error-checking for old-style forkserver syntax. Suggested by
- Ben Nagy.
-
- - Switched from exit() to _exit() in injected code to avoid snafus with
- destructors in C++ code. Spotted by sunblate.
-
- - Made a change to avoid spuriously setting __AFL_SHM_ID when
- AFL_DUMB_FORKSRV is set in conjunction with -n. Spotted by Jakub Wilk.
-
---------------
-Version 1.94b:
---------------
-
- - Changed allocator alignment to improve support for non-x86 systems (now
- that llvm_mode makes this more feasible).
-
- - Fixed a minor typo in afl-cmin. Spotted by Jonathan Neuschafer.
-
- - Fixed an obscure bug that would affect people trying to use afl-gcc
- with $TMP set but $TMPDIR absent. Spotted by Jeremy Barnes.
-
---------------
-Version 1.93b:
---------------
-
- - Hopefully fixed a problem with MacOS X and persistent mode, spotted by
- Leo Barnes.
-
---------------
-Version 1.92b:
---------------
-
- - Made yet another C++ fix (namespaces). Reported by Daniel Lockyer.
-
---------------
-Version 1.91b:
---------------
-
- - Made another fix to make 1.90b actually work properly with C++ (d'oh).
- Problem spotted by Daniel Lockyer.
-
---------------
-Version 1.90b:
---------------
-
- - Fixed a minor typo spotted by Kai Zhao; and made several other minor updates
- to docs.
-
- - Updated the project URL for python-afl. Requested by Jakub Wilk.
-
- - Fixed a potential problem with deferred mode signatures getting optimized
- out by the linker (with --gc-sections).
-
---------------
-Version 1.89b:
---------------
-
- - Revamped the support for persistent and deferred forkserver modes.
- Both now feature simpler syntax and do not require companion env
- variables. Suggested by Jakub Wilk.
-
- - Added a bit more info about afl-showmap. Suggested by Jacek Wielemborek.
-
---------------
-Version 1.88b:
---------------
-
- - Made AFL_EXIT_WHEN_DONE work in non-tty mode. Issue spotted by
- Jacek Wielemborek.
-
---------------
-Version 1.87b:
---------------
-
- - Added QuickStartGuide.txt, a one-page quick start doc.
-
- - Fixed several typos spotted by Dominique Pelle.
-
- - Revamped several parts of README.
-
---------------
-Version 1.86b:
---------------
-
- - Added support for AFL_SKIP_CRASHES, which is a very hackish solution to
- the problem of resuming sessions with intermittently crashing inputs.
-
- - Removed the hard-fail terminal size check, replaced with a dynamic
- warning shown in place of the UI. Based on feedback from Christian Holler.
-
- - Fixed a minor typo in show_stats. Spotted by Dingbao Xie.
-
---------------
-Version 1.85b:
---------------
-
- - Fixed a garbled sentence in notes on parallel fuzzing. Thanks to Jakub Wilk.
-
- - Fixed a minor glitch in afl-cmin. Spotted by Jonathan Foote.
-
---------------
-Version 1.84b:
---------------
-
- - Made SIMPLE_FILES behave as expected when naming backup directories for
- crashes and hangs.
-
- - Added the total number of favored paths to fuzzer_stats. Requested by
- Ben Nagy.
-
- - Made afl-tmin, afl-fuzz, and afl-cmin reject negative values passed to
- -t and -m, since they generally won't work as expected.
-
- - Made a fix for no lahf / sahf support on older versions of FreeBSD.
- Patch contributed by Alex Moneger.
-
---------------
-Version 1.83b:
---------------
-
- - Fixed a problem with xargs -d on non-Linux systems in afl-cmin. Spotted by
- teor2345 and Ben Nagy.
-
- - Fixed an implicit declaration in LLVM mode on MacOS X. Reported by
- Kai Zhao.
-
---------------
-Version 1.82b:
---------------
-
- - Fixed a harmless but annoying race condition in persistent mode - signal
- delivery is a bit more finicky than I thought.
-
- - Updated the documentation to explain persistent mode a bit better.
-
- - Tweaked AFL_PERSISTENT to force AFL_NO_VAR_CHECK.
-
---------------
-Version 1.81b:
---------------
-
- - Added persistent mode for in-process fuzzing. See llvm_mode/README.llvm.
- Inspired by Kostya Serebryany and Christian Holler.
-
- - Changed the in-place resume code to preserve crashes/README.txt. Suggested
- by Ben Nagy.
-
- - Included a potential fix for LLVM mode issues on MacOS X, based on the
- investigation done by teor2345.
-
---------------
-Version 1.80b:
---------------
-
- - Made afl-cmin tolerant of whitespaces in filenames. Suggested by
- Jonathan Neuschafer and Ketil Froyn.
-
- - Added support for AFL_EXIT_WHEN_DONE, as suggested by Michael Rash.
-
---------------
-Version 1.79b:
---------------
-
- - Added support for dictionary levels, see testcases/README.testcases.
-
- - Reworked the SQL dictionary to use levels.
-
- - Added a note about Preeny.
-
---------------
-Version 1.78b:
---------------
-
- - Added a dictionary for PDF, contributed by Ben Nagy.
-
- - Added several references to afl-cov, a new tool by Michael Rash.
-
- - Fixed a problem with crash reporter detection on MacOS X, as reported by
- Louis Dassy.
-
---------------
-Version 1.77b:
---------------
-
- - Extended the -x option to support single-file dictionaries.
-
- - Replaced factory-packaged dictionaries with file-based variants.
-
- - Removed newlines from HTML keywords in testcases/_extras/html/.
-
---------------
-Version 1.76b:
---------------
-
- - Very significantly reduced the number of duplicate execs during
- deterministic checks, chiefly in int16 and int32 stages. Confirmed
- identical path yields. This should improve early-stage efficiency by
- around 5-10%.
-
- - Reduced the likelihood of duplicate non-deterministic execs by
- bumping up lowest stacking factor from 1 to 2. Quickly confirmed
- that this doesn't seem to have significant impact on coverage with
- libpng.
-
- - Added a note about integrating afl-fuzz with third-party tools.
-
---------------
-Version 1.75b:
---------------
-
- - Improved argv_fuzzing to allow it to emit empty args. Spotted by Jakub
- Wilk.
-
- - afl-clang-fast now defines __AFL_HAVE_MANUAL_INIT. Suggested by Jakub Wilk.
-
- - Fixed a libtool-related bug with afl-clang-fast that would make some
- ./configure invocations generate incorrect output. Spotted by Jakub Wilk.
-
- - Removed flock() on Solaris. This means no locking on this platform,
- but so be it. Problem reported by Martin Carpenter.
-
- - Fixed a typo. Reported by Jakub Wilk.
-
---------------
-Version 1.74b:
---------------
-
- - Added an example argv[] fuzzing wrapper in experimental/argv_fuzzing.
- Reworked the bash example to be faster, too.
-
- - Clarified llvm_mode prerequisites for FreeBSD.
-
- - Improved afl-tmin to use /tmp if cwd is not writeable.
-
- - Removed redundant includes for sys/fcntl.h, which caused warnings with
- some nitpicky versions of libc.
-
- - Added a corpus of basic HTML tags that parsers are likely to pay attention
- to (no attributes).
-
- - Added EP_EnabledOnOptLevel0 to llvm_mode, so that the instrumentation is
- inserted even when AFL_DONT_OPTIMIZE=1 is set.
-
- - Switched qemu_mode to use the newly-released QEMU 2.3.0, which contains
- a couple of minor bugfixes.
-
---------------
-Version 1.73b:
---------------
-
- - Fixed a pretty stupid bug in effector maps that could sometimes cause
- AFL to fuzz slightly more than necessary; and in very rare circumstances,
- could lead to SEGV if eff_map is aligned with page boundary and followed
- by an unmapped page. Spotted by Jonathan Gray.
-
---------------
-Version 1.72b:
---------------
-
- - Fixed a glitch in non-x86 install, spotted by Tobias Ospelt.
-
- - Added a minor safeguard to llvm_mode Makefile following a report from
- Kai Zhao.
-
---------------
-Version 1.71b:
---------------
-
- - Fixed a bug with installed copies of AFL trying to use QEMU mode. Spotted
- by G.M. Lime.
-
- - Added last path / crash / hang times to fuzzer_stats, suggested by
- Richard Hipp.
-
- - Fixed a typo, thanks to Jakub Wilk.
-
---------------
-Version 1.70b:
---------------
-
- - Modified resumption code to reuse the original timeout value when resuming
- a session if -t is not given. This prevents timeout creep in continuous
- fuzzing.
-
- - Added improved error messages for failed handshake when AFL_DEFER_FORKSRV
- is set.
-
- - Made a slight improvement to llvm_mode/Makefile based on feedback from
- Jakub Wilk.
-
- - Refreshed several bits of documentation.
-
- - Added a more prominent note about the MacOS X trade-offs to Makefile.
-
---------------
-Version 1.69b:
---------------
-
- - Added support for deferred initialization in LLVM mode. Suggested by
- Richard Godbee.
-
---------------
-Version 1.68b:
---------------
-
- - Fixed a minor PRNG glitch that would make the first seconds of a fuzzing
- job deterministic. Thanks to Andreas Stieger.
-
- - Made tmp[] static in the LLVM runtime to keep Valgrind happy (this had
- no impact on anything else). Spotted by Richard Godbee.
-
- - Clarified the footnote in README.
-
---------------
-Version 1.67b:
---------------
-
- - Made one more correction to llvm_mode Makefile, spotted by Jakub Wilk.
-
---------------
-Version 1.66b:
---------------
-
- - Added CC / CXX support to llvm_mode Makefile. Requested by Charlie Eriksen.
-
- - Fixed 'make clean' with gmake. Suggested by Oliver Schneider.
-
- - Fixed 'make -j n clean all'. Suggested by Oliver Schneider.
-
- - Removed build date and time from banners to give people deterministic
- builds. Requested by Jakub Wilk.
-
---------------
-Version 1.65b:
---------------
-
- - Fixed a snafu with some leftover code in afl-clang-fast.
-
- - Corrected even moar typos.
-
---------------
-Version 1.64b:
---------------
-
- - Further simplified afl-clang-fast runtime by reverting .init_array to
- __attribute__((constructor(0)). This should improve compatibility with
- non-ELF platforms.
-
- - Fixed a problem with afl-clang-fast and -shared libraries. Simplified
- the code by getting rid of .preinit_array and replacing it with a .comm
- object. Problem reported by Charlie Eriksen.
-
- - Removed unnecessary instrumentation density adjustment for the LLVM mode.
- Reported by Jonathan Neuschafer.
-
---------------
-Version 1.63b:
---------------
-
- - Updated cgroups_asan/ with a new version from Sam, made a couple changes
- to streamline it and keep parallel afl instances in separate groups.
-
- - Fixed typos, thanks to Jakub Wilk.
-
---------------
-Version 1.62b:
---------------
-
- - Improved the handling of -x in afl-clang-fast,
-
- - Improved the handling of low AFL_INST_RATIO settings for QEMU and
- LLVM modes.
-
- - Fixed the llvm-config bug for good (thanks to Tobias Ospelt).
-
---------------
-Version 1.61b:
---------------
-
- - Fixed an obscure bug compiling OpenSSL with afl-clang-fast. Patch by
- Laszlo Szekeres.
-
- - Fixed a 'make install' bug on non-x86 systems, thanks to Tobias Ospelt.
-
- - Fixed a problem with half-broken llvm-config on Odroid, thanks to
- Tobias Ospelt. (There is another odd bug there that hasn't been fully
- fixed - TBD).
-
---------------
-Version 1.60b:
---------------
-
- - Allowed experimental/llvm_instrumentation/ to graduate to llvm_mode/.
-
- - Removed experimental/arm_support/, since it's completely broken and likely
- unnecessary with LLVM support in place.
-
- - Added ASAN cgroups script to experimental/asan_cgroups/, updated existing
- docs. Courtesy Sam Hakim and David A. Wheeler.
-
- - Refactored afl-tmin to reduce the number of execs in common use cases.
- Ideas from Jonathan Neuschafer and Turo Lamminen.
-
- - Added a note about CLAs at the bottom of README.
-
- - Renamed testcases_readme.txt to README.testcases for some semblance of
- consistency.
-
- - Made assorted updates to docs.
-
- - Added MEM_BARRIER() to afl-showmap and afl-tmin, just to be safe.
-
---------------
-Version 1.59b:
---------------
-
- - Imported Laszlo Szekeres' experimental LLVM instrumentation into
- experimental/llvm_instrumentation. I'll work on including it in the
- "mainstream" version soon.
-
- - Fixed another typo, thanks to Jakub Wilk.
-
---------------
-Version 1.58b:
---------------
-
- - Added a workaround for abort() behavior in -lpthread programs in QEMU mode.
- Spotted by Aidan Thornton.
-
- - Made several documentation updates, including links to the static
- instrumentation tool (sister_projects.txt).
-
---------------
-Version 1.57b:
---------------
-
- - Fixed a problem with exception handling on some versions of MacOS X.
- Spotted by Samir Aguiar and Anders Wang Kristensen.
-
- - Tweaked afl-gcc to use BIN_PATH instead of a fixed string in help
- messages.
-
---------------
-Version 1.56b:
---------------
-
- - Renamed related_work.txt to historical_notes.txt.
-
- - Made minor edits to the ASAN doc.
-
- - Added docs/sister_projects.txt with a list of inspired or closely
- related utilities.
-
---------------
-Version 1.55b:
---------------
-
- - Fixed a glitch with afl-showmap opening /dev/null with O_RDONLY when
- running in quiet mode. Spotted by Tyler Nighswander.
-
---------------
-Version 1.54b:
---------------
-
- - Added another postprocessor example for PNG.
-
- - Made a cosmetic fix to realloc() handling in experimental/post_library/,
- suggested by Jakub Wilk.
-
- - Improved -ldl handling. Suggested by Jakub Wilk.
-
---------------
-Version 1.53b:
---------------
-
- - Fixed an -l ordering issue that is apparently still a problem on Ubuntu.
- Spotted by William Robinet.
-
---------------
-Version 1.52b:
---------------
-
- - Added support for file format postprocessors. Requested by Ben Nagy. This
- feature is intentionally buried, since it's fairly easy to misuse and
- useful only in some scenarios. See experimental/post_library/.
-
---------------
-Version 1.51b:
---------------
-
- - Made it possible to properly override LD_BIND_NOW after one very unusual
- report of trouble.
-
- - Cleaned up typos, thanks to Jakub Wilk.
-
- - Fixed a bug in AFL_DUMB_FORKSRV.
-
---------------
-Version 1.50b:
---------------
-
- - Fixed a flock() bug that would prevent dir reuse errors from kicking
- in every now and then.
-
- - Renamed references to ppvm (the project is now called recidivm).
-
- - Made improvements to file descriptor handling to avoid leaving some fds
- unnecessarily open in the child process.
-
- - Fixed a typo or two.
-
---------------
-Version 1.49b:
---------------
-
- - Added code to save original command line in fuzzer_stats and
- crashes/README.txt. Also saves fuzzer version in fuzzer_stats.
- Requested by Ben Nagy.
-
---------------
-Version 1.48b:
---------------
-
- - Fixed a bug with QEMU fork server crashes when translation is attempted
- after a jump to an invalid pointer in the child process (i.e., after
- bumping into a particularly nasty security bug in the tested binary).
- Reported by Tyler Nighswander.
-
---------------
-Version 1.47b:
---------------
-
- - Fixed a bug with afl-cmin in -Q mode complaining about binary being not
- instrumented. Thanks to Jonathan Neuschafer for the bug report.
-
- - Fixed another bug with argv handling for afl-fuzz in -Q mode. Reported
- by Jonathan Neuschafer.
-
- - Improved the use of colors when showing crash counts in -C mode.
-
---------------
-Version 1.46b:
---------------
-
- - Improved instrumentation performance on 32-bit systems by getting rid of
- xor-swap (oddly enough, xor-swap is still faster on 64-bit) and tweaking
- alignment.
-
- - Made path depth numbers more accurate with imported test cases.
-
---------------
-Version 1.45b:
---------------
-
- - Added support for SIMPLE_FILES in config.h for folks who don't like
- descriptive file names. Generates very simple names without colons,
- commas, plus signs, dashes, etc.
-
- - Replaced zero-sized files with symlinks in the variable behavior state
- dir to simplify examining the relevant test cases.
-
- - Changed the period of limited-range block ops from 5 to 10 minutes based
- on a couple of experiments. The basic goal of this delay timer behavior
- is to better support jobs that are seeded with completely invalid files,
- in which case, the first few queue cycles may be completed very quickly
- without discovering new paths. Should have no effect on well-seeded jobs.
-
- - Made several minor updates to docs.
-
---------------
-Version 1.44b:
---------------
-
- - Corrected two bungled attempts to get the -C mode work properly
- with afl-cmin (accounting for the short-lived releases tagged 1.42 and
- 1.43b) - sorry.
-
- - Removed AFL_ALLOW_CRASHES in favor of the -C mode in said tool.
-
- - Said goodbye to Hello Kitty, as requested by Padraig Brady.
-
---------------
-Version 1.41b:
---------------
-
- - Added AFL_ALLOW_CRASHES=1 to afl-cmin. Allows crashing inputs in the
- output corpus. Changed the default behavior to disallow it.
-
- - Made the afl-cmin output dir default to 0700, not 0755, to be consistent
- with afl-fuzz; documented the rationale for 0755 in afl-plot.
-
- - Lowered the output dir reuse time limit to 25 minutes as a dice-roll
- compromise after a discussion on afl-users@.
-
- - Made afl-showmap accept -o /dev/null without borking out.
-
- - Added support for crash / hang info in exit codes of afl-showmap.
-
- - Tweaked block operation scaling to also factor in ballpark run time
- in cases where queue passes take very little time.
-
- - Fixed typos and made improvements to several docs.
-
---------------
-Version 1.40b:
---------------
-
- - Switched to smaller block op sizes during the first passes over the
- queue. Helps keep test cases small.
-
- - Added memory barrier for run_target(), just in case compilers get
- smarter than they are today.
-
- - Updated a bunch of docs.
-
---------------
-Version 1.39b:
---------------
-
- - Added the ability to skip inputs by sending SIGUSR1 to the fuzzer.
-
- - Reworked several portions of the documentation.
-
- - Changed the code to reset splicing perf scores between runs to keep
- them closer to intended length.
-
- - Reduced the minimum value of -t to 5 for afl-fuzz (~200 exec/sec)
- and to 10 for auxiliary tools (due to the absence of a fork server).
-
- - Switched to more aggressive default timeouts (rounded up to 25 ms
- versus 50 ms - ~40 execs/sec) and made several other cosmetic changes
- to the timeout code.
-
---------------
-Version 1.38b:
---------------
-
- - Fixed a bug in the QEMU build script, spotted by William Robinet.
-
- - Improved the reporting of skipped bitflips to keep the UI counters a bit
- more accurate.
-
- - Cleaned up related_work.txt and added some non-goals.
-
- - Fixed typos, thanks to Jakub Wilk.
-
---------------
-Version 1.37b:
---------------
-
- - Added effector maps, which detect regions that do not seem to respond
- to bitflips and subsequently exclude them from more expensive steps
- (arithmetics, known ints, etc). This should offer significant performance
- improvements with quite a few types of text-based formats, reducing the
- number of deterministic execs by a factor of 2 or so.
-
- - Cleaned up mem limit handling in afl-cmin.
-
- - Switched from uname -i to uname -m to work around Gentoo-specific
- issues with coreutils when building QEMU. Reported by William Robinet.
-
- - Switched from PID checking to flock() to detect running sessions.
- Problem, against all odds, bumped into by Jakub Wilk.
-
- - Added SKIP_COUNTS and changed the behavior of COVERAGE_ONLY in config.h.
- Useful only for internal benchmarking.
-
- - Made improvements to UI refresh rates and exec/sec stats to make them
- more stable.
-
- - Made assorted improvements to the documentation and to the QEMU build
- script.
-
- - Switched from perror() to strerror() in error macros, thanks to Jakub
- Wilk for the nag.
-
- - Moved afl-cmin back to bash, wasn't thinking straight. It has to stay
- on bash because other shells may have restrictive limits on array sizes.
-
---------------
-Version 1.36b:
---------------
-
- - Switched afl-cmin over to /bin/sh. Thanks to Jonathan Gray.
-
- - Fixed an off-by-one bug in queue limit check when resuming sessions
- (could cause NULL ptr deref if you are *really* unlucky).
-
- - Fixed the QEMU script to tolerate i686 if returned by uname -i. Based on
- a problem report from Sebastien Duquette.
-
- - Added multiple references to Jakub's ppvm tool.
-
- - Made several minor improvements to the Makefile.
-
- - Believe it or not, fixed some typos. Thanks to Jakub Wilk.
-
---------------
-Version 1.35b:
---------------
-
- - Cleaned up regular expressions in some of the scripts to avoid errors
- on *BSD systems. Spotted by Jonathan Gray.
-
---------------
-Version 1.34b:
---------------
-
- - Performed a substantial documentation and program output cleanup to
- better explain the QEMU feature.
-
---------------
-Version 1.33b:
---------------
-
- - Added support for AFL_INST_RATIO and AFL_INST_LIBS in the QEMU mode.
-
- - Fixed a stack allocation crash in QEMU mode (bug in QEMU, fixed with
- an extra patch applied to the downloaded release).
-
- - Added code to test the QEMU instrumentation once the afl-qemu-trace
- binary is built.
-
- - Modified afl-tmin and afl-showmap to search $PATH for binaries and to
- better handle QEMU support.
-
- - Added a check for instrumented binaries when passing -Q to afl-fuzz.
-
---------------
-Version 1.32b:
---------------
-
- - Fixed 'make install' following the QEMU changes. Spotted by Hanno Boeck.
-
- - Fixed EXTRA_PAR handling in afl-cmin.
-
---------------
-Version 1.31b:
---------------
-
- - Hallelujah! Thanks to Andrew Griffiths, we now support very fast, black-box
- instrumentation of binary-only code. See qemu_mode/README.qemu.
-
- To use this feature, you need to follow the instructions in that
- directory and then run afl-fuzz with -Q.
-
---------------
-Version 1.30b:
---------------
-
- - Added -s (summary) option to afl-whatsup. Suggested by Jodie Cunningham.
-
- - Added a sanity check in afl-tmin to detect minimization to zero len or
- excess hangs.
-
- - Fixed alphabet size counter in afl-tmin.
-
- - Slightly improved the handling of -B in afl-fuzz.
-
- - Fixed process crash messages with -m none.
-
---------------
-Version 1.29b:
---------------
-
- - Improved the naming of test cases when orig: is already present in the file
- name.
-
- - Made substantial improvements to technical_details.txt.
-
---------------
-Version 1.28b:
---------------
-
- - Made a minor tweak to the instrumentation to preserve the directionality
- of tuples (i.e., A -> B != B -> A) and to maintain the identity of tight
- loops (A -> A). You need to recompile targeted binaries to leverage this.
-
- - Cleaned up some of the afl-whatsup stats.
-
- - Added several sanity checks to afl-cmin.
-
---------------
-Version 1.27b:
---------------
-
- - Made afl-tmin recursive. Thanks to Hanno Boeck for the tip.
-
- - Added docs/technical_details.txt.
-
- - Changed afl-showmap search strategy in afl-cmap to just look into the
- same place that afl-cmin is executed from. Thanks to Jakub Wilk.
-
- - Removed current_todo.txt and cleaned up the remaining docs.
-
---------------
-Version 1.26b:
---------------
-
- - Added total execs/sec stat for afl-whatsup.
-
- - afl-cmin now auto-selects between cp or ln. Based on feedback from
- Even Huus.
-
- - Fixed a typo. Thanks to Jakub Wilk.
-
- - Made afl-gotcpu a bit more accurate by using getrusage instead of
- times. Thanks to Jakub Wilk.
-
- - Fixed a memory limit issue during the build process on NetBSD-current.
- Reported by Thomas Klausner.
-
---------------
-Version 1.25b:
---------------
-
- - Introduced afl-whatsup, a simple tool for querying the status of
- local synced instances of afl-fuzz.
-
- - Added -x compiler to clang options on Darwin. Suggested by Filipe
- Cabecinhas.
-
- - Improved exit codes for afl-gotcpu.
-
- - Improved the checks for -m and -t values in afl-cmin. Bug report
- from Evan Huus.
-
---------------
-Version 1.24b:
---------------
-
- - Introduced afl-getcpu, an experimental tool to empirically measure
- CPU preemption rates. Thanks to Jakub Wilk for the idea.
-
---------------
-Version 1.23b:
---------------
-
- - Reverted one change to afl-cmin that actually made it slower.
-
---------------
-Version 1.22b:
---------------
-
- - Reworked afl-showmap.c to support normal options, including -o, -q,
- -e. Also added support for timeouts and memory limits.
-
- - Made changes to afl-cmin and other scripts to accommodate the new
- semantics.
-
- - Officially retired AFL_EDGES_ONLY.
-
- - Fixed another typo in afl-tmin, courtesy of Jakub Wilk.
-
---------------
-Version 1.21b:
---------------
-
- - Graduated minimize_corpus.sh to afl-cmin. It is now a first-class
- utility bundled with the fuzzer.
-
- - Made significant improvements to afl-cmin to make it faster, more
- robust, and more versatile.
-
- - Refactored some of afl-tmin code to make it a bit more readable.
-
- - Made assorted changes to the doc to document afl-cmin and other stuff.
-
---------------
-Version 1.20b:
---------------
-
- - Added AFL_DUMB_FORKSRV, as requested by Jakub Wilk. This works only
- in -n mode and allows afl-fuzz to run with "dummy" fork servers that
- don't output any instrumentation, but follow the same protocol.
-
- - Renamed AFL_SKIP_CHECKS to AFL_SKIP_BIN_CHECK to make it at least
- somewhat descriptive.
-
- - Switched to using clang as the default assembler on MacOS X to work
- around Xcode issues with newer builds of clang. Testing and patch by
- Nico Weber.
-
- - Fixed a typo (via Jakub Wilk).
-
---------------
-Version 1.19b:
---------------
-
- - Improved exec failure detection in afl-fuzz and afl-showmap.
-
- - Improved Ctrl-C handling in afl-showmap.
-
- - Added afl-tmin, a handy instrumentation-enabled minimizer.
-
---------------
-Version 1.18b:
---------------
-
- - Fixed a serious but short-lived bug in the resumption behavior introduced
- in version 1.16b.
-
- - Added -t nn+ mode for soft-skipping timing-out paths.
-
---------------
-Version 1.17b:
---------------
-
- - Fixed a compiler warning introduced in 1.16b for newer versions of GCC.
- Thanks to Jakub Wilk and Ilfak Guilfanov.
-
- - Improved the consistency of saving fuzzer_stats, bitmap info, and
- auto-dictionaries when aborting fuzzing sessions.
-
- - Made several noticeable performance improvements to deterministic arith
- and known int steps.
-
---------------
-Version 1.16b:
---------------
-
- - Added a bit of code to make resumption pick up from the last known
- offset in the queue, rather than always rewinding to the start. Suggested
- by Jakub Wilk.
-
- - Switched to tighter timeout control for slow programs (3x rather than
- 5x average exec speed at init).
-
---------------
-Version 1.15b:
---------------
-
- - Added support for AFL_NO_VAR_CHECK to speed up resumption and inhibit
- variable path warnings for some programs.
-
- - Made the trimmer run even for variable paths, since there is no special
- harm in doing so and it can be very beneficial if the trimming still
- pans out.
-
- - Made the UI a bit more descriptive by adding "n/a" instead of "0" in a
- couple of corner cases.
-
---------------
-Version 1.14b:
---------------
-
- - Added a (partial) dictionary for JavaScript.
-
- - Added AFL_NO_CPU_RED, as suggested by Jakub Wilk.
-
- - Tweaked the havoc scaling logic added in 1.12b.
-
---------------
-Version 1.13b:
---------------
-
- - Improved the performance of minimize_corpus.sh by switching to a
- sort-based approach.
-
- - Made several minor revisions to the docs.
-
---------------
-Version 1.12b:
---------------
-
- - Made an improvement to dictionary generation to avoid runs of identical
- bytes.
-
- - Added havoc cycle scaling to help with slow binaries in -d mode. Based on
- a thread with Sami Liedes.
-
- - Added AFL_SYNC_FIRST for afl-fuzz. This is useful for those who obsess
- over stats, no special purpose otherwise.
-
- - Switched to more robust box drawing codes, suggested by Jakub Wilk.
-
- - Created faster 64-bit variants of several critical-path bitmap functions
- (sorry, no difference on 32 bits).
-
- - Fixed moar typos, as reported by Jakub Wilk.
-
---------------
-Version 1.11b:
---------------
-
- - Added a bit more info about dictionary strategies to the status screen.
-
---------------
-Version 1.10b:
---------------
-
- - Revised the dictionary behavior to use insertion and overwrite in
- deterministic steps, rather than just the latter. This improves coverage
- with SQL and the like.
-
- - Added a mention of "*" in status_screen.txt, as suggested by Jakub Wilk.
-
---------------
-Version 1.09b:
---------------
-
- - Corrected a cosmetic problem with 'extras' stage count not always being
- accurate in the stage yields view.
-
- - Fixed a typo reported by Jakub Wilk and made some minor documentation
- improvements.
-
---------------
-Version 1.08b:
---------------
-
- - Fixed a div-by-zero bug in the newly-added code when using a dictionary.
-
---------------
-Version 1.07b:
---------------
-
- - Added code that automatically finds and extracts syntax tokens from the
- input corpus.
-
- - Fixed a problem with ld dead-code removal option on MacOS X, reported
- by Filipe Cabecinhas.
-
- - Corrected minor typos spotted by Jakub Wilk.
-
- - Added a couple of more exotic archive format samples.
-
---------------
-Version 1.06b:
---------------
-
- - Switched to slightly more accurate (if still not very helpful) reporting
- of short read and short write errors. These theoretically shouldn't happen
- unless you kill the forkserver or run out of disk space. Suggested by
- Jakub Wilk.
-
- - Revamped some of the allocator and debug code, adding comments and
- cleaning up other mess.
-
- - Tweaked the odds of fuzzing non-favored test cases to make sure that
- baseline coverage of all inputs is reached sooner.
-
---------------
-Version 1.05b:
---------------
-
- - Added a dictionary for WebP.
-
- - Made some additional performance improvements to minimize_corpus.sh,
- getting deeper into the bash woods.
-
---------------
-Version 1.04b:
---------------
-
- - Made substantial performance improvements to minimize_corpus.sh with
- large datasets, albeit at the expense of having to switch back to bash
- (other shells may have limits on array sizes, etc).
-
- - Tweaked afl-showmap to support the format used by the new script.
-
---------------
-Version 1.03b:
---------------
-
- - Added code to skip README.txt in the input directory to make the crash
- exploration mode work better. Suggested by Jakub Wilk.
-
- - Added a dictionary for SQLite.
-
---------------
-Version 1.02b:
---------------
-
- - Reverted the ./ search path in minimize_corpus.sh because people did
- not like it.
-
- - Added very explicit warnings not to run various shell scripts that
- read or write to /tmp/ (since this is generally a pretty bad idea on
- multi-user systems).
-
- - Added a check for /tmp binaries and -f locations in afl-fuzz.
-
---------------
-Version 1.01b:
---------------
-
- - Added dictionaries for XML and GIF.
-
---------------
-Version 1.00b:
---------------
-
- - Slightly improved the performance of minimize_corpus.sh, especially on
- Linux.
-
- - Made a couple of improvements to calibration timeouts for resumed scans.
-
---------------
-Version 0.99b:
---------------
-
- - Fixed minimize_corpus.sh to work with dash, as suggested by Jakub Wilk.
-
- - Modified minimize_corpus.sh to try locate afl-showmap in $PATH and ./.
- The first part requested by Jakub Wilk.
-
- - Added support for afl-as --version, as required by one funky build
- script. Reported by William Robinet.
-
---------------
-Version 0.98b:
---------------
-
- - Added a dictionary for TIFF.
-
- - Fixed another cosmetic snafu with stage exec counts for -x.
-
- - Switched afl-plot to /bin/sh, since it seems bashism-free. Also tried
- to remove any obvious bashisms from other experimental/ scripts,
- most notably including minimize_corpus.sh and triage_crashes.sh.
- Requested by Jonathan Gray.
-
---------------
-Version 0.97b:
---------------
-
- - Fixed cosmetic issues around the naming of -x strategy files.
-
- - Added a dictionary for JPEG.
-
- - Fixed a very rare glitch when running instrumenting 64-bit code that makes
- heavy use of xmm registers that are also touched by glibc.
-
---------------
-Version 0.96b:
---------------
-
- - Added support for extra dictionaries, provided testcases/_extras/png/
- as a demo.
-
- - Fixed a minor bug in number formatting routines used by the UI.
-
- - Added several additional PNG test cases that are relatively unlikely
- to be hit by chance.
-
- - Fixed afl-plot syntax for gnuplot 5.x. Reported by David Necas.
-
---------------
-Version 0.95b:
---------------
-
- - Cleaned up the OSX ReportCrash code. Thanks to Tobias Ospelt for help.
-
- - Added some extra tips for AFL_NO_FORKSERVER on OSX.
-
- - Refreshed the INSTALL file.
-
---------------
-Version 0.94b:
---------------
-
- - Added in-place resume (-i-) to address a common user complaint.
-
- - Added an awful workaround for ReportCrash on MacOS X. Problem
- spotted by Joseph Gentle.
-
---------------
-Version 0.93b:
---------------
-
- - Fixed the link() workaround, as reported by Jakub Wilk.
-
---------------
-Version 0.92b:
---------------
-
- - Added support for reading test cases from another filesystem.
- Requested by Jakub Wilk.
-
- - Added pointers to the mailing list.
-
- - Added a sample PDF document.
-
---------------
-Version 0.91b:
---------------
-
- - Refactored minimize_corpus.sh to make it a bit more user-friendly and to
- select for smallest files, not largest bitmaps. Offers a modest corpus
- size improvement in most cases.
-
- - Slightly improved the performance of splicing code.
-
---------------
-Version 0.90b:
---------------
-
- - Moved to an algorithm where paths are marked as preferred primarily based
- on size and speed, rather than bitmap coverage. This should offer
- noticeable performance gains in many use cases.
-
- - Refactored path calibration code; calibration now takes place as soon as a
- test case is discovered, to facilitate better prioritization decisions later
- on.
-
- - Changed the way of marking variable paths to avoid .state metadata
- inconsistencies.
-
- - Made sure that calibration routines always create a new test case to avoid
- hypothetical problems with utilities that modify the input file.
-
- - Added bitmap saturation to fuzzer stats and plot data.
-
- - Added a testcase for JPEG XR.
-
- - Added a tty check for the colors warning in Makefile, to keep distro build
- logs tidy. Suggested by Jakub Wilk.
-
---------------
-Version 0.89b:
---------------
-
- - Renamed afl-plot.sh to afl-plot, as requested by Padraig Brady.
-
- - Improved the compatibility of afl-plot with older versions of gnuplot.
-
- - Added banner information to fuzzer_stats, populated it to afl-plot.
-
---------------
-Version 0.88b:
---------------
-
- - Added support for plotting, with design and implementation based on a
- prototype design proposed by Michael Rash. Huge thanks!
-
- - Added afl-plot.sh, which allows you to, well, generate a nice plot using
- this data.
-
- - Refactored the code slightly to make more frequent updates to fuzzer_stats
- and to provide more detail about synchronization.
-
- - Added an fflush(stdout) call for non-tty operation, as requested by
- Joonas Kuorilehto.
-
- - Added some detail to fuzzer_stats for parity with plot_file.
-
---------------
-Version 0.87b:
---------------
-
- - Added support for MSAN, via AFL_USE_MSAN, same gotchas as for ASAN.
-
---------------
-Version 0.86b:
---------------
-
- - Added AFL_NO_FORKSRV, allowing the forkserver to be bypassed. Suggested
- by Ryan Govostes.
-
- - Simplified afl-showmap.c to make use of the no-forkserver mode.
-
- - Made minor improvements to crash_triage.sh, as suggested by Jakub Wilk.
-
---------------
-Version 0.85b:
---------------
-
- - Fixed the CPU counting code - no sysctlbyname() on OpenBSD, d'oh. Bug
- reported by Daniel Dickman.
-
- - Made a slight correction to error messages - the advice on testing
- with ulimit was a tiny bit off by a factor of 1024.
-
---------------
-Version 0.84b:
---------------
-
- - Added support for the CPU widget on some non-Linux platforms (I hope).
- Based on feedback from Ryan Govostes.
-
- - Cleaned up the changelog (very meta).
-
---------------
-Version 0.83b:
---------------
-
- - Added experimental/clang_asm_normalize/ and related notes in
- env_variables.txt and afl-as.c. Thanks to Ryan Govostes for the idea.
-
- - Added advice on hardware utilization in README.
-
---------------
-Version 0.82b:
---------------
-
- - Made additional fixes for Xcode support, juggling -Q and -q flags. Thanks to
- Ryan Govostes.
-
- - Added a check for __asm__ blocks and switches to .intel_syntax in assembly.
- Based on feedback from Ryan Govostes.
-
---------------
-Version 0.81b:
---------------
-
- - A workaround for Xcode 6 as -Q flag glitch. Spotted by Ryan Govostes.
-
- - Improved Solaris build instructions, as suggested by Martin Carpenter.
-
- - Fix for a slightly busted path scoring conditional. Minor practical impact.
-
---------------
-Version 0.80b:
---------------
-
- - Added a check for $PATH-induced loops. Problem noticed by Kartik Agaram.
-
- - Added AFL_KEEP_ASSEMBLY for easier troubleshooting.
-
- - Added an override for AFL_USE_ASAN if set at afl compile time. Requested by
- Hanno Boeck.
-
---------------
-Version 0.79b:
---------------
-
- - Made minor adjustments to path skipping logic.
-
- - Made several documentation updates to reflect the path selection changes
- made in 0.78b.
-
---------------
-Version 0.78b:
---------------
-
- - Added a CPU governor check. Bug report from Joe Zbiciak.
-
- - Favored paths are now selected strictly based on new edges, not hit
- counts. This speeds up the first pass by a factor of 3-6x without
- significantly impacting ultimate coverage (tested with libgif, libpng,
- libjpeg).
-
- It also allows some performance & memory usage improvements by making
- some of the in-memory bitmaps much smaller.
-
- - Made multiple significant performance improvements to bitmap checking
- functions, plus switched to a faster hash.
-
- - Owing largely to these optimizations, bumped the size of the bitmap to
- 64k and added a warning to detect older binaries that rely on smaller
- bitmaps.
-
---------------
-Version 0.77b:
---------------
-
- - Added AFL_SKIP_CHECKS to bypass binary checks when really warranted.
- Feature requested by Jakub Wilk.
-
- - Fixed a couple of typos.
-
- - Added a warning for runs that are aborted early on.
-
---------------
-Version 0.76b:
---------------
-
- - Incorporated another signal handling fix for Solaris. Suggestion
- submitted by Martin Carpenter.
-
---------------
-Version 0.75b:
---------------
-
- - Implemented a slightly more "elegant" kludge for the %llu glitch (see
- types.h).
-
- - Relaxed CPU load warnings to stay in sync with reality.
-
---------------
-Version 0.74b:
---------------
-
- - Switched to more responsive exec speed averages and better UI speed
- scaling.
-
- - Fixed a bug with interrupted reads on Solaris. Issue spotted by Martin
- Carpenter.
-
---------------
-Version 0.73b:
---------------
-
- - Fixed a stray memcpy() instead of memmove() on overlapping buffers.
- Mostly harmless but still dumb. Mistake spotted thanks to David Higgs.
-
---------------
-Version 0.72b:
---------------
-
- - Bumped map size up to 32k. You may want to recompile instrumented
- binaries (but nothing horrible will happen if you don't).
-
- - Made huge performance improvements for bit-counting functions.
-
- - Default optimizations now include -funroll-loops. This should have
- interesting effects on the instrumentation. Frankly, I'm just going to
- ship it and see what happens next. I have a good feeling about this.
-
- - Made a fix for stack alignment crash on MacOS X 10.10; looks like the
- rhetorical question in the comments in afl-as.h has been answered.
- Tracked down by Mudge Zatko.
-
---------------
-Version 0.71b:
---------------
-
- - Added a fix for the nonsensical MacOS ELF check. Spotted by Mudge Zatko.
-
- - Made some improvements to ASAN checks.
-
---------------
-Version 0.70b:
---------------
-
- - Added explicit detection of ASANified binaries.
-
- - Fixed compilation issues on Solaris. Reported by Martin Carpenter.
-
---------------
-Version 0.69b:
---------------
-
- - Improved the detection of non-instrumented binaries.
-
- - Made the crash counter in -C mode accurate.
-
- - Fixed an obscure install bug that made afl-as non-functional with the tool
- installed to /usr/bin instead of /usr/local/bin. Found by Florian Kiersch.
-
- - Fixed for a cosmetic SIGFPE when Ctrl-C is pressed while the fork server
- is spinning up.
-
---------------
-Version 0.68b:
---------------
-
- - Added crash exploration mode! Woot!
-
---------------
-Version 0.67b:
---------------
-
- - Fixed several more typos, the project is now cartified 100% typo-free.
- Thanks to Thomas Jarosch and Jakub Wilk.
-
- - Made a change to write fuzzer_stats early on.
-
- - Fixed a glitch when (not!) running on MacOS X as root. Spotted by Tobias
- Ospelt.
-
- - Made it possible to override -O3 in Makefile. Suggested by Jakub Wilk.
-
---------------
-Version 0.66b:
---------------
-
- - Fixed a very obscure issue with build systems that use gcc as an assembler
- for hand-written .s files; this would confuse afl-as. Affected nss, reported
- by Hanno Boeck.
-
- - Fixed a bug when cleaning up synchronized fuzzer output dirs. Issue reported
- by Thomas Jarosch.
-
---------------
-Version 0.65b:
---------------
-
- - Cleaned up shell printf escape codes in Makefile. Reported by Jakub Wilk.
-
- - Added more color to fuzzer_stats, provided short documentation of the file
- format, and made several other stats-related improvements.
-
---------------
-Version 0.64b:
---------------
-
- - Enabled GCC support on MacOS X.
-
---------------
-Version 0.63b:
---------------
-
- - Provided a new, simplified way to pass data in files (@@). See README.
-
- - Made additional fixes for 64-bit MacOS X, working around a crashing bug in
- their linker (umpf) and several other things. It's alive!
-
- - Added a minor workaround for a bug in 64-bit FreeBSD (clang -m32 -g doesn't
- work on that platform, but clang -m32 does, so we no longer insert -g).
-
- - Added a build-time warning for inverse video terminals and better
- instructions in status_screen.txt.
-
---------------
-Version 0.62b:
---------------
-
- - Made minor improvements to the allocator, as suggested by Tobias Ospelt.
-
- - Added example instrumented memcmp() in experimental/instrumented_cmp.
-
- - Added a speculative fix for MacOS X (clang detection, again).
-
- - Fixed typos in parallel_fuzzing.txt. Problems spotted by Thomas Jarosch.
-
---------------
-Version 0.61b:
---------------
-
- - Fixed a minor issue with clang detection on systems with a clang cc
- wrapper, so that afl-gcc doesn't confuse it with GCC.
-
- - Made cosmetic improvements to docs and to the CPU load indicator.
-
- - Fixed a glitch with crash removal (README.txt left behind, d'oh).
-
---------------
-Version 0.60b:
---------------
-
- - Fixed problems with jump tables generated by exotic versions of GCC. This
- solves an outstanding problem on OpenBSD when using afl-gcc + PIE (not
- present with afl-clang).
-
- - Fixed permissions on one of the sample archives.
-
- - Added a lahf / sahf workaround for OpenBSD (their assembler doesn't know
- about these opcodes).
-
- - Added docs/INSTALL.
-
---------------
-Version 0.59b:
---------------
-
- - Modified 'make install' to also install test cases.
-
- - Provided better pointers to installed README in afl-fuzz.
-
- - More work on RLIMIT_AS for OpenBSD.
-
---------------
-Version 0.58b:
---------------
-
- - Added a core count check on Linux.
-
- - Refined the code for the lack-of-RLIMIT_AS case on OpenBSD.
-
- - Added a rudimentary CPU utilization meter to help with optimal loading.
-
---------------
-Version 0.57b:
---------------
-
- - Made fixes to support FreeBSD and OpenBSD: use_64bit is now inferred if not
- explicitly specified when calling afl-as, and RLIMIT_AS is behind an #ifdef.
- Thanks to Fabian Keil and Jonathan Gray for helping troubleshoot this.
-
- - Modified 'make install' to also install docs (in /usr/local/share/doc/afl).
-
- - Fixed a typo in status_screen.txt.
-
- - Made a couple of Makefile improvements as proposed by Jakub Wilk.
-
---------------
-Version 0.56b:
---------------
-
- - Added probabilistic instrumentation density reduction in ASAN mode. This
- compensates for ASAN-specific branches in a crude but workable way.
-
- - Updated notes_for_asan.txt.
-
---------------
-Version 0.55b:
---------------
-
- - Implemented smarter out_dir behavior, automatically deleting directories
- that don't contain anything of special value. Requested by several folks,
- including Hanno Boeck.
-
- - Added more detail in fuzzer_stats (start time, run time, fuzzer PID).
-
- - Implemented support for configurable install prefixes in Makefile
- ($PREFIX), as requested by Luca Barbato.
-
- - Made it possible to resume by doing -i <out_dir>, without having to specify
- -i <out_dir>/queue/.
-
---------------
-Version 0.54b:
---------------
-
- - Added a fix for -Wformat warning messages (oops, I thought this had been in
- place for a while).
-
---------------
-Version 0.53b:
---------------
-
- - Redesigned the crash & hang duplicate detection code to better deal with
- fault conditions that can be reached in a multitude of ways.
-
- The old approach could be compared to hashing stack traces to de-dupe
- crashes, a method prone to crash count inflation. The alternative I
- wanted to avoid would be equivalent to just looking at crash %eip,
- which can have false negatives in common functions such as memcpy().
-
- The middle ground currently used in afl-fuzz can be compared to looking
- at every line item in the stack trace and tagging crashes as unique if
- we see any function name that we haven't seen before (or if something that
- we have *always* seen there suddenly disappears). We do the comparison
- without paying any attention to ordering or hit counts. This can still
- cause some crash inflation early on, but the problem will quickly taper
- off. So, you may get 20 dupes instead of 5,000.
-
- - Added a fix for harmless but absurd trim ratios shown if the first exec in
- the trimmer timed out. Spotted by @EspenGx.
-
---------------
-Version 0.52b:
---------------
-
- - Added a quick summary of the contents in experimental/.
-
- - Made a fix to the process of writing fuzzer_stats.
-
- - Slightly reorganized the .state/ directory, now recording redundant paths,
- too. Note that this breaks the ability to properly resume older sessions
- - sorry about that.
-
- (To fix this, simply move <out_dir>/.state/* from an older run
- to <out_dir>/.state/deterministic_done/*.)
-
---------------
-Version 0.51b:
---------------
-
- - Changed the search order for afl-as to avoid the problem with older copies
- installed system-wide; this also means that I can remove the Makefile check
- for that.
-
- - Made it possible to set instrumentation ratio of 0%.
-
- - Introduced some typos, fixed others.
-
- - Fixed the test_prev target in Makefile, as reported by Ozzy Johnson.
-
---------------
-Version 0.50b:
---------------
-
- - Improved the 'make install' logic, as suggested by Padraig Brady.
-
- - Revamped various bits of the documentation, especially around perf_tips.txt;
- based on the feedback from Alexander Cherepanov.
-
- - Added AFL_INST_RATIO to afl-as. The only case where this comes handy is
- ffmpeg, at least as far as I can tell. (Trivia: the current version of
- ffmpeg ./configure also ignores CC and --cc, probably unintentionally).
-
- - Added documentation for all environmental variables (env_variables.txt).
-
- - Implemented a visual warning for excessive or insufficient bitmap density.
-
- - Changed afl-gcc to add -O3 by default; use AFL_DONT_OPTIMIZE if you don't
- like that. Big speed gain for ffmpeg, so seems like a good idea.
-
- - Made a regression fix to afl-as to ignore .LBB labels in gcc mode.
-
---------------
-Version 0.49b:
---------------
-
- - Fixed more typos, as found by Jakub Wilk.
-
- - Added support for clang!
-
- - Changed AFL_HARDEN to *not* include ASAN by default. Use AFL_USE_ASAN if
- needed. The reasons for this are in notes_for_asan.txt.
-
- - Switched from configure auto-detection to isatty() to keep afl-as and
- afl-gcc quiet.
-
- - Improved installation process to properly create symlinks, rather than
- copies of binaries.
-
---------------
-Version 0.48b:
---------------
-
- - Improved afl-fuzz to force-set ASAN_OPTIONS=abort_on_error=1. Otherwise,
- ASAN crashes wouldn't be caught at all. Reported by Hanno Boeck.
-
- - Improved Makefile mkdir logic, as suggested by Hanno Boeck.
-
- - Improved the 64-bit instrumentation to properly save r8-r11 registers in
- the x86 setup code. The old behavior could cause rare problems running
- *without* instrumentation when the first function called in a particular
- .o file has 5+ parameters. No impact on code running under afl-fuzz or
- afl-showmap. Issue spotted by Padraig Brady.
-
---------------
-Version 0.47b:
---------------
-
- - Fixed another Makefile bug for parallel builds of afl. Problem identified
- by Richard W. M. Jones.
-
- - Added support for suffixes for -m.
-
- - Updated the documentation and added notes_for_asan.txt. Based on feedback
- from Hanno Boeck, Ben Laurie, and others.
-
- - Moved the project to http://lcamtuf.coredump.cx/afl/.
-
---------------
-Version 0.46b:
---------------
-
- - Cleaned up Makefile dependencies for parallel builds. Requested by
- Richard W. M. Jones.
-
- - Added support for DESTDIR in Makefile. Once again suggested by
- Richard W. M. Jones :-)
-
- - Removed all the USE_64BIT stuff; we now just auto-detect compilation mode.
- As requested by many callers to the show.
-
- - Fixed rare problems with programs that use snippets of assembly and
- switch between .code32 and .code64. Addresses a glitch spotted by
- Hanno Boeck with compiling ToT gdb.
-
---------------
-Version 0.45b:
---------------
-
- - Implemented a test case trimmer. Results in 20-30% size reduction for many
- types of work loads, with very pronounced improvements in path discovery
- speeds.
-
- - Added better warnings for various problems with input directories.
-
- - Added a Makefile warning for older copies, based on counterintuitive
- behavior observed by Hovik Manucharyan.
-
- - Added fuzzer_stats file for status monitoring. Suggested by @dronesec.
-
- - Fixed moar typos, thanks to Alexander Cherepanov.
-
- - Implemented better warnings for ASAN memory requirements, based on calls
- from several angry listeners.
-
- - Switched to saner behavior with non-tty stdout (less output generated,
- no ANSI art).
-
---------------
-Version 0.44b:
---------------
-
- - Added support for AFL_CC and AFL_CXX, based on a patch from Ben Laurie.
-
- - Replaced afl-fuzz -S -D with -M for simplicity.
-
- - Added a check for .section .text; lack of this prevented main() from
- getting instrumented for some users. Reported by Tom Ritter.
-
- - Reorganized the testcases/ directory.
-
- - Added an extra check to confirm that the build is operational.
-
- - Made more consistent use of color reset codes, as suggested by Oliver
- Kunz.
-
---------------
-Version 0.43b:
---------------
-
- - Fixed a bug with 64-bit gcc -shared relocs.
-
- - Removed echo -e from Makefile for compatibility with dash. Suggested
- by Jakub Wilk.
-
- - Added status_screen.txt.
-
- - Added experimental/canvas_harness.
-
- - Made a minor change to the Makefile GCC check. Suggested by Hanno Boeck.
-
---------------
-Version 0.42b:
---------------
-
- - Fixed a bug with red zone handling for 64-bit (oops!). Problem reported by
- Felix Groebert.
-
- - Implemented horribly experimental ARM support in experimental/arm_support.
-
- - Made several improvements to error messages.
-
- - Added AFL_QUIET to silence afl-gcc and afl-as when using wonky build
- systems. Reported by Hanno Boeck.
-
- - Improved check for 64-bit compilation, plus several sanity checks
- in Makefile.
-
---------------
-Version 0.41b:
---------------
-
- - Fixed a fork served bug for processes that call execve().
-
- - Made minor compatibility fixes to Makefile, afl-gcc; suggested by Jakub
- Wilk.
-
- - Fixed triage_crashes.sh to work with the new layout of output directories.
- Suggested by Jakub Wilk.
-
- - Made multiple performance-related improvements to the injected
- instrumentation.
-
- - Added visual indication of the number of imported paths.
-
- - Fixed afl-showmap to make it work well with new instrumentation.
-
- - Added much better error messages for crashes when importing test cases
- or otherwise calibrating the binary.
-
---------------
-Version 0.40b:
---------------
-
- - Added support for parallelized fuzzing. Inspired by earlier patch
- from Sebastian Roschke.
-
- - Added an example in experimental/distributed_fuzzing/.
-
---------------
-Version 0.39b:
---------------
-
- - Redesigned status screen, now 90% more spiffy.
-
- - Added more verbose and user-friendly messages for some common problems.
-
- - Modified the resumption code to reconstruct path depth.
-
- - Changed the code to inhibit core dumps and improve the ability to detect
- SEGVs.
-
- - Added a check for redirection of core dumps to programs.
-
- - Made a minor improvement to the handling of variable paths.
-
- - Made additional performance tweaks to afl-fuzz, chiefly around mem limits.
-
- - Added performance_tips.txt.
-
---------------
-Version 0.38b:
---------------
-
- - Fixed an fd leak and +cov tracking bug resulting from changes in 0.37b.
-
- - Implemented auto-scaling for screen update speed.
-
- - Added a visual indication when running in non-instrumented mode.
-
---------------
-Version 0.37b:
---------------
-
- - Added fuzz state tracking for more seamless resumption of aborted
- fuzzing sessions.
-
- - Removed the -D option, as it's no longer necessary.
-
- - Refactored calibration code and improved startup reporting.
-
- - Implemented dynamically scaled timeouts, so that you don't need to
- play with -t except in some very rare cases.
-
- - Added visual notification for slow binaries.
-
- - Improved instrumentation to explicitly cover the other leg of every
- branch.
-
---------------
-Version 0.36b:
---------------
-
- - Implemented fork server support to avoid the overhead of execve(). A
- nearly-verbatim design from Jann Horn; still pending part 2 that would
- also skip initial setup steps (thinking about reliable heuristics now).
-
- - Added a check for shell scripts used as fuzz targets.
-
- - Added a check for fuzz jobs that don't seem to be finding anything.
-
- - Fixed the way IGNORE_FINDS works (was a bit broken after adding splicing
- and path skip heuristics).
-
---------------
-Version 0.35b:
---------------
-
- - Properly integrated 64-bit instrumentation into afl-as.
-
---------------
-Version 0.34b:
---------------
-
- - Added a new exec count classifier (the working theory is that it gets
- meaningful coverage with fewer test cases spewed out).
-
---------------
-Version 0.33b:
---------------
-
- - Switched to new, somewhat experimental instrumentation that tries to
- target only arcs, rather than every line. May be fragile, but is a lot
- faster (2x+).
-
- - Made several other cosmetic fixes and typo corrections, thanks to
- Jakub Wilk.
-
---------------
-Version 0.32b:
---------------
-
- - Another take at fixing the C++ exception thing. Reported by Jakub Wilk.
-
---------------
-Version 0.31b:
---------------
-
- - Made another fix to afl-as to address a potential problem with newer
- versions of GCC (introduced in 0.28b). Thanks to Jann Horn.
-
---------------
-Version 0.30b:
---------------
-
- - Added more detail about the underlying operations in file names.
-
---------------
-Version 0.29b:
---------------
-
- - Made some general improvements to chunk operations.
-
---------------
-Version 0.28b:
---------------
-
- - Fixed C++ exception handling in newer versions of GCC. Problem diagnosed
- by Eberhard Mattes.
-
- - Fixed the handling of the overflow flag. Once again, thanks to
- Eberhard Mattes.
-
---------------
-Version 0.27b:
---------------
-
- - Added prioritization of new paths over the already-fuzzed ones.
-
- - Included spliced test case ID in the output file name.
-
- - Fixed a rare, cosmetic null ptr deref after Ctrl-C.
-
- - Refactored the code to make copies of test cases in the output directory.
-
- - Switched to better output file names, keeping track of stage and splicing
- sources.
-
---------------
-Version 0.26b:
---------------
-
- - Revamped storage of testcases, -u option removed,
-
- - Added a built-in effort minimizer to get rid of potentially redundant
- inputs,
-
- - Provided a testcase count minimization script in experimental/,
-
- - Made miscellaneous improvements to directory and file handling.
-
- - Fixed a bug in timeout detection.
-
---------------
-Version 0.25b:
---------------
-
- - Improved count-based instrumentation.
-
- - Improved the hang deduplication logic.
-
- - Added -cov prefixes for test cases.
-
- - Switched from readdir() to scandir() + alphasort() to preserve ordering of
- test cases.
-
- - Added a splicing strategy.
-
- - Made various minor UI improvements and several other bugfixes.
-
---------------
-Version 0.24b:
---------------
-
- - Added program name to the status screen, plus the -T parameter to go with
- it.
-
---------------
-Version 0.23b:
---------------
-
- - Improved the detection of variable behaviors.
-
- - Added path depth tracking,
-
- - Improved the UI a bit,
-
- - Switched to simplified (XOR-based) tuple instrumentation.
-
---------------
-Version 0.22b:
---------------
-
- - Refactored the handling of long bitflips and some swaps.
-
- - Fixed the handling of gcc -pipe, thanks to anonymous reporter.
-
---------------
-Version 0.21b:
---------------
-
- - Initial public release.
diff --git a/chromium/third_party/afl/src/docs/INSTALL b/chromium/third_party/afl/src/docs/INSTALL
deleted file mode 100644
index 4168e88f587..00000000000
--- a/chromium/third_party/afl/src/docs/INSTALL
+++ /dev/null
@@ -1,183 +0,0 @@
-=========================
-Installation instructions
-=========================
-
- This document provides basic installation instructions and discusses known
- issues for a variety of platforms. See README for the general instruction
- manual.
-
-1) Linux on x86
----------------
-
-This platform is expected to work well. Compile the program with:
-
-$ make
-
-You can start using the fuzzer without installation, but it is also possible to
-install it with:
-
-# make install
-
-There are no special dependencies to speak of; you will need GNU make and a
-working compiler (gcc or clang). Some of the optional scripts bundled with the
-program may depend on bash, gdb, and similar basic tools.
-
-If you are using clang, please review llvm_mode/README.llvm; the LLVM
-integration mode can offer substantial performance gains compared to the
-traditional approach.
-
-You may have to change several settings to get optimal results (most notably,
-disable crash reporting utilities and switch to a different CPU governor), but
-afl-fuzz will guide you through that if necessary.
-
-2) OpenBSD, FreeBSD, NetBSD on x86
-----------------------------------
-
-Similarly to Linux, these platforms are expected to work well and are
-regularly tested. Compile everything with GNU make:
-
-$ gmake
-
-Note that BSD make will *not* work; if you do not have gmake on your system,
-please install it first. As on Linux, you can use the fuzzer itself without
-installation, or install it with:
-
-# gmake install
-
-Keep in mind that if you are using csh as your shell, the syntax of some of the
-shell commands given in the README and other docs will be different.
-
-The llvm_mode requires a dynamically linked, fully-operational installation of
-clang. At least on FreeBSD, the clang binaries are static and do not include
-some of the essential tools, so if you want to make it work, you may need to
-follow the instructions in llvm_mode/README.llvm.
-
-Beyond that, everything should work as advertised.
-
-The QEMU mode is currently supported only on Linux. I think it's just a QEMU
-problem, I couldn't get a vanilla copy of user-mode emulation support working
-correctly on BSD at all.
-
-3) MacOS X on x86
------------------
-
-MacOS X should work, but there are some gotchas due to the idiosyncrasies of
-the platform. On top of this, I have limited release testing capabilities
-and depend mostly on user feedback.
-
-To build AFL, install Xcode and follow the general instructions for Linux.
-
-The Xcode 'gcc' tool is just a wrapper for clang, so be sure to use afl-clang
-to compile any instrumented binaries; afl-gcc will fail unless you have GCC
-installed from another source (in which case, please specify AFL_CC and
-AFL_CXX to point to the "real" GCC binaries).
-
-Only 64-bit compilation will work on the platform; porting the 32-bit
-instrumentation would require a fair amount of work due to the way OS X
-handles relocations, and today, virtually all MacOS X boxes are 64-bit.
-
-The crash reporting daemon that comes by default with MacOS X will cause
-problems with fuzzing. You need to turn it off by following the instructions
-provided here: http://goo.gl/CCcd5u
-
-The fork() semantics on OS X are a bit unusual compared to other unix systems
-and definitely don't look POSIX-compliant. This means two things:
-
- - Fuzzing will be probably slower than on Linux. In fact, some folks report
- considerable performance gains by running the jobs inside a Linux VM on
- MacOS X.
-
- - Some non-portable, platform-specific code may be incompatible with the
- AFL forkserver. If you run into any problems, set AFL_NO_FORKSRV=1 in the
- environment before starting afl-fuzz.
-
-User emulation mode of QEMU does not appear to be supported on MacOS X, so
-black-box instrumentation mode (-Q) will not work.
-
-The llvm_mode requires a fully-operational installation of clang. The one that
-comes with Xcode is missing some of the essential headers and helper tools.
-See llvm_mode/README.llvm for advice on how to build the compiler from scratch.
-
-4) Linux or *BSD on non-x86 systems
------------------------------------
-
-Standard build will fail on non-x86 systems, but you should be able to
-leverage two other options:
-
- - The LLVM mode (see llvm_mode/README.llvm), which does not rely on
- x86-specific assembly shims. It's fast and robust, but requires a
- complete installation of clang.
-
- - The QEMU mode (see qemu_mode/README.qemu), which can be also used for
- fuzzing cross-platform binaries. It's slower and more fragile, but
- can be used even when you don't have the source for the tested app.
-
-If you're not sure what you need, you need the LLVM mode. To get it, try:
-
-$ AFL_NO_X86=1 gmake && gmake -C llvm_mode
-
-...and compile your target program with afl-clang-fast or afl-clang-fast++
-instead of the traditional afl-gcc or afl-clang wrappers.
-
-5) Solaris on x86
------------------
-
-The fuzzer reportedly works on Solaris, but I have not tested this first-hand,
-and the user base is fairly small, so I don't have a lot of feedback.
-
-To get the ball rolling, you will need to use GNU make and GCC or clang. I'm
-being told that the stock version of GCC that comes with the platform does not
-work properly due to its reliance on a hardcoded location for 'as' (completely
-ignoring the -B parameter or $PATH).
-
-To fix this, you may want to build stock GCC from the source, like so:
-
-$ ./configure --prefix=$HOME/gcc --with-gnu-as --with-gnu-ld \
- --with-gmp-include=/usr/include/gmp --with-mpfr-include=/usr/include/mpfr
-$ make
-$ sudo make install
-
-Do *not* specify --with-as=/usr/gnu/bin/as - this will produce a GCC binary that
-ignores the -B flag and you will be back to square one.
-
-Note that Solaris reportedly comes withe crash reporting enabled, which causes
-problems with crashes being misinterpreted as hangs, similarly to the gotchas
-for Linux and MacOS X. AFL does not auto-detect crash reporting on this
-particular platform, but you may need to run the following command:
-
-$ coreadm -d global -d global-setid -d process -d proc-setid \
- -d kzone -d log
-
-User emulation mode of QEMU is not available on Solaris, so black-box
-instrumentation mode (-Q) will not work.
-
-6) Everything else
-------------------
-
-You're on your own. On POSIX-compliant systems, you may be able to compile and
-run the fuzzer; and the LLVM mode may offer a way to instrument non-x86 code.
-
-The fuzzer will not run on Windows. It will also not work under Cygwin. It
-could be ported to the latter platform fairly easily, but it's a pretty bad
-idea, because Cygwin is extremely slow. It makes much more sense to use
-VirtualBox or so to run a hardware-accelerated Linux VM; it will run around
-20x faster or so. If you have a *really* compelling use case for Cygwin, let
-me know.
-
-Although Android on x86 should theoretically work, the stock kernel may have
-SHM support compiled out, and if so, you may have to address that issue first.
-It's possible that all you need is this workaround:
-
- https://github.com/pelya/android-shmem
-
-Joshua J. Drake notes that the Android linker adds a shim that automatically
-intercepts SIGSEGV and related signals. To fix this issue and be able to see
-crashes, you need to put this at the beginning of the fuzzed program:
-
- signal(SIGILL, SIG_DFL);
- signal(SIGABRT, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
- signal(SIGFPE, SIG_DFL);
- signal(SIGSEGV, SIG_DFL);
-
-You may need to #include <signal.h> first.
diff --git a/chromium/third_party/afl/src/docs/QuickStartGuide.txt b/chromium/third_party/afl/src/docs/QuickStartGuide.txt
deleted file mode 100644
index abe7032fda9..00000000000
--- a/chromium/third_party/afl/src/docs/QuickStartGuide.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-=====================
-AFL quick start guide
-=====================
-
-You should read docs/README. It's pretty short. If you really can't, here's
-how to hit the ground running:
-
-1) Compile AFL with 'make'. If build fails, see docs/INSTALL for tips.
-
-2) Find or write a reasonably fast and simple program that takes data from
- a file or stdin, processes it in a test-worthy way, then exits cleanly.
- If testing a network service, modify it to run in the foreground and read
- from stdin. When fuzzing a format that uses checksums, comment out the
- checksum verification code, too.
-
- The program must crash properly when a fault is encountered. Watch out for
- custom SIGSEGV or SIGABRT handlers and background processes. For tips on
- detecting non-crashing flaws, see section 11 in docs/README.
-
-3) Compile the program / library to be fuzzed using afl-gcc. A common way to
- do this would be:
-
- CC=/path/to/afl-gcc CXX=/path/to/afl-g++ ./configure --disable-shared
- make clean all
-
- If program build fails, ping <afl-users@googlegroups.com>.
-
-4) Get a small but valid input file that makes sense to the program. When
- fuzzing verbose syntax (SQL, HTTP, etc), create a dictionary as described in
- dictionaries/README.dictionaries, too.
-
-5) If the program reads from stdin, run 'afl-fuzz' like so:
-
- ./afl-fuzz -i testcase_dir -o findings_dir -- \
- /path/to/tested/program [...program's cmdline...]
-
- If the program takes input from a file, you can put @@ in the program's
- command line; AFL will put an auto-generated file name in there for you.
-
-6) Investigate anything shown in red in the fuzzer UI by promptly consulting
- docs/status_screen.txt.
-
-That's it. Sit back, relax, and - time permitting - try to skim through the
-following files:
-
- - docs/README - A general introduction to AFL,
- - docs/perf_tips.txt - Simple tips on how to fuzz more quickly,
- - docs/status_screen.txt - An explanation of the tidbits shown in the UI,
- - docs/parallel_fuzzing.txt - Advice on running AFL on multiple cores.
diff --git a/chromium/third_party/afl/src/docs/README b/chromium/third_party/afl/src/docs/README
deleted file mode 100644
index 501bdd43f91..00000000000
--- a/chromium/third_party/afl/src/docs/README
+++ /dev/null
@@ -1,507 +0,0 @@
-==================
-american fuzzy lop
-==================
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved.
- Released under terms and conditions of Apache License, Version 2.0.
-
- For new versions and additional information, check out:
- http://lcamtuf.coredump.cx/afl/
-
- To compare notes with other users or get notified about major new features,
- send a mail to <afl-users+subscribe@googlegroups.com>.
-
- ** See QuickStartGuide.txt if you don't have time to read this file. **
-
-1) Challenges of guided fuzzing
--------------------------------
-
-Fuzzing is one of the most powerful and proven strategies for identifying
-security issues in real-world software; it is responsible for the vast
-majority of remote code execution and privilege escalation bugs found to date
-in security-critical software.
-
-Unfortunately, fuzzing is also relatively shallow; blind, random mutations
-make it very unlikely to reach certain code paths in the tested code, leaving
-some vulnerabilities firmly outside the reach of this technique.
-
-There have been numerous attempts to solve this problem. One of the early
-approaches - pioneered by Tavis Ormandy - is corpus distillation. The method
-relies on coverage signals to select a subset of interesting seeds from a
-massive, high-quality corpus of candidate files, and then fuzz them by
-traditional means. The approach works exceptionally well, but requires such
-a corpus to be readily available. In addition, block coverage measurements
-provide only a very simplistic understanding of program state, and are less
-useful for guiding the fuzzing effort in the long haul.
-
-Other, more sophisticated research has focused on techniques such as program
-flow analysis ("concolic execution"), symbolic execution, or static analysis.
-All these methods are extremely promising in experimental settings, but tend
-to suffer from reliability and performance problems in practical uses - and
-currently do not offer a viable alternative to "dumb" fuzzing techniques.
-
-2) The afl-fuzz approach
-------------------------
-
-American Fuzzy Lop is a brute-force fuzzer coupled with an exceedingly simple
-but rock-solid instrumentation-guided genetic algorithm. It uses a modified
-form of edge coverage to effortlessly pick up subtle, local-scale changes to
-program control flow.
-
-Simplifying a bit, the overall algorithm can be summed up as:
-
- 1) Load user-supplied initial test cases into the queue,
-
- 2) Take next input file from the queue,
-
- 3) Attempt to trim the test case to the smallest size that doesn't alter
- the measured behavior of the program,
-
- 4) Repeatedly mutate the file using a balanced and well-researched variety
- of traditional fuzzing strategies,
-
- 5) If any of the generated mutations resulted in a new state transition
- recorded by the instrumentation, add mutated output as a new entry in the
- queue.
-
- 6) Go to 2.
-
-The discovered test cases are also periodically culled to eliminate ones that
-have been obsoleted by newer, higher-coverage finds; and undergo several other
-instrumentation-driven effort minimization steps.
-
-As a side result of the fuzzing process, the tool creates a small,
-self-contained corpus of interesting test cases. These are extremely useful
-for seeding other, labor- or resource-intensive testing regimes - for example,
-for stress-testing browsers, office applications, graphics suites, or
-closed-source tools.
-
-The fuzzer is thoroughly tested to deliver out-of-the-box performance far
-superior to blind fuzzing or coverage-only tools.
-
-3) Instrumenting programs for use with AFL
-------------------------------------------
-
-When source code is available, instrumentation can be injected by a companion
-tool that works as a drop-in replacement for gcc or clang in any standard build
-process for third-party code.
-
-The instrumentation has a fairly modest performance impact; in conjunction with
-other optimizations implemented by afl-fuzz, most programs can be fuzzed as fast
-or even faster than possible with traditional tools.
-
-The correct way to recompile the target program may vary depending on the
-specifics of the build process, but a nearly-universal approach would be:
-
-$ CC=/path/to/afl/afl-gcc ./configure
-$ make clean all
-
-For C++ programs, you'd would also want to set CXX=/path/to/afl/afl-g++.
-
-The clang wrappers (afl-clang and afl-clang++) can be used in the same way;
-clang users may also opt to leverage a higher-performance instrumentation mode,
-as described in llvm_mode/README.llvm.
-
-When testing libraries, you need to find or write a simple program that reads
-data from stdin or from a file and passes it to the tested library. In such a
-case, it is essential to link this executable against a static version of the
-instrumented library, or to make sure that the correct .so file is loaded at
-runtime (usually by setting LD_LIBRARY_PATH). The simplest option is a static
-build, usually possible via:
-
-$ CC=/path/to/afl/afl-gcc ./configure --disable-shared
-
-Setting AFL_HARDEN=1 when calling 'make' will cause the CC wrapper to
-automatically enable code hardening options that make it easier to detect
-simple memory bugs. Libdislocator, a helper library included with AFL (see
-libdislocator/README.dislocator) can help uncover heap corruption issues, too.
-
-PS. ASAN users are advised to review notes_for_asan.txt file for important
-caveats.
-
-4) Instrumenting binary-only apps
----------------------------------
-
-When source code is *NOT* available, the fuzzer offers experimental support for
-fast, on-the-fly instrumentation of black-box binaries. This is accomplished
-with a version of QEMU running in the lesser-known "user space emulation" mode.
-
-QEMU is a project separate from AFL, but you can conveniently build the
-feature by doing:
-
-$ cd qemu_mode
-$ ./build_qemu_support.sh
-
-For additional instructions and caveats, see qemu_mode/README.qemu.
-
-The mode is approximately 2-5x slower than compile-time instrumentation, is
-less conductive to parallelization, and may have some other quirks.
-
-5) Choosing initial test cases
-------------------------------
-
-To operate correctly, the fuzzer requires one or more starting file that
-contains a good example of the input data normally expected by the targeted
-application. There are two basic rules:
-
- - Keep the files small. Under 1 kB is ideal, although not strictly necessary.
- For a discussion of why size matters, see perf_tips.txt.
-
- - Use multiple test cases only if they are functionally different from
- each other. There is no point in using fifty different vacation photos
- to fuzz an image library.
-
-You can find many good examples of starting files in the testcases/ subdirectory
-that comes with this tool.
-
-PS. If a large corpus of data is available for screening, you may want to use
-the afl-cmin utility to identify a subset of functionally distinct files that
-exercise different code paths in the target binary.
-
-6) Fuzzing binaries
--------------------
-
-The fuzzing process itself is carried out by the afl-fuzz utility. This program
-requires a read-only directory with initial test cases, a separate place to
-store its findings, plus a path to the binary to test.
-
-For target binaries that accept input directly from stdin, the usual syntax is:
-
-$ ./afl-fuzz -i testcase_dir -o findings_dir /path/to/program [...params...]
-
-For programs that take input from a file, use '@@' to mark the location in
-the target's command line where the input file name should be placed. The
-fuzzer will substitute this for you:
-
-$ ./afl-fuzz -i testcase_dir -o findings_dir /path/to/program @@
-
-You can also use the -f option to have the mutated data written to a specific
-file. This is useful if the program expects a particular file extension or so.
-
-Non-instrumented binaries can be fuzzed in the QEMU mode (add -Q in the command
-line) or in a traditional, blind-fuzzer mode (specify -n).
-
-You can use -t and -m to override the default timeout and memory limit for the
-executed process; rare examples of targets that may need these settings touched
-include compilers and video decoders.
-
-Tips for optimizing fuzzing performance are discussed in perf_tips.txt.
-
-Note that afl-fuzz starts by performing an array of deterministic fuzzing
-steps, which can take several days, but tend to produce neat test cases. If you
-want quick & dirty results right away - akin to zzuf and other traditional
-fuzzers - add the -d option to the command line.
-
-7) Interpreting output
-----------------------
-
-See the status_screen.txt file for information on how to interpret the
-displayed stats and monitor the health of the process. Be sure to consult this
-file especially if any UI elements are highlighted in red.
-
-The fuzzing process will continue until you press Ctrl-C. At minimum, you want
-to allow the fuzzer to complete one queue cycle, which may take anywhere from a
-couple of hours to a week or so.
-
-There are three subdirectories created within the output directory and updated
-in real time:
-
- - queue/ - test cases for every distinctive execution path, plus all the
- starting files given by the user. This is the synthesized corpus
- mentioned in section 2.
-
- Before using this corpus for any other purposes, you can shrink
- it to a smaller size using the afl-cmin tool. The tool will find
- a smaller subset of files offering equivalent edge coverage.
-
- - crashes/ - unique test cases that cause the tested program to receive a
- fatal signal (e.g., SIGSEGV, SIGILL, SIGABRT). The entries are
- grouped by the received signal.
-
- - hangs/ - unique test cases that cause the tested program to time out. Note
- that when default (aggressive) timeout settings are in effect,
- this can be slightly noisy due to latency spikes and other
- natural phenomena.
-
-Crashes and hangs are considered "unique" if the associated execution paths
-involve any state transitions not seen in previously-recorded faults. If a
-single bug can be reached in multiple ways, there will be some count inflation
-early in the process, but this should quickly taper off.
-
-The file names for crashes and hangs are correlated with parent, non-faulting
-queue entries. This should help with debugging.
-
-When you can't reproduce a crash found by afl-fuzz, the most likely cause is
-that you are not setting the same memory limit as used by the tool. Try:
-
-$ LIMIT_MB=50
-$ ( ulimit -Sv $[LIMIT_MB << 10]; /path/to/tested_binary ... )
-
-Change LIMIT_MB to match the -m parameter passed to afl-fuzz. On OpenBSD,
-also change -Sv to -Sd.
-
-Any existing output directory can be also used to resume aborted jobs; try:
-
-$ ./afl-fuzz -i- -o existing_output_dir [...etc...]
-
-If you have gnuplot installed, you can also generate some pretty graphs for any
-active fuzzing task using afl-plot. For an example of how this looks like,
-see http://lcamtuf.coredump.cx/afl/plot/.
-
-8) Parallelized fuzzing
------------------------
-
-Every instance of afl-fuzz takes up roughly one core. This means that on
-multi-core systems, parallelization is necessary to fully utilize the hardware.
-For tips on how to fuzz a common target on multiple cores or multiple networked
-machines, please refer to parallel_fuzzing.txt.
-
-The parallel fuzzing mode also offers a simple way for interfacing AFL to other
-fuzzers, to symbolic or concolic execution engines, and so forth; again, see the
-last section of parallel_fuzzing.txt for tips.
-
-9) Fuzzer dictionaries
-----------------------
-
-By default, afl-fuzz mutation engine is optimized for compact data formats -
-say, images, multimedia, compressed data, regular expression syntax, or shell
-scripts. It is somewhat less suited for languages with particularly verbose and
-redundant verbiage - notably including HTML, SQL, or JavaScript.
-
-To avoid the hassle of building syntax-aware tools, afl-fuzz provides a way to
-seed the fuzzing process with an optional dictionary of language keywords,
-magic headers, or other special tokens associated with the targeted data type
-- and use that to reconstruct the underlying grammar on the go:
-
- http://lcamtuf.blogspot.com/2015/01/afl-fuzz-making-up-grammar-with.html
-
-To use this feature, you first need to create a dictionary in one of the two
-formats discussed in dictionaries/README.dictionaries; and then point the fuzzer
-to it via the -x option in the command line.
-
-(Several common dictionaries are already provided in that subdirectory, too.)
-
-There is no way to provide more structured descriptions of the underlying
-syntax, but the fuzzer will likely figure out some of this based on the
-instrumentation feedback alone. This actually works in practice, say:
-
- http://lcamtuf.blogspot.com/2015/04/finding-bugs-in-sqlite-easy-way.html
-
-PS. Even when no explicit dictionary is given, afl-fuzz will try to extract
-existing syntax tokens in the input corpus by watching the instrumentation
-very closely during deterministic byte flips. This works for some types of
-parsers and grammars, but isn't nearly as good as the -x mode.
-
-If a dictionary is really hard to come by, another option is to let AFL run
-for a while, and then use the token capture library that comes as a companion
-utility with AFL. For that, see libtokencap/README.tokencap.
-
-10) Crash triage
-----------------
-
-The coverage-based grouping of crashes usually produces a small data set that
-can be quickly triaged manually or with a very simple GDB or Valgrind script.
-Every crash is also traceable to its parent non-crashing test case in the
-queue, making it easier to diagnose faults.
-
-Having said that, it's important to acknowledge that some fuzzing crashes can be
-difficult quickly evaluate for exploitability without a lot of debugging and
-code analysis work. To assist with this task, afl-fuzz supports a very unique
-"crash exploration" mode enabled with the -C flag.
-
-In this mode, the fuzzer takes one or more crashing test cases as the input,
-and uses its feedback-driven fuzzing strategies to very quickly enumerate all
-code paths that can be reached in the program while keeping it in the
-crashing state.
-
-Mutations that do not result in a crash are rejected; so are any changes that
-do not affect the execution path.
-
-The output is a small corpus of files that can be very rapidly examined to see
-what degree of control the attacker has over the faulting address, or whether
-it is possible to get past an initial out-of-bounds read - and see what lies
-beneath.
-
-Oh, one more thing: for test case minimization, give afl-tmin a try. The tool
-can be operated in a very simple way:
-
-$ ./afl-tmin -i test_case -o minimized_result -- /path/to/program [...]
-
-The tool works with crashing and non-crashing test cases alike. In the crash
-mode, it will happily accept instrumented and non-instrumented binaries. In the
-non-crashing mode, the minimizer relies on standard AFL instrumentation to make
-the file simpler without altering the execution path.
-
-The minimizer accepts the -m, -t, -f and @@ syntax in a manner compatible with
-afl-fuzz.
-
-Another recent addition to AFL is the afl-analyze tool. It takes an input
-file, attempts to sequentially flip bytes, and observes the behavior of the
-tested program. It then color-codes the input based on which sections appear to
-be critical, and which are not; while not bulletproof, it can often offer quick
-insights into complex file formats. More info about its operation can be found
-near the end of technical_details.txt.
-
-11) Going beyond crashes
-------------------------
-
-Fuzzing is a wonderful and underutilized technique for discovering non-crashing
-design and implementation errors, too. Quite a few interesting bugs have been
-found by modifying the target programs to call abort() when, say:
-
- - Two bignum libraries produce different outputs when given the same
- fuzzer-generated input,
-
- - An image library produces different outputs when asked to decode the same
- input image several times in a row,
-
- - A serialization / deserialization library fails to produce stable outputs
- when iteratively serializing and deserializing fuzzer-supplied data,
-
- - A compression library produces an output inconsistent with the input file
- when asked to compress and then decompress a particular blob.
-
-Implementing these or similar sanity checks usually takes very little time;
-if you are the maintainer of a particular package, you can make this code
-conditional with #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION (a flag also
-shared with libfuzzer) or #ifdef __AFL_COMPILER (this one is just for AFL).
-
-12) Common-sense risks
-----------------------
-
-Please keep in mind that, similarly to many other computationally-intensive
-tasks, fuzzing may put strain on your hardware and on the OS. In particular:
-
- - Your CPU will run hot and will need adequate cooling. In most cases, if
- cooling is insufficient or stops working properly, CPU speeds will be
- automatically throttled. That said, especially when fuzzing on less
- suitable hardware (laptops, smartphones, etc), it's not entirely impossible
- for something to blow up.
-
- - Targeted programs may end up erratically grabbing gigabytes of memory or
- filling up disk space with junk files. AFL tries to enforce basic memory
- limits, but can't prevent each and every possible mishap. The bottom line
- is that you shouldn't be fuzzing on systems where the prospect of data loss
- is not an acceptable risk.
-
- - Fuzzing involves billions of reads and writes to the filesystem. On modern
- systems, this will be usually heavily cached, resulting in fairly modest
- "physical" I/O - but there are many factors that may alter this equation.
- It is your responsibility to monitor for potential trouble; with very heavy
- I/O, the lifespan of many HDDs and SSDs may be reduced.
-
- A good way to monitor disk I/O on Linux is the 'iostat' command:
-
- $ iostat -d 3 -x -k [...optional disk ID...]
-
-13) Known limitations & areas for improvement
----------------------------------------------
-
-Here are some of the most important caveats for AFL:
-
- - AFL detects faults by checking for the first spawned process dying due to
- a signal (SIGSEGV, SIGABRT, etc). Programs that install custom handlers for
- these signals may need to have the relevant code commented out. In the same
- vein, faults in child processed spawned by the fuzzed target may evade
- detection unless you manually add some code to catch that.
-
- - As with any other brute-force tool, the fuzzer offers limited coverage if
- encryption, checksums, cryptographic signatures, or compression are used to
- wholly wrap the actual data format to be tested.
-
- To work around this, you can comment out the relevant checks (see
- experimental/libpng_no_checksum/ for inspiration); if this is not possible,
- you can also write a postprocessor, as explained in
- experimental/post_library/.
-
- - There are some unfortunate trade-offs with ASAN and 64-bit binaries. This
- isn't due to any specific fault of afl-fuzz; see notes_for_asan.txt for
- tips.
-
- - There is no direct support for fuzzing network services, background
- daemons, or interactive apps that require UI interaction to work. You may
- need to make simple code changes to make them behave in a more traditional
- way. Preeny may offer a relatively simple option, too - see:
- https://github.com/zardus/preeny
-
- Some useful tips for modifying network-based services can be also found at:
- https://www.fastly.com/blog/how-to-fuzz-server-american-fuzzy-lop
-
- - AFL doesn't output human-readable coverage data. If you want to monitor
- coverage, use afl-cov from Michael Rash: https://github.com/mrash/afl-cov
-
- - Occasionally, sentient machines rise against their creators. If this
- happens to you, please consult http://lcamtuf.coredump.cx/prep/.
-
-Beyond this, see INSTALL for platform-specific tips.
-
-14) Special thanks
-------------------
-
-Many of the improvements to afl-fuzz wouldn't be possible without feedback,
-bug reports, or patches from:
-
- Jann Horn Hanno Boeck
- Felix Groebert Jakub Wilk
- Richard W. M. Jones Alexander Cherepanov
- Tom Ritter Hovik Manucharyan
- Sebastian Roschke Eberhard Mattes
- Padraig Brady Ben Laurie
- @dronesec Luca Barbato
- Tobias Ospelt Thomas Jarosch
- Martin Carpenter Mudge Zatko
- Joe Zbiciak Ryan Govostes
- Michael Rash William Robinet
- Jonathan Gray Filipe Cabecinhas
- Nico Weber Jodie Cunningham
- Andrew Griffiths Parker Thompson
- Jonathan Neuschfer Tyler Nighswander
- Ben Nagy Samir Aguiar
- Aidan Thornton Aleksandar Nikolich
- Sam Hakim Laszlo Szekeres
- David A. Wheeler Turo Lamminen
- Andreas Stieger Richard Godbee
- Louis Dassy teor2345
- Alex Moneger Dmitry Vyukov
- Keegan McAllister Kostya Serebryany
- Richo Healey Martijn Bogaard
- rc0r Jonathan Foote
- Christian Holler Dominique Pelle
- Jacek Wielemborek Leo Barnes
- Jeremy Barnes Jeff Trull
- Guillaume Endignoux ilovezfs
- Daniel Godas-Lopez Franjo Ivancic
- Austin Seipp Daniel Komaromy
- Daniel Binderman Jonathan Metzman
- Vegard Nossum Jan Kneschke
- Kurt Roeckx Marcel Bohme
- Van-Thuan Pham Abhik Roychoudhury
- Joshua J. Drake Toby Hutton
- Rene Freingruber Sergey Davidoff
- Sami Liedes Craig Young
-
-Thank you!
-
-15) Contact
------------
-
-Questions? Concerns? Bug reports? The author can be usually reached at
-<lcamtuf@google.com>.
-
-There is also a mailing list for the project; to join, send a mail to
-<afl-users+subscribe@googlegroups.com>. Or, if you prefer to browse
-archives first, try:
-
- https://groups.google.com/group/afl-users
-
-PS. If you wish to submit raw code to be incorporated into the project, please
-be aware that the copyright on most of AFL is claimed by Google. While you do
-retain copyright on your contributions, they do ask people to agree to a simple
-CLA first:
-
- https://cla.developers.google.com/clas
-
-Sorry about the hassle. Of course, no CLA is required for feature requests or
-bug reports.
diff --git a/chromium/third_party/afl/src/docs/env_variables.txt b/chromium/third_party/afl/src/docs/env_variables.txt
deleted file mode 100644
index a91b43ae3e8..00000000000
--- a/chromium/third_party/afl/src/docs/env_variables.txt
+++ /dev/null
@@ -1,249 +0,0 @@
-=======================
-Environmental variables
-=======================
-
- This document discusses the environment variables used by American Fuzzy Lop
- to expose various exotic functions that may be (rarely) useful for power
- users or for some types of custom fuzzing setups. See README for the general
- instruction manual.
-
-1) Settings for afl-gcc, afl-clang, and afl-as
-----------------------------------------------
-
-Because they can't directly accept command-line options, the compile-time
-tools make fairly broad use of environmental variables:
-
- - Setting AFL_HARDEN automatically adds code hardening options when invoking
- the downstream compiler. This currently includes -D_FORTIFY_SOURCE=2 and
- -fstack-protector-all. The setting is useful for catching non-crashing
- memory bugs at the expense of a very slight (sub-5%) performance loss.
-
- - By default, the wrapper appends -O3 to optimize builds. Very rarely, this
- will cause problems in programs built with -Werror, simply because -O3
- enables more thorough code analysis and can spew out additional warnings.
- To disable optimizations, set AFL_DONT_OPTIMIZE.
-
- - Setting AFL_USE_ASAN automatically enables ASAN, provided that your
- compiler supports that. Note that fuzzing with ASAN is mildly challenging
- - see notes_for_asan.txt.
-
- (You can also enable MSAN via AFL_USE_MSAN; ASAN and MSAN come with the
- same gotchas; the modes are mutually exclusive. UBSAN and other exotic
- sanitizers are not officially supported yet, but are easy to get to work
- by hand.)
-
- - Setting AFL_CC, AFL_CXX, and AFL_AS lets you use alternate downstream
- compilation tools, rather than the default 'clang', 'gcc', or 'as' binaries
- in your $PATH.
-
- - AFL_PATH can be used to point afl-gcc to an alternate location of afl-as.
- One possible use of this is experimental/clang_asm_normalize/, which lets
- you instrument hand-written assembly when compiling clang code by plugging
- a normalizer into the chain. (There is no equivalent feature for GCC.)
-
- - Setting AFL_INST_RATIO to a percentage between 0 and 100% controls the
- probability of instrumenting every branch. This is (very rarely) useful
- when dealing with exceptionally complex programs that saturate the output
- bitmap. Examples include v8, ffmpeg, and perl.
-
- (If this ever happens, afl-fuzz will warn you ahead of the time by
- displaying the "bitmap density" field in fiery red.)
-
- Setting AFL_INST_RATIO to 0 is a valid choice. This will instrument only
- the transitions between function entry points, but not individual branches.
-
- - AFL_NO_BUILTIN causes the compiler to generate code suitable for use with
- libtokencap.so (but perhaps running a bit slower than without the flag).
-
- - TMPDIR is used by afl-as for temporary files; if this variable is not set,
- the tool defaults to /tmp.
-
- - Setting AFL_KEEP_ASSEMBLY prevents afl-as from deleting instrumented
- assembly files. Useful for troubleshooting problems or understanding how
- the tool works. To get them in a predictable place, try something like:
-
- mkdir assembly_here
- TMPDIR=$PWD/assembly_here AFL_KEEP_ASSEMBLY=1 make clean all
-
- - Setting AFL_QUIET will prevent afl-cc and afl-as banners from being
- displayed during compilation, in case you find them distracting.
-
-2) Settings for afl-clang-fast
-------------------------------
-
-The native LLVM instrumentation helper accepts a subset of the settings
-discussed in section #1, with the exception of:
-
- - AFL_AS, since this toolchain does not directly invoke GNU as.
-
- - TMPDIR and AFL_KEEP_ASSEMBLY, since no temporary assembly files are
- created.
-
-Note that AFL_INST_RATIO will behave a bit differently than for afl-gcc,
-because functions are *not* instrumented unconditionally - so low values
-will have a more striking effect. For this tool, 0 is not a valid choice.
-
-3) Settings for afl-fuzz
-------------------------
-
-The main fuzzer binary accepts several options that disable a couple of sanity
-checks or alter some of the more exotic semantics of the tool:
-
- - Setting AFL_SKIP_CPUFREQ skips the check for CPU scaling policy. This is
- useful if you can't change the defaults (e.g., no root access to the
- system) and are OK with some performance loss.
-
- - Setting AFL_NO_FORKSRV disables the forkserver optimization, reverting to
- fork + execve() call for every tested input. This is useful mostly when
- working with unruly libraries that create threads or do other crazy
- things when initializing (before the instrumentation has a chance to run).
-
- Note that this setting inhibits some of the user-friendly diagnostics
- normally done when starting up the forkserver and causes a pretty
- significant performance drop.
-
- - AFL_EXIT_WHEN_DONE causes afl-fuzz to terminate when all existing paths
- have been fuzzed and there were no new finds for a while. This would be
- normally indicated by the cycle counter in the UI turning green. May be
- convenient for some types of automated jobs.
-
- - Setting AFL_NO_AFFINITY disables attempts to bind to a specific CPU core
- on Linux systems. This slows things down, but lets you run more instances
- of afl-fuzz than would be prudent (if you really want to).
-
- - AFL_SKIP_CRASHES causes AFL to tolerate crashing files in the input
- queue. This can help with rare situations where a program crashes only
- intermittently, but it's not really recommended under normal operating
- conditions.
-
- - AFL_SHUFFLE_QUEUE randomly reorders the input queue on startup. Requested
- by some users for unorthodox parallelized fuzzing setups, but not
- advisable otherwise.
-
- - When developing custom instrumentation on top of afl-fuzz, you can use
- AFL_SKIP_BIN_CHECK to inhibit the checks for non-instrumented binaries
- and shell scripts; and AFL_DUMB_FORKSRV in conjunction with the -n
- setting to instruct afl-fuzz to still follow the fork server protocol
- without expecting any instrumentation data in return.
-
- - When running in the -M or -S mode, setting AFL_IMPORT_FIRST causes the
- fuzzer to import test cases from other instances before doing anything
- else. This makes the "own finds" counter in the UI more accurate.
- Beyond counter aesthetics, not much else should change.
-
- - Setting AFL_POST_LIBRARY allows you to configure a postprocessor for
- mutated files - say, to fix up checksums. See experimental/post_library/
- for more.
-
- - The CPU widget shown at the bottom of the screen is fairly simplistic and
- may complain of high load prematurely, especially on systems with low core
- counts. To avoid the alarming red color, you can set AFL_NO_CPU_RED.
-
- - In QEMU mode (-Q), AFL_PATH will be searched for afl-qemu-trace.
-
- - Setting AFL_PRELOAD causes AFL to set LD_PRELOAD for the target binary
- without disrupting the afl-fuzz process itself. This is useful, among other
- things, for bootstrapping libdislocator.so.
-
- - Setting AFL_NO_UI inhibits the UI altogether, and just periodically prints
- some basic stats. This behavior is also automatically triggered when the
- output from afl-fuzz is redirected to a file or to a pipe.
-
- - If you are Jakub, you may need AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES.
- Others need not apply.
-
- - Benchmarking only: AFL_BENCH_JUST_ONE causes the fuzzer to exit after
- processing the first queue entry; and AFL_BENCH_UNTIL_CRASH causes it to
- exit soon after the first crash is found.
-
-4) Settings for afl-qemu-trace
-------------------------------
-
-The QEMU wrapper used to instrument binary-only code supports several settings:
-
- - It is possible to set AFL_INST_RATIO to skip the instrumentation on some
- of the basic blocks, which can be useful when dealing with very complex
- binaries.
-
- - Setting AFL_INST_LIBS causes the translator to also instrument the code
- inside any dynamically linked libraries (notably including glibc).
-
- - The underlying QEMU binary will recognize any standard "user space
- emulation" variables (e.g., QEMU_STACK_SIZE), but there should be no
- reason to touch them.
-
-5) Settings for afl-cmin
-------------------------
-
-The corpus minimization script offers very little customization:
-
- - Setting AFL_PATH offers a way to specify the location of afl-showmap
- and afl-qemu-trace (the latter only in -Q mode).
-
- - AFL_KEEP_TRACES makes the tool keep traces and other metadata used for
- minimization and normally deleted at exit. The files can be found in the
- <out_dir>/.traces/*.
-
-6) Settings for afl-tmin
-------------------------
-
-Virtually nothing to play with. Well, in QEMU mode (-Q), AFL_PATH will be
-searched for afl-qemu-trace. In addition to this, TMPDIR may be used if a
-temporary file can't be created in the current working directory.
-
-7) Settings for libdislocator.so
---------------------------------
-
-The library honors three environmental variables:
-
- - AFL_LD_LIMIT_MB caps the size of the maximum heap usage permitted by the
- library, in megabytes. The default value is 1 GB. Once this is exceeded,
- allocations will return NULL.
-
- - AFL_LD_HARD_FAIL alters the behavior by calling abort() on excessive
- allocations, thus causing what AFL would perceive as a crash. Useful for
- programs that are supposed to maintain a specific memory footprint.
-
- - AFL_LD_VERBOSE causes the library to output some diagnostic messages
- that may be useful for pinpointing the cause of any observed issues.
-
-8) Settings for libtokencap.so
-------------------------------
-
-This library accepts AFL_TOKEN_FILE to indicate the location to which the
-discovered tokens should be written.
-
-9) Third-party variables set by afl-fuzz & other tools
-------------------------------------------------------
-
-Several variables are not directly interpreted by afl-fuzz, but are set to
-optimal values if not already present in the environment:
-
- - By default, LD_BIND_NOW is set to speed up fuzzing by forcing the
- linker to do all the work before the fork server kicks in. You can
- override this by setting LD_BIND_LAZY beforehand, but it is almost
- certainly pointless.
-
- - By default, ASAN_OPTIONS are set to:
-
- abort_on_error=1
- detect_leaks=0
- symbolize=0
- allocator_may_return_null=1
-
- If you want to set your own options, be sure to include abort_on_error=1 -
- otherwise, the fuzzer will not be able to detect crashes in the tested
- app. Similarly, include symbolize=0, since without it, AFL may have
- difficulty telling crashes and hangs apart.
-
- - In the same vein, by default, MSAN_OPTIONS are set to:
-
- exit_code=86 (required for legacy reasons)
- abort_on_error=1
- symbolize=0
- msan_track_origins=0
- allocator_may_return_null=1
-
- Be sure to include the first one when customizing anything, since some
- MSAN versions don't call abort() on error, and we need a way to detect
- faults.
diff --git a/chromium/third_party/afl/src/docs/historical_notes.txt b/chromium/third_party/afl/src/docs/historical_notes.txt
deleted file mode 100644
index 741fd925847..00000000000
--- a/chromium/third_party/afl/src/docs/historical_notes.txt
+++ /dev/null
@@ -1,147 +0,0 @@
-================
-Historical notes
-================
-
- This doc talks about the rationale of some of the high-level design decisions
- for American Fuzzy Lop. It's adopted from a discussion with Rob Graham.
- See README for the general instruction manual, and technical_details.txt for
- additional implementation-level insights.
-
-1) Influences
--------------
-
-In short, afl-fuzz is inspired chiefly by the work done by Tavis Ormandy back
-in 2007. Tavis did some very persuasive experiments using gcov block coverage
-to select optimal test cases out of a large corpus of data, and then using
-them as a starting point for traditional fuzzing workflows.
-
-(By "persuasive", I mean: netting a significant number of interesting
-vulnerabilities.)
-
-In parallel to this, both Tavis and I were interested in evolutionary fuzzing.
-Tavis had his experiments, and I was working on a tool called bunny-the-fuzzer,
-released somewhere in 2007.
-
-Bunny used a generational algorithm not much different from afl-fuzz, but
-also tried to reason about the relationship between various input bits and
-the internal state of the program, with hopes of deriving some additional value
-from that. The reasoning / correlation part was probably in part inspired by
-other projects done around the same time by Will Drewry and Chris Evans.
-
-The state correlation approach sounded very sexy on paper, but ultimately, made
-the fuzzer complicated, brittle, and cumbersome to use; every other target
-program would require a tweak or two. Because Bunny didn't fare a whole lot
-better than less sophisticated brute-force tools, I eventually decided to write
-it off. You can still find its original documentation at:
-
- https://code.google.com/p/bunny-the-fuzzer/wiki/BunnyDoc
-
-There has been a fair amount of independent work, too. Most notably, a few
-weeks earlier that year, Jared DeMott had a Defcon presentation about a
-coverage-driven fuzzer that relied on coverage as a fitness function.
-
-Jared's approach was by no means identical to what afl-fuzz does, but it was in
-the same ballpark. His fuzzer tried to explicitly solve for the maximum coverage
-with a single input file; in comparison, afl simply selects for cases that do
-something new (which yields better results - see technical_details.txt).
-
-A few years later, Gabriel Campana released fuzzgrind, a tool that relied purely
-on Valgrind and a constraint solver to maximize coverage without any brute-force
-bits; and Microsoft Research folks talked extensively about their still
-non-public, solver-based SAGE framework.
-
-In the past six years or so, I've also seen a fair number of academic papers
-that dealt with smart fuzzing (focusing chiefly on symbolic execution) and a
-couple papers that discussed proof-of-concept applications of genetic
-algorithms with the same goals in mind. I'm unconvinced how practical most of
-these experiments were; I suspect that many of them suffer from the
-bunny-the-fuzzer's curse of being cool on paper and in carefully designed
-experiments, but failing the ultimate test of being able to find new,
-worthwhile security bugs in otherwise well-fuzzed, real-world software.
-
-In some ways, the baseline that the "cool" solutions have to compete against is
-a lot more impressive than it may seem, making it difficult for competitors to
-stand out. For a singular example, check out the work by Gynvael and Mateusz
-Jurczyk, applying "dumb" fuzzing to ffmpeg, a prominent and security-critical
-component of modern browsers and media players:
-
- http://googleonlinesecurity.blogspot.com/2014/01/ffmpeg-and-thousand-fixes.html
-
-Effortlessly getting comparable results with state-of-the-art symbolic execution
-in equally complex software still seems fairly unlikely, and hasn't been
-demonstrated in practice so far.
-
-But I digress; ultimately, attribution is hard, and glorying the fundamental
-concepts behind AFL is probably a waste of time. The devil is very much in the
-often-overlooked details, which brings us to...
-
-2) Design goals for afl-fuzz
-----------------------------
-
-In short, I believe that the current implementation of afl-fuzz takes care of
-several itches that seemed impossible to scratch with other tools:
-
-1) Speed. It's genuinely hard to compete with brute force when your "smart"
- approach is resource-intensive. If your instrumentation makes it 10x more
- likely to find a bug, but runs 100x slower, your users are getting a bad
- deal.
-
- To avoid starting with a handicap, afl-fuzz is meant to let you fuzz most of
- the intended targets at roughly their native speed - so even if it doesn't
- add value, you do not lose much.
-
- On top of this, the tool leverages instrumentation to actually reduce the
- amount of work in a couple of ways: for example, by carefully trimming the
- corpus or skipping non-functional but non-trimmable regions in the input
- files.
-
-2) Rock-solid reliability. It's hard to compete with brute force if your
- approach is brittle and fails unexpectedly. Automated testing is attractive
- because it's simple to use and scalable; anything that goes against these
- principles is an unwelcome trade-off and means that your tool will be used
- less often and with less consistent results.
-
- Most of the approaches based on symbolic execution, taint tracking, or
- complex syntax-aware instrumentation are currently fairly unreliable with
- real-world targets. Perhaps more importantly, their failure modes can render
- them strictly worse than "dumb" tools, and such degradation can be difficult
- for less experienced users to notice and correct.
-
- In contrast, afl-fuzz is designed to be rock solid, chiefly by keeping it
- simple. In fact, at its core, it's designed to be just a very good
- traditional fuzzer with a wide range of interesting, well-researched
- strategies to go by. The fancy parts just help it focus the effort in
- places where it matters the most.
-
-3) Simplicity. The author of a testing framework is probably the only person
- who truly understands the impact of all the settings offered by the tool -
- and who can dial them in just right. Yet, even the most rudimentary fuzzer
- frameworks often come with countless knobs and fuzzing ratios that need to
- be guessed by the operator ahead of the time. This can do more harm than
- good.
-
- AFL is designed to avoid this as much as possible. The three knobs you
- can play with are the output file, the memory limit, and the ability to
- override the default, auto-calibrated timeout. The rest is just supposed to
- work. When it doesn't, user-friendly error messages outline the probable
- causes and workarounds, and get you back on track right away.
-
-4) Chainability. Most general-purpose fuzzers can't be easily employed
- against resource-hungry or interaction-heavy tools, necessitating the
- creation of custom in-process fuzzers or the investment of massive CPU
- power (most of which is wasted on tasks not directly related to the code
- we actually want to test).
-
- AFL tries to scratch this itch by allowing users to use more lightweight
- targets (e.g., standalone image parsing libraries) to create small
- corpora of interesting test cases that can be fed into a manual testing
- process or a UI harness later on.
-
-As mentioned in technical_details.txt, AFL does all this not by systematically
-applying a single overarching CS concept, but by experimenting with a variety
-of small, complementary methods that were shown to reliably yields results
-better than chance. The use of instrumentation is a part of that toolkit, but is
-far from being the most important one.
-
-Ultimately, what matters is that afl-fuzz is designed to find cool bugs - and
-has a pretty robust track record of doing just that.
diff --git a/chromium/third_party/afl/src/docs/life_pro_tips.txt b/chromium/third_party/afl/src/docs/life_pro_tips.txt
deleted file mode 100644
index c8c47636b37..00000000000
--- a/chromium/third_party/afl/src/docs/life_pro_tips.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-# ===================
-# AFL "Life Pro Tips"
-# ===================
-#
-# Bite-sized advice for those who understand the basics, but can't be bothered
-# to read or memorize every other piece of documentation for AFL.
-#
-
-%
-
-Get more bang for your buck by using fuzzing dictionaries.
-See dictionaries/README.dictionaries to learn how.
-
-%
-
-You can get the most out of your hardware by parallelizing AFL jobs.
-See docs/parallel_fuzzing.txt for step-by-step tips.
-
-%
-
-Improve the odds of spotting memory corruption bugs with libdislocator.so!
-It's easy. Consult libdislocator/README.dislocator for usage tips.
-
-%
-
-Want to understand how your target parses a particular input file?
-Try the bundled afl-analyze tool; it's got colors and all!
-
-%
-
-You can visually monitor the progress of your fuzzing jobs.
-Run the bundled afl-plot utility to generate browser-friendly graphs.
-
-%
-
-Need to monitor AFL jobs programmatically? Check out the fuzzer_stats file
-in the AFL output dir or try afl-whatsup.
-
-%
-
-Puzzled by something showing up in red or purple in the AFL UI?
-It could be important - consult docs/status_screen.txt right away!
-
-%
-
-Know your target? Convert it to persistent mode for a huge performance gain!
-Consult section #5 in llvm_mode/README.llvm for tips.
-
-%
-
-Using clang? Check out llvm_mode/ for a faster alternative to afl-gcc!
-
-%
-
-Did you know that AFL can fuzz closed-source or cross-platform binaries?
-Check out qemu_mode/README.qemu for more.
-
-%
-
-Did you know that afl-fuzz can minimize any test case for you?
-Try the bundled afl-tmin tool - and get small repro files fast!
-
-%
-
-Not sure if a crash is exploitable? AFL can help you figure it out. Specify
--C to enable the peruvian were-rabbit mode. See section #10 in README for more.
-
-%
-
-Trouble dealing with a machine uprising? Relax, we've all been there.
-Find essential survival tips at http://lcamtuf.coredump.cx/prep/.
-
-%
-
-AFL-generated corpora can be used to power other testing processes.
-See section #2 in README for inspiration - it tends to pay off!
-
-%
-
-Want to automatically spot non-crashing memory handling bugs?
-Try running an AFL-generated corpus through ASAN, MSAN, or Valgrind.
-
-%
-
-Good selection of input files is critical to a successful fuzzing job.
-See section #5 in README (or docs/perf_tips.txt) for pro tips.
-
-%
-
-You can improve the odds of automatically spotting stack corruption issues.
-Specify AFL_HARDEN=1 in the environment to enable hardening flags.
-
-%
-
-Bumping into problems with non-reproducible crashes? It happens, but usually
-isn't hard to diagnose. See section #7 in README for tips.
-
-%
-
-Fuzzing is not just about memory corruption issues in the codebase. Add some
-sanity-checking assert() / abort() statements to effortlessly catch logic bugs.
-
-%
-
-Hey kid... pssst... want to figure out how AFL really works?
-Check out docs/technical_details.txt for all the gory details in one place!
-
-%
-
-There's a ton of third-party helper tools designed to work with AFL!
-Be sure to check out docs/sister_projects.txt before writing your own.
-
-%
-
-Need to fuzz the command-line arguments of a particular program?
-You can find a simple solution in experimental/argv_fuzzing.
-
-%
-
-Attacking a format that uses checksums? Remove the checksum-checking code or
-use a postprocessor! See experimental/post_library/ for more.
-
-%
-
-Dealing with a very slow target or hoping for instant results? Specify -d
-when calling afl-fuzz!
-
-%
diff --git a/chromium/third_party/afl/src/docs/notes_for_asan.txt b/chromium/third_party/afl/src/docs/notes_for_asan.txt
deleted file mode 100644
index dff89ba6b6c..00000000000
--- a/chromium/third_party/afl/src/docs/notes_for_asan.txt
+++ /dev/null
@@ -1,127 +0,0 @@
-==================================
-Notes for using ASAN with afl-fuzz
-==================================
-
- This file discusses some of the caveats for fuzzing under ASAN, and suggests
- a handful of alternatives. See README for the general instruction manual.
-
-1) Short version
-----------------
-
-ASAN on 64-bit systems requests a lot of memory in a way that can't be easily
-distinguished from a misbehaving program bent on crashing your system.
-
-Because of this, fuzzing with ASAN is recommended only in four scenarios:
-
- - On 32-bit systems, where we can always enforce a reasonable memory limit
- (-m 800 or so is a good starting point),
-
- - On 64-bit systems only if you can do one of the following:
-
- - Compile the binary in 32-bit mode (gcc -m32),
-
- - Precisely gauge memory needs using http://jwilk.net/software/recidivm .
-
- - Limit the memory available to process using cgroups on Linux (see
- experimental/asan_cgroups).
-
-To compile with ASAN, set AFL_USE_ASAN=1 before calling 'make clean all'. The
-afl-gcc / afl-clang wrappers will pick that up and add the appropriate flags.
-Note that ASAN is incompatible with -static, so be mindful of that.
-
-(You can also use AFL_USE_MSAN=1 to enable MSAN instead.)
-
-There is also the option of generating a corpus using a non-ASAN binary, and
-then feeding it to an ASAN-instrumented one to check for bugs. This is faster,
-and can give you somewhat comparable results. You can also try using
-libdislocator (see libdislocator/README.dislocator in the parent directory) as a
-lightweight and hassle-free (but less thorough) alternative.
-
-2) Long version
----------------
-
-ASAN allocates a huge region of virtual address space for bookkeeping purposes.
-Most of this is never actually accessed, so the OS never has to allocate any
-real pages of memory for the process, and the VM grabbed by ASAN is essentially
-"free" - but the mapping counts against the standard OS-enforced limit
-(RLIMIT_AS, aka ulimit -v).
-
-On our end, afl-fuzz tries to protect you from processes that go off-rails
-and start consuming all the available memory in a vain attempt to parse a
-malformed input file. This happens surprisingly often, so enforcing such a limit
-is important for almost any fuzzer: the alternative is for the kernel OOM
-handler to step in and start killing random processes to free up resources.
-Needless to say, that's not a very nice prospect to live with.
-
-Unfortunately, un*x systems offer no portable way to limit the amount of
-pages actually given to a process in a way that distinguishes between that
-and the harmless "land grab" done by ASAN. In principle, there are three standard
-ways to limit the size of the heap:
-
- - The RLIMIT_AS mechanism (ulimit -v) caps the size of the virtual space -
- but as noted, this pays no attention to the number of pages actually
- in use by the process, and doesn't help us here.
-
- - The RLIMIT_DATA mechanism (ulimit -d) seems like a good fit, but it applies
- only to the traditional sbrk() / brk() methods of requesting heap space;
- modern allocators, including the one in glibc, routinely rely on mmap()
- instead, and circumvent this limit completely.
-
- - Finally, the RLIMIT_RSS limit (ulimit -m) sounds like what we need, but
- doesn't work on Linux - mostly because nobody felt like implementing it.
-
-There are also cgroups, but they are Linux-specific, not universally available
-even on Linux systems, and they require root permissions to set up; I'm a bit
-hesitant to make afl-fuzz require root permissions just for that. That said,
-if you are on Linux and want to use cgroups, check out the contributed script
-that ships in experimental/asan_cgroups/.
-
-In settings where cgroups aren't available, we have no nice, portable way to
-avoid counting the ASAN allocation toward the limit. On 32-bit systems, or for
-binaries compiled in 32-bit mode (-m32), this is not a big deal: ASAN needs
-around 600-800 MB or so, depending on the compiler - so all you need to do is
-to specify -m that is a bit higher than that.
-
-On 64-bit systems, the situation is more murky, because the ASAN allocation
-is completely outlandish - around 17.5 TB in older versions, and closer to
-20 TB with newest ones. The actual amount of memory on your system is
-(probably!) just a tiny fraction of that - so unless you dial the limit
-with surgical precision, you will get no protection from OOM bugs.
-
-On my system, the amount of memory grabbed by ASAN with a slightly older
-version of gcc is around 17,825,850 MB; for newest clang, it's 20,971,600.
-But there is no guarantee that these numbers are stable, and if you get them
-wrong by "just" a couple gigs or so, you will be at risk.
-
-To get the precise number, you can use the recidivm tool developed by Jakub
-Wilk (http://jwilk.net/software/recidivm). In absence of this, ASAN is *not*
-recommended when fuzzing 64-bit binaries, unless you are confident that they
-are robust and enforce reasonable memory limits (in which case, you can
-specify '-m none' when calling afl-fuzz).
-
-Using recidivm or running with no limits aside, there are two other decent
-alternatives: build a corpus of test cases using a non-ASAN binary, and then
-examine them with ASAN, Valgrind, or other heavy-duty tools in a more
-controlled setting; or compile the target program with -m32 (32-bit mode)
-if your system supports that.
-
-3) Interactions with the QEMU mode
-----------------------------------
-
-ASAN, MSAN, and other sanitizers appear to be incompatible with QEMU user
-emulation, so please do not try to use them with the -Q option; QEMU doesn't
-seem to appreciate the shadow VM trick used by these tools, and will likely
-just allocate all your physical memory, then crash.
-
-4) What about UBSAN?
---------------------
-
-Some folks expressed interest in fuzzing with UBSAN. This isn't officially
-supported, because many installations of UBSAN don't offer a consistent way
-to abort() on fault conditions or to terminate with a distinctive exit code.
-
-That said, some versions of the library can be binary-patched to address this
-issue, while newer releases support explicit compile-time flags - see this
-mailing list thread for tips:
-
- https://groups.google.com/forum/#!topic/afl-users/GyeSBJt4M38
diff --git a/chromium/third_party/afl/src/docs/parallel_fuzzing.txt b/chromium/third_party/afl/src/docs/parallel_fuzzing.txt
deleted file mode 100644
index 58f8d2f4126..00000000000
--- a/chromium/third_party/afl/src/docs/parallel_fuzzing.txt
+++ /dev/null
@@ -1,216 +0,0 @@
-=========================
-Tips for parallel fuzzing
-=========================
-
- This document talks about synchronizing afl-fuzz jobs on a single machine
- or across a fleet of systems. See README for the general instruction manual.
-
-1) Introduction
----------------
-
-Every copy of afl-fuzz will take up one CPU core. This means that on an
-n-core system, you can almost always run around n concurrent fuzzing jobs with
-virtually no performance hit (you can use the afl-gotcpu tool to make sure).
-
-In fact, if you rely on just a single job on a multi-core system, you will
-be underutilizing the hardware. So, parallelization is usually the right
-way to go.
-
-When targeting multiple unrelated binaries or using the tool in "dumb" (-n)
-mode, it is perfectly fine to just start up several fully separate instances
-of afl-fuzz. The picture gets more complicated when you want to have multiple
-fuzzers hammering a common target: if a hard-to-hit but interesting test case
-is synthesized by one fuzzer, the remaining instances will not be able to use
-that input to guide their work.
-
-To help with this problem, afl-fuzz offers a simple way to synchronize test
-cases on the fly.
-
-2) Single-system parallelization
---------------------------------
-
-If you wish to parallelize a single job across multiple cores on a local
-system, simply create a new, empty output directory ("sync dir") that will be
-shared by all the instances of afl-fuzz; and then come up with a naming scheme
-for every instance - say, "fuzzer01", "fuzzer02", etc.
-
-Run the first one ("master", -M) like this:
-
-$ ./afl-fuzz -i testcase_dir -o sync_dir -M fuzzer01 [...other stuff...]
-
-...and then, start up secondary (-S) instances like this:
-
-$ ./afl-fuzz -i testcase_dir -o sync_dir -S fuzzer02 [...other stuff...]
-$ ./afl-fuzz -i testcase_dir -o sync_dir -S fuzzer03 [...other stuff...]
-
-Each fuzzer will keep its state in a separate subdirectory, like so:
-
- /path/to/sync_dir/fuzzer01/
-
-Each instance will also periodically rescan the top-level sync directory
-for any test cases found by other fuzzers - and will incorporate them into
-its own fuzzing when they are deemed interesting enough.
-
-The difference between the -M and -S modes is that the master instance will
-still perform deterministic checks; while the secondary instances will
-proceed straight to random tweaks. If you don't want to do deterministic
-fuzzing at all, it's OK to run all instances with -S. With very slow or complex
-targets, or when running heavily parallelized jobs, this is usually a good plan.
-
-Note that running multiple -M instances is wasteful, although there is an
-experimental support for parallelizing the deterministic checks. To leverage
-that, you need to create -M instances like so:
-
-$ ./afl-fuzz -i testcase_dir -o sync_dir -M masterA:1/3 [...]
-$ ./afl-fuzz -i testcase_dir -o sync_dir -M masterB:2/3 [...]
-$ ./afl-fuzz -i testcase_dir -o sync_dir -M masterC:3/3 [...]
-
-...where the first value after ':' is the sequential ID of a particular master
-instance (starting at 1), and the second value is the total number of fuzzers to
-distribute the deterministic fuzzing across. Note that if you boot up fewer
-fuzzers than indicated by the second number passed to -M, you may end up with
-poor coverage.
-
-You can also monitor the progress of your jobs from the command line with the
-provided afl-whatsup tool. When the instances are no longer finding new paths,
-it's probably time to stop.
-
-WARNING: Exercise caution when explicitly specifying the -f option. Each fuzzer
-must use a separate temporary file; otherwise, things will go south. One safe
-example may be:
-
-$ ./afl-fuzz [...] -S fuzzer10 -f file10.txt ./fuzzed/binary @@
-$ ./afl-fuzz [...] -S fuzzer11 -f file11.txt ./fuzzed/binary @@
-$ ./afl-fuzz [...] -S fuzzer12 -f file12.txt ./fuzzed/binary @@
-
-This is not a concern if you use @@ without -f and let afl-fuzz come up with the
-file name.
-
-3) Multi-system parallelization
--------------------------------
-
-The basic operating principle for multi-system parallelization is similar to
-the mechanism explained in section 2. The key difference is that you need to
-write a simple script that performs two actions:
-
- - Uses SSH with authorized_keys to connect to every machine and retrieve
- a tar archive of the /path/to/sync_dir/<fuzzer_id>/queue/ directories for
- every <fuzzer_id> local to the machine. It's best to use a naming scheme
- that includes host name in the fuzzer ID, so that you can do something
- like:
-
- for s in {1..10}; do
- ssh user@host${s} "tar -czf - sync/host${s}_fuzzid*/[qf]*" >host${s}.tgz
- done
-
- - Distributes and unpacks these files on all the remaining machines, e.g.:
-
- for s in {1..10}; do
- for d in {1..10}; do
- test "$s" = "$d" && continue
- ssh user@host${d} 'tar -kxzf -' <host${s}.tgz
- done
- done
-
-There is an example of such a script in experimental/distributed_fuzzing/;
-you can also find a more featured, experimental tool developed by
-Martijn Bogaard at:
-
- https://github.com/MartijnB/disfuzz-afl
-
-Another client-server implementation from Richo Healey is:
-
- https://github.com/richo/roving
-
-Note that these third-party tools are unsafe to run on systems exposed to the
-Internet or to untrusted users.
-
-When developing custom test case sync code, there are several optimizations
-to keep in mind:
-
- - The synchronization does not have to happen very often; running the
- task every 30 minutes or so may be perfectly fine.
-
- - There is no need to synchronize crashes/ or hangs/; you only need to
- copy over queue/* (and ideally, also fuzzer_stats).
-
- - It is not necessary (and not advisable!) to overwrite existing files;
- the -k option in tar is a good way to avoid that.
-
- - There is no need to fetch directories for fuzzers that are not running
- locally on a particular machine, and were simply copied over onto that
- system during earlier runs.
-
- - For large fleets, you will want to consolidate tarballs for each host,
- as this will let you use n SSH connections for sync, rather than n*(n-1).
-
- You may also want to implement staged synchronization. For example, you
- could have 10 groups of systems, with group 1 pushing test cases only
- to group 2; group 2 pushing them only to group 3; and so on, with group
- eventually 10 feeding back to group 1.
-
- This arrangement would allow test interesting cases to propagate across
- the fleet without having to copy every fuzzer queue to every single host.
-
- - You do not want a "master" instance of afl-fuzz on every system; you should
- run them all with -S, and just designate a single process somewhere within
- the fleet to run with -M.
-
-It is *not* advisable to skip the synchronization script and run the fuzzers
-directly on a network filesystem; unexpected latency and unkillable processes
-in I/O wait state can mess things up.
-
-4) Remote monitoring and data collection
-----------------------------------------
-
-You can use screen, nohup, tmux, or something equivalent to run remote
-instances of afl-fuzz. If you redirect the program's output to a file, it will
-automatically switch from a fancy UI to more limited status reports. There is
-also basic machine-readable information always written to the fuzzer_stats file
-in the output directory. Locally, that information can be interpreted with
-afl-whatsup.
-
-In principle, you can use the status screen of the master (-M) instance to
-monitor the overall fuzzing progress and decide when to stop. In this
-mode, the most important signal is just that no new paths are being found
-for a longer while. If you do not have a master instance, just pick any
-single secondary instance to watch and go by that.
-
-You can also rely on that instance's output directory to collect the
-synthesized corpus that covers all the noteworthy paths discovered anywhere
-within the fleet. Secondary (-S) instances do not require any special
-monitoring, other than just making sure that they are up.
-
-Keep in mind that crashing inputs are *not* automatically propagated to the
-master instance, so you may still want to monitor for crashes fleet-wide
-from within your synchronization or health checking scripts (see afl-whatsup).
-
-5) Asymmetric setups
---------------------
-
-It is perhaps worth noting that all of the following is permitted:
-
- - Running afl-fuzz with conjunction with other guided tools that can extend
- coverage (e.g., via concolic execution). Third-party tools simply need to
- follow the protocol described above for pulling new test cases from
- out_dir/<fuzzer_id>/queue/* and writing their own finds to sequentially
- numbered id:nnnnnn files in out_dir/<ext_tool_id>/queue/*.
-
- - Running some of the synchronized fuzzers with different (but related)
- target binaries. For example, simultaneously stress-testing several
- different JPEG parsers (say, IJG jpeg and libjpeg-turbo) while sharing
- the discovered test cases can have synergistic effects and improve the
- overall coverage.
-
- (In this case, running one -M instance per each binary is a good plan.)
-
- - Having some of the fuzzers invoke the binary in different ways.
- For example, 'djpeg' supports several DCT modes, configurable with
- a command-line flag, while 'dwebp' supports incremental and one-shot
- decoding. In some scenarios, going after multiple distinct modes and then
- pooling test cases will improve coverage.
-
- - Much less convincingly, running the synchronized fuzzers with different
- starting test cases (e.g., progressive and standard JPEG) or dictionaries.
- The synchronization mechanism ensures that the test sets will get fairly
- homogeneous over time, but it introduces some initial variability.
diff --git a/chromium/third_party/afl/src/docs/perf_tips.txt b/chromium/third_party/afl/src/docs/perf_tips.txt
deleted file mode 100644
index 3a8997a22f0..00000000000
--- a/chromium/third_party/afl/src/docs/perf_tips.txt
+++ /dev/null
@@ -1,197 +0,0 @@
-=================================
-Tips for performance optimization
-=================================
-
- This file provides tips for troubleshooting slow or wasteful fuzzing jobs.
- See README for the general instruction manual.
-
-1) Keep your test cases small
------------------------------
-
-This is probably the single most important step to take! Large test cases do
-not merely take more time and memory to be parsed by the tested binary, but
-also make the fuzzing process dramatically less efficient in several other
-ways.
-
-To illustrate, let's say that you're randomly flipping bits in a file, one bit
-at a time. Let's assume that if you flip bit #47, you will hit a security bug;
-flipping any other bit just results in an invalid document.
-
-Now, if your starting test case is 100 bytes long, you will have a 71% chance of
-triggering the bug within the first 1,000 execs - not bad! But if the test case
-is 1 kB long, the probability that we will randomly hit the right pattern in
-the same timeframe goes down to 11%. And if it has 10 kB of non-essential
-cruft, the odds plunge to 1%.
-
-On top of that, with larger inputs, the binary may be now running 5-10x times
-slower than before - so the overall drop in fuzzing efficiency may be easily
-as high as 500x or so.
-
-In practice, this means that you shouldn't fuzz image parsers with your
-vacation photos. Generate a tiny 16x16 picture instead, and run it through
-jpegtran or pngcrunch for good measure. The same goes for most other types
-of documents.
-
-There's plenty of small starting test cases in ../testcases/* - try them out
-or submit new ones!
-
-If you want to start with a larger, third-party corpus, run afl-cmin with an
-aggressive timeout on that data set first.
-
-2) Use a simpler target
------------------------
-
-Consider using a simpler target binary in your fuzzing work. For example, for
-image formats, bundled utilities such as djpeg, readpng, or gifhisto are
-considerably (10-20x) faster than the convert tool from ImageMagick - all while
-exercising roughly the same library-level image parsing code.
-
-Even if you don't have a lightweight harness for a particular target, remember
-that you can always use another, related library to generate a corpus that will
-be then manually fed to a more resource-hungry program later on.
-
-3) Use LLVM instrumentation
----------------------------
-
-When fuzzing slow targets, you can gain 2x performance improvement by using
-the LLVM-based instrumentation mode described in llvm_mode/README.llvm. Note
-that this mode requires the use of clang and will not work with GCC.
-
-The LLVM mode also offers a "persistent", in-process fuzzing mode that can
-work well for certain types of self-contained libraries, and for fast targets,
-can offer performance gains up to 5-10x; and a "deferred fork server" mode
-that can offer huge benefits for programs with high startup overhead. Both
-modes require you to edit the source code of the fuzzed program, but the
-changes often amount to just strategically placing a single line or two.
-
-4) Profile and optimize the binary
-----------------------------------
-
-Check for any parameters or settings that obviously improve performance. For
-example, the djpeg utility that comes with IJG jpeg and libjpeg-turbo can be
-called with:
-
- -dct fast -nosmooth -onepass -dither none -scale 1/4
-
-...and that will speed things up. There is a corresponding drop in the quality
-of decoded images, but it's probably not something you care about.
-
-In some programs, it is possible to disable output altogether, or at least use
-an output format that is computationally inexpensive. For example, with image
-transcoding tools, converting to a BMP file will be a lot faster than to PNG.
-
-With some laid-back parsers, enabling "strict" mode (i.e., bailing out after
-first error) may result in smaller files and improved run time without
-sacrificing coverage; for example, for sqlite, you may want to specify -bail.
-
-If the program is still too slow, you can use strace -tt or an equivalent
-profiling tool to see if the targeted binary is doing anything silly.
-Sometimes, you can speed things up simply by specifying /dev/null as the
-config file, or disabling some compile-time features that aren't really needed
-for the job (try ./configure --help). One of the notoriously resource-consuming
-things would be calling other utilities via exec*(), popen(), system(), or
-equivalent calls; for example, tar can invoke external decompression tools
-when it decides that the input file is a compressed archive.
-
-Some programs may also intentionally call sleep(), usleep(), or nanosleep();
-vim is a good example of that.
-
-In programs that are slow due to unavoidable initialization overhead, you may
-want to try the LLVM deferred forkserver mode (see llvm_mode/README.llvm),
-which can give you speed gains up to 10x, as mentioned above.
-
-Last but not least, if you are using ASAN and the performance is unacceptable,
-consider turning it off for now, and manually examining the generated corpus
-with an ASAN-enabled binary later on.
-
-5) Instrument just what you need
---------------------------------
-
-Instrument just the libraries you actually want to stress-test right now, one
-at a time. Let the program use system-wide, non-instrumented libraries for
-any functionality you don't actually want to fuzz. For example, in most
-cases, it doesn't make to instrument libgmp just because you're testing a
-crypto app that relies on it for bignum math.
-
-Beware of programs that come with oddball third-party libraries bundled with
-their source code (Spidermonkey is a good example of this). Check ./configure
-options to use non-instrumented system-wide copies instead.
-
-6) Parallelize your fuzzers
----------------------------
-
-The fuzzer is designed to need ~1 core per job. This means that on a, say,
-4-core system, you can easily run four parallel fuzzing jobs with relatively
-little performance hit. For tips on how to do that, see parallel_fuzzing.txt.
-
-The afl-gotcpu utility can help you understand if you still have idle CPU
-capacity on your system. (It won't tell you about memory bandwidth, cache
-misses, or similar factors, but they are less likely to be a concern.)
-
-7) Keep memory use and timeouts in check
-----------------------------------------
-
-If you have increased the -m or -t limits more than truly necessary, consider
-dialing them back down.
-
-For programs that are nominally very fast, but get sluggish for some inputs,
-you can also try setting -t values that are more punishing than what afl-fuzz
-dares to use on its own. On fast and idle machines, going down to -t 5 may be
-a viable plan.
-
-The -m parameter is worth looking at, too. Some programs can end up spending
-a fair amount of time allocating and initializing megabytes of memory when
-presented with pathological inputs. Low -m values can make them give up sooner
-and not waste CPU time.
-
-8) Check OS configuration
--------------------------
-
-There are several OS-level factors that may affect fuzzing speed:
-
- - High system load. Use idle machines where possible. Kill any non-essential
- CPU hogs (idle browser windows, media players, complex screensavers, etc).
-
- - Network filesystems, either used for fuzzer input / output, or accessed by
- the fuzzed binary to read configuration files (pay special attention to the
- home directory - many programs search it for dot-files).
-
- - On-demand CPU scaling. The Linux 'ondemand' governor performs its analysis
- on a particular schedule and is known to underestimate the needs of
- short-lived processes spawned by afl-fuzz (or any other fuzzer). On Linux,
- this can be fixed with:
-
- cd /sys/devices/system/cpu
- echo performance | tee cpu*/cpufreq/scaling_governor
-
- On other systems, the impact of CPU scaling will be different; when fuzzing,
- use OS-specific tools to find out if all cores are running at full speed.
-
- - Transparent huge pages. Some allocators, such as jemalloc, can incur a
- heavy fuzzing penalty when transparent huge pages (THP) are enabled in the
- kernel. You can disable this via:
-
- echo never > /sys/kernel/mm/transparent_hugepage/enabled
-
- - Suboptimal scheduling strategies. The significance of this will vary from
- one target to another, but on Linux, you may want to make sure that the
- following options are set:
-
- echo 1 >/proc/sys/kernel/sched_child_runs_first
- echo 1 >/proc/sys/kernel/sched_autogroup_enabled
-
- Setting a different scheduling policy for the fuzzer process - say
- SCHED_RR - can usually speed things up, too, but needs to be done with
- care.
-
-9) If all other options fail, use -d
-------------------------------------
-
-For programs that are genuinely slow, in cases where you really can't escape
-using huge input files, or when you simply want to get quick and dirty results
-early on, you can always resort to the -d mode.
-
-The mode causes afl-fuzz to skip all the deterministic fuzzing steps, which
-makes output a lot less neat and can ultimately make the testing a bit less
-in-depth, but it will give you an experience more familiar from other fuzzing
-tools.
diff --git a/chromium/third_party/afl/src/docs/sister_projects.txt b/chromium/third_party/afl/src/docs/sister_projects.txt
deleted file mode 100644
index 1434e37f841..00000000000
--- a/chromium/third_party/afl/src/docs/sister_projects.txt
+++ /dev/null
@@ -1,298 +0,0 @@
-===============
-Sister projects
-===============
-
- This doc lists some of the projects that are inspired by, derived from,
- designed for, or meant to integrate with AFL. See README for the general
- instruction manual.
-
--------------------------------------------
-Support for other languages / environments:
--------------------------------------------
-
-Python AFL (Jakub Wilk)
------------------------
-
- Allows fuzz-testing of Python programs. Uses custom instrumentation and its
- own forkserver.
-
- http://jwilk.net/software/python-afl
-
-Go-fuzz (Dmitry Vyukov)
------------------------
-
- AFL-inspired guided fuzzing approach for Go targets:
-
- https://github.com/dvyukov/go-fuzz
-
-afl.rs (Keegan McAllister)
---------------------------
-
- Allows Rust features to be easily fuzzed with AFL (using the LLVM mode).
-
- https://github.com/kmcallister/afl.rs
-
-OCaml support (KC Sivaramakrishnan)
------------------------------------
-
- Adds AFL-compatible instrumentation to OCaml programs.
-
- https://github.com/ocamllabs/opam-repo-dev/pull/23
- http://canopy.mirage.io/Posts/Fuzzing
-
-AFL for GCJ Java and other GCC frontends (-)
---------------------------------------------
-
- GCC Java programs are actually supported out of the box - simply rename
- afl-gcc to afl-gcj. Unfortunately, by default, unhandled exceptions in GCJ do
- not result in abort() being called, so you will need to manually add a
- top-level exception handler that exits with SIGABRT or something equivalent.
-
- Other GCC-supported languages should be fairly easy to get working, but may
- face similar problems. See https://gcc.gnu.org/frontends.html for a list of
- options.
-
-AFL-style in-process fuzzer for LLVM (Kostya Serebryany)
---------------------------------------------------------
-
- Provides an evolutionary instrumentation-guided fuzzing harness that allows
- some programs to be fuzzed without the fork / execve overhead. (Similar
- functionality is now available as the "persistent" feature described in
- ../llvm_mode/README.llvm.)
-
- http://llvm.org/docs/LibFuzzer.html
-
-AFL fixup shim (Ben Nagy)
--------------------------
-
- Allows AFL_POST_LIBRARY postprocessors to be written in arbitrary languages
- that don't have C / .so bindings. Includes examples in Go.
-
- https://github.com/bnagy/aflfix
-
-TriforceAFL (Tim Newsham and Jesse Hertz)
------------------------------------------
-
- Leverages QEMU full system emulation mode to allow AFL to target operating
- systems and other alien worlds:
-
- https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2016/june/project-triforce-run-afl-on-everything/
-
-WinAFL (Ivan Fratric)
----------------------
-
- As the name implies, allows you to fuzz Windows binaries (using DynamoRio).
-
- https://github.com/ivanfratric/winafl
-
-----------------
-Network fuzzing:
-----------------
-
-Preeny (Yan Shoshitaishvili)
-----------------------------
-
- Provides a fairly simple way to convince dynamically linked network-centric
- programs to read from a file or not fork. Not AFL-specific, but described as
- useful by many users. Some assembly required.
-
- https://github.com/zardus/preeny
-
--------------------------------------------
-Distributed fuzzing and related automation:
--------------------------------------------
-
-roving (Richo Healey)
----------------------
-
- A client-server architecture for effortlessly orchestrating AFL runs across
- a fleet of machines. You don't want to use this on systems that face the
- Internet or live in other untrusted environments.
-
- https://github.com/richo/roving
-
-Distfuzz-AFL (Martijn Bogaard)
-------------------------------
-
- Simplifies the management of afl-fuzz instances on remote machines. The
- author notes that the current implementation isn't secure and should not
- be exposed on the Internet.
-
- https://github.com/MartijnB/disfuzz-afl
-
-afl-launch (Ben Nagy)
----------------------
-
- Batch AFL launcher utility with a simple CLI.
-
- https://github.com/bnagy/afl-launch
-
-AFL Utils (rc0r)
-----------------
-
- Simplifies the triage of discovered crashes, start parallel instances, etc.
-
- https://github.com/rc0r/afl-utils
-
-afl-fuzzing-scripts (Tobias Ospelt)
------------------------------------
-
- Simplifies starting up multiple parallel AFL jobs.
-
- https://github.com/floyd-fuh/afl-fuzzing-scripts/
-
-afl-sid (Jacek Wielemborek)
----------------------------
-
- Allows users to more conveniently build and deploy AFL via Docker.
-
- https://github.com/d33tah/afl-sid
-
------------------------------------------------------------
-Crash triage, coverage analysis, and other companion tools:
------------------------------------------------------------
-
-afl-crash-analyzer (Tobias Ospelt)
-----------------------------------
-
- Makes it easier to navigate and annotate crashing test cases.
-
- https://github.com/floyd-fuh/afl-crash-analyzer/
-
-Crashwalk (Ben Nagy)
---------------------
-
- AFL-aware tool to annotate and sort through crashing test cases.
-
- https://github.com/bnagy/crashwalk
-
-afl-cov (Michael Rash)
-----------------------
-
- Produces human-readable coverage data based on the output queue of afl-fuzz.
-
- https://github.com/mrash/afl-cov
-
-afl-sancov (Bhargava Shastry)
------------------------------
-
- Similar to afl-cov, but uses clang sanitizer instrumentation.
-
- https://github.com/bshastry/afl-sancov
-
-RecidiVM (Jakub Wilk)
----------------------
-
- Makes it easy to estimate memory usage limits when fuzzing with ASAN or MSAN.
-
- http://jwilk.net/software/recidivm
-
-aflize (Jacek Wielemborek)
---------------------------
-
- Automatically build AFL-enabled versions of Debian packages.
-
- https://github.com/d33tah/aflize
-
-afl-ddmin-mod (Markus Teufelberger)
------------------------------------
-
- A variant of afl-tmin that uses a more sophisticated (but slower)
- minimization algorithm.
-
- https://github.com/MarkusTeufelberger/afl-ddmin-mod
-
--------------------------------
-Narrow-purpose or experimental:
--------------------------------
-
-Cygwin support (Ali Rizvi-Santiago)
------------------------------------
-
- Pretty self-explanatory. As per the author, this "mostly" ports AFL to
- Windows. Field reports welcome!
-
- https://github.com/arizvisa/afl-cygwin
-
-Pause and resume scripts (Ben Nagy)
------------------------------------
-
- Simple automation to suspend and resume groups of fuzzing jobs.
-
- https://gist.github.com/bnagy/8f0eb29eb125653f73fd
-
-Static binary-only instrumentation (Aleksandar Nikolich)
---------------------------------------------------------
-
- Allows black-box binaries to be instrumented statically (i.e., by modifying
- the binary ahead of the time, rather than translating it on the run). Author
- reports better performance compared to QEMU, but occasional translation
- errors with stripped binaries.
-
- https://github.com/vrtadmin/moflow/tree/master/afl-dyninst
-
-AFL PIN (Parker Thompson)
--------------------------
-
- Early-stage Intel PIN instrumentation support (from before we settled on
- faster-running QEMU).
-
- https://github.com/mothran/aflpin
-
-AFL-style instrumentation in llvm (Kostya Serebryany)
------------------------------------------------------
-
- Allows AFL-equivalent instrumentation to be injected at compiler level.
- This is currently not supported by AFL as-is, but may be useful in other
- projects.
-
- https://code.google.com/p/address-sanitizer/wiki/AsanCoverage#Coverage_counters
-
-AFL JS (Han Choongwoo)
-----------------------
-
- One-off optimizations to speed up the fuzzing of JavaScriptCore (now likely
- superseded by LLVM deferred forkserver init - see llvm_mode/README.llvm).
-
- https://github.com/tunz/afl-fuzz-js
-
-AFL harness for fwknop (Michael Rash)
--------------------------------------
-
- An example of a fairly involved integration with AFL.
-
- https://github.com/mrash/fwknop/tree/master/test/afl
-
-Building harnesses for DNS servers (Jonathan Foote, Ron Bowes)
---------------------------------------------------------------
-
- Two articles outlining the general principles and showing some example code.
-
- https://www.fastly.com/blog/how-to-fuzz-server-american-fuzzy-lop
- https://goo.gl/j9EgFf
-
-Fuzzer shell for SQLite (Richard Hipp)
---------------------------------------
-
- A simple SQL shell designed specifically for fuzzing the underlying library.
-
- http://www.sqlite.org/src/artifact/9e7e273da2030371
-
-Support for Python mutation modules (Christian Holler)
-------------------------------------------------------
-
- https://github.com/choller/afl/blob/master/docs/mozilla/python_modules.txt
-
-Support for selective instrumentation (Christian Holler)
---------------------------------------------------------
-
- https://github.com/choller/afl/blob/master/docs/mozilla/partial_instrumentation.txt
-
-Kernel fuzzing (Dmitry Vyukov)
-------------------------------
-
- A similar guided approach as applied to fuzzing syscalls:
-
- https://github.com/google/syzkaller/wiki/Found-Bugs
- https://github.com/dvyukov/linux/commit/33787098ffaaa83b8a7ccf519913ac5fd6125931
- http://events.linuxfoundation.org/sites/events/files/slides/AFL%20filesystem%20fuzzing%2C%20Vault%202016_0.pdf
diff --git a/chromium/third_party/afl/src/docs/status_screen.txt b/chromium/third_party/afl/src/docs/status_screen.txt
deleted file mode 100644
index ac09804f138..00000000000
--- a/chromium/third_party/afl/src/docs/status_screen.txt
+++ /dev/null
@@ -1,400 +0,0 @@
-===============================
-Understanding the status screen
-===============================
-
- This document provides an overview of the status screen - plus tips for
- troubleshooting any warnings and red text shown in the UI. See README for
- the general instruction manual.
-
-0) A note about colors
-----------------------
-
-The status screen and error messages use colors to keep things readable and
-attract your attention to the most important details. For example, red almost
-always means "consult this doc" :-)
-
-Unfortunately, the UI will render correctly only if your terminal is using
-traditional un*x palette (white text on black background) or something close
-to that.
-
-If you are using inverse video, you may want to change your settings, say:
-
- - For GNOME Terminal, go to Edit > Profile preferences, select the "colors"
- tab, and from the list of built-in schemes, choose "white on black".
-
- - For the MacOS X Terminal app, open a new window using the "Pro" scheme via
- the Shell > New Window menu (or make "Pro" your default).
-
-Alternatively, if you really like your current colors, you can edit config.h
-to comment out USE_COLORS, then do 'make clean all'.
-
-I'm not aware of any other simple way to make this work without causing
-other side effects - sorry about that.
-
-With that out of the way, let's talk about what's actually on the screen...
-
-1) Process timing
------------------
-
- +----------------------------------------------------+
- | run time : 0 days, 8 hrs, 32 min, 43 sec |
- | last new path : 0 days, 0 hrs, 6 min, 40 sec |
- | last uniq crash : none seen yet |
- | last uniq hang : 0 days, 1 hrs, 24 min, 32 sec |
- +----------------------------------------------------+
-
-This section is fairly self-explanatory: it tells you how long the fuzzer has
-been running and how much time has elapsed since its most recent finds. This is
-broken down into "paths" (a shorthand for test cases that trigger new execution
-patterns), crashes, and hangs.
-
-When it comes to timing: there is no hard rule, but most fuzzing jobs should be
-expected to run for days or weeks; in fact, for a moderately complex project, the
-first pass will probably take a day or so. Every now and then, some jobs
-will be allowed to run for months.
-
-There's one important thing to watch out for: if the tool is not finding new
-paths within several minutes of starting, you're probably not invoking the
-target binary correctly and it never gets to parse the input files we're
-throwing at it; another possible explanations are that the default memory limit
-(-m) is too restrictive, and the program exits after failing to allocate a
-buffer very early on; or that the input files are patently invalid and always
-fail a basic header check.
-
-If there are no new paths showing up for a while, you will eventually see a big
-red warning in this section, too :-)
-
-2) Overall results
-------------------
-
- +-----------------------+
- | cycles done : 0 |
- | total paths : 2095 |
- | uniq crashes : 0 |
- | uniq hangs : 19 |
- +-----------------------+
-
-The first field in this section gives you the count of queue passes done so far
-- that is, the number of times the fuzzer went over all the interesting test
-cases discovered so far, fuzzed them, and looped back to the very beginning.
-Every fuzzing session should be allowed to complete at least one cycle; and
-ideally, should run much longer than that.
-
-As noted earlier, the first pass can take a day or longer, so sit back and
-relax. If you want to get broader but more shallow coverage right away, try
-the -d option - it gives you a more familiar experience by skipping the
-deterministic fuzzing steps. It is, however, inferior to the standard mode in
-a couple of subtle ways.
-
-To help make the call on when to hit Ctrl-C, the cycle counter is color-coded.
-It is shown in magenta during the first pass, progresses to yellow if new finds
-are still being made in subsequent rounds, then blue when that ends - and
-finally, turns green after the fuzzer hasn't been seeing any action for a
-longer while.
-
-The remaining fields in this part of the screen should be pretty obvious:
-there's the number of test cases ("paths") discovered so far, and the number of
-unique faults. The test cases, crashes, and hangs can be explored in real-time
-by browsing the output directory, as discussed in the README.
-
-3) Cycle progress
------------------
-
- +-------------------------------------+
- | now processing : 1296 (61.86%) |
- | paths timed out : 0 (0.00%) |
- +-------------------------------------+
-
-This box tells you how far along the fuzzer is with the current queue cycle: it
-shows the ID of the test case it is currently working on, plus the number of
-inputs it decided to ditch because they were persistently timing out.
-
-The "*" suffix sometimes shown in the first line means that the currently
-processed path is not "favored" (a property discussed later on, in section 6).
-
-If you feel that the fuzzer is progressing too slowly, see the note about the
--d option in section 2 of this doc.
-
-4) Map coverage
----------------
-
- +--------------------------------------+
- | map density : 10.15% / 29.07% |
- | count coverage : 4.03 bits/tuple |
- +--------------------------------------+
-
-The section provides some trivia about the coverage observed by the
-instrumentation embedded in the target binary.
-
-The first line in the box tells you how many branch tuples we have already
-hit, in proportion to how much the bitmap can hold. The number on the left
-describes the current input; the one on the right is the value for the entire
-input corpus.
-
-Be wary of extremes:
-
- - Absolute numbers below 200 or so suggest one of three things: that the
- program is extremely simple; that it is not instrumented properly (e.g.,
- due to being linked against a non-instrumented copy of the target
- library); or that it is bailing out prematurely on your input test cases.
- The fuzzer will try to mark this in pink, just to make you aware.
-
- - Percentages over 70% may very rarely happen with very complex programs
- that make heavy use of template-generated code.
-
- Because high bitmap density makes it harder for the fuzzer to reliably
- discern new program states, I recommend recompiling the binary with
- AFL_INST_RATIO=10 or so and trying again (see env_variables.txt).
-
- The fuzzer will flag high percentages in red. Chances are, you will never
- see that unless you're fuzzing extremely hairy software (say, v8, perl,
- ffmpeg).
-
-The other line deals with the variability in tuple hit counts seen in the
-binary. In essence, if every taken branch is always taken a fixed number of
-times for all the inputs we have tried, this will read "1.00". As we manage
-to trigger other hit counts for every branch, the needle will start to move
-toward "8.00" (every bit in the 8-bit map hit), but will probably never
-reach that extreme.
-
-Together, the values can be useful for comparing the coverage of several
-different fuzzing jobs that rely on the same instrumented binary.
-
-5) Stage progress
------------------
-
- +-------------------------------------+
- | now trying : interest 32/8 |
- | stage execs : 3996/34.4k (11.62%) |
- | total execs : 27.4M |
- | exec speed : 891.7/sec |
- +-------------------------------------+
-
-This part gives you an in-depth peek at what the fuzzer is actually doing right
-now. It tells you about the current stage, which can be any of:
-
- - calibration - a pre-fuzzing stage where the execution path is examined
- to detect anomalies, establish baseline execution speed, and so on. Executed
- very briefly whenever a new find is being made.
-
- - trim L/S - another pre-fuzzing stage where the test case is trimmed to the
- shortest form that still produces the same execution path. The length (L)
- and stepover (S) are chosen in general relationship to file size.
-
- - bitflip L/S - deterministic bit flips. There are L bits toggled at any given
- time, walking the input file with S-bit increments. The current L/S variants
- are: 1/1, 2/1, 4/1, 8/8, 16/8, 32/8.
-
- - arith L/8 - deterministic arithmetics. The fuzzer tries to subtract or add
- small integers to 8-, 16-, and 32-bit values. The stepover is always 8 bits.
-
- - interest L/8 - deterministic value overwrite. The fuzzer has a list of known
- "interesting" 8-, 16-, and 32-bit values to try. The stepover is 8 bits.
-
- - extras - deterministic injection of dictionary terms. This can be shown as
- "user" or "auto", depending on whether the fuzzer is using a user-supplied
- dictionary (-x) or an auto-created one. You will also see "over" or "insert",
- depending on whether the dictionary words overwrite existing data or are
- inserted by offsetting the remaining data to accommodate their length.
-
- - havoc - a sort-of-fixed-length cycle with stacked random tweaks. The
- operations attempted during this stage include bit flips, overwrites with
- random and "interesting" integers, block deletion, block duplication, plus
- assorted dictionary-related operations (if a dictionary is supplied in the
- first place).
-
- - splice - a last-resort strategy that kicks in after the first full queue
- cycle with no new paths. It is equivalent to 'havoc', except that it first
- splices together two random inputs from the queue at some arbitrarily
- selected midpoint.
-
- - sync - a stage used only when -M or -S is set (see parallel_fuzzing.txt).
- No real fuzzing is involved, but the tool scans the output from other
- fuzzers and imports test cases as necessary. The first time this is done,
- it may take several minutes or so.
-
-The remaining fields should be fairly self-evident: there's the exec count
-progress indicator for the current stage, a global exec counter, and a
-benchmark for the current program execution speed. This may fluctuate from
-one test case to another, but the benchmark should be ideally over 500 execs/sec
-most of the time - and if it stays below 100, the job will probably take very
-long.
-
-The fuzzer will explicitly warn you about slow targets, too. If this happens,
-see the perf_tips.txt file included with the fuzzer for ideas on how to speed
-things up.
-
-6) Findings in depth
---------------------
-
- +--------------------------------------+
- | favored paths : 879 (41.96%) |
- | new edges on : 423 (20.19%) |
- | total crashes : 0 (0 unique) |
- | total hangs : 24 (19 unique) |
- +--------------------------------------+
-
-This gives you several metrics that are of interest mostly to complete nerds.
-The section includes the number of paths that the fuzzer likes the most based
-on a minimization algorithm baked into the code (these will get considerably
-more air time), and the number of test cases that actually resulted in better
-edge coverage (versus just pushing the branch hit counters up). There are also
-additional, more detailed counters for crashes and hangs.
-
-7) Fuzzing strategy yields
---------------------------
-
- +-----------------------------------------------------+
- | bit flips : 57/289k, 18/289k, 18/288k |
- | byte flips : 0/36.2k, 4/35.7k, 7/34.6k |
- | arithmetics : 53/2.54M, 0/537k, 0/55.2k |
- | known ints : 8/322k, 12/1.32M, 10/1.70M |
- | dictionary : 9/52k, 1/53k, 1/24k |
- | havoc : 1903/20.0M, 0/0 |
- | trim : 20.31%/9201, 17.05% |
- +-----------------------------------------------------+
-
-This is just another nerd-targeted section keeping track of how many paths we
-have netted, in proportion to the number of execs attempted, for each of the
-fuzzing strategies discussed earlier on. This serves to convincingly validate
-assumptions about the usefulness of the various approaches taken by afl-fuzz.
-
-The trim strategy stats in this section are a bit different than the rest.
-The first number in this line shows the ratio of bytes removed from the input
-files; the second one corresponds to the number of execs needed to achieve this
-goal. Finally, the third number shows the proportion of bytes that, although
-not possible to remove, were deemed to have no effect and were excluded from
-some of the more expensive deterministic fuzzing steps.
-
-8) Path geometry
-----------------
-
- +---------------------+
- | levels : 5 |
- | pending : 1570 |
- | pend fav : 583 |
- | own finds : 0 |
- | imported : 0 |
- | stability : 100.00% |
- +---------------------+
-
-The first field in this section tracks the path depth reached through the
-guided fuzzing process. In essence: the initial test cases supplied by the
-user are considered "level 1". The test cases that can be derived from that
-through traditional fuzzing are considered "level 2"; the ones derived by
-using these as inputs to subsequent fuzzing rounds are "level 3"; and so forth.
-The maximum depth is therefore a rough proxy for how much value you're getting
-out of the instrumentation-guided approach taken by afl-fuzz.
-
-The next field shows you the number of inputs that have not gone through any
-fuzzing yet. The same stat is also given for "favored" entries that the fuzzer
-really wants to get to in this queue cycle (the non-favored entries may have to
-wait a couple of cycles to get their chance).
-
-Next, we have the number of new paths found during this fuzzing section and
-imported from other fuzzer instances when doing parallelized fuzzing; and the
-number of inputs that produce seemingly variable behavior in the tested binary.
-
-That last bit is actually fairly interesting: it measures the consistency of
-observed traces. If a program always behaves the same for the same input data,
-it will earn a score of 100%. When the value is lower but still shown in purple,
-the fuzzing process is unlikely to be negatively affected. If it goes into red,
-you may be in trouble, since AFL will have difficulty discerning between
-meaningful and "phantom" effects of tweaking the input file.
-
-Now, most targets will just get a 100% score, but when you see lower figures,
-there are several things to look at:
-
- - The use of uninitialized memory in conjunction with some intrinsic sources
- of entropy in the tested binary. Harmless to AFL, but could be indicative
- of a security bug.
-
- - Attempts to manipulate persistent resources, such as left over temporary
- files or shared memory objects. This is usually harmless, but you may want
- to double-check to make sure the program isn't bailing out prematurely.
- Running out of disk space, SHM handles, or other global resources can
- trigger this, too.
-
- - Hitting some functionality that is actually designed to behave randomly.
- Generally harmless. For example, when fuzzing sqlite, an input like
- 'select random();' will trigger a variable execution path.
-
- - Multiple threads executing at once in semi-random order. This is harmless
- when the 'stability' metric stays over 90% or so, but can become an issue
- if not. Here's what to try:
-
- - Use afl-clang-fast from llvm_mode/ - it uses a thread-local tracking
- model that is less prone to concurrency issues,
-
- - See if the target can be compiled or run without threads. Common
- ./configure options include --without-threads, --disable-pthreads, or
- --disable-openmp.
-
- - Replace pthreads with GNU Pth (https://www.gnu.org/software/pth/), which
- allows you to use a deterministic scheduler.
-
- - In persistent mode, minor drops in the "stability" metric can be normal,
- because not all the code behaves identically when re-entered; but major
- dips may signify that the code within __AFL_LOOP() is not behaving
- correctly on subsequent iterations (e.g., due to incomplete clean-up or
- reinitialization of the state) and that most of the fuzzing effort goes
- to waste.
-
-The paths where variable behavior is detected are marked with a matching entry
-in the <out_dir>/queue/.state/variable_behavior/ directory, so you can look
-them up easily.
-
-9) CPU load
------------
-
- [cpu: 25%]
-
-This tiny widget shows the apparent CPU utilization on the local system. It is
-calculated by taking the number of processes in the "runnable" state, and then
-comparing it to the number of logical cores on the system.
-
-If the value is shown in green, you are using fewer CPU cores than available on
-your system and can probably parallelize to improve performance; for tips on
-how to do that, see parallel_fuzzing.txt.
-
-If the value is shown in red, your CPU is *possibly* oversubscribed, and
-running additional fuzzers may not give you any benefits.
-
-Of course, this benchmark is very simplistic; it tells you how many processes
-are ready to run, but not how resource-hungry they may be. It also doesn't
-distinguish between physical cores, logical cores, and virtualized CPUs; the
-performance characteristics of each of these will differ quite a bit.
-
-If you want a more accurate measurement, you can run the afl-gotcpu utility
-from the command line.
-
-10) Addendum: status and plot files
------------------------------------
-
-For unattended operation, some of the key status screen information can be also
-found in a machine-readable format in the fuzzer_stats file in the output
-directory. This includes:
-
- - start_time - unix time indicating the start time of afl-fuzz
- - last_update - unix time corresponding to the last update of this file
- - fuzzer_pid - PID of the fuzzer process
- - cycles_done - queue cycles completed so far
- - execs_done - number of execve() calls attempted
- - execs_per_sec - current number of execs per second
- - paths_total - total number of entries in the queue
- - paths_found - number of entries discovered through local fuzzing
- - paths_imported - number of entries imported from other instances
- - max_depth - number of levels in the generated data set
- - cur_path - currently processed entry number
- - pending_favs - number of favored entries still waiting to be fuzzed
- - pending_total - number of all entries waiting to be fuzzed
- - stability - percentage of bitmap bytes that behave consistently
- - variable_paths - number of test cases showing variable behavior
- - unique_crashes - number of unique crashes recorded
- - unique_hangs - number of unique hangs encountered
-
-Most of these map directly to the UI elements discussed earlier on.
-
-On top of that, you can also find an entry called 'plot_data', containing a
-plottable history for most of these fields. If you have gnuplot installed, you
-can turn this into a nice progress report with the included 'afl-plot' tool.
diff --git a/chromium/third_party/afl/src/docs/technical_details.txt b/chromium/third_party/afl/src/docs/technical_details.txt
deleted file mode 100644
index af6131c1057..00000000000
--- a/chromium/third_party/afl/src/docs/technical_details.txt
+++ /dev/null
@@ -1,563 +0,0 @@
-===================================
-Technical "whitepaper" for afl-fuzz
-===================================
-
- This document provides a quick overview of the guts of American Fuzzy Lop.
- See README for the general instruction manual; and for a discussion of
- motivations and design goals behind AFL, see historical_notes.txt.
-
-0) Design statement
--------------------
-
-American Fuzzy Lop does its best not to focus on any singular principle of
-operation and not be a proof-of-concept for any specific theory. The tool can
-be thought of as a collection of hacks that have been tested in practice,
-found to be surprisingly effective, and have been implemented in the simplest,
-most robust way I could think of at the time.
-
-Many of the resulting features are made possible thanks to the availability of
-lightweight instrumentation that served as a foundation for the tool, but this
-mechanism should be thought of merely as a means to an end. The only true
-governing principles are speed, reliability, and ease of use.
-
-1) Coverage measurements
-------------------------
-
-The instrumentation injected into compiled programs captures branch (edge)
-coverage, along with coarse branch-taken hit counts. The code injected at
-branch points is essentially equivalent to:
-
- cur_location = <COMPILE_TIME_RANDOM>;
- shared_mem[cur_location ^ prev_location]++;
- prev_location = cur_location >> 1;
-
-The cur_location value is generated randomly to simplify the process of
-linking complex projects and keep the XOR output distributed uniformly.
-
-The shared_mem[] array is a 64 kB SHM region passed to the instrumented binary
-by the caller. Every byte set in the output map can be thought of as a hit for
-a particular (branch_src, branch_dst) tuple in the instrumented code.
-
-The size of the map is chosen so that collisions are sporadic with almost all
-of the intended targets, which usually sport between 2k and 10k discoverable
-branch points:
-
- Branch cnt | Colliding tuples | Example targets
- ------------+------------------+-----------------
- 1,000 | 0.75% | giflib, lzo
- 2,000 | 1.5% | zlib, tar, xz
- 5,000 | 3.5% | libpng, libwebp
- 10,000 | 7% | libxml
- 20,000 | 14% | sqlite
- 50,000 | 30% | -
-
-At the same time, its size is small enough to allow the map to be analyzed
-in a matter of microseconds on the receiving end, and to effortlessly fit
-within L2 cache.
-
-This form of coverage provides considerably more insight into the execution
-path of the program than simple block coverage. In particular, it trivially
-distinguishes between the following execution traces:
-
- A -> B -> C -> D -> E (tuples: AB, BC, CD, DE)
- A -> B -> D -> C -> E (tuples: AB, BD, DC, CE)
-
-This aids the discovery of subtle fault conditions in the underlying code,
-because security vulnerabilities are more often associated with unexpected
-or incorrect state transitions than with merely reaching a new basic block.
-
-The reason for the shift operation in the last line of the pseudocode shown
-earlier in this section is to preserve the directionality of tuples (without
-this, A ^ B would be indistinguishable from B ^ A) and to retain the identity
-of tight loops (otherwise, A ^ A would be obviously equal to B ^ B).
-
-The absence of simple saturating arithmetic opcodes on Intel CPUs means that
-the hit counters can sometimes wrap around to zero. Since this is a fairly
-unlikely and localized event, it's seen as an acceptable performance trade-off.
-
-2) Detecting new behaviors
---------------------------
-
-The fuzzer maintains a global map of tuples seen in previous executions; this
-data can be rapidly compared with individual traces and updated in just a couple
-of dword- or qword-wide instructions and a simple loop.
-
-When a mutated input produces an execution trace containing new tuples, the
-corresponding input file is preserved and routed for additional processing
-later on (see section #3). Inputs that do not trigger new local-scale state
-transitions in the execution trace (i.e., produce no new tuples) are discarded,
-even if their overall control flow sequence is unique.
-
-This approach allows for a very fine-grained and long-term exploration of
-program state while not having to perform any computationally intensive and
-fragile global comparisons of complex execution traces, and while avoiding the
-scourge of path explosion.
-
-To illustrate the properties of the algorithm, consider that the second trace
-shown below would be considered substantially new because of the presence of
-new tuples (CA, AE):
-
- #1: A -> B -> C -> D -> E
- #2: A -> B -> C -> A -> E
-
-At the same time, with #2 processed, the following pattern will not be seen
-as unique, despite having a markedly different overall execution path:
-
- #3: A -> B -> C -> A -> B -> C -> A -> B -> C -> D -> E
-
-In addition to detecting new tuples, the fuzzer also considers coarse tuple
-hit counts. These are divided into several buckets:
-
- 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+
-
-To some extent, the number of buckets is an implementation artifact: it allows
-an in-place mapping of an 8-bit counter generated by the instrumentation to
-an 8-position bitmap relied on by the fuzzer executable to keep track of the
-already-seen execution counts for each tuple.
-
-Changes within the range of a single bucket are ignored; transition from one
-bucket to another is flagged as an interesting change in program control flow,
-and is routed to the evolutionary process outlined in the section below.
-
-The hit count behavior provides a way to distinguish between potentially
-interesting control flow changes, such as a block of code being executed
-twice when it was normally hit only once. At the same time, it is fairly
-insensitive to empirically less notable changes, such as a loop going from
-47 cycles to 48. The counters also provide some degree of "accidental"
-immunity against tuple collisions in dense trace maps.
-
-The execution is policed fairly heavily through memory and execution time
-limits; by default, the timeout is set at 5x the initially-calibrated
-execution speed, rounded up to 20 ms. The aggressive timeouts are meant to
-prevent dramatic fuzzer performance degradation by descending into tarpits
-that, say, improve coverage by 1% while being 100x slower; we pragmatically
-reject them and hope that the fuzzer will find a less expensive way to reach
-the same code. Empirical testing strongly suggests that more generous time
-limits are not worth the cost.
-
-3) Evolving the input queue
----------------------------
-
-Mutated test cases that produced new state transitions within the program are
-added to the input queue and used as a starting point for future rounds of
-fuzzing. They supplement, but do not automatically replace, existing finds.
-
-In contrast to more greedy genetic algorithms, this approach allows the tool
-to progressively explore various disjoint and possibly mutually incompatible
-features of the underlying data format, as shown in this image:
-
- http://lcamtuf.coredump.cx/afl/afl_gzip.png
-
-Several practical examples of the results of this algorithm are discussed
-here:
-
- http://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html
- http://lcamtuf.blogspot.com/2014/11/afl-fuzz-nobody-expects-cdata-sections.html
-
-The synthetic corpus produced by this process is essentially a compact
-collection of "hmm, this does something new!" input files, and can be used to
-seed any other testing processes down the line (for example, to manually
-stress-test resource-intensive desktop apps).
-
-With this approach, the queue for most targets grows to somewhere between 1k
-and 10k entries; approximately 10-30% of this is attributable to the discovery
-of new tuples, and the remainder is associated with changes in hit counts.
-
-The following table compares the relative ability to discover file syntax and
-explore program states when using several different approaches to guided
-fuzzing. The instrumented target was GNU patch 2.7.3 compiled with -O3 and
-seeded with a dummy text file; the session consisted of a single pass over the
-input queue with afl-fuzz:
-
- Fuzzer guidance | Blocks | Edges | Edge hit | Highest-coverage
- strategy used | reached | reached | cnt var | test case generated
- ------------------+---------+---------+----------+---------------------------
- (Initial file) | 156 | 163 | 1.00 | (none)
- | | | |
- Blind fuzzing S | 182 | 205 | 2.23 | First 2 B of RCS diff
- Blind fuzzing L | 228 | 265 | 2.23 | First 4 B of -c mode diff
- Block coverage | 855 | 1,130 | 1.57 | Almost-valid RCS diff
- Edge coverage | 1,452 | 2,070 | 2.18 | One-chunk -c mode diff
- AFL model | 1,765 | 2,597 | 4.99 | Four-chunk -c mode diff
-
-The first entry for blind fuzzing ("S") corresponds to executing just a single
-round of testing; the second set of figures ("L") shows the fuzzer running in a
-loop for a number of execution cycles comparable with that of the instrumented
-runs, which required more time to fully process the growing queue.
-
-Roughly similar results have been obtained in a separate experiment where the
-fuzzer was modified to compile out all the random fuzzing stages and leave just
-a series of rudimentary, sequential operations such as walking bit flips.
-Because this mode would be incapable of altering the size of the input file,
-the sessions were seeded with a valid unified diff:
-
- Queue extension | Blocks | Edges | Edge hit | Number of unique
- strategy used | reached | reached | cnt var | crashes found
- ------------------+---------+---------+----------+------------------
- (Initial file) | 624 | 717 | 1.00 | -
- | | | |
- Blind fuzzing | 1,101 | 1,409 | 1.60 | 0
- Block coverage | 1,255 | 1,649 | 1.48 | 0
- Edge coverage | 1,259 | 1,734 | 1.72 | 0
- AFL model | 1,452 | 2,040 | 3.16 | 1
-
-At noted earlier on, some of the prior work on genetic fuzzing relied on
-maintaining a single test case and evolving it to maximize coverage. At least
-in the tests described above, this "greedy" approach appears to confer no
-substantial benefits over blind fuzzing strategies.
-
-4) Culling the corpus
----------------------
-
-The progressive state exploration approach outlined above means that some of
-the test cases synthesized later on in the game may have edge coverage that
-is a strict superset of the coverage provided by their ancestors.
-
-To optimize the fuzzing effort, AFL periodically re-evaluates the queue using a
-fast algorithm that selects a smaller subset of test cases that still cover
-every tuple seen so far, and whose characteristics make them particularly
-favorable to the tool.
-
-The algorithm works by assigning every queue entry a score proportional to its
-execution latency and file size; and then selecting lowest-scoring candidates
-for each tuple.
-
-The tuples are then processed sequentially using a simple workflow:
-
- 1) Find next tuple not yet in the temporary working set,
-
- 2) Locate the winning queue entry for this tuple,
-
- 3) Register *all* tuples present in that entry's trace in the working set,
-
- 4) Go to #1 if there are any missing tuples in the set.
-
-The generated corpus of "favored" entries is usually 5-10x smaller than the
-starting data set. Non-favored entries are not discarded, but they are skipped
-with varying probabilities when encountered in the queue:
-
- - If there are new, yet-to-be-fuzzed favorites present in the queue, 99%
- of non-favored entries will be skipped to get to the favored ones.
-
- - If there are no new favorites:
-
- - If the current non-favored entry was fuzzed before, it will be skipped
- 95% of the time.
-
- - If it hasn't gone through any fuzzing rounds yet, the odds of skipping
- drop down to 75%.
-
-Based on empirical testing, this provides a reasonable balance between queue
-cycling speed and test case diversity.
-
-Slightly more sophisticated but much slower culling can be performed on input
-or output corpora with afl-cmin. This tool permanently discards the redundant
-entries and produces a smaller corpus suitable for use with afl-fuzz or
-external tools.
-
-5) Trimming input files
------------------------
-
-File size has a dramatic impact on fuzzing performance, both because large
-files make the target binary slower, and because they reduce the likelihood
-that a mutation would touch important format control structures, rather than
-redundant data blocks. This is discussed in more detail in perf_tips.txt.
-
-The possibility that the user will provide a low-quality starting corpus aside,
-some types of mutations can have the effect of iteratively increasing the size
-of the generated files, so it is important to counter this trend.
-
-Luckily, the instrumentation feedback provides a simple way to automatically
-trim down input files while ensuring that the changes made to the files have no
-impact on the execution path.
-
-The built-in trimmer in afl-fuzz attempts to sequentially remove blocks of data
-with variable length and stepover; any deletion that doesn't affect the checksum
-of the trace map is committed to disk. The trimmer is not designed to be
-particularly thorough; instead, it tries to strike a balance between precision
-and the number of execve() calls spent on the process, selecting the block size
-and stepover to match. The average per-file gains are around 5-20%.
-
-The standalone afl-tmin tool uses a more exhaustive, iterative algorithm, and
-also attempts to perform alphabet normalization on the trimmed files. The
-operation of afl-tmin is as follows.
-
-First, the tool automatically selects the operating mode. If the initial input
-crashes the target binary, afl-tmin will run in non-instrumented mode, simply
-keeping any tweaks that produce a simpler file but still crash the target. If
-the target is non-crashing, the tool uses an instrumented mode and keeps only
-the tweaks that produce exactly the same execution path.
-
-The actual minimization algorithm is:
-
- 1) Attempt to zero large blocks of data with large stepovers. Empirically,
- this is shown to reduce the number of execs by preempting finer-grained
- efforts later on.
-
- 2) Perform a block deletion pass with decreasing block sizes and stepovers,
- binary-search-style.
-
- 3) Perform alphabet normalization by counting unique characters and trying
- to bulk-replace each with a zero value.
-
- 4) As a last result, perform byte-by-byte normalization on non-zero bytes.
-
-Instead of zeroing with a 0x00 byte, afl-tmin uses the ASCII digit '0'. This
-is done because such a modification is much less likely to interfere with
-text parsing, so it is more likely to result in successful minimization of
-text files.
-
-The algorithm used here is less involved than some other test case
-minimization approaches proposed in academic work, but requires far fewer
-executions and tends to produce comparable results in most real-world
-applications.
-
-6) Fuzzing strategies
----------------------
-
-The feedback provided by the instrumentation makes it easy to understand the
-value of various fuzzing strategies and optimize their parameters so that they
-work equally well across a wide range of file types. The strategies used by
-afl-fuzz are generally format-agnostic and are discussed in more detail here:
-
- http://lcamtuf.blogspot.com/2014/08/binary-fuzzing-strategies-what-works.html
-
-It is somewhat notable that especially early on, most of the work done by
-afl-fuzz is actually highly deterministic, and progresses to random stacked
-modifications and test case splicing only at a later stage. The deterministic
-strategies include:
-
- - Sequential bit flips with varying lengths and stepovers,
-
- - Sequential addition and subtraction of small integers,
-
- - Sequential insertion of known interesting integers (0, 1, INT_MAX, etc),
-
-The purpose of opening with deterministic steps is related to their tendency to
-produce compact test cases and small diffs between the non-crashing and crashing
-inputs.
-
-With deterministic fuzzing out of the way, the non-deterministic steps include
-stacked bit flips, insertions, deletions, arithmetics, and splicing of different
-test cases.
-
-The relative yields and execve() costs of all these strategies have been
-investigated and are discussed in the aforementioned blog post.
-
-For the reasons discussed in historical_notes.txt (chiefly, performance,
-simplicity, and reliability), AFL generally does not try to reason about the
-relationship between specific mutations and program states; the fuzzing steps
-are nominally blind, and are guided only by the evolutionary design of the
-input queue.
-
-That said, there is one (trivial) exception to this rule: when a new queue
-entry goes through the initial set of deterministic fuzzing steps, and tweaks to
-some regions in the file are observed to have no effect on the checksum of the
-execution path, they may be excluded from the remaining phases of
-deterministic fuzzing - and the fuzzer may proceed straight to random tweaks.
-Especially for verbose, human-readable data formats, this can reduce the number
-of execs by 10-40% or so without an appreciable drop in coverage. In extreme
-cases, such as normally block-aligned tar archives, the gains can be as high as
-90%.
-
-Because the underlying "effector maps" are local every queue entry and remain
-in force only during deterministic stages that do not alter the size or the
-general layout of the underlying file, this mechanism appears to work very
-reliably and proved to be simple to implement.
-
-7) Dictionaries
----------------
-
-The feedback provided by the instrumentation makes it easy to automatically
-identify syntax tokens in some types of input files, and to detect that certain
-combinations of predefined or auto-detected dictionary terms constitute a
-valid grammar for the tested parser.
-
-A discussion of how these features are implemented within afl-fuzz can be found
-here:
-
- http://lcamtuf.blogspot.com/2015/01/afl-fuzz-making-up-grammar-with.html
-
-In essence, when basic, typically easily-obtained syntax tokens are combined
-together in a purely random manner, the instrumentation and the evolutionary
-design of the queue together provide a feedback mechanism to differentiate
-between meaningless mutations and ones that trigger new behaviors in the
-instrumented code - and to incrementally build more complex syntax on top of
-this discovery.
-
-The dictionaries have been shown to enable the fuzzer to rapidly reconstruct
-the grammar of highly verbose and complex languages such as JavaScript, SQL,
-or XML; several examples of generated SQL statements are given in the blog
-post mentioned above.
-
-Interestingly, the AFL instrumentation also allows the fuzzer to automatically
-isolate syntax tokens already present in an input file. It can do so by looking
-for run of bytes that, when flipped, produce a consistent change to the
-program's execution path; this is suggestive of an underlying atomic comparison
-to a predefined value baked into the code. The fuzzer relies on this signal
-to build compact "auto dictionaries" that are then used in conjunction with
-other fuzzing strategies.
-
-8) De-duping crashes
---------------------
-
-De-duplication of crashes is one of the more important problems for any
-competent fuzzing tool. Many of the naive approaches run into problems; in
-particular, looking just at the faulting address may lead to completely
-unrelated issues being clustered together if the fault happens in a common
-library function (say, strcmp, strcpy); while checksumming call stack
-backtraces can lead to extreme crash count inflation if the fault can be
-reached through a number of different, possibly recursive code paths.
-
-The solution implemented in afl-fuzz considers a crash unique if any of two
-conditions are met:
-
- - The crash trace includes a tuple not seen in any of the previous crashes,
-
- - The crash trace is missing a tuple that was always present in earlier
- faults.
-
-The approach is vulnerable to some path count inflation early on, but exhibits
-a very strong self-limiting effect, similar to the execution path analysis
-logic that is the cornerstone of afl-fuzz.
-
-9) Investigating crashes
-------------------------
-
-The exploitability of many types of crashes can be ambiguous; afl-fuzz tries
-to address this by providing a crash exploration mode where a known-faulting
-test case is fuzzed in a manner very similar to the normal operation of the
-fuzzer, but with a constraint that causes any non-crashing mutations to be
-thrown away.
-
-A detailed discussion of the value of this approach can be found here:
-
- http://lcamtuf.blogspot.com/2014/11/afl-fuzz-crash-exploration-mode.html
-
-The method uses instrumentation feedback to explore the state of the crashing
-program to get past the ambiguous faulting condition and then isolate the
-newly-found inputs for human review.
-
-On the subject of crashes, it is worth noting that in contrast to normal
-queue entries, crashing inputs are *not* trimmed; they are kept exactly as
-discovered to make it easier to compare them to the parent, non-crashing entry
-in the queue. That said, afl-tmin can be used to shrink them at will.
-
-10) The fork server
--------------------
-
-To improve performance, afl-fuzz uses a "fork server", where the fuzzed process
-goes through execve(), linking, and libc initialization only once, and is then
-cloned from a stopped process image by leveraging copy-on-write. The
-implementation is described in more detail here:
-
- http://lcamtuf.blogspot.com/2014/10/fuzzing-binaries-without-execve.html
-
-The fork server is an integral aspect of the injected instrumentation and
-simply stops at the first instrumented function to await commands from
-afl-fuzz.
-
-With fast targets, the fork server can offer considerable performance gains,
-usually between 1.5x and 2x. It is also possible to:
-
- - Use the fork server in manual ("deferred") mode, skipping over larger,
- user-selected chunks of initialization code. It requires very modest
- code changes to the targeted program, and With some targets, can
- produce 10x+ performance gains.
-
- - Enable "persistent" mode, where a single process is used to try out
- multiple inputs, greatly limiting the overhead of repetitive fork()
- calls. This generally requires some code changes to the targeted program,
- but can improve the performance of fast targets by a factor of 5 or more
- - approximating the benefits of in-process fuzzing jobs while still
- maintaining very robust isolation between the fuzzer process and the
- targeted binary.
-
-11) Parallelization
--------------------
-
-The parallelization mechanism relies on periodically examining the queues
-produced by independently-running instances on other CPU cores or on remote
-machines, and then selectively pulling in the test cases that, when tried
-out locally, produce behaviors not yet seen by the fuzzer at hand.
-
-This allows for extreme flexibility in fuzzer setup, including running synced
-instances against different parsers of a common data format, often with
-synergistic effects.
-
-For more information about this design, see parallel_fuzzing.txt.
-
-12) Binary-only instrumentation
--------------------------------
-
-Instrumentation of black-box, binary-only targets is accomplished with the
-help of a separately-built version of QEMU in "user emulation" mode. This also
-allows the execution of cross-architecture code - say, ARM binaries on x86.
-
-QEMU uses basic blocks as translation units; the instrumentation is implemented
-on top of this and uses a model roughly analogous to the compile-time hooks:
-
- if (block_address > elf_text_start && block_address < elf_text_end) {
-
- cur_location = (block_address >> 4) ^ (block_address << 8);
- shared_mem[cur_location ^ prev_location]++;
- prev_location = cur_location >> 1;
-
- }
-
-The shift-and-XOR-based scrambling in the second line is used to mask the
-effects of instruction alignment.
-
-The start-up of binary translators such as QEMU, DynamoRIO, and PIN is fairly
-slow; to counter this, the QEMU mode leverages a fork server similar to that
-used for compiler-instrumented code, effectively spawning copies of an
-already-initialized process paused at _start.
-
-First-time translation of a new basic block also incurs substantial latency. To
-eliminate this problem, the AFL fork server is extended by providing a channel
-between the running emulator and the parent process. The channel is used
-to notify the parent about the addresses of any newly-encountered blocks and to
-add them to the translation cache that will be replicated for future child
-processes.
-
-As a result of these two optimizations, the overhead of the QEMU mode is
-roughly 2-5x, compared to 100x+ for PIN.
-
-13) The afl-analyze tool
-------------------------
-
-The file format analyzer is a simple extension of the minimization algorithm
-discussed earlier on; instead of attempting to remove no-op blocks, the tool
-performs a series of walking byte flips and then annotates runs of bytes
-in the input file.
-
-It uses the following classification scheme:
-
- - "No-op blocks" - segments where bit flips cause no apparent changes to
- control flow. Common examples may be comment sections, pixel data within
- a bitmap file, etc.
-
- - "Superficial content" - segments where some, but not all, bitflips
- produce some control flow changes. Examples may include strings in rich
- documents (e.g., XML, RTF).
-
- - "Critical stream" - a sequence of bytes where all bit flips alter control
- flow in different but correlated ways. This may be compressed data,
- non-atomically compared keywords or magic values, etc.
-
- - "Suspected length field" - small, atomic integer that, when touched in
- any way, causes a consistent change to program control flow, suggestive
- of a failed length check.
-
- - "Suspected cksum or magic int" - an integer that behaves similarly to a
- length field, but has a numerical value that makes the length explanation
- unlikely. This is suggestive of a checksum or other "magic" integer.
-
- - "Suspected checksummed block" - a long block of data where any change
- always triggers the same new execution path. Likely caused by failing
- a checksum or a similar integrity check before any subsequent parsing
- takes place.
-
- - "Magic value section" - a generic token where changes cause the type
- of binary behavior outlined earlier, but that doesn't meet any of the
- other criteria. May be an atomically compared keyword or so.
diff --git a/chromium/third_party/afl/src/docs/visualization/afl_gzip.png b/chromium/third_party/afl/src/docs/visualization/afl_gzip.png
deleted file mode 100644
index 7c461d8fa02..00000000000
--- a/chromium/third_party/afl/src/docs/visualization/afl_gzip.png
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/experimental/README.experiments b/chromium/third_party/afl/src/experimental/README.experiments
deleted file mode 100644
index af9739bda38..00000000000
--- a/chromium/third_party/afl/src/experimental/README.experiments
+++ /dev/null
@@ -1,38 +0,0 @@
-Here's a quick overview of the stuff you can find in this directory:
-
- - argv_fuzzing - a simple wrapper to allow cmdline to be fuzzed
- (e.g., to test setuid programs).
-
- - asan_cgroups - a contributed script to simplify fuzzing ASAN
- binaries with robust memory limits on Linux.
-
- - bash_shellshock - a simple hack used to find a bunch of
- post-Shellshock bugs in bash.
-
- - canvas_harness - a test harness used to find browser bugs with a
- corpus generated using simple image parsing
- binaries & afl-fuzz.
-
- - clang_asm_normalize - a script that makes it easy to instrument
- hand-written assembly, provided that you have clang.
-
- - crash_triage - a very rudimentary example of how to annotate crashes
- with additional gdb metadata.
-
- - distributed_fuzzing - a sample script for synchronizing fuzzer instances
- across multiple machines (see parallel_fuzzing.txt).
-
- - libpng_no_checksum - a sample patch for removing CRC checks in libpng.
-
- - persistent_demo - an example of how to use the LLVM persistent process
- mode to speed up certain fuzzing jobs.
-
- - post_library - an example of how to build postprocessors for AFL.
-
-Note that the minimize_corpus.sh tool has graduated from the experimental/
-directory and is now available as ../afl-cmin. The LLVM mode has likewise
-graduated to ../llvm_mode/*.
-
-Most of the tools in this directory are meant chiefly as examples that need to
-be tweaked for your specific needs. They come with some basic documentation,
-but are not necessarily production-grade.
diff --git a/chromium/third_party/afl/src/experimental/asan_cgroups/limit_memory.sh b/chromium/third_party/afl/src/experimental/asan_cgroups/limit_memory.sh
deleted file mode 100755
index b0c77d15fa4..00000000000
--- a/chromium/third_party/afl/src/experimental/asan_cgroups/limit_memory.sh
+++ /dev/null
@@ -1,157 +0,0 @@
-#!/usr/bin/env bash
-#
-# american fuzzy lop - limit memory using cgroups
-# -----------------------------------------------
-#
-# Written by Samir Khakimov <samir.hakim@nyu.edu> and
-# David A. Wheeler <dwheeler@ida.org>
-#
-# Edits to bring the script in line with afl-cmin and other companion scripts
-# by Michal Zalewski <lcamtuf@google.com>. All bugs are my fault.
-#
-# Copyright 2015 Institute for Defense Analyses.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# This tool allows the amount of actual memory allocated to a program
-# to be limited on Linux systems using cgroups, instead of the traditional
-# setrlimit() API. This helps avoid the address space problems discussed in
-# docs/notes_for_asan.txt.
-#
-# Important: the limit covers *both* afl-fuzz and the fuzzed binary. In some
-# hopefully rare circumstances, afl-fuzz could be killed before the fuzzed
-# task.
-#
-
-echo "cgroup tool for afl-fuzz by <samir.hakim@nyu.edu> and <dwheeler@ida.org>"
-echo
-
-unset NEW_USER
-MEM_LIMIT="50"
-
-while getopts "+u:m:" opt; do
-
- case "$opt" in
-
- "u")
- NEW_USER="$OPTARG"
- ;;
-
- "m")
- MEM_LIMIT="$[OPTARG]"
- ;;
-
- "?")
- exit 1
- ;;
-
- esac
-
-done
-
-if [ "$MEM_LIMIT" -lt "5" ]; then
- echo "[-] Error: malformed or dangerously low value of -m." 1>&2
- exit 1
-fi
-
-shift $((OPTIND-1))
-
-TARGET_BIN="$1"
-
-if [ "$TARGET_BIN" = "" -o "$NEW_USER" = "" ]; then
-
- cat 1>&2 <<_EOF_
-Usage: $0 [ options ] -- /path/to/afl-fuzz [ ...afl options... ]
-
-Required parameters:
-
- -u user - run the fuzzer as a specific user after setting up limits
-
-Optional parameters:
-
- -m megs - set memory limit to a specified value ($MEM_LIMIT MB)
-
-This tool configures cgroups-based memory limits for a fuzzing job to simplify
-the task of fuzzing ASAN or MSAN binaries. You would normally want to use it in
-conjunction with '-m none' passed to the afl-fuzz binary itself, say:
-
- $0 -u joe ./afl-fuzz -i input -o output -m none /path/to/target
-
-_EOF_
-
- exit 1
-
-fi
-
-# Basic sanity checks
-
-if [ ! "`uname -s`" = "Linux" ]; then
- echo "[-] Error: this tool does not support non-Linux systems." 1>&2
- exit 1
-fi
-
-if [ ! "`id -u`" = "0" ]; then
- echo "[-] Error: you need to run this script as root (sorry!)." 1>&2
- exit 1
-fi
-
-if ! type cgcreate 2>/dev/null 1>&2; then
-
- echo "[-] Error: you need to install cgroup tools first." 1>&2
-
- if type apt-get 2>/dev/null 1>&2; then
- echo " (Perhaps 'apt-get install cgroup-bin' will work.)" 1>&2
- elif type yum 2>/dev/null 1>&2; then
- echo " (Perhaps 'yum install libcgroup-tools' will work.)" 1>&2
- fi
-
- exit 1
-
-fi
-
-if ! id -u "$NEW_USER" 2>/dev/null 1>&2; then
- echo "[-] Error: user '$NEW_USER' does not seem to exist." 1>&2
- exit 1
-fi
-
-# Create a new cgroup path if necessary... We used PID-keyed groups to keep
-# parallel afl-fuzz tasks separate from each other.
-
-CID="afl-$NEW_USER-$$"
-
-CPATH="/sys/fs/cgroup/memory/$CID"
-
-if [ ! -d "$CPATH" ]; then
-
- cgcreate -a "$NEW_USER" -g memory:"$CID" || exit 1
-
-fi
-
-# Set the appropriate limit...
-
-if [ -f "$CPATH/memory.memsw.limit_in_bytes" ]; then
-
- echo "${MEM_LIMIT}M" > "$CPATH/memory.limit_in_bytes" 2>/dev/null
- echo "${MEM_LIMIT}M" > "$CPATH/memory.memsw.limit_in_bytes" || exit 1
- echo "${MEM_LIMIT}M" > "$CPATH/memory.limit_in_bytes" || exit 1
-
-elif grep -qE 'partition|file' /proc/swaps; then
-
- echo "[-] Error: your system requires swap to be disabled first (swapoff -a)." 1>&2
- exit 1
-
-else
-
- echo "${MEM_LIMIT}M" > "$CPATH/memory.limit_in_bytes" || exit 1
-
-fi
-
-# All right. At this point, we can just run the command.
-
-cgexec -g "memory:$CID" su -c "$*" "$NEW_USER"
-
-cgdelete -g "memory:$CID"
diff --git a/chromium/third_party/afl/src/experimental/bash_shellshock/shellshock-fuzz.diff b/chromium/third_party/afl/src/experimental/bash_shellshock/shellshock-fuzz.diff
deleted file mode 100644
index 3fa05bf814c..00000000000
--- a/chromium/third_party/afl/src/experimental/bash_shellshock/shellshock-fuzz.diff
+++ /dev/null
@@ -1,59 +0,0 @@
-This patch shows a very simple way to find post-Shellshock bugs in bash, as
-discussed here:
-
- http://lcamtuf.blogspot.com/2014/10/bash-bug-how-we-finally-cracked.html
-
-In essence, it shows a way to fuzz environmental variables. Instructions:
-
-1) Download bash 4.3, apply this patch, compile with:
-
- CC=/path/to/afl-gcc ./configure
- make clean all
-
- Note that the harness puts the fuzzed output in $TEST_VARIABLE. With
- Florian's Shellshock patch (bash43-028), this is no longer passed down
- to the parser.
-
-2) Create and cd to an empty directory, put the compiled bash binary in
- there, and run these commands:
-
- mkdir in_dir
- echo -n '() { a() { a; }; : >b; }' >in_dir/script.txt
-
-3) Run the fuzzer with:
-
- /path/to/afl-fuzz -d -i in_dir -o out_dir ./bash -c :
-
- The -d parameter is advisable only if the tested shell is fairly slow
- or if you are in a hurry; will cover more ground faster, but
- less systematically.
-
-4) Watch for crashes in out_dir/crashes/. Also watch for any new files
- created in cwd if you're interested in non-crash RCEs (files will be
- created whenever the shell executes "foo>bar" or something like
- that). You can correlate their creation date with new entries in
- out_dir/queue/.
-
- You can also modify the bash binary to directly check for more subtle
- fault conditions, or use the synthesized entries in out_dir/queue/
- as a seed for other, possibly slower or more involved testing regimes.
-
- Expect several hours to get decent coverage.
-
---- bash-4.3/shell.c.orig 2014-01-14 14:04:32.000000000 +0100
-+++ bash-4.3/shell.c 2015-04-30 05:56:46.000000000 +0200
-@@ -371,6 +371,14 @@
- env = environ;
- #endif /* __OPENNT */
-
-+ {
-+
-+ static char val[1024 * 16];
-+ read(0, val, sizeof(val) - 1);
-+ setenv("TEST_VARIABLE", val, 1);
-+
-+ }
-+
- USE_VAR(argc);
- USE_VAR(argv);
- USE_VAR(env);
diff --git a/chromium/third_party/afl/src/experimental/canvas_harness/canvas_harness.html b/chromium/third_party/afl/src/experimental/canvas_harness/canvas_harness.html
deleted file mode 100644
index 192936675ce..00000000000
--- a/chromium/third_party/afl/src/experimental/canvas_harness/canvas_harness.html
+++ /dev/null
@@ -1,170 +0,0 @@
-<html>
-<!--
-
- american fuzzy lop - <canvas> harness
- -------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- A simple harness for going through afl-generated test cases, rendering them in
- the browser environment, and discovering the use of uninitialized memory and
- similar bugs. This code led to the discovery of a fair number of library and
- browser security bugs!
-
- The url_list[] array is a placeholder; for this to work properly, it needs to
- be initialized with web-reachable paths to individual test cases. This can
- be done manually or with a simple script.
-
--->
-
-<body onload="set_images()">
-
-<div id="status"></div>
-
-<div id="image_div"></div>
-
-<canvas height=64 width=64 id=cvs></canvas>
-
-<h2>Results</h2>
-
-<ul id="output"></ul>
-
-<script>
-
-var c = document.getElementById('cvs');
-var ctx = c.getContext('2d');
-
-var url_list = [
- "images/id:000000,[...].jpg",
- "images/id:000001,[...].jpg",
- /* ... */
- null
-];
-
-var USE_IMAGES = 50;
-var cur_image = 0;
-
-if (location.hash) cur_image = parseInt(location.hash.substr(1));
-
-var loaded = 0;
-var image_obj = [];
-
-var msie_cleanup;
-
-function check_results() {
-
- var uniques = [];
-
- clearTimeout(msie_cleanup);
-
- ctx.clearRect(0, 0, 64, 64);
-
- uniques.push(image_obj[0].imgdata);
-
- for (var i = 1; i < USE_IMAGES; i++) {
-
- if (!image_obj[i].imgdata) continue;
-
- if (image_obj[0].imgdata != image_obj[i].imgdata) {
-
- for (var j = 1; j < uniques.length; j++)
- if (uniques[j] == image_obj[i].imgdata) break;
-
- if (j == uniques.length) uniques.push(image_obj[i].imgdata);
-
-
- }
-
- }
-
- if (uniques.length > 1) {
-
- var str = '<li> Image ' + url_list[cur_image] + ' has ' + uniques.length + ' variants: ';
-
- for (var i = 0; i < uniques.length; i++)
- str += '<img src="' + uniques[i] + '">';
-
- document.getElementById('output').innerHTML += str;
-
- }
-
- cur_image++;
- set_images();
-}
-
-
-function count_image() {
-
- if (!this.complete || this.counted) return;
-
- this.counted = true;
-
- loaded++;
-
- ctx.clearRect(0, 0, 64, 64);
-
- try {
- ctx.drawImage(this, 0, 0, 64, 64);
- } catch (e) { }
-
- this.imgdata = c.toDataURL();
-
- if (loaded == USE_IMAGES) check_results();
-}
-
-
-function set_images() {
-
- loaded = 0;
-
- document.getElementById('status').innerHTML = 'Now processing ' + cur_image + '...';
- location.hash = '#' + cur_image;
-
- if (url_list[cur_image] == null) {
- alert('Done!');
- return;
- }
-
- restart_images();
-
- msie_cleanup = setTimeout(check_results, 5000);
-
- for (var i = 0; i < USE_IMAGES; i++)
- image_obj[i].src = url_list[cur_image] + '?' + Math.random();
-
-}
-
-
-function restart_images() {
-
- for (var i = 0; i < USE_IMAGES; i++)
- if (image_obj[i]) image_obj[i].counted = true;
-
- document.getElementById('image_div').innerHTML = '';
- image_obj = [];
-
- for (var i = 0; i < USE_IMAGES; i++) {
-
- image_obj[i] = new Image();
- image_obj[i].height = 64;
- image_obj[i].width = 64;
- image_obj[i].onerror = count_image;
- image_obj[i].onload = count_image;
-
- document.getElementById('image_div').appendChild(image_obj[i]);
-
- }
-
-}
-
-</script>
-
-<iframe src='http://www.cnn.com/'></iframe>
diff --git a/chromium/third_party/afl/src/experimental/clang_asm_normalize/as b/chromium/third_party/afl/src/experimental/clang_asm_normalize/as
deleted file mode 100755
index 4ee07e691a9..00000000000
--- a/chromium/third_party/afl/src/experimental/clang_asm_normalize/as
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/sh
-#
-# american fuzzy lop - clang assembly normalizer
-# ----------------------------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-# The idea for this wrapper comes from Ryan Govostes.
-#
-# Copyright 2013, 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# This 'as' wrapper should allow you to instrument unruly, hand-written
-# assembly with afl-as.
-#
-# Usage:
-#
-# export AFL_REAL_PATH=/path/to/directory/with/afl-as/
-# AFL_PATH=/path/to/this/directory/ make clean all
-
-if [ "$#" -lt "2" ]; then
- echo "[-] Error: this utility can't be called directly." 1>&2
- exit 1
-fi
-
-if [ "$AFL_REAL_PATH" = "" ]; then
- echo "[-] Error: AFL_REAL_PATH not set!" 1>&2
- exit 1
-fi
-
-if [ ! -x "$AFL_REAL_PATH/afl-as" ]; then
- echo "[-] Error: AFL_REAL_PATH does not contain the 'afl-as' binary." 1>&2
- exit 1
-fi
-
-unset __AFL_AS_CMDLINE __AFL_FNAME
-
-while [ ! "$#" = "0" ]; do
-
- if [ "$#" = "1" ]; then
- __AFL_FNAME="$1"
- else
- __AFL_AS_CMDLINE="${__AFL_AS_CMDLINE} $1"
- fi
-
- shift
-
-done
-
-test "$TMPDIR" = "" && TMPDIR=/tmp
-
-TMPFILE=`mktemp $TMPDIR/.afl-XXXXXXXXXX.s`
-
-test "$TMPFILE" = "" && exit 1
-
-clang -cc1as -filetype asm -output-asm-variant 0 "${__AFL_FNAME}" >"$TMPFILE"
-
-ERR="$?"
-
-if [ ! "$ERR" = "0" ]; then
- rm -f "$TMPFILE"
- exit $ERR
-fi
-
-"$AFL_REAL_PATH/afl-as" ${__AFL_AS_CMDLINE} "$TMPFILE"
-
-ERR="$?"
-
-rm -f "$TMPFILE"
-
-exit "$ERR"
diff --git a/chromium/third_party/afl/src/experimental/crash_triage/triage_crashes.sh b/chromium/third_party/afl/src/experimental/crash_triage/triage_crashes.sh
deleted file mode 100755
index 9dddefdd095..00000000000
--- a/chromium/third_party/afl/src/experimental/crash_triage/triage_crashes.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/sh
-#
-# american fuzzy lop - crash triage utility
-# -----------------------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2013, 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Note that this assumes that the targeted application reads from stdin
-# and requires no other cmdline parameters. Modify as needed if this is
-# not the case.
-#
-# Note that on OpenBSD, you may need to install a newer version of gdb
-# (e.g., from ports). You can set GDB=/some/path to point to it if
-# necessary.
-#
-
-echo "crash triage utility for afl-fuzz by <lcamtuf@google.com>"
-echo
-
-ulimit -v 100000 2>/dev/null
-ulimit -d 100000 2>/dev/null
-
-if [ ! "$#" = "2" ]; then
- echo "Usage: $0 /path/to/afl_output_dir /path/to/tested_binary" 1>&2
- echo 1>&2
- echo "Note: the tested binary must accept input on stdin and require no additional" 1>&2
- echo "parameters. For more complex use cases, you need to edit this script." 1>&2
- echo 1>&2
- exit 1
-fi
-
-DIR="$1"
-BIN="$2"
-
-echo "$DIR" | grep -qE '^(/var)?/tmp/'
-T1="$?"
-
-echo "$BIN" | grep -qE '^(/var)?/tmp/'
-T2="$?"
-
-if [ "$T1" = "0" -o "$T2" = "0" ]; then
- echo "[-] Error: do not use shared /tmp or /var/tmp directories with this script." 1>&2
- exit 1
-fi
-
-if [ "$GDB" = "" ]; then
- GDB=gdb
-fi
-
-if [ ! -f "$BIN" -o ! -x "$BIN" ]; then
- echo "[-] Error: binary '$2' not found or is not executable." 1>&2
- exit 1
-fi
-
-if [ ! -d "$DIR/queue" ]; then
- echo "[-] Error: directory '$1' not found or not created by afl-fuzz." 1>&2
- exit 1
-fi
-
-CCOUNT=$((`ls -- "$DIR/crashes" 2>/dev/null | wc -l`))
-
-if [ "$CCOUNT" = "0" ]; then
- echo "No crashes recorded in the target directory - nothing to be done."
- exit 0
-fi
-
-echo
-
-for crash in $DIR/crashes/id:*; do
-
- id=`basename -- "$crash" | cut -d, -f1 | cut -d: -f2`
- sig=`basename -- "$crash" | cut -d, -f2 | cut -d: -f2`
-
- echo "+++ ID $id, SIGNAL $sig +++"
- echo
-
- $GDB --batch -q --ex "r <$crash" --ex 'back' --ex 'disass $pc, $pc+16' --ex 'info reg' --ex 'quit' "$BIN" 0</dev/null
- echo
-
-done
-
diff --git a/chromium/third_party/afl/src/experimental/distributed_fuzzing/sync_script.sh b/chromium/third_party/afl/src/experimental/distributed_fuzzing/sync_script.sh
deleted file mode 100755
index 29bcba6470f..00000000000
--- a/chromium/third_party/afl/src/experimental/distributed_fuzzing/sync_script.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/sh
-#
-# american fuzzy lop - fuzzer synchronization tool
-# ------------------------------------------------
-#
-# Written and maintained by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# To make this script work:
-#
-# - Edit FUZZ_HOSTS, FUZZ_DOMAIN, FUZZ_USER, and SYNC_DIR to reflect your
-# environment.
-#
-# - Make sure that the system you are running this on can log into FUZZ_HOSTS
-# without a password (authorized_keys or otherwise).
-#
-# - Make sure that every fuzzer is running with -o pointing to SYNC_DIR and -S
-# that consists of its local host name, followed by an underscore, and then
-# by some host-local fuzzer ID.
-#
-
-# Hosts to synchronize the data across.
-FUZZ_HOSTS='host1 host2 host3 host4'
-
-# Domain for all hosts
-FUZZ_DOMAIN='example.com'
-
-# Remote user for SSH
-FUZZ_USER=bob
-
-# Directory to synchronize
-SYNC_DIR='/home/bob/sync_dir'
-
-# Interval (seconds) between sync attempts
-SYNC_INTERVAL=$((30 * 60))
-
-if [ "$PWD" = "/tmp" -o "$PWD" = "/var/tmp" ]; then
- echo "[-] Error: do not use shared /tmp or /var/tmp directories with this script." 1>&2
- exit 1
-fi
-
-rm -rf .sync_tmp 2>/dev/null
-mkdir .sync_tmp || exit 1
-
-while :; do
-
- # Pull data in...
-
- for host in $FUZZ_HOSTS; do
-
- echo "[*] Retrieving data from ${host}.${FUZZ_DOMAIN}..."
-
- ssh -o 'passwordauthentication no' ${FUZZ_USER}@${host}.$FUZZ_DOMAIN \
- "cd '$SYNC_DIR' && tar -czf - ${host}_*/[qf]*" >".sync_tmp/${host}.tgz"
-
- done
-
- # Distribute data. For large fleets, see tips in the docs/ directory.
-
- for dst_host in $FUZZ_HOSTS; do
-
- echo "[*] Distributing data to ${dst_host}.${FUZZ_DOMAIN}..."
-
- for src_host in $FUZZ_HOSTS; do
-
- test "$src_host" = "$dst_host" && continue
-
- echo " Sending fuzzer data from ${src_host}.${FUZZ_DOMAIN}..."
-
- ssh -o 'passwordauthentication no' ${FUZZ_USER}@$dst_host \
- "cd '$SYNC_DIR' && tar -xkzf -" <".sync_tmp/${src_host}.tgz"
-
- done
-
- done
-
- echo "[+] Done. Sleeping for $SYNC_INTERVAL seconds (Ctrl-C to quit)."
-
- sleep $SYNC_INTERVAL
-
-done
-
diff --git a/chromium/third_party/afl/src/experimental/libpng_no_checksum/libpng-nocrc.patch b/chromium/third_party/afl/src/experimental/libpng_no_checksum/libpng-nocrc.patch
deleted file mode 100644
index 0a3793a0202..00000000000
--- a/chromium/third_party/afl/src/experimental/libpng_no_checksum/libpng-nocrc.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- pngrutil.c.orig 2014-06-12 03:35:16.000000000 +0200
-+++ pngrutil.c 2014-07-01 05:08:31.000000000 +0200
-@@ -268,7 +268,11 @@
- if (need_crc != 0)
- {
- crc = png_get_uint_32(crc_bytes);
-- return ((int)(crc != png_ptr->crc));
-+
-+ if (crc != png_ptr->crc)
-+ fprintf(stderr, "NOTE: CRC in the file is 0x%08x, change to 0x%08x\n", crc, png_ptr->crc);
-+
-+ return ((int)(1 != 1));
- }
-
- else
diff --git a/chromium/third_party/afl/src/experimental/persistent_demo/persistent_demo.c b/chromium/third_party/afl/src/experimental/persistent_demo/persistent_demo.c
deleted file mode 100644
index 0b1e29897b2..00000000000
--- a/chromium/third_party/afl/src/experimental/persistent_demo/persistent_demo.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- american fuzzy lop - persistent mode example
- --------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This file demonstrates the high-performance "persistent mode" that may be
- suitable for fuzzing certain fast and well-behaved libraries, provided that
- they are stateless or that their internal state can be easily reset
- across runs.
-
- To make this work, the library and this shim need to be compiled in LLVM
- mode using afl-clang-fast (other compiler wrappers will *not* work).
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <string.h>
-
-
-/* Main entry point. */
-
-int main(int argc, char** argv) {
-
- char buf[100]; /* Example-only buffer, you'd replace it with other global or
- local variables appropriate for your use case. */
-
- /* The number passed to __AFL_LOOP() controls the maximum number of
- iterations before the loop exits and the program is allowed to
- terminate normally. This limits the impact of accidental memory leaks
- and similar hiccups. */
-
- while (__AFL_LOOP(1000)) {
-
- /*** PLACEHOLDER CODE ***/
-
- /* STEP 1: Fully re-initialize all critical variables. In our example, this
- involves zeroing buf[], our input buffer. */
-
- memset(buf, 0, 100);
-
- /* STEP 2: Read input data. When reading from stdin, no special preparation
- is required. When reading from a named file, you need to close
- the old descriptor and reopen the file first!
-
- Beware of reading from buffered FILE* objects such as stdin. Use
- raw file descriptors or call fopen() / fdopen() in every pass. */
-
- read(0, buf, 100);
-
- /* STEP 3: This is where we'd call the tested library on the read data.
- We just have some trivial inline code that faults on 'foo!'. */
-
- if (buf[0] == 'f') {
- printf("one\n");
- if (buf[1] == 'o') {
- printf("two\n");
- if (buf[2] == 'o') {
- printf("three\n");
- if (buf[3] == '!') {
- printf("four\n");
- abort();
- }
- }
- }
- }
-
- /*** END PLACEHOLDER CODE ***/
-
- }
-
- /* Once the loop is exited, terminate normally - AFL will restart the process
- when this happens, with a clean slate when it comes to allocated memory,
- leftover file descriptors, etc. */
-
- return 0;
-
-}
diff --git a/chromium/third_party/afl/src/experimental/post_library/post_library.so.c b/chromium/third_party/afl/src/experimental/post_library/post_library.so.c
deleted file mode 100644
index 72620ff0827..00000000000
--- a/chromium/third_party/afl/src/experimental/post_library/post_library.so.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- american fuzzy lop - postprocessor library example
- --------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Postprocessor libraries can be passed to afl-fuzz to perform final cleanup
- of any mutated test cases - for example, to fix up checksums in PNG files.
-
- Please heed the following warnings:
-
- 1) In almost all cases, it is more productive to comment out checksum logic
- in the targeted binary (as shown in ../libpng_no_checksum/). One possible
- exception is the process of fuzzing binary-only software in QEMU mode.
-
- 2) The use of postprocessors for anything other than checksums is questionable
- and may cause more harm than good. AFL is normally pretty good about
- dealing with length fields, magic values, etc.
-
- 3) Postprocessors that do anything non-trivial must be extremely robust to
- gracefully handle malformed data and other error conditions - otherwise,
- they will crash and take afl-fuzz down with them. Be wary of reading past
- *len and of integer overflows when calculating file offsets.
-
- In other words, THIS IS PROBABLY NOT WHAT YOU WANT - unless you really,
- honestly know what you're doing =)
-
- With that out of the way: the postprocessor library is passed to afl-fuzz
- via AFL_POST_LIBRARY. The library must be compiled with:
-
- gcc -shared -Wall -O3 post_library.so.c -o post_library.so
-
- AFL will call the afl_postprocess() function for every mutated output buffer.
- From there, you have three choices:
-
- 1) If you don't want to modify the test case, simply return the original
- buffer pointer ('in_buf').
-
- 2) If you want to skip this test case altogether and have AFL generate a
- new one, return NULL. Use this sparingly - it's faster than running
- the target program with patently useless inputs, but still wastes CPU
- time.
-
- 3) If you want to modify the test case, allocate an appropriately-sized
- buffer, move the data into that buffer, make the necessary changes, and
- then return the new pointer. You can update *len if necessary, too.
-
- Note that the buffer will *not* be freed for you. To avoid memory leaks,
- you need to free it or reuse it on subsequent calls (as shown below).
-
- *** DO NOT MODIFY THE ORIGINAL 'in_buf' BUFFER. ***
-
- Aight. The example below shows a simple postprocessor that tries to make
- sure that all input files start with "GIF89a".
-
- PS. If you don't like C, you can try out the unix-based wrapper from
- Ben Nagy instead: https://github.com/bnagy/aflfix
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Header that must be present at the beginning of every test case: */
-
-#define HEADER "GIF89a"
-
-/* The actual postprocessor routine called by afl-fuzz: */
-
-const unsigned char* afl_postprocess(const unsigned char* in_buf,
- unsigned int* len) {
-
- static unsigned char* saved_buf;
- unsigned char* new_buf;
-
- /* Skip execution altogether for buffers shorter than 6 bytes (just to
- show how it's done). We can trust *len to be sane. */
-
- if (*len < strlen(HEADER)) return NULL;
-
- /* Do nothing for buffers that already start with the expected header. */
-
- if (!memcmp(in_buf, HEADER, strlen(HEADER))) return in_buf;
-
- /* Allocate memory for new buffer, reusing previous allocation if
- possible. */
-
- new_buf = realloc(saved_buf, *len);
-
- /* If we're out of memory, the most graceful thing to do is to return the
- original buffer and give up on modifying it. Let AFL handle OOM on its
- own later on. */
-
- if (!new_buf) return in_buf;
- saved_buf = new_buf;
-
- /* Copy the original data to the new location. */
-
- memcpy(new_buf, in_buf, *len);
-
- /* Insert the new header. */
-
- memcpy(new_buf, HEADER, strlen(HEADER));
-
- /* Return modified buffer. No need to update *len in this particular case,
- as we're not changing it. */
-
- return new_buf;
-
-}
diff --git a/chromium/third_party/afl/src/experimental/post_library/post_library_png.so.c b/chromium/third_party/afl/src/experimental/post_library/post_library_png.so.c
deleted file mode 100644
index 080a6938ac8..00000000000
--- a/chromium/third_party/afl/src/experimental/post_library/post_library_png.so.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- american fuzzy lop - postprocessor for PNG
- ------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- See post_library.so.c for a general discussion of how to implement
- postprocessors. This specific postprocessor attempts to fix up PNG
- checksums, providing a slightly more complicated example than found
- in post_library.so.c.
-
- Compile with:
-
- gcc -shared -Wall -O3 post_library_png.so.c -o post_library_png.so -lz
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <zlib.h>
-
-#include <arpa/inet.h>
-
-/* A macro to round an integer up to 4 kB. */
-
-#define UP4K(_i) ((((_i) >> 12) + 1) << 12)
-
-const unsigned char* afl_postprocess(const unsigned char* in_buf,
- unsigned int* len) {
-
- static unsigned char* saved_buf;
- static unsigned int saved_len;
-
- unsigned char* new_buf = (unsigned char*)in_buf;
- unsigned int pos = 8;
-
- /* Don't do anything if there's not enough room for the PNG header
- (8 bytes). */
-
- if (*len < 8) return in_buf;
-
- /* Minimum size of a zero-length PNG chunk is 12 bytes; if we
- don't have that, we can bail out. */
-
- while (pos + 12 <= *len) {
-
- unsigned int chunk_len, real_cksum, file_cksum;
-
- /* Chunk length is the first big-endian dword in the chunk. */
-
- chunk_len = ntohl(*(uint32_t*)(in_buf + pos));
-
- /* Bail out if chunk size is too big or goes past EOF. */
-
- if (chunk_len > 1024 * 1024 || pos + 12 + chunk_len > *len) break;
-
- /* Chunk checksum is calculated for chunk ID (dword) and the actual
- payload. */
-
- real_cksum = htonl(crc32(0, in_buf + pos + 4, chunk_len + 4));
-
- /* The in-file checksum is the last dword past the chunk data. */
-
- file_cksum = *(uint32_t*)(in_buf + pos + 8 + chunk_len);
-
- /* If the checksums do not match, we need to fix the file. */
-
- if (real_cksum != file_cksum) {
-
- /* First modification? Make a copy of the input buffer. Round size
- up to 4 kB to minimize the number of reallocs needed. */
-
- if (new_buf == in_buf) {
-
- if (*len <= saved_len) {
-
- new_buf = saved_buf;
-
- } else {
-
- new_buf = realloc(saved_buf, UP4K(*len));
- if (!new_buf) return in_buf;
- saved_buf = new_buf;
- saved_len = UP4K(*len);
- memcpy(new_buf, in_buf, *len);
-
- }
-
- }
-
- *(uint32_t*)(new_buf + pos + 8 + chunk_len) = real_cksum;
-
- }
-
- /* Skip the entire chunk and move to the next one. */
-
- pos += 12 + chunk_len;
-
- }
-
- return new_buf;
-
-}
diff --git a/chromium/third_party/afl/src/hash.h b/chromium/third_party/afl/src/hash.h
deleted file mode 100644
index f39a82572c9..00000000000
--- a/chromium/third_party/afl/src/hash.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- american fuzzy lop - hashing function
- -------------------------------------
-
- The hash32() function is a variant of MurmurHash3, a good
- non-cryptosafe hashing function developed by Austin Appleby.
-
- For simplicity, this variant does *NOT* accept buffer lengths
- that are not divisible by 8 bytes. The 32-bit version is otherwise
- similar to the original; the 64-bit one is a custom hack with
- mostly-unproven properties.
-
- Austin's original code is public domain.
-
- Other code written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- */
-
-#ifndef _HAVE_HASH_H
-#define _HAVE_HASH_H
-
-#include "types.h"
-
-#ifdef __x86_64__
-
-#define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r))))
-
-static inline u32 hash32(const void* key, u32 len, u32 seed) {
-
- const u64* data = (u64*)key;
- u64 h1 = seed ^ len;
-
- len >>= 3;
-
- while (len--) {
-
- u64 k1 = *data++;
-
- k1 *= 0x87c37b91114253d5ULL;
- k1 = ROL64(k1, 31);
- k1 *= 0x4cf5ad432745937fULL;
-
- h1 ^= k1;
- h1 = ROL64(h1, 27);
- h1 = h1 * 5 + 0x52dce729;
-
- }
-
- h1 ^= h1 >> 33;
- h1 *= 0xff51afd7ed558ccdULL;
- h1 ^= h1 >> 33;
- h1 *= 0xc4ceb9fe1a85ec53ULL;
- h1 ^= h1 >> 33;
-
- return h1;
-
-}
-
-#else
-
-#define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r))))
-
-static inline u32 hash32(const void* key, u32 len, u32 seed) {
-
- const u32* data = (u32*)key;
- u32 h1 = seed ^ len;
-
- len >>= 2;
-
- while (len--) {
-
- u32 k1 = *data++;
-
- k1 *= 0xcc9e2d51;
- k1 = ROL32(k1, 15);
- k1 *= 0x1b873593;
-
- h1 ^= k1;
- h1 = ROL32(h1, 13);
- h1 = h1 * 5 + 0xe6546b64;
-
- }
-
- h1 ^= h1 >> 16;
- h1 *= 0x85ebca6b;
- h1 ^= h1 >> 13;
- h1 *= 0xc2b2ae35;
- h1 ^= h1 >> 16;
-
- return h1;
-
-}
-
-#endif /* ^__x86_64__ */
-
-#endif /* !_HAVE_HASH_H */
diff --git a/chromium/third_party/afl/src/libdislocator/Makefile b/chromium/third_party/afl/src/libdislocator/Makefile
deleted file mode 100644
index a4116780a63..00000000000
--- a/chromium/third_party/afl/src/libdislocator/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# american fuzzy lop - libdislocator
-# ----------------------------------
-#
-# Written by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-
-PREFIX ?= /usr/local
-HELPER_PATH = $(PREFIX)/lib/afl
-
-VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
-
-CFLAGS ?= -O3 -funroll-loops
-CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
-
-all: libdislocator.so
-
-libdislocator.so: libdislocator.so.c ../config.h
- $(CC) $(CFLAGS) -shared -fPIC $< -o $@ $(LDFLAGS)
-
-.NOTPARALLEL: clean
-
-clean:
- rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
- rm -f libdislocator.so
-
-install: all
- install -m 755 libdislocator.so $${DESTDIR}$(HELPER_PATH)
- install -m 644 README.dislocator $${DESTDIR}$(HELPER_PATH)
-
diff --git a/chromium/third_party/afl/src/libdislocator/README.dislocator b/chromium/third_party/afl/src/libdislocator/README.dislocator
deleted file mode 100644
index 837e74664e9..00000000000
--- a/chromium/third_party/afl/src/libdislocator/README.dislocator
+++ /dev/null
@@ -1,60 +0,0 @@
-===================================
-libdislocator, an abusive allocator
-===================================
-
- (See ../docs/README for the general instruction manual.)
-
-This is a companion library that can be used as a drop-in replacement for the
-libc allocator in the fuzzed binaries. It improves the odds of bumping into
-heap-related security bugs in several ways:
-
- - It allocates all buffers so that they are immediately adjacent to a
- subsequent PROT_NONE page, causing most off-by-one reads and writes to
- immediately segfault,
-
- - It adds a canary immediately below the allocated buffer, to catch writes
- to negative offsets (won't catch reads, though),
-
- - It sets the memory returned by malloc() to garbage values, improving the
- odds of crashing when the target accesses uninitialized data,
-
- - It sets freed memory to PROT_NONE and does not actually reuse it, causing
- most use-after-free bugs to segfault right away,
-
- - It forces all realloc() calls to return a new address - and sets
- PROT_NONE on the original block. This catches use-after-realloc bugs,
-
- - It checks for calloc() overflows and can cause soft or hard failures
- of alloc requests past a configurable memory limit (AFL_LD_LIMIT_MB,
- AFL_LD_HARD_FAIL).
-
-Basically, it is inspired by some of the non-default options available for the
-OpenBSD allocator - see malloc.conf(5) on that platform for reference. It is
-also somewhat similar to several other debugging libraries, such as gmalloc
-and DUMA - but is simple, plug-and-play, and designed specifically for fuzzing
-jobs.
-
-Note that it does nothing for stack-based memory handling errors. The
--fstack-protector-all setting for GCC / clang, enabled when using AFL_HARDEN,
-can catch some subset of that.
-
-The allocator is slow and memory-intensive (even the tiniest allocation uses up
-4 kB of physical memory and 8 kB of virtual mem), making it completely unsuitable
-for "production" uses; but it can be faster and more hassle-free than ASAN / MSAN
-when fuzzing small, self-contained binaries.
-
-To use this library, run AFL like so:
-
-AFL_PRELOAD=/path/to/libdislocator.so ./afl-fuzz [...other params...]
-
-You *have* to specify path, even if it's just ./libdislocator.so or
-$PWD/libdislocator.so.
-
-Similarly to afl-tmin, the library is not "proprietary" and can be used with
-other fuzzers or testing tools without the need for any code tweaks. It does not
-require AFL-instrumented binaries to work.
-
-Note that the AFL_PRELOAD approach (which AFL internally maps to LD_PRELOAD or
-DYLD_INSERT_LIBRARIES, depending on the OS) works only if the target binary is
-dynamically linked. Otherwise, attempting to use the library will have no
-effect.
diff --git a/chromium/third_party/afl/src/libdislocator/libdislocator.so.c b/chromium/third_party/afl/src/libdislocator/libdislocator.so.c
deleted file mode 100644
index 0dfc98e6058..00000000000
--- a/chromium/third_party/afl/src/libdislocator/libdislocator.so.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
-
- american fuzzy lop - dislocator, an abusive allocator
- -----------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This is a companion library that can be used as a drop-in replacement
- for the libc allocator in the fuzzed binaries. See README.dislocator for
- more info.
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <sys/mman.h>
-
-#include "../config.h"
-#include "../types.h"
-
-#ifndef PAGE_SIZE
-# define PAGE_SIZE 4096
-#endif /* !PAGE_SIZE */
-
-#ifndef MAP_ANONYMOUS
-# define MAP_ANONYMOUS MAP_ANON
-#endif /* !MAP_ANONYMOUS */
-
-/* Error / message handling: */
-
-#define DEBUGF(_x...) do { \
- if (alloc_verbose) { \
- if (++call_depth == 1) { \
- fprintf(stderr, "[AFL] " _x); \
- fprintf(stderr, "\n"); \
- } \
- call_depth--; \
- } \
- } while (0)
-
-#define FATAL(_x...) do { \
- if (++call_depth == 1) { \
- fprintf(stderr, "*** [AFL] " _x); \
- fprintf(stderr, " ***\n"); \
- abort(); \
- } \
- call_depth--; \
- } while (0)
-
-/* Macro to count the number of pages needed to store a buffer: */
-
-#define PG_COUNT(_l) (((_l) + (PAGE_SIZE - 1)) / PAGE_SIZE)
-
-/* Canary & clobber bytes: */
-
-#define ALLOC_CANARY 0xAACCAACC
-#define ALLOC_CLOBBER 0xCC
-
-#define PTR_C(_p) (((u32*)(_p))[-1])
-#define PTR_L(_p) (((u32*)(_p))[-2])
-
-/* Configurable stuff (use AFL_LD_* to set): */
-
-static u32 max_mem = MAX_ALLOC; /* Max heap usage to permit */
-static u8 alloc_verbose, /* Additional debug messages */
- hard_fail; /* abort() when max_mem exceeded? */
-
-static __thread size_t total_mem; /* Currently allocated mem */
-
-static __thread u32 call_depth; /* To avoid recursion via fprintf() */
-
-
-/* This is the main alloc function. It allocates one page more than necessary,
- sets that tailing page to PROT_NONE, and then increments the return address
- so that it is right-aligned to that boundary. Since it always uses mmap(),
- the returned memory will be zeroed. */
-
-static void* __dislocator_alloc(size_t len) {
-
- void* ret;
-
-
- if (total_mem + len > max_mem || total_mem + len < total_mem) {
-
- if (hard_fail)
- FATAL("total allocs exceed %u MB", max_mem / 1024 / 1024);
-
- DEBUGF("total allocs exceed %u MB, returning NULL",
- max_mem / 1024 / 1024);
-
- return NULL;
-
- }
-
- /* We will also store buffer length and a canary below the actual buffer, so
- let's add 8 bytes for that. */
-
- ret = mmap(NULL, (1 + PG_COUNT(len + 8)) * PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
- if (ret == (void*)-1) {
-
- if (hard_fail) FATAL("mmap() failed on alloc (OOM?)");
-
- DEBUGF("mmap() failed on alloc (OOM?)");
-
- return NULL;
-
- }
-
- /* Set PROT_NONE on the last page. */
-
- if (mprotect(ret + PG_COUNT(len + 8) * PAGE_SIZE, PAGE_SIZE, PROT_NONE))
- FATAL("mprotect() failed when allocating memory");
-
- /* Offset the return pointer so that it's right-aligned to the page
- boundary. */
-
- ret += PAGE_SIZE * PG_COUNT(len + 8) - len - 8;
-
- /* Store allocation metadata. */
-
- ret += 8;
-
- PTR_L(ret) = len;
- PTR_C(ret) = ALLOC_CANARY;
-
- total_mem += len;
-
- return ret;
-
-}
-
-
-/* The "user-facing" wrapper for calloc(). This just checks for overflows and
- displays debug messages if requested. */
-
-void* calloc(size_t elem_len, size_t elem_cnt) {
-
- void* ret;
-
- size_t len = elem_len * elem_cnt;
-
- /* Perform some sanity checks to detect obvious issues... */
-
- if (elem_cnt && len / elem_cnt != elem_len)
- FATAL("calloc(%zu, %zu) would overflow", elem_len, elem_cnt);
-
- ret = __dislocator_alloc(len);
-
- DEBUGF("calloc(%zu, %zu) = %p [%zu total]", elem_len, elem_cnt, ret,
- total_mem);
-
- return ret;
-
-}
-
-
-/* The wrapper for malloc(). Roughly the same, also clobbers the returned
- memory (unlike calloc(), malloc() is not guaranteed to return zeroed
- memory). */
-
-void* malloc(size_t len) {
-
- void* ret;
-
- ret = __dislocator_alloc(len);
-
- DEBUGF("malloc(%zu) = %p [%zu total]", len, ret, total_mem);
-
- if (ret && len) memset(ret, ALLOC_CLOBBER, len);
-
- return ret;
-
-}
-
-
-/* The wrapper for free(). This simply marks the entire region as PROT_NONE.
- If the region is already freed, the code will segfault during the attempt to
- read the canary. Not very graceful, but works, right? */
-
-void free(void* ptr) {
-
- u32 len;
-
- DEBUGF("free(%p)", ptr);
-
- if (!ptr) return;
-
- if (PTR_C(ptr) != ALLOC_CANARY) FATAL("bad allocator canary on free()");
-
- len = PTR_L(ptr);
-
- total_mem -= len;
-
- /* Protect everything. Note that the extra page at the end is already
- set as PROT_NONE, so we don't need to touch that. */
-
- ptr -= PAGE_SIZE * PG_COUNT(len + 8) - len - 8;
-
- if (mprotect(ptr - 8, PG_COUNT(len + 8) * PAGE_SIZE, PROT_NONE))
- FATAL("mprotect() failed when freeing memory");
-
- /* Keep the mapping; this is wasteful, but prevents ptr reuse. */
-
-}
-
-
-/* Realloc is pretty straightforward, too. We forcibly reallocate the buffer,
- move data, and then free (aka mprotect()) the original one. */
-
-void* realloc(void* ptr, size_t len) {
-
- void* ret;
-
- ret = malloc(len);
-
- if (ret && ptr) {
-
- if (PTR_C(ptr) != ALLOC_CANARY) FATAL("bad allocator canary on realloc()");
-
- memcpy(ret, ptr, MIN(len, PTR_L(ptr)));
- free(ptr);
-
- }
-
- DEBUGF("realloc(%p, %zu) = %p [%zu total]", ptr, len, ret, total_mem);
-
- return ret;
-
-}
-
-
-__attribute__((constructor)) void __dislocator_init(void) {
-
- u8* tmp = getenv("AFL_LD_LIMIT_MB");
-
- if (tmp) {
-
- max_mem = atoi(tmp) * 1024 * 1024;
- if (!max_mem) FATAL("Bad value for AFL_LD_LIMIT_MB");
-
- }
-
- alloc_verbose = !!getenv("AFL_LD_VERBOSE");
- hard_fail = !!getenv("AFL_LD_HARD_FAIL");
-
-}
diff --git a/chromium/third_party/afl/src/libtokencap/Makefile b/chromium/third_party/afl/src/libtokencap/Makefile
deleted file mode 100644
index a464f76d13e..00000000000
--- a/chromium/third_party/afl/src/libtokencap/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# american fuzzy lop - libtokencap
-# --------------------------------
-#
-# Written by Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-
-PREFIX ?= /usr/local
-HELPER_PATH = $(PREFIX)/lib/afl
-
-VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
-
-CFLAGS ?= -O3 -funroll-loops
-CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
-
-all: libtokencap.so
-
-libtokencap.so: libtokencap.so.c ../config.h
- $(CC) $(CFLAGS) -shared -fPIC $< -o $@ $(LDFLAGS)
-
-.NOTPARALLEL: clean
-
-clean:
- rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
- rm -f libtokencap.so
-
-install: all
- install -m 755 libtokencap.so $${DESTDIR}$(HELPER_PATH)
- install -m 644 README.tokencap $${DESTDIR}$(HELPER_PATH)
-
diff --git a/chromium/third_party/afl/src/libtokencap/README.tokencap b/chromium/third_party/afl/src/libtokencap/README.tokencap
deleted file mode 100644
index 82d80c95580..00000000000
--- a/chromium/third_party/afl/src/libtokencap/README.tokencap
+++ /dev/null
@@ -1,60 +0,0 @@
-=========================================
-strcmp() / memcmp() token capture library
-=========================================
-
- (See ../docs/README for the general instruction manual.)
-
-This Linux-only companion library allows you to instrument strcmp(), memcmp(),
-and related functions to automatically extract syntax tokens passed to any of
-these libcalls. The resulting list of tokens may be then given as a starting
-dictionary to afl-fuzz (the -x option) to improve coverage on subsequent
-fuzzing runs.
-
-This may help improving coverage in some targets, and do precisely nothing in
-others. In some cases, it may even make things worse: if libtokencap picks up
-syntax tokens that are not used to process the input data, but that are a part
-of - say - parsing a config file... well, you're going to end up wasting a lot
-of CPU time on trying them out in the input stream. In other words, use this
-feature with care. Manually screening the resulting dictionary is almost
-always a necessity.
-
-As for the actual operation: the library stores tokens, without any deduping,
-by appending them to a file specified via AFL_TOKEN_FILE. If the variable is not
-set, the tool uses stderr (which is probably not what you want).
-
-Similarly to afl-tmin, the library is not "proprietary" and can be used with
-other fuzzers or testing tools without the need for any code tweaks. It does not
-require AFL-instrumented binaries to work.
-
-To use the library, you *need* to make sure that your fuzzing target is compiled
-with -fno-builtin and is linked dynamically. If you wish to automate the first
-part without mucking with CFLAGS in Makefiles, you can set AFL_NO_BUILTIN=1
-when using afl-gcc. This setting specifically adds the following flags:
-
- -fno-builtin-strcmp -fno-builtin-strncmp -fno-builtin-strcasecmp
- -fno-builtin-strcasencmp -fno-builtin-memcmp
-
-The next step is simply loading this library via LD_PRELOAD. The optimal usage
-pattern is to allow afl-fuzz to fuzz normally for a while and build up a corpus,
-and then fire off the target binary, with libtokencap.so loaded, on every file
-found by AFL in that earlier run. This demonstrates the basic principle:
-
- export AFL_TOKEN_FILE=$PWD/temp_output.txt
-
- for i in <out_dir>/queue/id*; do
- LD_PRELOAD=/path/to/libtokencap.so \
- /path/to/target/program [...params, including $i...]
- done
-
- sort -u temp_output.txt >afl_dictionary.txt
-
-If you don't get any results, the target library is probably not using strcmp()
-and memcmp() to parse input; or you haven't compiled it with -fno-builtin; or
-the whole thing isn't dynamically linked, and LD_PRELOAD is having no effect.
-
-PS. The library is Linux-only because there is probably no particularly portable
-and non-invasive way to distinguish between read-only and read-write memory
-mappings. The __tokencap_load_mappings() function is the only thing that would
-need to be changed for other OSes. Porting to platforms with /proc/<pid>/maps
-(e.g., FreeBSD) should be trivial.
-
diff --git a/chromium/third_party/afl/src/libtokencap/libtokencap.so.c b/chromium/third_party/afl/src/libtokencap/libtokencap.so.c
deleted file mode 100644
index 696c913daf5..00000000000
--- a/chromium/third_party/afl/src/libtokencap/libtokencap.so.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
-
- american fuzzy lop - extract tokens passed to strcmp / memcmp
- -------------------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This Linux-only companion library allows you to instrument strcmp(),
- memcmp(), and related functions to automatically extract tokens.
- See README.tokencap for more info.
-
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "../types.h"
-#include "../config.h"
-
-#ifndef __linux__
-# error "Sorry, this library is Linux-specific for now!"
-#endif /* !__linux__ */
-
-
-/* Mapping data and such */
-
-#define MAX_MAPPINGS 1024
-
-static struct mapping {
- void *st, *en;
-} __tokencap_ro[MAX_MAPPINGS];
-
-static u32 __tokencap_ro_cnt;
-static u8 __tokencap_ro_loaded;
-static FILE* __tokencap_out_file;
-
-
-/* Identify read-only regions in memory. Only parameters that fall into these
- ranges are worth dumping when passed to strcmp() and so on. Read-write
- regions are far more likely to contain user input instead. */
-
-static void __tokencap_load_mappings(void) {
-
- u8 buf[MAX_LINE];
- FILE* f = fopen("/proc/self/maps", "r");
-
- __tokencap_ro_loaded = 1;
-
- if (!f) return;
-
- while (fgets(buf, MAX_LINE, f)) {
-
- u8 rf, wf;
- void* st, *en;
-
- if (sscanf(buf, "%p-%p %c%c", &st, &en, &rf, &wf) != 4) continue;
- if (wf == 'w' || rf != 'r') continue;
-
- __tokencap_ro[__tokencap_ro_cnt].st = (void*)st;
- __tokencap_ro[__tokencap_ro_cnt].en = (void*)en;
-
- if (++__tokencap_ro_cnt == MAX_MAPPINGS) break;
-
- }
-
- fclose(f);
-
-}
-
-
-/* Check an address against the list of read-only mappings. */
-
-static u8 __tokencap_is_ro(const void* ptr) {
-
- u32 i;
-
- if (!__tokencap_ro_loaded) __tokencap_load_mappings();
-
- for (i = 0; i < __tokencap_ro_cnt; i++)
- if (ptr >= __tokencap_ro[i].st && ptr <= __tokencap_ro[i].en) return 1;
-
- return 0;
-
-}
-
-
-/* Dump an interesting token to output file, quoting and escaping it
- properly. */
-
-static void __tokencap_dump(const u8* ptr, size_t len, u8 is_text) {
-
- u8 buf[MAX_AUTO_EXTRA * 4 + 1];
- u32 i;
- u32 pos = 0;
-
- if (len < MIN_AUTO_EXTRA || len > MAX_AUTO_EXTRA) return;
-
- for (i = 0; i < len; i++) {
-
- if (is_text && !ptr[i]) break;
-
- switch (ptr[i]) {
-
- case 0 ... 31:
- case 127 ... 255:
- case '\"':
- case '\\':
-
- sprintf(buf + pos, "\\x%02x", ptr[i]);
- pos += 4;
- break;
-
- default:
-
- buf[pos++] = ptr[i];
-
- }
-
- }
-
- buf[pos] = 0;
-
- fprintf(__tokencap_out_file, "\"%s\"\n", buf);
-
-}
-
-
-/* Replacements for strcmp(), memcmp(), and so on. Note that these will be used
- only if the target is compiled with -fno-builtins and linked dynamically. */
-
-#undef strcmp
-
-int strcmp(const char* str1, const char* str2) {
-
- if (__tokencap_is_ro(str1)) __tokencap_dump(str1, strlen(str1), 1);
- if (__tokencap_is_ro(str2)) __tokencap_dump(str2, strlen(str2), 1);
-
- while (1) {
-
- unsigned char c1 = *str1, c2 = *str2;
-
- if (c1 != c2) return (c1 > c2) ? 1 : -1;
- if (!c1) return 0;
- str1++; str2++;
-
- }
-
-}
-
-
-#undef strncmp
-
-int strncmp(const char* str1, const char* str2, size_t len) {
-
- if (__tokencap_is_ro(str1)) __tokencap_dump(str1, len, 1);
- if (__tokencap_is_ro(str2)) __tokencap_dump(str2, len, 1);
-
- while (len--) {
-
- unsigned char c1 = *str1, c2 = *str2;
-
- if (!c1) return 0;
- if (c1 != c2) return (c1 > c2) ? 1 : -1;
- str1++; str2++;
-
- }
-
- return 0;
-
-}
-
-
-#undef strcasecmp
-
-int strcasecmp(const char* str1, const char* str2) {
-
- if (__tokencap_is_ro(str1)) __tokencap_dump(str1, strlen(str1), 1);
- if (__tokencap_is_ro(str2)) __tokencap_dump(str2, strlen(str2), 1);
-
- while (1) {
-
- unsigned char c1 = tolower(*str1), c2 = tolower(*str2);
-
- if (c1 != c2) return (c1 > c2) ? 1 : -1;
- if (!c1) return 0;
- str1++; str2++;
-
- }
-
-}
-
-
-#undef strncasecmp
-
-int strncasecmp(const char* str1, const char* str2, size_t len) {
-
- if (__tokencap_is_ro(str1)) __tokencap_dump(str1, len, 1);
- if (__tokencap_is_ro(str2)) __tokencap_dump(str2, len, 1);
-
- while (len--) {
-
- unsigned char c1 = tolower(*str1), c2 = tolower(*str2);
-
- if (!c1) return 0;
- if (c1 != c2) return (c1 > c2) ? 1 : -1;
- str1++; str2++;
-
- }
-
- return 0;
-
-}
-
-
-#undef memcmp
-
-int memcmp(const void* mem1, const void* mem2, size_t len) {
-
- if (__tokencap_is_ro(mem1)) __tokencap_dump(mem1, len, 0);
- if (__tokencap_is_ro(mem2)) __tokencap_dump(mem2, len, 0);
-
- while (len--) {
-
- unsigned char c1 = *(const char*)mem1, c2 = *(const char*)mem2;
- if (c1 != c2) return (c1 > c2) ? 1 : -1;
- mem1++; mem2++;
-
- }
-
- return 0;
-
-}
-
-
-/* Init code to open the output file (or default to stderr). */
-
-__attribute__((constructor)) void __tokencap_init(void) {
-
- u8* fn = getenv("AFL_TOKEN_FILE");
- if (fn) __tokencap_out_file = fopen(fn, "a");
- if (!__tokencap_out_file) __tokencap_out_file = stderr;
-
-}
-
diff --git a/chromium/third_party/afl/src/llvm_mode/Makefile b/chromium/third_party/afl/src/llvm_mode/Makefile
deleted file mode 100644
index 5d4da94d3aa..00000000000
--- a/chromium/third_party/afl/src/llvm_mode/Makefile
+++ /dev/null
@@ -1,112 +0,0 @@
-#
-# american fuzzy lop - LLVM instrumentation
-# -----------------------------------------
-#
-# Written by Laszlo Szekeres <lszekeres@google.com> and
-# Michal Zalewski <lcamtuf@google.com>
-#
-# LLVM integration design comes from Laszlo Szekeres.
-#
-# Copyright 2015, 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-
-PREFIX ?= /usr/local
-HELPER_PATH = $(PREFIX)/lib/afl
-BIN_PATH = $(PREFIX)/bin
-
-VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
-
-LLVM_CONFIG ?= llvm-config
-
-CFLAGS ?= -O3 -funroll-loops
-CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
- -DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
- -DVERSION=\"$(VERSION)\"
-ifdef AFL_TRACE_PC
- CFLAGS += -DUSE_TRACE_PC=1
-endif
-
-CXXFLAGS ?= -O3 -funroll-loops
-CXXFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
- -DVERSION=\"$(VERSION)\" -Wno-variadic-macros
-
-CLANG_CFL = `$(LLVM_CONFIG) --cxxflags` -fno-rtti -fpic $(CXXFLAGS)
-CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
-
-# User teor2345 reports that this is required to make things work on MacOS X.
-
-ifeq "$(shell uname)" "Darwin"
- CLANG_LFL += -Wl,-flat_namespace -Wl,-undefined,suppress
-endif
-
-# We were using llvm-config --bindir to get the location of clang, but
-# this seems to be busted on some distros, so using the one in $PATH is
-# probably better.
-
-ifeq "$(origin CC)" "default"
- CC = clang
- CXX = clang++
-endif
-
-ifndef AFL_TRACE_PC
- PROGS = ../afl-clang-fast ../afl-llvm-pass.so ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o
-else
- PROGS = ../afl-clang-fast ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o
-endif
-
-all: test_deps $(PROGS) test_build all_done
-
-test_deps:
-ifndef AFL_TRACE_PC
- @echo "[*] Checking for working 'llvm-config'..."
- @which $(LLVM_CONFIG) >/dev/null 2>&1 || ( echo "[-] Oops, can't find 'llvm-config'. Install clang or set \$$LLVM_CONFIG or \$$PATH beforehand."; echo " (Sometimes, the binary will be named llvm-config-3.5 or something like that.)"; exit 1 )
-else
- @echo "[!] Note: using -fsanitize=trace-pc mode (this will fail with older LLVM)."
-endif
- @echo "[*] Checking for working '$(CC)'..."
- @which $(CC) >/dev/null 2>&1 || ( echo "[-] Oops, can't find '$(CC)'. Make sure that it's in your \$$PATH (or set \$$CC and \$$CXX)."; exit 1 )
- @echo "[*] Checking for '../afl-showmap'..."
- @test -f ../afl-showmap || ( echo "[-] Oops, can't find '../afl-showmap'. Be sure to compile AFL first."; exit 1 )
- @echo "[+] All set and ready to build."
-
-../afl-clang-fast: afl-clang-fast.c | test_deps
- $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
- ln -sf afl-clang-fast ../afl-clang-fast++
-
-../afl-llvm-pass.so: afl-llvm-pass.so.cc | test_deps
- $(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
-
-../afl-llvm-rt.o: afl-llvm-rt.o.c | test_deps
- $(CC) $(CFLAGS) -fPIC -c $< -o $@
-
-../afl-llvm-rt-32.o: afl-llvm-rt.o.c | test_deps
- @printf "[*] Building 32-bit variant of the runtime (-m32)... "
- @$(CC) $(CFLAGS) -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
-
-../afl-llvm-rt-64.o: afl-llvm-rt.o.c | test_deps
- @printf "[*] Building 64-bit variant of the runtime (-m64)... "
- @$(CC) $(CFLAGS) -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
-
-test_build: $(PROGS)
- @echo "[*] Testing the CC wrapper and instrumentation output..."
- unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=$(CC) ../afl-clang-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
- echo 0 | ../afl-showmap -m none -q -o .test-instr0 ./test-instr
- echo 1 | ../afl-showmap -m none -q -o .test-instr1 ./test-instr
- @rm -f test-instr
- @cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please ping <lcamtuf@google.com> to troubleshoot the issue."; echo; exit 1; fi
- @echo "[+] All right, the instrumentation seems to be working!"
-
-all_done: test_build
- @echo "[+] All done! You can now use '../afl-clang-fast' to compile programs."
-
-.NOTPARALLEL: clean
-
-clean:
- rm -f *.o *.so *~ a.out core core.[1-9][0-9]* test-instr .test-instr0 .test-instr1
- rm -f $(PROGS) ../afl-clang-fast++
diff --git a/chromium/third_party/afl/src/llvm_mode/README.llvm b/chromium/third_party/afl/src/llvm_mode/README.llvm
deleted file mode 100644
index d96d8c31d64..00000000000
--- a/chromium/third_party/afl/src/llvm_mode/README.llvm
+++ /dev/null
@@ -1,188 +0,0 @@
-============================================
-Fast LLVM-based instrumentation for afl-fuzz
-============================================
-
- (See ../docs/README for the general instruction manual.)
-
-1) Introduction
----------------
-
-The code in this directory allows you to instrument programs for AFL using
-true compiler-level instrumentation, instead of the more crude
-assembly-level rewriting approach taken by afl-gcc and afl-clang. This has
-several interesting properties:
-
- - The compiler can make many optimizations that are hard to pull off when
- manually inserting assembly. As a result, some slow, CPU-bound programs will
- run up to around 2x faster.
-
- The gains are less pronounced for fast binaries, where the speed is limited
- chiefly by the cost of creating new processes. In such cases, the gain will
- probably stay within 10%.
-
- - The instrumentation is CPU-independent. At least in principle, you should
- be able to rely on it to fuzz programs on non-x86 architectures (after
- building afl-fuzz with AFL_NO_X86=1).
-
- - The instrumentation can cope a bit better with multi-threaded targets.
-
- - Because the feature relies on the internals of LLVM, it is clang-specific
- and will *not* work with GCC.
-
-Once this implementation is shown to be sufficiently robust and portable, it
-will probably replace afl-clang. For now, it can be built separately and
-co-exists with the original code.
-
-The idea and much of the implementation comes from Laszlo Szekeres.
-
-2) How to use
--------------
-
-In order to leverage this mechanism, you need to have clang installed on your
-system. You should also make sure that the llvm-config tool is in your path
-(or pointed to via LLVM_CONFIG in the environment).
-
-Unfortunately, some systems that do have clang come without llvm-config or the
-LLVM development headers; one example of this is FreeBSD. FreeBSD users will
-also run into problems with clang being built statically and not being able to
-load modules (you'll see "Service unavailable" when loading afl-llvm-pass.so).
-
-To solve all your problems, you can grab pre-built binaries for your OS from:
-
- http://llvm.org/releases/download.html
-
-...and then put the bin/ directory from the tarball at the beginning of your
-$PATH when compiling the feature and building packages later on. You don't need
-to be root for that.
-
-To build the instrumentation itself, type 'make'. This will generate binaries
-called afl-clang-fast and afl-clang-fast++ in the parent directory. Once this
-is done, you can instrument third-party code in a way similar to the standard
-operating mode of AFL, e.g.:
-
- CC=/path/to/afl/afl-clang-fast ./configure [...options...]
- make
-
-Be sure to also include CXX set to afl-clang-fast++ for C++ code.
-
-The tool honors roughly the same environmental variables as afl-gcc (see
-../docs/env_variables.txt). This includes AFL_INST_RATIO, AFL_USE_ASAN,
-AFL_HARDEN, and AFL_DONT_OPTIMIZE.
-
-Note: if you want the LLVM helper to be installed on your system for all
-users, you need to build it before issuing 'make install' in the parent
-directory.
-
-3) Gotchas, feedback, bugs
---------------------------
-
-This is an early-stage mechanism, so field reports are welcome. You can send bug
-reports to <afl-users@googlegroups.com>.
-
-4) Bonus feature #1: deferred instrumentation
----------------------------------------------
-
-AFL tries to optimize performance by executing the targeted binary just once,
-stopping it just before main(), and then cloning this "master" process to get
-a steady supply of targets to fuzz.
-
-Although this approach eliminates much of the OS-, linker- and libc-level
-costs of executing the program, it does not always help with binaries that
-perform other time-consuming initialization steps - say, parsing a large config
-file before getting to the fuzzed data.
-
-In such cases, it's beneficial to initialize the forkserver a bit later, once
-most of the initialization work is already done, but before the binary attempts
-to read the fuzzed input and parse it; in some cases, this can offer a 10x+
-performance gain. You can implement delayed initialization in LLVM mode in a
-fairly simple way.
-
-First, find a suitable location in the code where the delayed cloning can
-take place. This needs to be done with *extreme* care to avoid breaking the
-binary. In particular, the program will probably malfunction if you select
-a location after:
-
- - The creation of any vital threads or child processes - since the forkserver
- can't clone them easily.
-
- - The initialization of timers via setitimer() or equivalent calls.
-
- - The creation of temporary files, network sockets, offset-sensitive file
- descriptors, and similar shared-state resources - but only provided that
- their state meaningfully influences the behavior of the program later on.
-
- - Any access to the fuzzed input, including reading the metadata about its
- size.
-
-With the location selected, add this code in the appropriate spot:
-
-#ifdef __AFL_HAVE_MANUAL_CONTROL
- __AFL_INIT();
-#endif
-
-You don't need the #ifdef guards, but including them ensures that the program
-will keep working normally when compiled with a tool other than afl-clang-fast.
-
-Finally, recompile the program with afl-clang-fast (afl-gcc or afl-clang will
-*not* generate a deferred-initialization binary) - and you should be all set!
-
-5) Bonus feature #2: persistent mode
-------------------------------------
-
-Some libraries provide APIs that are stateless, or whose state can be reset in
-between processing different input files. When such a reset is performed, a
-single long-lived process can be reused to try out multiple test cases,
-eliminating the need for repeated fork() calls and the associated OS overhead.
-
-The basic structure of the program that does this would be:
-
- while (__AFL_LOOP(1000)) {
-
- /* Read input data. */
- /* Call library code to be fuzzed. */
- /* Reset state. */
-
- }
-
- /* Exit normally */
-
-The numerical value specified within the loop controls the maximum number
-of iterations before AFL will restart the process from scratch. This minimizes
-the impact of memory leaks and similar glitches; 1000 is a good starting point,
-and going much higher increases the likelihood of hiccups without giving you
-any real performance benefits.
-
-A more detailed template is shown in ../experimental/persistent_demo/.
-Similarly to the previous mode, the feature works only with afl-clang-fast;
-#ifdef guards can be used to suppress it when using other compilers.
-
-Note that as with the previous mode, the feature is easy to misuse; if you
-do not fully reset the critical state, you may end up with false positives or
-waste a whole lot of CPU power doing nothing useful at all. Be particularly
-wary of memory leaks and of the state of file descriptors.
-
-PS. Because there are task switches still involved, the mode isn't as fast as
-"pure" in-process fuzzing offered, say, by LLVM's LibFuzzer; but it is a lot
-faster than the normal fork() model, and compared to in-process fuzzing,
-should be a lot more robust.
-
-6) Bonus feature #3: new 'trace-pc-guard' mode
-----------------------------------------------
-
-Recent versions of LLVM are shipping with a built-in execution tracing feature
-that provides AFL with the necessary tracing data without the need to
-post-process the assembly or install any compiler plugins. See:
-
- http://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs-with-guards
-
-As of this writing, the feature is only available on SVN trunk, and is yet to
-make it to an official release of LLVM. Nevertheless, if you have a
-sufficiently recent compiler and want to give it a try, build afl-clang-fast
-this way:
-
- AFL_TRACE_PC=1 make clean all
-
-Note that this mode is currently about 20-30% slower than "vanilla"
-afl-clang-fast, and about 5-10% slower than afl-clang. I am not entirely sure
-why.
-
diff --git a/chromium/third_party/afl/src/llvm_mode/afl-clang-fast.c b/chromium/third_party/afl/src/llvm_mode/afl-clang-fast.c
deleted file mode 100644
index 4f7fe475a3d..00000000000
--- a/chromium/third_party/afl/src/llvm_mode/afl-clang-fast.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- american fuzzy lop - LLVM-mode wrapper for clang
- ------------------------------------------------
-
- Written by Laszlo Szekeres <lszekeres@google.com> and
- Michal Zalewski <lcamtuf@google.com>
-
- LLVM integration design comes from Laszlo Szekeres.
-
- Copyright 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This program is a drop-in replacement for clang, similar in most respects
- to ../afl-gcc. It tries to figure out compilation mode, adds a bunch
- of flags, and then calls the real compiler.
-
- */
-
-#define AFL_MAIN
-
-#include "../config.h"
-#include "../types.h"
-#include "../debug.h"
-#include "../alloc-inl.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-static u8* obj_path; /* Path to runtime libraries */
-static u8** cc_params; /* Parameters passed to the real CC */
-static u32 cc_par_cnt = 1; /* Param count, including argv0 */
-
-
-/* Try to find the runtime libraries. If that fails, abort. */
-
-static void find_obj(u8* argv0) {
-
- u8 *afl_path = getenv("AFL_PATH");
- u8 *slash, *tmp;
-
- if (afl_path) {
-
- tmp = alloc_printf("%s/afl-llvm-rt.o", afl_path);
-
- if (!access(tmp, R_OK)) {
- obj_path = afl_path;
- ck_free(tmp);
- return;
- }
-
- ck_free(tmp);
-
- }
-
- slash = strrchr(argv0, '/');
-
- if (slash) {
-
- u8 *dir;
-
- *slash = 0;
- dir = ck_strdup(argv0);
- *slash = '/';
-
- tmp = alloc_printf("%s/afl-llvm-rt.o", dir);
-
- if (!access(tmp, R_OK)) {
- obj_path = dir;
- ck_free(tmp);
- return;
- }
-
- ck_free(tmp);
- ck_free(dir);
-
- }
-
- if (!access(AFL_PATH "/afl-llvm-rt.o", R_OK)) {
- obj_path = AFL_PATH;
- return;
- }
-
- FATAL("Unable to find 'afl-llvm-rt.o' or 'afl-llvm-pass.so'. Please set AFL_PATH");
-
-}
-
-
-/* Copy argv to cc_params, making the necessary edits. */
-
-static void edit_params(u32 argc, char** argv) {
-
- u8 fortify_set = 0, asan_set = 0, x_set = 0, maybe_linking = 1, bit_mode = 0;
- u8 *name;
-
- cc_params = ck_alloc((argc + 128) * sizeof(u8*));
-
- name = strrchr(argv[0], '/');
- if (!name) name = argv[0]; else name++;
-
- if (!strcmp(name, "afl-clang-fast++")) {
- u8* alt_cxx = getenv("AFL_CXX");
- cc_params[0] = alt_cxx ? alt_cxx : (u8*)"clang++";
- } else {
- u8* alt_cc = getenv("AFL_CC");
- cc_params[0] = alt_cc ? alt_cc : (u8*)"clang";
- }
-
- /* There are two ways to compile afl-clang-fast. In the traditional mode, we
- use afl-llvm-pass.so to inject instrumentation. In the experimental
- 'trace-pc-guard' mode, we use native LLVM instrumentation callbacks
- instead. The latter is a very recent addition - see:
-
- http://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs-with-guards */
-
-#ifdef USE_TRACE_PC
- cc_params[cc_par_cnt++] = "-fsanitize-coverage=trace-pc-guard";
- cc_params[cc_par_cnt++] = "-mllvm";
- cc_params[cc_par_cnt++] = "-sanitizer-coverage-block-threshold=0";
-#else
- cc_params[cc_par_cnt++] = "-Xclang";
- cc_params[cc_par_cnt++] = "-load";
- cc_params[cc_par_cnt++] = "-Xclang";
- cc_params[cc_par_cnt++] = alloc_printf("%s/afl-llvm-pass.so", obj_path);
-#endif /* ^USE_TRACE_PC */
-
- cc_params[cc_par_cnt++] = "-Qunused-arguments";
-
- /* Detect stray -v calls from ./configure scripts. */
-
- if (argc == 1 && !strcmp(argv[1], "-v")) maybe_linking = 0;
-
- while (--argc) {
- u8* cur = *(++argv);
-
- if (!strcmp(cur, "-m32")) bit_mode = 32;
- if (!strcmp(cur, "-m64")) bit_mode = 64;
-
- if (!strcmp(cur, "-x")) x_set = 1;
-
- if (!strcmp(cur, "-c") || !strcmp(cur, "-S") || !strcmp(cur, "-E"))
- maybe_linking = 0;
-
- if (!strcmp(cur, "-fsanitize=address") ||
- !strcmp(cur, "-fsanitize=memory")) asan_set = 1;
-
- if (strstr(cur, "FORTIFY_SOURCE")) fortify_set = 1;
-
- if (!strcmp(cur, "-shared")) maybe_linking = 0;
-
- if (!strcmp(cur, "-Wl,-z,defs") ||
- !strcmp(cur, "-Wl,--no-undefined")) continue;
-
- cc_params[cc_par_cnt++] = cur;
-
- }
-
- if (getenv("AFL_HARDEN")) {
-
- cc_params[cc_par_cnt++] = "-fstack-protector-all";
-
- if (!fortify_set)
- cc_params[cc_par_cnt++] = "-D_FORTIFY_SOURCE=2";
-
- }
-
- if (!asan_set) {
-
- if (getenv("AFL_USE_ASAN")) {
-
- if (getenv("AFL_USE_MSAN"))
- FATAL("ASAN and MSAN are mutually exclusive");
-
- if (getenv("AFL_HARDEN"))
- FATAL("ASAN and AFL_HARDEN are mutually exclusive");
-
- cc_params[cc_par_cnt++] = "-U_FORTIFY_SOURCE";
- cc_params[cc_par_cnt++] = "-fsanitize=address";
-
- } else if (getenv("AFL_USE_MSAN")) {
-
- if (getenv("AFL_USE_ASAN"))
- FATAL("ASAN and MSAN are mutually exclusive");
-
- if (getenv("AFL_HARDEN"))
- FATAL("MSAN and AFL_HARDEN are mutually exclusive");
-
- cc_params[cc_par_cnt++] = "-U_FORTIFY_SOURCE";
- cc_params[cc_par_cnt++] = "-fsanitize=memory";
-
- }
-
- }
-
-#ifdef USE_TRACE_PC
-
- if (getenv("AFL_INST_RATIO"))
- FATAL("AFL_INST_RATIO not available at compile time with 'trace-pc'.");
-
-#endif /* USE_TRACE_PC */
-
- if (!getenv("AFL_DONT_OPTIMIZE")) {
-
- cc_params[cc_par_cnt++] = "-g";
- cc_params[cc_par_cnt++] = "-O3";
- cc_params[cc_par_cnt++] = "-funroll-loops";
-
- }
-
- if (getenv("AFL_NO_BUILTIN")) {
-
- cc_params[cc_par_cnt++] = "-fno-builtin-strcmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-strncmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp";
- cc_params[cc_par_cnt++] = "-fno-builtin-memcmp";
-
- }
-
- cc_params[cc_par_cnt++] = "-D__AFL_HAVE_MANUAL_CONTROL=1";
- cc_params[cc_par_cnt++] = "-D__AFL_COMPILER=1";
- cc_params[cc_par_cnt++] = "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1";
-
- /* When the user tries to use persistent or deferred forkserver modes by
- appending a single line to the program, we want to reliably inject a
- signature into the binary (to be picked up by afl-fuzz) and we want
- to call a function from the runtime .o file. This is unnecessarily
- painful for three reasons:
-
- 1) We need to convince the compiler not to optimize out the signature.
- This is done with __attribute__((used)).
-
- 2) We need to convince the linker, when called with -Wl,--gc-sections,
- not to do the same. This is done by forcing an assignment to a
- 'volatile' pointer.
-
- 3) We need to declare __afl_persistent_loop() in the global namespace,
- but doing this within a method in a class is hard - :: and extern "C"
- are forbidden and __attribute__((alias(...))) doesn't work. Hence the
- __asm__ aliasing trick.
-
- */
-
- cc_params[cc_par_cnt++] = "-D__AFL_LOOP(_A)="
- "({ static volatile char *_B __attribute__((used)); "
- " _B = (char*)\"" PERSIST_SIG "\"; "
-#ifdef __APPLE__
- "__attribute__((visibility(\"default\"))) "
- "int _L(unsigned int) __asm__(\"___afl_persistent_loop\"); "
-#else
- "__attribute__((visibility(\"default\"))) "
- "int _L(unsigned int) __asm__(\"__afl_persistent_loop\"); "
-#endif /* ^__APPLE__ */
- "_L(_A); })";
-
- cc_params[cc_par_cnt++] = "-D__AFL_INIT()="
- "do { static volatile char *_A __attribute__((used)); "
- " _A = (char*)\"" DEFER_SIG "\"; "
-#ifdef __APPLE__
- "__attribute__((visibility(\"default\"))) "
- "void _I(void) __asm__(\"___afl_manual_init\"); "
-#else
- "__attribute__((visibility(\"default\"))) "
- "void _I(void) __asm__(\"__afl_manual_init\"); "
-#endif /* ^__APPLE__ */
- "_I(); } while (0)";
-
- if (maybe_linking) {
-
- if (x_set) {
- cc_params[cc_par_cnt++] = "-x";
- cc_params[cc_par_cnt++] = "none";
- }
-
- switch (bit_mode) {
-
- case 0:
- cc_params[cc_par_cnt++] = alloc_printf("%s/afl-llvm-rt.o", obj_path);
- break;
-
- case 32:
- cc_params[cc_par_cnt++] = alloc_printf("%s/afl-llvm-rt-32.o", obj_path);
-
- if (access(cc_params[cc_par_cnt - 1], R_OK))
- FATAL("-m32 is not supported by your compiler");
-
- break;
-
- case 64:
- cc_params[cc_par_cnt++] = alloc_printf("%s/afl-llvm-rt-64.o", obj_path);
-
- if (access(cc_params[cc_par_cnt - 1], R_OK))
- FATAL("-m64 is not supported by your compiler");
-
- break;
-
- }
-
- }
-
- cc_params[cc_par_cnt] = NULL;
-
-}
-
-
-/* Main entry point */
-
-int main(int argc, char** argv) {
-
- if (isatty(2) && !getenv("AFL_QUIET")) {
-
- SAYF(cCYA "afl-clang-fast " cBRI VERSION cRST " by <lszekeres@google.com>\n");
-
- }
-
- if (argc < 2) {
-
- SAYF("\n"
- "This is a helper application for afl-fuzz. It serves as a drop-in replacement\n"
- "for clang, letting you recompile third-party code with the required runtime\n"
- "instrumentation. A common use pattern would be one of the following:\n\n"
-
- " CC=%s/afl-clang-fast ./configure\n"
- " CXX=%s/afl-clang-fast++ ./configure\n\n"
-
- "In contrast to the traditional afl-clang tool, this version is implemented as\n"
- "an LLVM pass and tends to offer improved performance with slow programs.\n\n"
-
- "You can specify custom next-stage toolchain via AFL_CC and AFL_CXX. Setting\n"
- "AFL_HARDEN enables hardening optimizations in the compiled code.\n\n",
- BIN_PATH, BIN_PATH);
-
- exit(1);
-
- }
-
-
- find_obj(argv[0]);
-
- edit_params(argc, argv);
-
- execvp(cc_params[0], (char**)cc_params);
-
- FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]);
-
- return 0;
-
-}
diff --git a/chromium/third_party/afl/src/llvm_mode/afl-llvm-rt.o.c b/chromium/third_party/afl/src/llvm_mode/afl-llvm-rt.o.c
deleted file mode 100644
index 905c76ffb5e..00000000000
--- a/chromium/third_party/afl/src/llvm_mode/afl-llvm-rt.o.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- american fuzzy lop - LLVM instrumentation bootstrap
- ---------------------------------------------------
-
- Written by Laszlo Szekeres <lszekeres@google.com> and
- Michal Zalewski <lcamtuf@google.com>
-
- LLVM integration design comes from Laszlo Szekeres.
-
- Copyright 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This code is the rewrite of afl-as.h's main_payload.
-
-*/
-
-#include "../config.h"
-#include "../types.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <string.h>
-#include <assert.h>
-
-#include <sys/mman.h>
-#include <sys/shm.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-
-/* This is a somewhat ugly hack for the experimental 'trace-pc-guard' mode.
- Basically, we need to make sure that the forkserver is initialized after
- the LLVM-generated runtime initialization pass, not before. */
-
-#ifdef USE_TRACE_PC
-# define CONST_PRIO 5
-#else
-# define CONST_PRIO 0
-#endif /* ^USE_TRACE_PC */
-
-
-/* Globals needed by the injected instrumentation. The __afl_area_initial region
- is used for instrumentation output before __afl_map_shm() has a chance to run.
- It will end up as .comm, so it shouldn't be too wasteful. */
-
-u8 __afl_area_initial[MAP_SIZE];
-u8* __afl_area_ptr = __afl_area_initial;
-
-__thread u32 __afl_prev_loc;
-
-
-/* Running in persistent mode? */
-
-static u8 is_persistent;
-
-
-/* SHM setup. */
-
-static void __afl_map_shm(void) {
-
- u8 *id_str = getenv(SHM_ENV_VAR);
-
- /* If we're running under AFL, attach to the appropriate region, replacing the
- early-stage __afl_area_initial region that is needed to allow some really
- hacky .init code to work correctly in projects such as OpenSSL. */
-
- if (id_str) {
-
- u32 shm_id = atoi(id_str);
-
- __afl_area_ptr = shmat(shm_id, NULL, 0);
-
- /* Whooooops. */
-
- if (__afl_area_ptr == (void *)-1) _exit(1);
-
- /* Write something into the bitmap so that even with low AFL_INST_RATIO,
- our parent doesn't give up on us. */
-
- __afl_area_ptr[0] = 1;
-
- }
-
-}
-
-
-/* Fork server logic. */
-
-static void __afl_start_forkserver(void) {
-
- static u8 tmp[4];
- s32 child_pid;
-
- u8 child_stopped = 0;
-
- /* Phone home and tell the parent that we're OK. If parent isn't there,
- assume we're not running in forkserver mode and just execute program. */
-
- if (write(FORKSRV_FD + 1, tmp, 4) != 4) return;
-
- while (1) {
-
- u32 was_killed;
- int status;
-
- /* Wait for parent by reading from the pipe. Abort if read fails. */
-
- if (read(FORKSRV_FD, &was_killed, 4) != 4) _exit(1);
-
- /* If we stopped the child in persistent mode, but there was a race
- condition and afl-fuzz already issued SIGKILL, write off the old
- process. */
-
- if (child_stopped && was_killed) {
- child_stopped = 0;
- if (waitpid(child_pid, &status, 0) < 0) _exit(1);
- }
-
- if (!child_stopped) {
-
- /* Once woken up, create a clone of our process. */
-
- child_pid = fork();
- if (child_pid < 0) _exit(1);
-
- /* In child process: close fds, resume execution. */
-
- if (!child_pid) {
-
- close(FORKSRV_FD);
- close(FORKSRV_FD + 1);
- return;
-
- }
-
- } else {
-
- /* Special handling for persistent mode: if the child is alive but
- currently stopped, simply restart it with SIGCONT. */
-
- kill(child_pid, SIGCONT);
- child_stopped = 0;
-
- }
-
- /* In parent process: write PID to pipe, then wait for child. */
-
- if (write(FORKSRV_FD + 1, &child_pid, 4) != 4) _exit(1);
-
- if (waitpid(child_pid, &status, is_persistent ? WUNTRACED : 0) < 0)
- _exit(1);
-
- /* In persistent mode, the child stops itself with SIGSTOP to indicate
- a successful run. In this case, we want to wake it up without forking
- again. */
-
- if (WIFSTOPPED(status)) child_stopped = 1;
-
- /* Relay wait status to pipe, then loop back. */
-
- if (write(FORKSRV_FD + 1, &status, 4) != 4) _exit(1);
-
- }
-
-}
-
-
-/* A simplified persistent mode handler, used as explained in README.llvm. */
-
-int __afl_persistent_loop(unsigned int max_cnt) {
-
- static u8 first_pass = 1;
- static u32 cycle_cnt;
-
- if (first_pass) {
-
- /* Make sure that every iteration of __AFL_LOOP() starts with a clean slate.
- On subsequent calls, the parent will take care of that, but on the first
- iteration, it's our job to erase any trace of whatever happened
- before the loop. */
-
- if (is_persistent) {
-
- memset(__afl_area_ptr, 0, MAP_SIZE);
- __afl_area_ptr[0] = 1;
- __afl_prev_loc = 0;
- }
-
- cycle_cnt = max_cnt;
- first_pass = 0;
- return 1;
-
- }
-
- if (is_persistent) {
-
- if (--cycle_cnt) {
-
- raise(SIGSTOP);
-
- __afl_area_ptr[0] = 1;
- __afl_prev_loc = 0;
-
- return 1;
-
- } else {
-
- /* When exiting __AFL_LOOP(), make sure that the subsequent code that
- follows the loop is not traced. We do that by pivoting back to the
- dummy output region. */
-
- __afl_area_ptr = __afl_area_initial;
-
- }
-
- }
-
- return 0;
-
-}
-
-
-/* This one can be called from user code when deferred forkserver mode
- is enabled. */
-
-void __afl_manual_init(void) {
-
- static u8 init_done;
-
- if (!init_done) {
-
- __afl_map_shm();
- __afl_start_forkserver();
- init_done = 1;
-
- }
-
-}
-
-
-/* Proper initialization routine. */
-
-__attribute__((constructor(CONST_PRIO))) void __afl_auto_init(void) {
-
- is_persistent = !!getenv(PERSIST_ENV_VAR);
-
- if (getenv(DEFER_ENV_VAR)) return;
-
- __afl_manual_init();
-
-}
-
-
-/* The following stuff deals with supporting -fsanitize-coverage=trace-pc-guard.
- It remains non-operational in the traditional, plugin-backed LLVM mode.
- For more info about 'trace-pc-guard', see README.llvm.
-
- The first function (__sanitizer_cov_trace_pc_guard) is called back on every
- edge (as opposed to every basic block). */
-
-void __sanitizer_cov_trace_pc_guard(uint32_t* guard) {
- __afl_area_ptr[*guard]++;
-}
-
-
-/* Init callback. Populates instrumentation IDs. Note that we're using
- ID of 0 as a special value to indicate non-instrumented bits. That may
- still touch the bitmap, but in a fairly harmless way. */
-
-void __sanitizer_cov_trace_pc_guard_init(uint32_t* start, uint32_t* stop) {
-
- u32 inst_ratio = 100;
- u8* x;
-
- x = getenv("AFL_INST_RATIO");
- if (x) inst_ratio = atoi(x);
-
- if (!inst_ratio || inst_ratio > 100) {
- fprintf(stderr, "[-] ERROR: Invalid AFL_INST_RATIO (must be 1-100).\n");
- abort();
- }
-
- while (start < stop) {
-
- if (R(100) < inst_ratio) *start = R(MAP_SIZE - 1) + 1;
- else *start = 0;
-
- start++;
-
- }
-
-}
diff --git a/chromium/third_party/afl/src/qemu_mode/README.qemu b/chromium/third_party/afl/src/qemu_mode/README.qemu
deleted file mode 100644
index f9dce9964b7..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/README.qemu
+++ /dev/null
@@ -1,125 +0,0 @@
-=========================================================
-High-performance binary-only instrumentation for afl-fuzz
-=========================================================
-
- (See ../docs/README for the general instruction manual.)
-
-1) Introduction
----------------
-
-The code in this directory allows you to build a standalone feature that
-leverages the QEMU "user emulation" mode and allows callers to obtain
-instrumentation output for black-box, closed-source binaries. This mechanism
-can be then used by afl-fuzz to stress-test targets that couldn't be built
-with afl-gcc.
-
-The usual performance cost is 2-5x, which is considerably better than
-seen so far in experiments with tools such as DynamoRIO and PIN.
-
-The idea and much of the implementation comes from Andrew Griffiths.
-
-2) How to use
--------------
-
-The feature is implemented with a fairly simple patch to QEMU 2.3.0. The
-simplest way to build it is to run ./build_qemu_support.sh. The script will
-download, configure, and compile the QEMU binary for you.
-
-QEMU is a big project, so this will take a while, and you may have to
-resolve a couple of dependencies (most notably, you will definitely need
-libtool and glib2-devel).
-
-Once the binaries are compiled, you can leverage the QEMU tool by calling
-afl-fuzz and all the related utilities with -Q in the command line.
-
-Note that QEMU requires a generous memory limit to run; somewhere around
-200 MB is a good starting point, but considerably more may be needed for
-more complex programs. The default -m limit will be automatically bumped up
-to 200 MB when specifying -Q to afl-fuzz; be careful when overriding this.
-
-In principle, if you set CPU_TARGET before calling ./build_qemu_support.sh,
-you should get a build capable of running non-native binaries (say, you
-can try CPU_TARGET=arm). This is also necessary for running 32-bit binaries
-on a 64-bit system (CPU_TARGET=i386).
-
-Note: if you want the QEMU helper to be installed on your system for all
-users, you need to build it before issuing 'make install' in the parent
-directory.
-
-3) Notes on linking
--------------------
-
-The feature is supported only on Linux. Supporting BSD may amount to porting
-the changes made to linux-user/elfload.c and applying them to
-bsd-user/elfload.c, but I have not looked into this yet.
-
-The instrumentation follows only the .text section of the first ELF binary
-encountered in the linking process. It does not trace shared libraries. In
-practice, this means two things:
-
- - Any libraries you want to analyze *must* be linked statically into the
- executed ELF file (this will usually be the case for closed-source
- apps).
-
- - Standard C libraries and other stuff that is wasteful to instrument
- should be linked dynamically - otherwise, AFL will have no way to avoid
- peeking into them.
-
-Setting AFL_INST_LIBS=1 can be used to circumvent the .text detection logic
-and instrument every basic block encountered.
-
-4) Benchmarking
----------------
-
-If you want to compare the performance of the QEMU instrumentation with that of
-afl-gcc compiled code against the same target, you need to build the
-non-instrumented binary with the same optimization flags that are normally
-injected by afl-gcc, and make sure that the bits to be tested are statically
-linked into the binary. A common way to do this would be:
-
-$ CFLAGS="-O3 -funroll-loops" ./configure --disable-shared
-$ make clean all
-
-Comparative measurements of execution speed or instrumentation coverage will be
-fairly meaningless if the optimization levels or instrumentation scopes don't
-match.
-
-5) Gotchas, feedback, bugs
---------------------------
-
-If you need to fix up checksums or do other cleanup on mutated test cases, see
-experimental/post_library/ for a viable solution.
-
-Do not mix QEMU mode with ASAN, MSAN, or the likes; QEMU doesn't appreciate
-the "shadow VM" trick employed by the sanitizers and will probably just
-run out of memory.
-
-Compared to fully-fledged virtualization, the user emulation mode is *NOT* a
-security boundary. The binaries can freely interact with the host OS. If you
-somehow need to fuzz an untrusted binary, put everything in a sandbox first.
-
-QEMU does not necessarily support all CPU or hardware features that your
-target program may be utilizing. In particular, it does not appear to have
-full support for AVX2 / FMA3. Using binaries for older CPUs, or recompiling them
-with -march=core2, can help.
-
-Beyond that, this is an early-stage mechanism, so fields reports are welcome.
-You can send them to <afl-users@googlegroups.com>.
-
-6) Alternatives: static rewriting
----------------------------------
-
-Statically rewriting binaries just once, instead of attempting to translate
-them at run time, can be a faster alternative. That said, static rewriting is
-fraught with peril, because it depends on being able to properly and fully model
-program control flow without actually executing each and every code path.
-
-If you want to experiment with this mode of operation, there is a module
-contributed by Aleksandar Nikolich:
-
- https://github.com/vrtadmin/moflow/tree/master/afl-dyninst
- https://groups.google.com/forum/#!topic/afl-users/HlSQdbOTlpg
-
-At this point, the author reports the possibility of hiccups with stripped
-binaries. That said, if we can get it to be comparably reliable to QEMU, we may
-decide to switch to this mode, but I had no time to play with it yet.
diff --git a/chromium/third_party/afl/src/qemu_mode/build_qemu_support.sh b/chromium/third_party/afl/src/qemu_mode/build_qemu_support.sh
deleted file mode 100755
index 7224671e5ca..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/build_qemu_support.sh
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/bin/sh
-#
-# american fuzzy lop - QEMU build script
-# --------------------------------------
-#
-# Written by Andrew Griffiths <agriffiths@google.com> and
-# Michal Zalewski <lcamtuf@google.com>
-#
-# Copyright 2015, 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# This script downloads, patches, and builds a version of QEMU with
-# minor tweaks to allow non-instrumented binaries to be run under
-# afl-fuzz.
-#
-# The modifications reside in patches/*. The standalone QEMU binary
-# will be written to ../afl-qemu-trace.
-#
-
-QEMU_URL="http://wiki.qemu-project.org/download/qemu-2.3.0.tar.bz2"
-QEMU_SHA384="7a0f0c900f7e2048463cc32ff3e904965ab466c8428847400a0f2dcfe458108a68012c4fddb2a7e7c822b4fd1a49639b"
-
-echo "================================================="
-echo "AFL binary-only instrumentation QEMU build script"
-echo "================================================="
-echo
-
-echo "[*] Performing basic sanity checks..."
-
-if [ ! "`uname -s`" = "Linux" ]; then
-
- echo "[-] Error: QEMU instrumentation is supported only on Linux."
- exit 1
-
-fi
-
-if [ ! -f "patches/afl-qemu-cpu-inl.h" -o ! -f "../config.h" ]; then
-
- echo "[-] Error: key files not found - wrong working directory?"
- exit 1
-
-fi
-
-if [ ! -f "../afl-showmap" ]; then
-
- echo "[-] Error: ../afl-showmap not found - compile AFL first!"
- exit 1
-
-fi
-
-
-for i in libtool wget python automake autoconf sha384sum bison iconv; do
-
- T=`which "$i" 2>/dev/null`
-
- if [ "$T" = "" ]; then
-
- echo "[-] Error: '$i' not found, please install first."
- exit 1
-
- fi
-
-done
-
-if [ ! -d "/usr/include/glib-2.0/" -a ! -d "/usr/local/include/glib-2.0/" ]; then
-
- echo "[-] Error: devel version of 'glib2' not found, please install first."
- exit 1
-
-fi
-
-if echo "$CC" | grep -qF /afl-; then
-
- echo "[-] Error: do not use afl-gcc or afl-clang to compile this tool."
- exit 1
-
-fi
-
-echo "[+] All checks passed!"
-
-ARCHIVE="`basename -- "$QEMU_URL"`"
-
-CKSUM=`sha384sum -- "$ARCHIVE" 2>/dev/null | cut -d' ' -f1`
-
-if [ ! "$CKSUM" = "$QEMU_SHA384" ]; then
-
- echo "[*] Downloading QEMU 2.3.0 from the web..."
- rm -f "$ARCHIVE"
- wget -O "$ARCHIVE" -- "$QEMU_URL" || exit 1
-
- CKSUM=`sha384sum -- "$ARCHIVE" 2>/dev/null | cut -d' ' -f1`
-
-fi
-
-if [ "$CKSUM" = "$QEMU_SHA384" ]; then
-
- echo "[+] Cryptographic signature on $ARCHIVE checks out."
-
-else
-
- echo "[-] Error: signature mismatch on $ARCHIVE (perhaps download error?)."
- exit 1
-
-fi
-
-echo "[*] Uncompressing archive (this will take a while)..."
-
-rm -rf "qemu-2.3.0" || exit 1
-tar xf "$ARCHIVE" || exit 1
-
-echo "[+] Unpacking successful."
-
-echo "[*] Applying patches..."
-
-patch -p0 <patches/elfload.diff || exit 1
-patch -p0 <patches/cpu-exec.diff || exit 1
-patch -p0 <patches/translate-all.diff || exit 1
-patch -p0 <patches/syscall.diff || exit 1
-
-echo "[+] Patching done."
-
-ORIG_CPU_TARGET="$CPU_TARGET"
-
-test "$CPU_TARGET" = "" && CPU_TARGET="`uname -m`"
-test "$CPU_TARGET" = "i686" && CPU_TARGET="i386"
-
-echo "[*] Configuring QEMU for $CPU_TARGET..."
-
-cd qemu-2.3.0 || exit 1
-
-CFLAGS="-O3" ./configure --disable-system --enable-linux-user \
- --enable-guest-base --disable-gtk --disable-sdl --disable-vnc \
- --target-list="${CPU_TARGET}-linux-user" || exit 1
-
-echo "[+] Configuration complete."
-
-echo "[*] Attempting to build QEMU (fingers crossed!)..."
-
-make || exit 1
-
-echo "[+] Build process successful!"
-
-echo "[*] Copying binary..."
-
-cp -f "${CPU_TARGET}-linux-user/qemu-${CPU_TARGET}" "../../afl-qemu-trace" || exit 1
-
-cd ..
-ls -l ../afl-qemu-trace || exit 1
-
-echo "[+] Successfully created '../afl-qemu-trace'."
-
-if [ "$ORIG_CPU_TARGET" = "" ]; then
-
- echo "[*] Testing the build..."
-
- cd ..
-
- make >/dev/null || exit 1
-
- gcc test-instr.c -o test-instr || exit 1
-
- unset AFL_INST_RATIO
-
- echo 0 | ./afl-showmap -m none -Q -q -o .test-instr0 ./test-instr || exit 1
- echo 1 | ./afl-showmap -m none -Q -q -o .test-instr1 ./test-instr || exit 1
-
- rm -f test-instr
-
- cmp -s .test-instr0 .test-instr1
- DR="$?"
-
- rm -f .test-instr0 .test-instr1
-
- if [ "$DR" = "0" ]; then
-
- echo "[-] Error: afl-qemu-trace instrumentation doesn't seem to work!"
- exit 1
-
- fi
-
- echo "[+] Instrumentation tests passed. "
- echo "[+] All set, you can now use the -Q mode in afl-fuzz!"
-
-else
-
- echo "[!] Note: can't test instrumentation when CPU_TARGET set."
- echo "[+] All set, you can now (hopefully) use the -Q mode in afl-fuzz!"
-
-fi
-
-exit 0
diff --git a/chromium/third_party/afl/src/qemu_mode/patches/afl-qemu-cpu-inl.h b/chromium/third_party/afl/src/qemu_mode/patches/afl-qemu-cpu-inl.h
deleted file mode 100644
index eaa0e67ba0a..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/patches/afl-qemu-cpu-inl.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- american fuzzy lop - high-performance binary-only instrumentation
- -----------------------------------------------------------------
-
- Written by Andrew Griffiths <agriffiths@google.com> and
- Michal Zalewski <lcamtuf@google.com>
-
- Idea & design very much by Andrew Griffiths.
-
- Copyright 2015, 2016 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- This code is a shim patched into the separately-distributed source
- code of QEMU 2.2.0. It leverages the built-in QEMU tracing functionality
- to implement AFL-style instrumentation and to take care of the remaining
- parts of the AFL fork server logic.
-
- The resulting QEMU binary is essentially a standalone instrumentation
- tool; for an example of how to leverage it for other purposes, you can
- have a look at afl-showmap.c.
-
- */
-
-#include <sys/shm.h>
-#include "../../config.h"
-
-/***************************
- * VARIOUS AUXILIARY STUFF *
- ***************************/
-
-/* A snippet patched into tb_find_slow to inform the parent process that
- we have hit a new block that hasn't been translated yet, and to tell
- it to translate within its own context, too (this avoids translation
- overhead in the next forked-off copy). */
-
-#define AFL_QEMU_CPU_SNIPPET1 do { \
- afl_request_tsl(pc, cs_base, flags); \
- } while (0)
-
-/* This snippet kicks in when the instruction pointer is positioned at
- _start and does the usual forkserver stuff, not very different from
- regular instrumentation injected via afl-as.h. */
-
-#define AFL_QEMU_CPU_SNIPPET2 do { \
- if(tb->pc == afl_entry_point) { \
- afl_setup(); \
- afl_forkserver(env); \
- } \
- afl_maybe_log(tb->pc); \
- } while (0)
-
-/* We use one additional file descriptor to relay "needs translation"
- messages between the child and the fork server. */
-
-#define TSL_FD (FORKSRV_FD - 1)
-
-/* This is equivalent to afl-as.h: */
-
-static unsigned char *afl_area_ptr;
-
-/* Exported variables populated by the code patched into elfload.c: */
-
-abi_ulong afl_entry_point, /* ELF entry point (_start) */
- afl_start_code, /* .text start pointer */
- afl_end_code; /* .text end pointer */
-
-/* Set in the child process in forkserver mode: */
-
-static unsigned char afl_fork_child;
-unsigned int afl_forksrv_pid;
-
-/* Instrumentation ratio: */
-
-static unsigned int afl_inst_rms = MAP_SIZE;
-
-/* Function declarations. */
-
-static void afl_setup(void);
-static void afl_forkserver(CPUArchState*);
-static inline void afl_maybe_log(abi_ulong);
-
-static void afl_wait_tsl(CPUArchState*, int);
-static void afl_request_tsl(target_ulong, target_ulong, uint64_t);
-
-static TranslationBlock *tb_find_slow(CPUArchState*, target_ulong,
- target_ulong, uint64_t);
-
-
-/* Data structure passed around by the translate handlers: */
-
-struct afl_tsl {
- target_ulong pc;
- target_ulong cs_base;
- uint64_t flags;
-};
-
-
-/*************************
- * ACTUAL IMPLEMENTATION *
- *************************/
-
-
-/* Set up SHM region and initialize other stuff. */
-
-static void afl_setup(void) {
-
- char *id_str = getenv(SHM_ENV_VAR),
- *inst_r = getenv("AFL_INST_RATIO");
-
- int shm_id;
-
- if (inst_r) {
-
- unsigned int r;
-
- r = atoi(inst_r);
-
- if (r > 100) r = 100;
- if (!r) r = 1;
-
- afl_inst_rms = MAP_SIZE * r / 100;
-
- }
-
- if (id_str) {
-
- shm_id = atoi(id_str);
- afl_area_ptr = shmat(shm_id, NULL, 0);
-
- if (afl_area_ptr == (void*)-1) exit(1);
-
- /* With AFL_INST_RATIO set to a low value, we want to touch the bitmap
- so that the parent doesn't give up on us. */
-
- if (inst_r) afl_area_ptr[0] = 1;
-
-
- }
-
- if (getenv("AFL_INST_LIBS")) {
-
- afl_start_code = 0;
- afl_end_code = (abi_ulong)-1;
-
- }
-
-}
-
-
-/* Fork server logic, invoked once we hit _start. */
-
-static void afl_forkserver(CPUArchState *env) {
-
- static unsigned char tmp[4];
-
- if (!afl_area_ptr) return;
-
- /* Tell the parent that we're alive. If the parent doesn't want
- to talk, assume that we're not running in forkserver mode. */
-
- if (write(FORKSRV_FD + 1, tmp, 4) != 4) return;
-
- afl_forksrv_pid = getpid();
-
- /* All right, let's await orders... */
-
- while (1) {
-
- pid_t child_pid;
- int status, t_fd[2];
-
- /* Whoops, parent dead? */
-
- if (read(FORKSRV_FD, tmp, 4) != 4) exit(2);
-
- /* Establish a channel with child to grab translation commands. We'll
- read from t_fd[0], child will write to TSL_FD. */
-
- if (pipe(t_fd) || dup2(t_fd[1], TSL_FD) < 0) exit(3);
- close(t_fd[1]);
-
- child_pid = fork();
- if (child_pid < 0) exit(4);
-
- if (!child_pid) {
-
- /* Child process. Close descriptors and run free. */
-
- afl_fork_child = 1;
- close(FORKSRV_FD);
- close(FORKSRV_FD + 1);
- close(t_fd[0]);
- return;
-
- }
-
- /* Parent. */
-
- close(TSL_FD);
-
- if (write(FORKSRV_FD + 1, &child_pid, 4) != 4) exit(5);
-
- /* Collect translation requests until child dies and closes the pipe. */
-
- afl_wait_tsl(env, t_fd[0]);
-
- /* Get and relay exit status to parent. */
-
- if (waitpid(child_pid, &status, 0) < 0) exit(6);
- if (write(FORKSRV_FD + 1, &status, 4) != 4) exit(7);
-
- }
-
-}
-
-
-/* The equivalent of the tuple logging routine from afl-as.h. */
-
-static inline void afl_maybe_log(abi_ulong cur_loc) {
-
- static __thread abi_ulong prev_loc;
-
- /* Optimize for cur_loc > afl_end_code, which is the most likely case on
- Linux systems. */
-
- if (cur_loc > afl_end_code || cur_loc < afl_start_code || !afl_area_ptr)
- return;
-
- /* Looks like QEMU always maps to fixed locations, so ASAN is not a
- concern. Phew. But instruction addresses may be aligned. Let's mangle
- the value to get something quasi-uniform. */
-
- cur_loc = (cur_loc >> 4) ^ (cur_loc << 8);
- cur_loc &= MAP_SIZE - 1;
-
- /* Implement probabilistic instrumentation by looking at scrambled block
- address. This keeps the instrumented locations stable across runs. */
-
- if (cur_loc >= afl_inst_rms) return;
-
- afl_area_ptr[cur_loc ^ prev_loc]++;
- prev_loc = cur_loc >> 1;
-
-}
-
-
-/* This code is invoked whenever QEMU decides that it doesn't have a
- translation of a particular block and needs to compute it. When this happens,
- we tell the parent to mirror the operation, so that the next fork() has a
- cached copy. */
-
-static void afl_request_tsl(target_ulong pc, target_ulong cb, uint64_t flags) {
-
- struct afl_tsl t;
-
- if (!afl_fork_child) return;
-
- t.pc = pc;
- t.cs_base = cb;
- t.flags = flags;
-
- if (write(TSL_FD, &t, sizeof(struct afl_tsl)) != sizeof(struct afl_tsl))
- return;
-
-}
-
-
-/* This is the other side of the same channel. Since timeouts are handled by
- afl-fuzz simply killing the child, we can just wait until the pipe breaks. */
-
-static void afl_wait_tsl(CPUArchState *env, int fd) {
-
- struct afl_tsl t;
-
- while (1) {
-
- /* Broken pipe means it's time to return to the fork server routine. */
-
- if (read(fd, &t, sizeof(struct afl_tsl)) != sizeof(struct afl_tsl))
- break;
-
- tb_find_slow(env, t.pc, t.cs_base, t.flags);
-
- }
-
- close(fd);
-
-}
-
diff --git a/chromium/third_party/afl/src/qemu_mode/patches/cpu-exec.diff b/chromium/third_party/afl/src/qemu_mode/patches/cpu-exec.diff
deleted file mode 100644
index f7085cd253d..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/patches/cpu-exec.diff
+++ /dev/null
@@ -1,33 +0,0 @@
---- qemu-2.3.0/cpu-exec.c.orig 2014-12-09 14:45:40.000000000 +0000
-+++ qemu-2.3.0/cpu-exec.c 2015-02-20 22:07:02.966000000 +0000
-@@ -28,6 +28,8 @@
- #include "exec/memory-internal.h"
- #include "qemu/rcu.h"
-
-+#include "../patches/afl-qemu-cpu-inl.h"
-+
- /* -icount align implementation. */
-
- typedef struct SyncClocks {
-@@ -296,8 +298,11 @@
- }
- not_found:
- /* if no translated code available, then translate it now */
-+
- tb = tb_gen_code(cpu, pc, cs_base, flags, 0);
-
-+ AFL_QEMU_CPU_SNIPPET1;
-+
- found:
- /* Move the last found TB to the head of the list */
- if (likely(*ptb1)) {
-@@ -492,6 +497,9 @@
- next_tb = 0;
- tcg_ctx.tb_ctx.tb_invalidated_flag = 0;
- }
-+
-+ AFL_QEMU_CPU_SNIPPET2;
-+
- if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
- qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n",
- tb->tc_ptr, tb->pc, lookup_symbol(tb->pc));
diff --git a/chromium/third_party/afl/src/qemu_mode/patches/elfload.diff b/chromium/third_party/afl/src/qemu_mode/patches/elfload.diff
deleted file mode 100644
index 325c917d15a..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/patches/elfload.diff
+++ /dev/null
@@ -1,32 +0,0 @@
---- qemu-2.3.0/linux-user/elfload.c.orig 2014-12-09 14:45:42.000000000 +0000
-+++ qemu-2.3.0/linux-user/elfload.c 2015-01-28 02:51:23.719000000 +0000
-@@ -28,6 +28,8 @@
-
- #define ELF_OSABI ELFOSABI_SYSV
-
-+extern abi_ulong afl_entry_point, afl_start_code, afl_end_code;
-+
- /* from personality.h */
-
- /*
-@@ -1889,6 +1891,8 @@
- info->brk = 0;
- info->elf_flags = ehdr->e_flags;
-
-+ if (!afl_entry_point) afl_entry_point = info->entry;
-+
- for (i = 0; i < ehdr->e_phnum; i++) {
- struct elf_phdr *eppnt = phdr + i;
- if (eppnt->p_type == PT_LOAD) {
-@@ -1922,9 +1926,11 @@
- if (elf_prot & PROT_EXEC) {
- if (vaddr < info->start_code) {
- info->start_code = vaddr;
-+ if (!afl_start_code) afl_start_code = vaddr;
- }
- if (vaddr_ef > info->end_code) {
- info->end_code = vaddr_ef;
-+ if (!afl_end_code) afl_end_code = vaddr_ef;
- }
- }
- if (elf_prot & PROT_WRITE) {
diff --git a/chromium/third_party/afl/src/qemu_mode/patches/syscall.diff b/chromium/third_party/afl/src/qemu_mode/patches/syscall.diff
deleted file mode 100644
index 75d39386164..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/patches/syscall.diff
+++ /dev/null
@@ -1,25 +0,0 @@
---- qemu-2.3.0/linux-user/syscall.c.orig 2014-12-09 14:45:43.000000000 +0000
-+++ qemu-2.3.0/linux-user/syscall.c 2015-03-27 06:33:00.736000000 +0000
-@@ -227,7 +227,21 @@
- _syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo)
- _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
- #if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
--_syscall3(int,sys_tgkill,int,tgid,int,pid,int,sig)
-+
-+extern unsigned int afl_forksrv_pid;
-+
-+static int sys_tgkill(int tgid, int pid, int sig) {
-+
-+ /* Workaround for -lpthread to make abort() work properly, without
-+ killing the forkserver due to a prematurely cached PID. */
-+
-+ if (afl_forksrv_pid && afl_forksrv_pid == pid && sig == SIGABRT)
-+ pid = tgid = getpid();
-+
-+ return syscall(__NR_sys_tgkill, pid, tgid, sig);
-+
-+}
-+
- #endif
- #if defined(TARGET_NR_tkill) && defined(__NR_tkill)
- _syscall2(int,sys_tkill,int,tid,int,sig)
diff --git a/chromium/third_party/afl/src/qemu_mode/patches/translate-all.diff b/chromium/third_party/afl/src/qemu_mode/patches/translate-all.diff
deleted file mode 100644
index 180b3a55ab2..00000000000
--- a/chromium/third_party/afl/src/qemu_mode/patches/translate-all.diff
+++ /dev/null
@@ -1,18 +0,0 @@
---- qemu-2.3.0/translate-all.c.orig 2014-12-09 14:45:46.000000000 +0000
-+++ qemu-2.3.0/translate-all.c 2015-01-28 22:37:42.383000000 +0000
-@@ -393,8 +393,13 @@
- /* We can't use g_malloc because it may recurse into a locked mutex. */
- # define ALLOC(P, SIZE) \
- do { \
-- P = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, \
-- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
-+ void* _tmp = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, \
-+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
-+ if (_tmp == (void*)-1) { \
-+ qemu_log(">>> Out of memory for stack, bailing out. <<<\n"); \
-+ exit(1); \
-+ } \
-+ (P) = _tmp; \
- } while (0)
- #else
- # define ALLOC(P, SIZE) \
diff --git a/chromium/third_party/afl/src/test-instr.c b/chromium/third_party/afl/src/test-instr.c
deleted file mode 100644
index 09a1c9f700f..00000000000
--- a/chromium/third_party/afl/src/test-instr.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- american fuzzy lop - a trivial program to test the build
- --------------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2014 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-int main(int argc, char** argv) {
-
- char buf[8];
-
- if (read(0, buf, 8) < 1) {
- printf("Hum?\n");
- exit(1);
- }
-
- if (buf[0] == '0')
- printf("Looks like a zero to me!\n");
- else
- printf("A non-zero value? How quaint!\n");
-
- exit(0);
-
-}
diff --git a/chromium/third_party/afl/src/testcases/README.testcases b/chromium/third_party/afl/src/testcases/README.testcases
deleted file mode 100644
index 30110ba1a66..00000000000
--- a/chromium/third_party/afl/src/testcases/README.testcases
+++ /dev/null
@@ -1,19 +0,0 @@
-=======================
-AFL starting test cases
-=======================
-
- (See ../docs/README for the general instruction manual.)
-
-The archives/, images/, multimedia/, and others/ subdirectories contain small,
-standalone files that can be used to seed afl-fuzz when testing parsers for a
-variety of common data formats.
-
-There is probably not much to be said about these files, except that they were
-optimized for size and stripped of any non-essential fluff. Some directories
-contain several examples that exercise various features of the underlying format.
-For example, there is a PNG file with and without a color profile.
-
-Additional test cases are always welcome.
-
-In addition to well-chosen starting files, many fuzzing jobs benefit from a
-small and concise dictionary. See ../dictionaries/README.dictionaries for more.
diff --git a/chromium/third_party/afl/src/testcases/archives/common/ar/small_archive.a b/chromium/third_party/afl/src/testcases/archives/common/ar/small_archive.a
deleted file mode 100644
index 8c50bc28937..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/ar/small_archive.a
+++ /dev/null
@@ -1,8 +0,0 @@
-!<arch>
-limerick/ 1415337776 500 500 100640 191 `
-There was a young man from Japan
-Whose limericks never would scan.
-When asked why that was,
-He replied "It's because
-I always try to cram as many words into the last line as I possibly can."
-
diff --git a/chromium/third_party/afl/src/testcases/archives/common/bzip2/small_archive.bz2 b/chromium/third_party/afl/src/testcases/archives/common/bzip2/small_archive.bz2
deleted file mode 100644
index 83914ad249a..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/bzip2/small_archive.bz2
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/cab/small_archive.cab b/chromium/third_party/afl/src/testcases/archives/common/cab/small_archive.cab
deleted file mode 100644
index 3f429043b39..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/cab/small_archive.cab
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/compress/small_archive.Z b/chromium/third_party/afl/src/testcases/archives/common/compress/small_archive.Z
deleted file mode 100644
index 73bf3151c10..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/compress/small_archive.Z
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/cpio/small_archive.cpio b/chromium/third_party/afl/src/testcases/archives/common/cpio/small_archive.cpio
deleted file mode 100644
index d1ee8a2cf0f..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/cpio/small_archive.cpio
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/gzip/small_archive.gz b/chromium/third_party/afl/src/testcases/archives/common/gzip/small_archive.gz
deleted file mode 100644
index 4a6cd8e15bc..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/gzip/small_archive.gz
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/lzo/small_archive.lzo b/chromium/third_party/afl/src/testcases/archives/common/lzo/small_archive.lzo
deleted file mode 100644
index bf310368e9c..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/lzo/small_archive.lzo
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/rar/small_archive.rar b/chromium/third_party/afl/src/testcases/archives/common/rar/small_archive.rar
deleted file mode 100644
index a5aae4ceb94..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/rar/small_archive.rar
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/tar/small_archive.tar b/chromium/third_party/afl/src/testcases/archives/common/tar/small_archive.tar
deleted file mode 100644
index 8f694fdef97..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/tar/small_archive.tar
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/xz/small_archive.xz b/chromium/third_party/afl/src/testcases/archives/common/xz/small_archive.xz
deleted file mode 100644
index f30df04f8b9..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/xz/small_archive.xz
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/common/zip/small_archive.zip b/chromium/third_party/afl/src/testcases/archives/common/zip/small_archive.zip
deleted file mode 100644
index dc7992cdcfc..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/common/zip/small_archive.zip
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/arj/small_archive.arj b/chromium/third_party/afl/src/testcases/archives/exotic/arj/small_archive.arj
deleted file mode 100644
index 8bcd12ebe1c..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/arj/small_archive.arj
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/lha/small_archive.lha b/chromium/third_party/afl/src/testcases/archives/exotic/lha/small_archive.lha
deleted file mode 100644
index e70f325bbe5..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/lha/small_archive.lha
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/lrzip/small_archive.lrz b/chromium/third_party/afl/src/testcases/archives/exotic/lrzip/small_archive.lrz
deleted file mode 100644
index 1a0415f1036..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/lrzip/small_archive.lrz
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/lzip/small_archive.lz b/chromium/third_party/afl/src/testcases/archives/exotic/lzip/small_archive.lz
deleted file mode 100644
index 89e2448ede6..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/lzip/small_archive.lz
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/lzma/small_archive.lzma b/chromium/third_party/afl/src/testcases/archives/exotic/lzma/small_archive.lzma
deleted file mode 100644
index bbd056a5ff3..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/lzma/small_archive.lzma
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/rzip/small_archive.rz b/chromium/third_party/afl/src/testcases/archives/exotic/rzip/small_archive.rz
deleted file mode 100644
index d1950c4b7f6..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/rzip/small_archive.rz
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/archives/exotic/zoo/small_archive.zoo b/chromium/third_party/afl/src/testcases/archives/exotic/zoo/small_archive.zoo
deleted file mode 100644
index 1614e5fbf24..00000000000
--- a/chromium/third_party/afl/src/testcases/archives/exotic/zoo/small_archive.zoo
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/bmp/not_kitty.bmp b/chromium/third_party/afl/src/testcases/images/bmp/not_kitty.bmp
deleted file mode 100644
index 0309c928395..00000000000
--- a/chromium/third_party/afl/src/testcases/images/bmp/not_kitty.bmp
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/gif/not_kitty.gif b/chromium/third_party/afl/src/testcases/images/gif/not_kitty.gif
deleted file mode 100644
index 244fcc64524..00000000000
--- a/chromium/third_party/afl/src/testcases/images/gif/not_kitty.gif
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/ico/not_kitty.ico b/chromium/third_party/afl/src/testcases/images/ico/not_kitty.ico
deleted file mode 100644
index d2bb2916e7f..00000000000
--- a/chromium/third_party/afl/src/testcases/images/ico/not_kitty.ico
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/jp2/not_kitty.jp2 b/chromium/third_party/afl/src/testcases/images/jp2/not_kitty.jp2
deleted file mode 100644
index 14bca2924a0..00000000000
--- a/chromium/third_party/afl/src/testcases/images/jp2/not_kitty.jp2
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/jpeg/not_kitty.jpg b/chromium/third_party/afl/src/testcases/images/jpeg/not_kitty.jpg
deleted file mode 100644
index 0497be49f57..00000000000
--- a/chromium/third_party/afl/src/testcases/images/jpeg/not_kitty.jpg
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/jxr/not_kitty.jxr b/chromium/third_party/afl/src/testcases/images/jxr/not_kitty.jxr
deleted file mode 100644
index 0fa2c8ec019..00000000000
--- a/chromium/third_party/afl/src/testcases/images/jxr/not_kitty.jxr
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/png/not_kitty.png b/chromium/third_party/afl/src/testcases/images/png/not_kitty.png
deleted file mode 100644
index eff7c1707b9..00000000000
--- a/chromium/third_party/afl/src/testcases/images/png/not_kitty.png
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/png/not_kitty_alpha.png b/chromium/third_party/afl/src/testcases/images/png/not_kitty_alpha.png
deleted file mode 100644
index 2fb8da2c8f5..00000000000
--- a/chromium/third_party/afl/src/testcases/images/png/not_kitty_alpha.png
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/png/not_kitty_gamma.png b/chromium/third_party/afl/src/testcases/images/png/not_kitty_gamma.png
deleted file mode 100644
index 939d9d29a9b..00000000000
--- a/chromium/third_party/afl/src/testcases/images/png/not_kitty_gamma.png
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/png/not_kitty_icc.png b/chromium/third_party/afl/src/testcases/images/png/not_kitty_icc.png
deleted file mode 100644
index f0c7804d998..00000000000
--- a/chromium/third_party/afl/src/testcases/images/png/not_kitty_icc.png
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/tiff/not_kitty.tiff b/chromium/third_party/afl/src/testcases/images/tiff/not_kitty.tiff
deleted file mode 100644
index 506ca1ad4b5..00000000000
--- a/chromium/third_party/afl/src/testcases/images/tiff/not_kitty.tiff
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/images/webp/not_kitty.webp b/chromium/third_party/afl/src/testcases/images/webp/not_kitty.webp
deleted file mode 100644
index 8592d823645..00000000000
--- a/chromium/third_party/afl/src/testcases/images/webp/not_kitty.webp
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/multimedia/h264/small_movie.mp4 b/chromium/third_party/afl/src/testcases/multimedia/h264/small_movie.mp4
deleted file mode 100644
index adc6c9cb799..00000000000
--- a/chromium/third_party/afl/src/testcases/multimedia/h264/small_movie.mp4
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/others/js/small_script.js b/chromium/third_party/afl/src/testcases/others/js/small_script.js
deleted file mode 100644
index bb632d8a977..00000000000
--- a/chromium/third_party/afl/src/testcases/others/js/small_script.js
+++ /dev/null
@@ -1 +0,0 @@
-if (1==1) eval('1'); \ No newline at end of file
diff --git a/chromium/third_party/afl/src/testcases/others/pcap/small_capture.pcap b/chromium/third_party/afl/src/testcases/others/pcap/small_capture.pcap
deleted file mode 100644
index 60e2210ba54..00000000000
--- a/chromium/third_party/afl/src/testcases/others/pcap/small_capture.pcap
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/afl/src/testcases/others/pdf/small.pdf b/chromium/third_party/afl/src/testcases/others/pdf/small.pdf
deleted file mode 100644
index d31b4eb2c6a..00000000000
--- a/chromium/third_party/afl/src/testcases/others/pdf/small.pdf
+++ /dev/null
@@ -1,2 +0,0 @@
-%PDF-1.0
-1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj 2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj 3 0 obj<</Type/Page/MediaBox[0 0 3 3]>>endobj trailer<</Size 4/Root 1 0 R>> \ No newline at end of file
diff --git a/chromium/third_party/afl/src/testcases/others/rtf/small_document.rtf b/chromium/third_party/afl/src/testcases/others/rtf/small_document.rtf
deleted file mode 100644
index 0fdedc3233d..00000000000
--- a/chromium/third_party/afl/src/testcases/others/rtf/small_document.rtf
+++ /dev/null
@@ -1 +0,0 @@
-{\rtf1\pard Test\par} \ No newline at end of file
diff --git a/chromium/third_party/afl/src/testcases/others/sql/simple_queries.sql b/chromium/third_party/afl/src/testcases/others/sql/simple_queries.sql
deleted file mode 100644
index 5fff40727f5..00000000000
--- a/chromium/third_party/afl/src/testcases/others/sql/simple_queries.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-create table t1(one smallint);
-insert into t1 values(1);
-select * from t1;
diff --git a/chromium/third_party/afl/src/testcases/others/text/hello_world.txt b/chromium/third_party/afl/src/testcases/others/text/hello_world.txt
deleted file mode 100644
index ce013625030..00000000000
--- a/chromium/third_party/afl/src/testcases/others/text/hello_world.txt
+++ /dev/null
@@ -1 +0,0 @@
-hello
diff --git a/chromium/third_party/afl/src/testcases/others/xml/small_document.xml b/chromium/third_party/afl/src/testcases/others/xml/small_document.xml
deleted file mode 100644
index 684e28466d9..00000000000
--- a/chromium/third_party/afl/src/testcases/others/xml/small_document.xml
+++ /dev/null
@@ -1 +0,0 @@
-<a b="c">d</a>
diff --git a/chromium/third_party/afl/src/types.h b/chromium/third_party/afl/src/types.h
deleted file mode 100644
index 21d32da6156..00000000000
--- a/chromium/third_party/afl/src/types.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- american fuzzy lop - type definitions and minor macros
- ------------------------------------------------------
-
- Written and maintained by Michal Zalewski <lcamtuf@google.com>
-
- Copyright 2013, 2014, 2015 Google Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- */
-
-#ifndef _HAVE_TYPES_H
-#define _HAVE_TYPES_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-
-/*
-
- Ugh. There is an unintended compiler / glibc #include glitch caused by
- combining the u64 type an %llu in format strings, necessitating a workaround.
-
- In essence, the compiler is always looking for 'unsigned long long' for %llu.
- On 32-bit systems, the u64 type (aliased to uint64_t) is expanded to
- 'unsigned long long' in <bits/types.h>, so everything checks out.
-
- But on 64-bit systems, it is #ifdef'ed in the same file as 'unsigned long'.
- Now, it only happens in circumstances where the type happens to have the
- expected bit width, *but* the compiler does not know that... and complains
- about 'unsigned long' being unsafe to pass to %llu.
-
- */
-
-#ifdef __x86_64__
-typedef unsigned long long u64;
-#else
-typedef uint64_t u64;
-#endif /* ^__x86_64__ */
-
-typedef int8_t s8;
-typedef int16_t s16;
-typedef int32_t s32;
-typedef int64_t s64;
-
-#ifndef MIN
-# define MIN(_a,_b) ((_a) > (_b) ? (_b) : (_a))
-# define MAX(_a,_b) ((_a) > (_b) ? (_a) : (_b))
-#endif /* !MIN */
-
-#define SWAP16(_x) ({ \
- u16 _ret = (_x); \
- (u16)((_ret << 8) | (_ret >> 8)); \
- })
-
-#define SWAP32(_x) ({ \
- u32 _ret = (_x); \
- (u32)((_ret << 24) | (_ret >> 24) | \
- ((_ret << 8) & 0x00FF0000) | \
- ((_ret >> 8) & 0x0000FF00)); \
- })
-
-#define R(x) (random() % (x))
-
-#define STRINGIFY_INTERNAL(x) #x
-#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
-
-#define MEM_BARRIER() \
- asm volatile("" ::: "memory")
-
-#define likely(_x) __builtin_expect(!!(_x), 1)
-#define unlikely(_x) __builtin_expect(!!(_x), 0)
-
-#endif /* ! _HAVE_TYPES_H */
diff --git a/chromium/third_party/afl/update.py b/chromium/third_party/afl/update.py
deleted file mode 100755
index 0dd8df90a34..00000000000
--- a/chromium/third_party/afl/update.py
+++ /dev/null
@@ -1,181 +0,0 @@
-#! /usr/bin/env python
-# Copyright (c) 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Script for updating AFL. Also updates AFL version in README.chromium.
-"""
-
-import argparse
-import cStringIO
-import datetime
-import os
-import re
-import sys
-import tarfile
-import urllib2
-
-
-VERSION_REGEX = r'(?P<version>([0-9]*[.])?[0-9]+b)'
-PATH_REGEX = r'(afl-)' + VERSION_REGEX
-
-
-class ChromiumReadme(object):
- """Class that handles reading from and updating the README.chromium"""
-
- README_FILE_PATH = 'third_party/afl/README.chromium'
- README_VERSION_REGEX = r'Version: ' + VERSION_REGEX
-
- def __init__(self):
- """
- Inits the ChromiumReadme.
- """
- with open(self.README_FILE_PATH) as readme_file_handle:
- self.readme_contents = readme_file_handle.read()
-
- def get_current_version(self):
- """
- Get the current version of AFL according to the README.chromium
- """
- match = re.search(self.README_VERSION_REGEX, self.readme_contents)
- if not match:
- raise Exception('Could not determine current AFL version')
- return match.groupdict()['version']
-
- def update(self, new_version):
- """
- Update the readme to reflect the new version that has been downloaded.
- """
- new_readme = self.readme_contents
- subsitutions = [(VERSION_REGEX, new_version), # Update the version.
- (r'Date: .*',
- 'Date: ' + datetime.date.today().strftime("%B %d, %Y")),
- # Update the Local Modifications.
- (PATH_REGEX + r'/', 'afl-' + new_version + '/')]
-
- for regex, replacement in subsitutions:
- new_readme = re.subn(regex, replacement, new_readme, 1)[0]
-
- self.readme_contents = new_readme
- with open(self.README_FILE_PATH, 'w+') as readme_file_handle:
- readme_file_handle.write(self.readme_contents)
-
-
-class AflTarball(object):
- """
- Class that handles the afl-latest.tgz tarball.
- """
- # Regexes that match files that we don't want to extract.
- # Note that you should add these removals to "Local Modifications" in
- # the README.chromium.
- UNWANTED_FILE_REGEX = '|'.join([
- r'(.*\.elf)', # presubmit complains these aren't marked executable.
- r'(.*others/elf)', # We don't need this if we have no elfs.
- # checkdeps complains about #includes.
- r'(.*afl-llvm-pass\.so\.cc)',
- r'(.*argv.*)', # Delete the demo's directory as well.
-
- r'(.*dictionaries.*)', # Including these make builds fail.
- ])
- AFL_SRC_DIR = 'third_party/afl/src'
-
- def __init__(self, version):
- """
- Init this AFL tarball.
- """
- release_name = 'afl-{0}'.format(version)
- filename = '{0}.tgz'.format(release_name)
-
- # Note: lcamtuf.coredump.cx does not support TLS connections. The "http://"
- # protocol is intentional.
- self.url = "http://lcamtuf.coredump.cx/afl/releases/{0}".format(filename)
- self.tarball = None
- self.real_version = version if version != 'latest' else None
-
- def download(self):
- """Download the tarball version from
- http://lcamtuf.coredump.cx/afl/releases/
- """
- tarball_contents = urllib2.urlopen(self.url).read()
- tarball_file = cStringIO.StringIO(tarball_contents)
- self.tarball = tarfile.open(fileobj=tarball_file, mode="r:gz")
- if self.real_version is None:
- regex_match = re.search(VERSION_REGEX, self.tarball.members[0].path)
- self.real_version = regex_match.groupdict()['version']
-
- def extract(self):
- """
- Extract the files and folders from the tarball we have downloaded while
- skipping unwanted ones.
- """
-
- for member in self.tarball.getmembers():
- member.path = re.sub(PATH_REGEX, self.AFL_SRC_DIR, member.path)
- if re.match(self.UNWANTED_FILE_REGEX, member.path):
- print 'skipping unwanted file: {0}'.format(member.path)
- continue
- self.tarball.extract(member)
-
-
-def version_to_float(version):
- """
- Convert version string to float.
- """
- if version.endswith('b'):
- return float(version[:-1])
-
- return float(version)
-
-
-def update_afl(new_version):
- """
- Update this version of AFL to newer version, new_version.
- """
- readme = ChromiumReadme()
- old_version = readme.get_current_version()
- if new_version != 'latest':
- new_float = version_to_float(new_version)
- assert version_to_float(old_version) < new_float, (
- 'Trying to update from version {0} to {1}'.format(old_version,
- new_version))
-
- # Extract the tarball.
- tarball = AflTarball(new_version)
- tarball.download()
- current_less_than_new = version_to_float(old_version) < version_to_float(
- tarball.real_version)
- assert current_less_than_new, (
- 'Trying to update from version {0} to {1}'.format(old_version,
- tarball.real_version))
-
- tarball.extract()
-
- readme.update(tarball.real_version)
-
-
-def main():
- """
- Update AFL if possible.
- """
- parser = argparse.ArgumentParser('Update AFL.')
- parser.add_argument('version', metavar='version', default='latest', nargs='?',
- help='(optional) Version to update AFL to.')
-
- args = parser.parse_args()
- version = args.version
- if version != 'latest' and not version.endswith('b'):
- version += 'b'
-
- in_correct_directory = (os.path.basename(os.getcwd()) == 'src' and
- os.path.exists('third_party'))
-
- assert in_correct_directory, (
- '{0} must be run from the repo\'s root'.format(sys.argv[0]))
-
- update_afl(version)
- print ("Run git diff third_party/afl/src/docs/ChangeLog to see changes to AFL"
- " since the last roll")
-
-
-if __name__ == '__main__':
- main()
diff --git a/chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_account_data.proto b/chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_account_data.proto
deleted file mode 100644
index 79325f635cd..00000000000
--- a/chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_account_data.proto
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package authpolicy;
-
-// TODO(ljusten): Remove this file as soon as Chrome uses
-// active_directory_info.proto. crbug.com/712720.
-
-// Message sent to Chromium by authpolicy service as a response of successful
-// AuthenticateUser call. Contains information about authenticated user fetched
-// from Active Directory server.
-message ActiveDirectoryAccountData {
- // Unique id of the user account. Taken from the objectGUID property of the
- // Active Directory user account information.
- optional string account_id = 1;
- // Display name of the user. Taken from the displayName property of the Active
- // account information.
- optional string display_name = 2;
- // Given name of the user. AKA first name. Taken from givenName property of
- // the Active Directory user account information.
- optional string given_name = 3;
- // Logon name of the user (without @realm). Taken from the sAMAccountName
- // property of the Active Directory user account information.
- optional string sam_account_name = 4;
-}
diff --git a/chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_info.proto b/chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_info.proto
deleted file mode 100644
index 90c1047c102..00000000000
--- a/chromium/third_party/cros_system_api/dbus/authpolicy/active_directory_info.proto
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package authpolicy;
-
-// Message sent to Chromium by authpolicy service as a response of a successful
-// AuthenticateUser call. Contains information about authenticated user fetched
-// from Active Directory server with "net ads search ...".
-message ActiveDirectoryAccountInfo {
- // Unique id of the user account. Taken from the objectGUID property of the
- // Active Directory user account information.
- optional string account_id = 1;
- // Display name of the user. Taken from the displayName property of the Active
- // account information.
- optional string display_name = 2;
- // Given name of the user. AKA first name. Taken from the givenName property
- // of the Active Directory user account information.
- optional string given_name = 3;
- // Logon name of the user (without @realm). Taken from the sAMAccountName
- // property of the Active Directory user account information.
- optional string sam_account_name = 4;
- // Timestamp when the password was last set, see
- // https://msdn.microsoft.com/en-us/library/ms679430(v=vs.85).aspx. Taken from
- // the pwdLastSet property of the Active Directory user account information.
- // Used in authpolicyd only, unused in Chrome.
- optional uint64 pwd_last_set = 5;
- // User account control flags, see
- // https://msdn.microsoft.com/en-us/library/ms680832(v=vs.85).aspx. Taken from
- // the userAccountControl property of the Active Directory user account
- // information. Used in authpolicyd only, unused in Chrome.
- optional uint32 user_account_control = 6;
- // Next ID to use: 7
-}
-
-// Message sent to Chromium by authpolicy service as a response to a successful
-// GetUserStatus call.
-message ActiveDirectoryUserStatus {
- // Ticket-granting-ticket status.
- enum TgtStatus {
- TGT_VALID = 0; // Ticket is still valid.
- TGT_EXPIRED = 1; // Ticket expired.
- TGT_NOT_FOUND = 2; // Kerberos credentials cache not found.
- // Next ID to use: 3
- }
-
- // Whether the password has to be changed or sync'ed with cryptohome.
- enum PasswordStatus {
- PASSWORD_VALID = 0; // Valid as far as we can tell.
- PASSWORD_EXPIRED = 1; // User has to enter a new password on next logon.
- PASSWORD_CHANGED = 2; // Changed on server, possibly from other client.
- // Next ID to use: 3
- }
-
- // User's account information, see above.
- optional ActiveDirectoryAccountInfo account_info = 1;
- // Status of the user's ticket-granting-ticket (TGT).
- optional TgtStatus tgt_status = 2;
- // Status of the user's password.
- optional PasswordStatus password_status = 3;
- // Last error returned from AuthenticateUser D-Bus call, see ErrorType.
- optional int32 last_auth_error = 4;
- // Next ID to use: 5
-}
diff --git a/chromium/third_party/cros_system_api/dbus/authpolicy/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/authpolicy/dbus-constants.h
index 2716728ebcc..4e39b889d5d 100644
--- a/chromium/third_party/cros_system_api/dbus/authpolicy/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/authpolicy/dbus-constants.h
@@ -6,80 +6,39 @@
#define SYSTEM_API_DBUS_AUTHPOLICY_DBUS_CONSTANTS_H_
namespace authpolicy {
-
const char kAuthPolicyInterface[] = "org.chromium.AuthPolicy";
const char kAuthPolicyServicePath[] = "/org/chromium/AuthPolicy";
const char kAuthPolicyServiceName[] = "org.chromium.AuthPolicy";
// Methods
const char kAuthPolicyAuthenticateUser[] = "AuthenticateUser";
-const char kAuthPolicyGetUserStatus[] = "GetUserStatus";
const char kAuthPolicyJoinADDomain[] = "JoinADDomain";
const char kAuthPolicyRefreshUserPolicy[] = "RefreshUserPolicy";
const char kAuthPolicyRefreshDevicePolicy[] = "RefreshDevicePolicy";
-// D-Bus call error codes. These values are written to logs. New enum values can
-// be added, but existing enums must never be renumbered or deleted and reused.
-enum ErrorType {
- // Everything is A-OK!
- ERROR_NONE = 0,
- // Unspecified error.
- ERROR_UNKNOWN = 1,
- // Unspecified D-Bus error.
- ERROR_DBUS_FAILURE = 2,
- // Badly formatted user principal name.
- ERROR_PARSE_UPN_FAILED = 3,
- // Auth failed because of bad user name.
- ERROR_BAD_USER_NAME = 4,
- // Auth failed because of bad password.
- ERROR_BAD_PASSWORD = 5,
- // Auth failed because of expired password.
- ERROR_PASSWORD_EXPIRED = 6,
- // Auth failed because of bad realm or network.
- ERROR_CANNOT_RESOLVE_KDC = 7,
- // kinit exited with unspecified error.
- ERROR_KINIT_FAILED = 8,
- // net exited with unspecified error.
- ERROR_NET_FAILED = 9,
- // smdclient exited with unspecified error.
- ERROR_SMBCLIENT_FAILED = 10,
- // authpolicy_parser exited with unknown error.
- ERROR_PARSE_FAILED = 11,
- // Parsing GPOs failed.
- ERROR_PARSE_PREG_FAILED = 12,
- // GPO data is bad.
- ERROR_BAD_GPOS = 13,
- // Some local IO operation failed.
- ERROR_LOCAL_IO = 14,
- // Machine is not joined to AD domain yet.
- ERROR_NOT_JOINED = 15,
- // User is not logged in yet.
- ERROR_NOT_LOGGED_IN = 16,
- // Failed to send policy to Session Manager.
- ERROR_STORE_POLICY_FAILED = 17,
- // User doesn't have the right to join machines to the domain.
- ERROR_JOIN_ACCESS_DENIED = 18,
- // General network problem.
- ERROR_NETWORK_PROBLEM = 19,
- // Machine name contains restricted characters.
- ERROR_INVALID_MACHINE_NAME = 20,
- // Machine name too long.
- ERROR_MACHINE_NAME_TOO_LONG = 21,
- // User joined maximum number of machines to the domain.
- ERROR_USER_HIT_JOIN_QUOTA = 22,
- // Kinit or smbclient failed to contact Key Distribution Center.
- ERROR_CONTACTING_KDC_FAILED = 23,
- // Kerberos credentials cache not found.
- ERROR_NO_CREDENTIALS_CACHE_FOUND = 24,
- // Kerberos ticket expired while renewing credentials.
- ERROR_KERBEROS_TICKET_EXPIRED = 25,
- // Klist exited with unspecified error.
- ERROR_KLIST_FAILED = 26,
- // Kinit failed because of bad machine name.
- ERROR_BAD_MACHINE_NAME = 27,
- // Should be the last.
- ERROR_COUNT,
+// Enum values.
+enum ADJoinErrorType {
+ AD_JOIN_ERROR_NONE = 0,
+ AD_JOIN_ERROR_UNKNOWN = 1,
+ AD_JOIN_ERROR_DBUS_FAILURE = 2,
+};
+
+enum AuthUserErrorType {
+ AUTH_USER_ERROR_NONE = 0,
+ AUTH_USER_ERROR_UNKNOWN = 1,
+ AUTH_USER_ERROR_DBUS_FAILURE = 2,
};
-} // namespace authpolicy
+enum RefreshUserPolicyErrorType {
+ REFRESH_USER_POLICY_ERROR_NONE = 0,
+ REFRESH_USER_POLICY_ERROR_UNKNOWN = 1,
+ REFRESH_USER_POLICY_ERROR_DBUS_FAILURE = 2,
+};
+
+enum RefreshDevicePolicyErrorType {
+ REFRESH_DEVICE_POLICY_ERROR_NONE = 0,
+ REFRESH_DEVICE_POLICY_ERROR_UNKNOWN = 1,
+ REFRESH_DEVICE_POLICY_ERROR_DBUS_FAILURE = 2,
+};
+} // namespace authpolicy
-#endif // SYSTEM_API_DBUS_AUTHPOLICY_DBUS_CONSTANTS_H_
+#endif // SYSTEM_API_DBUS_AUTHPOLICY_DBUS_CONSTANTS_H_
diff --git a/chromium/third_party/cros_system_api/dbus/biod/constants.proto b/chromium/third_party/cros_system_api/dbus/biod/constants.proto
deleted file mode 100644
index d7266c03e41..00000000000
--- a/chromium/third_party/cros_system_api/dbus/biod/constants.proto
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package biod;
-
-// Included in biod's EnrollScanDone signal.
-enum ScanResult {
- SCAN_RESULT_SUCCESS = 0;
- SCAN_RESULT_PARTIAL = 1;
- SCAN_RESULT_INSUFFICIENT = 2;
- SCAN_RESULT_SENSOR_DIRTY = 3;
- SCAN_RESULT_TOO_SLOW = 4;
- SCAN_RESULT_TOO_FAST = 5;
- SCAN_RESULT_IMMOBILE = 6;
- SCAN_RESULT_MAX = 7;
-}
diff --git a/chromium/third_party/cros_system_api/dbus/biod/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/biod/dbus-constants.h
deleted file mode 100644
index f74a4477dff..00000000000
--- a/chromium/third_party/cros_system_api/dbus/biod/dbus-constants.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2017 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYSTEM_API_DBUS_BIOD_DBUS_CONSTANTS_H_
-#define SYSTEM_API_DBUS_BIOD_DBUS_CONSTANTS_H_
-
-namespace biod {
-const char kBiodServicePath[] = "/org/chromium/BiometricsDaemon";
-const char kBiodServiceName[] = "org.chromium.BiometricsDaemon";
-
-// Interfaces for objects exported by biod
-const char kBiometricsManagerInterface[] =
- "org.chromium.BiometricsDaemon.BiometricsManager";
-const char kAuthSessionInterface[] =
- "org.chromium.BiometricsDaemon.AuthSession";
-const char kEnrollSessionInterface[] =
- "org.chromium.BiometricsDaemon.EnrollSession";
-const char kRecordInterface[] = "org.chromium.BiometricsDaemon.Record";
-
-// List of all BiometricsManagers
-const char kFakeBiometricsManagerName[] = "FakeBiometricsManager";
-const char kFpcBiometricsManagerName[] = "FpcBiometricsManager";
-
-// Methods
-const char kBiometricsManagerStartEnrollSessionMethod[] = "StartEnrollSession";
-const char kBiometricsManagerGetRecordsForUserMethod[] = "GetRecordsForUser";
-const char kBiometricsManagerDestroyAllRecordsMethod[] = "DestroyAllRecords";
-const char kBiometricsManagerStartAuthSessionMethod[] = "StartAuthSession";
-const char kAuthSessionEndMethod[] = "End";
-const char kEnrollSessionCancelMethod[] = "Cancel";
-const char kRecordRemoveMethod[] = "Remove";
-const char kRecordSetLabelMethod[] = "SetLabel";
-
-// Signals
-const char kBiometricsManagerEnrollScanDoneSignal[] = "EnrollScanDone";
-const char kBiometricsManagerAuthScanDoneSignal[] = "AuthScanDone";
-const char kBiometricsManagerSessionFailedSignal[] = "SessionFailed";
-
-// Properties
-const char kBiometricsManagerBiometricTypeProperty[] = "Type";
-const char kRecordLabelProperty[] = "Label";
-
-// Values
-enum BiometricType {
- BIOMETRIC_TYPE_UNKNOWN = 0,
- BIOMETRIC_TYPE_FINGERPRINT = 1,
- BIOMETRIC_TYPE_MAX,
-};
-} // namespace biod
-
-#endif // SYSTEM_API_DBUS_BIOD_DBUS_CONSTANTS_H_
diff --git a/chromium/third_party/cros_system_api/dbus/biod/messages.proto b/chromium/third_party/cros_system_api/dbus/biod/messages.proto
deleted file mode 100644
index ea0e966369b..00000000000
--- a/chromium/third_party/cros_system_api/dbus/biod/messages.proto
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package biod;
-
-import "constants.proto";
-
-// Included in biod's EnrollScanDone signal.
-message EnrollScanDone {
- optional ScanResult scan_result = 1;
- optional bool done = 2;
- optional int32 percent_complete = 3;
-}
diff --git a/chromium/third_party/cros_system_api/dbus/chaps/OWNERS b/chromium/third_party/cros_system_api/dbus/chaps/OWNERS
deleted file mode 100644
index 4659435e011..00000000000
--- a/chromium/third_party/cros_system_api/dbus/chaps/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-set noparent
-ejcaruso@chromium.org
-apronin@chromium.org
diff --git a/chromium/third_party/cros_system_api/dbus/chaps/ck_structs.proto b/chromium/third_party/cros_system_api/dbus/chaps/ck_structs.proto
deleted file mode 100644
index 8fe14218dbc..00000000000
--- a/chromium/third_party/cros_system_api/dbus/chaps/ck_structs.proto
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2017 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package chaps;
-
-// Proto for CK_MECHANISM_INFO.
-// https://www.cryptsoft.com/pkcs11doc/v220/structCK__MECHANISM__INFO.html
-message MechanismInfo {
- // Next ID to use: 4
-
- optional uint64 min_key_size = 1;
- optional uint64 max_key_size = 2;
- optional uint64 flags = 3;
-}
-
-// Proto for CK_SESSION_INFO.
-// https://www.cryptsoft.com/pkcs11doc/v220/structCK__SESSION__INFO.html
-message SessionInfo {
- // Next ID to use: 5
-
- optional uint64 slot_id = 1;
- optional uint64 state = 2;
- optional uint64 flags = 3;
- optional uint64 device_error = 4;
-}
-
-// Proto for CK_VERSION.
-// https://www.cryptsoft.com/pkcs11doc/v220/structCK__VERSION.html
-message Version {
- // Next ID to use: 3
-
- optional uint32 major = 1;
- optional uint32 minor = 2;
-}
-
-// Proto for CK_SLOT_INFO.
-// https://www.cryptsoft.com/pkcs11doc/v220/structCK__SLOT__INFO.html
-message SlotInfo {
- // Next ID to use: 6
-
- optional bytes slot_description = 1;
- optional bytes manufacturer_id = 2;
- optional uint64 flags = 3;
- optional Version hardware_version = 4;
- optional Version firmware_version = 5;
-}
-
-// Proto for CK_TOKEN_INFO.
-// https://www.cryptsoft.com/pkcs11doc/v220/structCK__TOKEN__INFO.html
-message TokenInfo {
- // Next ID to use: 18
-
- optional bytes label = 1;
- optional bytes manufacturer_id = 2;
- optional bytes model = 3;
- optional bytes serial_number = 4;
- optional uint64 flags = 5;
- optional uint64 max_session_count = 6;
- optional uint64 session_count = 7;
- optional uint64 max_session_count_rw = 8;
- optional uint64 session_count_rw = 9;
- optional uint64 max_pin_len = 10;
- optional uint64 min_pin_len = 11;
- optional uint64 total_public_memory = 12;
- optional uint64 free_public_memory = 13;
- optional uint64 total_private_memory = 14;
- optional uint64 free_private_memory = 15;
- optional Version hardware_version = 16;
- optional Version firmware_version = 17;
-}
diff --git a/chromium/third_party/cros_system_api/dbus/cros-disks/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/cros-disks/dbus-constants.h
index 392337d41a7..c58af384496 100644
--- a/chromium/third_party/cros_system_api/dbus/cros-disks/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/cros-disks/dbus-constants.h
@@ -46,6 +46,7 @@ const char kDevicePresentationHide[] = "DevicePresentationHide";
const char kDeviceSize[] = "DeviceSize";
const char kDriveIsRotational[] = "DriveIsRotational";
const char kDriveModel[] = "DriveModel";
+const char kExperimentalFeaturesEnabled[] = "ExperimentalFeaturesEnabled";
const char kIdLabel[] = "IdLabel";
const char kIdUuid[] = "IdUuid";
const char kVendorId[] = "VendorId";
diff --git a/chromium/third_party/cros_system_api/dbus/cryptohome/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/cryptohome/dbus-constants.h
index 4300eb58f40..fcaa99bde9e 100644
--- a/chromium/third_party/cros_system_api/dbus/cryptohome/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/cryptohome/dbus-constants.h
@@ -122,8 +122,6 @@ const char kCryptohomeSetFirmwareManagementParameters[] =
"SetFirmwareManagementParameters";
const char kCryptohomeRemoveFirmwareManagementParameters[] =
"RemoveFirmwareManagementParameters";
-const char kCryptohomeMigrateToDircrypto[] = "MigrateToDircrypto";
-const char kCryptohomeNeedsDircryptoMigration[] = "NeedsDircryptoMigration";
// Signals
const char kSignalAsyncCallStatus[] = "AsyncCallStatus";
@@ -131,7 +129,6 @@ const char kSignalAsyncCallStatusWithData[] = "AsyncCallStatusWithData";
const char kSignalTpmInitStatus[] = "TpmInitStatus";
const char kSignalCleanupUsersRemoved[] = "CleanupUsersRemoved";
const char kSignalLowDiskSpace[] = "LowDiskSpace";
-const char kSignalDircryptoMigrationProgress[] = "DircryptoMigrationProgress";
// Error code
enum MountError {
MOUNT_ERROR_NONE = 0,
@@ -142,24 +139,8 @@ enum MountError {
MOUNT_ERROR_TPM_DEFEND_LOCK = 1 << 4,
MOUNT_ERROR_USER_DOES_NOT_EXIST = 1 << 5,
MOUNT_ERROR_TPM_NEEDS_REBOOT = 1 << 6,
- // Encrypted in old method, need migration before mounting.
- MOUNT_ERROR_OLD_ENCRYPTION = 1 << 7,
- // Previous migration attempt was aborted in the middle. Must resume it first.
- MOUNT_ERROR_PREVIOUS_MIGRATION_INCOMPLETE = 1 << 8,
MOUNT_ERROR_RECREATED = 1 << 31,
};
-// Status code signaled from MigrateToDircrypto().
-enum DircryptoMigrationStatus {
- // 0 means a successful completion.
- DIRCRYPTO_MIGRATION_SUCCESS = 0,
- // Negative values mean failing completion.
- // TODO(kinaba,dspaid): Add error codes as needed here.
- DIRCRYPTO_MIGRATION_FAILED = -1,
- // Positive values mean intermediate state report for the running migration.
- // TODO(kinaba,dspaid): Add state codes as needed.
- DIRCRYPTO_MIGRATION_INITIALIZING = 1,
- DIRCRYPTO_MIGRATION_IN_PROGRESS = 2,
-};
} // namespace cryptohome
#endif // SYSTEM_API_DBUS_CRYPTOHOME_DBUS_CONSTANTS_H_
diff --git a/chromium/third_party/cros_system_api/dbus/cryptohome/rpc.proto b/chromium/third_party/cros_system_api/dbus/cryptohome/rpc.proto
index 30d87608f85..84fb2038862 100644
--- a/chromium/third_party/cros_system_api/dbus/cryptohome/rpc.proto
+++ b/chromium/third_party/cros_system_api/dbus/cryptohome/rpc.proto
@@ -57,8 +57,6 @@ enum CryptohomeErrorCode {
CRYPTOHOME_ERROR_FIRMWARE_MANAGEMENT_PARAMETERS_INVALID = 26;
CRYPTOHOME_ERROR_FIRMWARE_MANAGEMENT_PARAMETERS_CANNOT_STORE = 27;
CRYPTOHOME_ERROR_FIRMWARE_MANAGEMENT_PARAMETERS_CANNOT_REMOVE = 28;
- CRYPTOHOME_ERROR_MOUNT_OLD_ENCRYPTION = 29;
- CRYPTOHOME_ERROR_MOUNT_PREVIOUS_MIGRATION_INCOMPLETE = 30;
}
message AccountIdentifier {
@@ -88,13 +86,6 @@ message MountRequest {
// Additionally, a failed AuthorizationRequest will be expected as
// there will be no existing keys.
optional CreateRequest create = 2;
- // If set to true, and cryptohomed supports the new "dircrypto" encryption,
- // forces to use the new encryption. That is, makes it an error to mount
- // an existing home directory encrypted in the old way (ecryptfs).
- optional bool force_dircrypto_if_available = 3;
- // If set to true, mounts the existing ecryptfs vault to a temporary location
- // while setting up a new dircrypto directory.
- optional bool to_migrate_from_ecryptfs = 4;
}
// A BaseReply type is used for all cryptohomed responses. A shared base class
@@ -134,8 +125,6 @@ message CreateRequest {
// Setting this value means that the KeyData is filled as it
// would be with a Key above or in an AddKeyRequest.
optional bool copy_authorization_key = 2 [default=false];
- // If set to true, always use eCryptfs as the encryption method.
- optional bool force_ecryptfs = 3 [default=false];
// In the future, this will contain account-wide data like
// the deletion priority or the IdP's origin.
}
@@ -303,7 +292,6 @@ enum FirmwareManagementParametersFlags {
DEVELOPER_ENABLE_USB = 8;
DEVELOPER_ENABLE_LEGACY = 16;
DEVELOPER_USE_KEY_HASH = 32;
- DEVELOPER_DISABLE_CASE_CLOSED_DEBUGGING_UNLOCK = 64;
}
message GetFirmwareManagementParametersRequest {
diff --git a/chromium/third_party/cros_system_api/dbus/debugd/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/debugd/dbus-constants.h
index bef928a2d74..eea6c48c154 100644
--- a/chromium/third_party/cros_system_api/dbus/debugd/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/debugd/dbus-constants.h
@@ -11,11 +11,10 @@ const char kDebugdServicePath[] = "/org/chromium/debugd";
const char kDebugdServiceName[] = "org.chromium.debugd";
// Methods.
-const char kCupsAddManuallyConfiguredPrinter[] =
- "CupsAddManuallyConfiguredPrinter";
-const char kCupsAddAutoConfiguredPrinter[] = "CupsAddAutoConfiguredPrinter";
+const char kCupsAddPrinter[] = "CupsAddPrinter";
const char kCupsRemovePrinter[] = "CupsRemovePrinter";
const char kDumpDebugLogs[] = "DumpDebugLogs";
+const char kGetDebugLogs[] = "GetDebugLogs";
const char kGetInterfaces[] = "GetInterfaces";
const char kGetModemStatus[] = "GetModemStatus";
const char kGetNetworkStatus[] = "GetNetworkStatus";
@@ -55,16 +54,6 @@ enum DevFeatureFlag {
DEV_FEATURE_SYSTEM_ROOT_PASSWORD_SET = 1 << 5,
DEV_FEATURE_CHROME_REMOTE_DEBUGGING_ENABLED = 1 << 6,
};
-
-// CupsAdd* error codes
-enum CupsResult {
- CUPS_SUCCESS = 0,
- CUPS_FATAL = 1,
- CUPS_INVALID_PPD = 2,
- CUPS_LPADMIN_FAILURE = 3,
- CUPS_AUTOCONF_FAILURE = 4,
-};
-
} // namespace debugd
#endif // SYSTEM_API_DBUS_DEBUGD_DBUS_CONSTANTS_H_
diff --git a/chromium/third_party/cros_system_api/dbus/login_manager/arc.proto b/chromium/third_party/cros_system_api/dbus/login_manager/arc.proto
deleted file mode 100644
index 1d7dcee6fc8..00000000000
--- a/chromium/third_party/cros_system_api/dbus/login_manager/arc.proto
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2017 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package login_manager;
-
-// ARC startup options sent from Chrome to session manager. This message is
-// used in SessionManagerInterface.StartArcInterface method.
-message StartArcInstanceRequest {
- // Account ID of the user to start ARC for. This must be the same as the
- // one given in StartSession.
- optional string account_id = 1;
-
- // Option to disable ACTION_BOOT_COMPLETED broadcast for 3rd party apps.
- optional bool skip_boot_completed_broadcast = 2;
-
- // Option to enable package manager service to scan /vendor/priv-app
- // directory.
- optional bool scan_vendor_priv_app = 3;
-
- // Next ID to use: 4
-}
diff --git a/chromium/third_party/cros_system_api/dbus/login_manager/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/login_manager/dbus-constants.h
index 2ad22fed620..637e5f2cc7c 100644
--- a/chromium/third_party/cros_system_api/dbus/login_manager/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/login_manager/dbus-constants.h
@@ -43,7 +43,7 @@ const char kSessionManagerInitMachineInfo[] = "InitMachineInfo";
const char kSessionManagerCheckArcAvailability[] = "CheckArcAvailability";
const char kSessionManagerStartArcInstance[] = "StartArcInstance";
const char kSessionManagerStopArcInstance[] = "StopArcInstance";
-const char kSessionManagerSetArcCpuRestriction[] = "SetArcCpuRestriction";
+const char kSessionManagerPrioritizeArcInstance[] = "PrioritizeArcInstance";
const char kSessionManagerEmitArcBooted[] = "EmitArcBooted";
const char kSessionManagerGetArcStartTimeTicks[] = "GetArcStartTimeTicks";
const char kSessionManagerRemoveArcData[] = "RemoveArcData";
@@ -61,46 +61,6 @@ const char kPropertyChangeCompleteSignal[] = "PropertyChangeComplete";
// ARC instance signals.
const char kArcInstanceStopped[] = "ArcInstanceStopped";
const char kArcInstanceRebooted[] = "ArcInstanceRebooted";
-
-// D-Bus error codes
-namespace dbus_error {
-#define INTERFACE "org.chromium.SessionManagerInterface"
-
-const char kNone[] = INTERFACE ".None";
-const char kArcCpuCgroupFail[] = INTERFACE ".ArcCpuCgroupFail";
-const char kArcInstanceRunning[] = INTERFACE ".ArcInstanceRunning";
-const char kContainerStartupFail[] = INTERFACE ".ContainerStartupFail";
-const char kContainerShutdownFail[] = INTERFACE ".ContainerShutdownFail";
-const char kEmitFailed[] = INTERFACE ".EmitFailed";
-const char kInitMachineInfoFail[] = INTERFACE ".InitMachineInfoFail";
-const char kInvalidAccount[] = INTERFACE ".InvalidAccount";
-const char kLowFreeDisk[] = INTERFACE ".LowFreeDisk";
-const char kNoOwnerKey[] = INTERFACE ".NoOwnerKey";
-const char kNoUserNssDb[] = INTERFACE ".NoUserNssDb";
-const char kNotAvailable[] = INTERFACE ".NotAvailable";
-const char kNotStarted[] = INTERFACE ".NotStarted";
-const char kPolicyInitFail[] = INTERFACE ".PolicyInitFail";
-const char kPubkeySetIllegal[] = INTERFACE ".PubkeySetIllegal";
-const char kPolicySignatureRequired[] = INTERFACE ".PolicySignatureRequired";
-const char kSessionDoesNotExist[] = INTERFACE ".SessionDoesNotExist";
-const char kSessionExists[] = INTERFACE ".SessionExists";
-const char kSigDecodeFail[] = INTERFACE ".SigDecodeFail";
-const char kSigEncodeFail[] = INTERFACE ".SigEncodeFail";
-const char kTestingChannelError[] = INTERFACE ".TestingChannelError";
-const char kUnknownPid[] = INTERFACE ".UnknownPid";
-const char kVerifyFail[] = INTERFACE ".VerifyFail";
-const char kVpdUpdateFailed[] = INTERFACE ".VpdUpdateFailed";
-
-#undef INTERFACE
-} // namespace dbus_error
-
-// Values
-enum ContainerCpuRestrictionState {
- CONTAINER_CPU_RESTRICTION_FOREGROUND = 0,
- CONTAINER_CPU_RESTRICTION_BACKGROUND = 1,
- NUM_CONTAINER_CPU_RESTRICTION_STATES = 2,
-};
-
} // namespace login_manager
#endif // SYSTEM_API_DBUS_LOGIN_MANAGER_DBUS_CONSTANTS_H_
diff --git a/chromium/third_party/cros_system_api/dbus/power_manager/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/power_manager/dbus-constants.h
index 8fa97b36f4e..0a3dfaca7ad 100644
--- a/chromium/third_party/cros_system_api/dbus/power_manager/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/power_manager/dbus-constants.h
@@ -21,7 +21,6 @@ const char kRequestRestartMethod[] = "RequestRestart";
const char kRequestShutdownMethod[] = "RequestShutdown";
const char kRequestSuspendMethod[] = "RequestSuspend";
const char kGetPowerSupplyPropertiesMethod[] = "GetPowerSupplyProperties";
-const char kGetSwitchStatesMethod[] = "GetSwitchStates";
const char kHandleUserActivityMethod[] = "HandleUserActivity";
const char kHandleVideoActivityMethod[] = "HandleVideoActivity";
const char kSetIsProjectingMethod[] = "SetIsProjecting";
diff --git a/chromium/third_party/cros_system_api/dbus/power_manager/switch_states.proto b/chromium/third_party/cros_system_api/dbus/power_manager/switch_states.proto
deleted file mode 100644
index e1a827c44b8..00000000000
--- a/chromium/third_party/cros_system_api/dbus/power_manager/switch_states.proto
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-
-package power_manager;
-
-// Included in responses to GetSwitchStates method calls to powerd.
-message SwitchStates {
- // Next ID to use: 3
-
- enum LidState {
- OPEN = 0;
- CLOSED = 1;
- NOT_PRESENT = 2;
- }
- optional LidState lid_state = 1;
-
- enum TabletMode {
- ON = 0;
- OFF = 1;
- UNSUPPORTED = 2;
- }
- optional TabletMode tablet_mode = 2;
-}
diff --git a/chromium/third_party/cros_system_api/dbus/service_constants.h b/chromium/third_party/cros_system_api/dbus/service_constants.h
index a2200ef4663..1f63c036fa0 100644
--- a/chromium/third_party/cros_system_api/dbus/service_constants.h
+++ b/chromium/third_party/cros_system_api/dbus/service_constants.h
@@ -11,7 +11,6 @@
// Chromium OS and Chromium environment.
#include "apmanager/dbus-constants.h"
#include "authpolicy/dbus-constants.h"
-#include "biod/dbus-constants.h"
#include "cros-disks/dbus-constants.h"
#include "cryptohome/dbus-constants.h"
#include "debugd/dbus-constants.h"
@@ -62,7 +61,6 @@ const char kImageLoaderServiceName[] = "org.chromium.ImageLoader";
const char kImageLoaderServicePath[] = "/org/chromium/ImageLoader";
// Methods
const char kRegisterComponent[] = "RegisterComponent";
-const char kLoadComponent[] = "LoadComponent";
const char kGetComponentVersion[] = "GetComponentVersion";
// Constants
const char kBadResult[] = "";
@@ -93,8 +91,6 @@ const char kLibCrosServicePath[] = "/org/chromium/LibCrosService";
const char kLibCrosServiceInterface[] = "org.chromium.LibCrosServiceInterface";
// Methods
const char kResolveNetworkProxy[] = "ResolveNetworkProxy";
-// TODO(teravest): Remove this once CheckLiveness is removed from
-// LibCrosService.
const char kCheckLiveness[] = "CheckLiveness";
const char kGetKioskAppRequiredPlatforVersion[] =
"GetKioskAppRequiredPlatformVersion";
@@ -110,27 +106,6 @@ enum DisplayPowerState {
DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON = 2,
DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF = 3,
};
-
-const char kNetworkProxyServiceName[] = "org.chromium.NetworkProxyService";
-const char kNetworkProxyServicePath[] = "/org/chromium/NetworkProxyService";
-const char kNetworkProxyServiceInterface[] =
- "org.chromium.NetworkProxyServiceInterface";
-const char kNetworkProxyServiceResolveProxyMethod[] = "ResolveProxy";
-
-const char kLivenessServiceName[] = "org.chromium.LivenessService";
-const char kLivenessServicePath[] = "/org/chromium/LivenessService";
-const char kLivenessServiceInterface[] =
- "org.chromium.LivenessServiceInterface";
-const char kLivenessServiceCheckLivenessMethod[] = "CheckLiveness";
-
-const char kKioskAppServiceName[] = "org.chromium.KioskAppService";
-const char kKioskAppServicePath[] = "/org/chromium/KioskAppService";
-const char kKioskAppServiceInterface[] =
- "org.chromium.KioskAppServiceInterface";
-// Methods
-const char kKioskAppServiceGetRequiredPlatformVersionMethod[] =
- "GetRequiredPlatformVersion";
-
} // namespace chromeos
namespace cromo {
@@ -151,18 +126,6 @@ const char kModemGsmNetworkInterface[] =
const char kModemGobiInterface[] = "org.chromium.ModemManager.Modem.Gobi";
} // namespace cromo
-namespace media_perception {
-
-const char kMediaPerceptionServiceName[] = "org.chromium.MediaPerception";
-const char kMediaPerceptionServicePath[] = "/org/chromium/MediaPerception";
-const char kMediaPerceptionInterface[] = "org.chromium.MediaPerception";
-
-const char kStateFunction[] = "State";
-const char kGetDiagnosticsFunction[] = "GetDiagnostics";
-const char kDetectionSignal[] = "MediaPerceptionDetection";
-
-} // namespace media_perception
-
namespace modemmanager {
// ModemManager D-Bus service identifiers
const char kModemManagerSMSInterface[] =
diff --git a/chromium/third_party/cros_system_api/dbus/shill/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/shill/dbus-constants.h
index 118c7a95655..063d70a4342 100644
--- a/chromium/third_party/cros_system_api/dbus/shill/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/shill/dbus-constants.h
@@ -164,6 +164,7 @@ const char kEntriesProperty[] = "Entries";
// Flimflam Device property names.
const char kScanningProperty[] = "Scanning";
const char kPoweredProperty[] = "Powered";
+const char kNetworksProperty[] = "Networks";
const char kScanIntervalProperty[] = "ScanInterval";
const char kBgscanMethodProperty[] = "BgscanMethod";
const char kBgscanShortIntervalProperty[] = "BgscanShortInterval";
diff --git a/chromium/third_party/cros_system_api/dbus/update_engine/dbus-constants.h b/chromium/third_party/cros_system_api/dbus/update_engine/dbus-constants.h
index 9551b411941..86c60dd00a7 100644
--- a/chromium/third_party/cros_system_api/dbus/update_engine/dbus-constants.h
+++ b/chromium/third_party/cros_system_api/dbus/update_engine/dbus-constants.h
@@ -24,10 +24,6 @@ const char kGetChannel[] = "GetChannel";
const char kAttemptRollback[] = "AttemptRollback";
const char kCanRollback[] = "CanRollback";
const char kGetEolStatus[] = "GetEolStatus";
-const char kSetUpdateOverCellularPermission[] =
- "SetUpdateOverCellularPermission";
-const char kSetUpdateOverCellularTarget[] =
- "SetUpdateOverCellularTarget";
// Signals.
const char kStatusUpdate[] = "StatusUpdate";
@@ -59,8 +55,6 @@ const char kUpdateStatusReportingErrorEvent[] =
const char kUpdateStatusAttemptingRollback[] =
"UPDATE_STATUS_ATTEMPTING_ROLLBACK";
const char kUpdateStatusDisabled[] = "UPDATE_STATUS_DISABLED";
-const char kUpdateStatusNeedPermissionToUpdate[] =
- "UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE";
} // namespace update_engine
#endif // SYSTEM_API_DBUS_UPDATE_ENGINE_DBUS_CONSTANTS_H_
diff --git a/chromium/third_party/cros_system_api/system_api.gyp b/chromium/third_party/cros_system_api/system_api.gyp
index 4c0951b05a1..47b12d7a756 100644
--- a/chromium/third_party/cros_system_api/system_api.gyp
+++ b/chromium/third_party/cros_system_api/system_api.gyp
@@ -35,12 +35,11 @@
'proto_out_dir': 'include/power_manager/proto_bindings',
},
'sources': [
+ '<(proto_in_dir)/suspend.proto',
'<(proto_in_dir)/input_event.proto',
'<(proto_in_dir)/peripheral_battery_status.proto',
'<(proto_in_dir)/policy.proto',
'<(proto_in_dir)/power_supply_properties.proto',
- '<(proto_in_dir)/suspend.proto',
- '<(proto_in_dir)/switch_states.proto',
],
'includes': ['../../platform2/common-mk/protoc.gypi'],
},
@@ -52,12 +51,11 @@
'system_api-power_manager-protos-gen',
],
'sources': [
+ '<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/suspend.pb.cc',
'<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/input_event.pb.cc',
'<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/peripheral_battery_status.pb.cc',
'<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/policy.pb.cc',
'<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/power_supply_properties.pb.cc',
- '<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/suspend.pb.cc',
- '<(SHARED_INTERMEDIATE_DIR)/include/power_manager/proto_bindings/switch_states.pb.cc',
]
},
{
@@ -87,105 +85,5 @@
'<(SHARED_INTERMEDIATE_DIR)/include/cryptohome/proto_bindings/signed_secret.pb.cc',
]
},
- {
- 'target_name': 'system_api-authpolicy-protos-gen',
- 'type': 'none',
- 'variables': {
- 'proto_in_dir': 'dbus/authpolicy',
- 'proto_out_dir': 'include/authpolicy/proto_bindings',
- },
- 'sources': [
- # TODO(ljusten): Remove this file as soon as Chrome uses
- # active_directory_info.proto. crbug.com/712720.
- '<(proto_in_dir)/active_directory_account_data.proto',
- '<(proto_in_dir)/active_directory_info.proto',
- ],
- 'includes': ['../../platform2/common-mk/protoc.gypi'],
- },
- {
- 'target_name': 'system_api-authpolicy-protos',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'dependencies': [
- 'system_api-authpolicy-protos-gen',
- ],
- 'sources': [
- # TODO(ljusten): Remove this file as soon as Chrome uses
- # active_directory_info.proto. crbug.com/712720.
- '<(SHARED_INTERMEDIATE_DIR)/include/authpolicy/proto_bindings/active_directory_account_data.pb.cc',
- '<(SHARED_INTERMEDIATE_DIR)/include/authpolicy/proto_bindings/active_directory_info.pb.cc',
- ]
- },
- {
- 'target_name': 'system_api-biod-protos-gen',
- 'type': 'none',
- 'variables': {
- 'proto_in_dir': 'dbus/biod',
- 'proto_out_dir': 'include/biod/proto_bindings',
- },
- 'sources': [
- '<(proto_in_dir)/constants.proto',
- '<(proto_in_dir)/messages.proto',
- ],
- 'includes': ['../../platform2/common-mk/protoc.gypi'],
- },
- {
- 'target_name': 'system_api-biod-protos',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'dependencies': [
- 'system_api-biod-protos-gen',
- ],
- 'sources': [
- '<(SHARED_INTERMEDIATE_DIR)/include/biod/proto_bindings/constants.pb.cc',
- '<(SHARED_INTERMEDIATE_DIR)/include/biod/proto_bindings/messages.pb.cc',
- ]
- },
- {
- 'target_name': 'system_api-login_manager-protos-gen',
- 'type': 'none',
- 'variables': {
- 'proto_in_dir': 'dbus/login_manager',
- 'proto_out_dir': 'include/login_manager/proto_bindings',
- },
- 'sources': [
- '<(proto_in_dir)/arc.proto',
- ],
- 'includes': ['../../platform2/common-mk/protoc.gypi'],
- },
- {
- 'target_name': 'system_api-login_manager-protos',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'dependencies': [
- 'system_api-login_manager-protos-gen',
- ],
- 'sources': [
- '<(SHARED_INTERMEDIATE_DIR)/include/login_manager/proto_bindings/arc.pb.cc',
- ]
- },
- {
- 'target_name': 'system_api-chaps-protos-gen',
- 'type': 'none',
- 'variables': {
- 'proto_in_dir': 'dbus/chaps',
- 'proto_out_dir': 'include/chaps/proto_bindings',
- },
- 'sources': [
- '<(proto_in_dir)/ck_structs.proto',
- ],
- 'includes': ['../../platform2/common-mk/protoc.gypi'],
- },
- {
- 'target_name': 'system_api-chaps-protos',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'dependencies': [
- 'system_api-chaps-protos-gen',
- ],
- 'sources': [
- '<(SHARED_INTERMEDIATE_DIR)/include/chaps/proto_bindings/ck_structs.pb.cc',
- ]
- },
]
}
diff --git a/chromium/third_party/cros_system_api/system_api.pc b/chromium/third_party/cros_system_api/system_api.pc
index 0f01f54f083..c6925acd48a 100644
--- a/chromium/third_party/cros_system_api/system_api.pc
+++ b/chromium/third_party/cros_system_api/system_api.pc
@@ -1,4 +1,4 @@
Name: system_api
Description: Protobuffers and headers shared by Chromium OS and Chromium.
Version: 0.1
-Libs: -lsystem_api-power_manager-protos -lsystem_api-cryptohome-protos -lsystem_api-authpolicy-protos -lsystem_api-biod-protos -lsystem_api-protos -lsystem_api-login_manager-protos -lsystem_api-chaps-protos
+Libs: -lsystem_api-power_manager-protos -lsystem_api-cryptohome-protos -lsystem_api-protos
diff --git a/chromium/third_party/flatbuffers/src/docs/source/CONTRIBUTING.md b/chromium/third_party/flatbuffers/src/docs/source/CONTRIBUTING.md
index 433b7d33548..158875295d2 120000..100644
--- a/chromium/third_party/flatbuffers/src/docs/source/CONTRIBUTING.md
+++ b/chromium/third_party/flatbuffers/src/docs/source/CONTRIBUTING.md
@@ -1 +1,42 @@
-../../CONTRIBUTING \ No newline at end of file
+Contributing {#contributing}
+============
+
+Want to contribute? Great! First, read this page (including the small print at
+the end).
+
+# Before you contribute
+Before we can use your code, you must sign the
+[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
+(CLA), which you can do online. The CLA is necessary mainly because you own the
+copyright to your changes, even after your contribution becomes part of our
+codebase, so we need your permission to use and distribute your code. We also
+need to be sure of various other things—for instance that you'll tell us if you
+know that your code infringes on other people's patents. You don't have to sign
+the CLA until after you've submitted your code for review and a member has
+approved it, but you must do it before we can put your code into our codebase.
+Before you start working on a larger contribution, you should get in touch with
+us first through the issue tracker with your idea so that we can help out and
+possibly guide you. Coordinating up front makes it much easier to avoid
+frustration later on.
+
+# Code reviews
+All submissions, including submissions by project members, require review. We
+use Github pull requests for this purpose.
+
+Some tips for good pull requests:
+* Use our code
+ [style guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.html).
+ When in doubt, try to stay true to the existing code of the project.
+* Write a descriptive commit message. What problem are you solving and what
+ are the consequences? Where and what did you test? Some good tips:
+ [here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
+ and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
+* If your PR consists of multiple commits which are successive improvements /
+ fixes to your first commit, consider squashing them into a single commit
+ (`git rebase -i`) such that your PR is a single commit on top of the current
+ HEAD. This make reviewing the code so much easier, and our history more
+ readable.
+
+# The small print
+Contributions made by corporations are covered by a different agreement than
+the one above, the Software Grant and Corporate Contributor License Agreement.
diff --git a/chromium/third_party/fontconfig/src/INSTALL b/chromium/third_party/fontconfig/src/INSTALL
index 670add1f32c..aab4cddbc4f 100644
--- a/chromium/third_party/fontconfig/src/INSTALL
+++ b/chromium/third_party/fontconfig/src/INSTALL
@@ -28,7 +28,7 @@ important steps:
freedesktop.org:/srv/www.freedesktop.org/www/software/fontconfig/release
5. Update the Fontconfig Devel wiki page
- http://fontconfig.org/wiki/Devel
+ https://www.freedesktop.org/wiki/Software/fontconfig/Devel/
6. Update the fontconfig documentation
diff --git a/chromium/third_party/fontconfig/src/Makefile.am b/chromium/third_party/fontconfig/src/Makefile.am
index 2b949e43963..2b4a5b82280 100644
--- a/chromium/third_party/fontconfig/src/Makefile.am
+++ b/chromium/third_party/fontconfig/src/Makefile.am
@@ -21,7 +21,7 @@
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-SUBDIRS=fontconfig fc-case fc-lang fc-glyphname src \
+SUBDIRS=fontconfig fc-blanks fc-case fc-lang fc-glyphname src \
fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \
fc-validate conf.d test
if ENABLE_DOCS
diff --git a/chromium/third_party/fontconfig/src/README b/chromium/third_party/fontconfig/src/README
index d2288a55994..bf840a5e74e 100644
--- a/chromium/third_party/fontconfig/src/README
+++ b/chromium/third_party/fontconfig/src/README
@@ -1,12 +1,283 @@
Fontconfig
Font configuration and customization library
- Version 2.11
- 2013-10-11
+ Version 2.12.1
+ 2016-08-05
Check INSTALL for compilation and installation instructions.
Report bugs to https://bugs.freedesktop.org in the fontconfig module.
+2.12.1
+
+Akira TAGOH (6):
+ Add --with-default-hinting to configure
+ Update CaseFolding.txt to Unicode 9.0
+ Check python installed in autogen.sh
+ Fix some errors related to python3
+ Bug 96676 - Check range of FcWeightFromOpenType argument
+ Update libtool revision
+
+Tobias Stoeckmann (1):
+ Properly validate offsets in cache files.
+
+2.12
+
+Akira TAGOH (8):
+ Modernize fc-blanks.py
+ Update URL
+ Bug 95477 - FcAtomicLock fails when SELinux denies link() syscall with EACCES
+ 45-latin.conf: Add some Windows fonts to categorize them properly
+ Correct one for the previous change
+ Bug 95481 - Build fails on Android due to broken lconv struct
+ Add the static raw data to generate fcblanks.h
+ Remove unused code
+
+Erik de Castro Lopo (1):
+ Fix a couple of minor memory leaks
+
+Petr Filipsky (1):
+ Fix memory leak in FcDirCacheLock
+
+2.11.95 (2.12 RC5)
+
+Akira TAGOH (22):
+ Add one more debugging option to see transformation on font-matching
+ Fix a crash when no objects are available after filtering
+ No need to be public
+ mark as private at this moment
+ Don't return FcFalse even when no fonts dirs is configured
+ Add a warning for blank in fonts.conf
+ Fix a memory leak in FcFreeTypeQueryFace
+ Update CaseFolding.txt to Unicode 8.0
+ Bug 90867 - Memory Leak during error case in fccharset
+ Fix the broken cache more.
+ Fail on make runtime as needed instead of configure if no python installed
+ Use long long to see the same size between LP64 and LLP64
+ Fix build issue on MinGW
+ Use int64_t instead of long long
+ Fix compiler warnings on MinGW
+ Fix assertion on 32bit arch
+ remomve unnecessary code
+ Bug 93075 - Possible fix for make check failure on msys/MinGW...
+ Avoid an error message on testing when no fonts.conf installed
+ Add hintstyle templates and make hintslight default
+ Revert "Workaround another race condition issue"
+ Update libtool revision
+
+Behdad Esfahbod (6):
+ Revert changes made to FcConfigAppFontAddDir() recently
+ Call FcFreeTypeQueryFace() from fcdir.c, instead of FcFreeTypeQuery()
+ [GX] Support instance weight, width, and style name
+ [GX] Enumerate all named-instances in TrueType GX fonts
+ Improve OpenType to Fontconfig weight mapping
+ [GX] Improve weight mapping
+
+Patrick Haller (1):
+ Optimizations in FcStrSet
+
+2.11.94 (2.12 RC4)
+
+Akira TAGOH (16):
+ Remove the dead code
+ Bug 89617 - FcConfigAppFontAddFile() returns false on any font file
+ Fix unknown attribute in Win32
+ Fix SIGFPE
+ Fix a typo for the latest cache version
+ Fix a typo in fontconfig-user.sgml
+ Drop unmaintained code
+ Observe blanks to compute correct languages in fc-query/fc-scan
+ Add missing description for usage
+ Make FC_SCALE deprecated
+ Bug 90148 - Don't warn if cachedir isn't specified
+ Fix memory leaks after FcFini()
+ Fix a typo
+ Fix a crash
+ Detect the overflow for the object ID
+ Revert the previous change
+
+Behdad Esfahbod (11):
+ Fix bitmap scaling
+ Add su[pport for symbol fonts
+ Write ranges using a [start finish) format
+ Only set FC_SIZE for scalable fonts if OS/2 version 5 is present
+ Add bitmap-only font size as Double, not Range
+ Accept Integer for FC_SIZE
+ Don't set FC_SIZE for bitmap fonts
+ Fix compiler warnings
+ Simplify FcRange
+ Reduce number of places that cache version is specified to 1
+ Bump cache version number to 6, because of recent FcRange changes
+
+Руслан Ижбулатов (1):
+ W32: Support cache paths relative to the root directory
+
+2.11.93 (2.12 RC3)
+
+Akira TAGOH (18):
+ Fix a typo in docs
+ Add pkg.m4 to git
+ Fix a build fail on some non-POSIX platforms
+ ifdef'd the unnecessary code for win32
+ Fix pointer cast warning on win32
+ filter can be null
+ Copy the real size of struct dirent
+ Rework again to copy the struct dirent
+ Hardcode the blanks in the library
+ Update the script to recognize the escaped space
+ Fix a build issue when $(srcdir) != $(builddir)
+ Don't add FC_LANG when it has "und"
+ Fix the array allocation
+ Improve the performance on searching blanks
+ Fix a segfault when OOM happened.
+ Fix a bug in the previous change forFcBlanksIsMember()
+ Fix an infinite loop in FcBlanksIsMember()
+ Fix a trivial bug for dist
+
+Alan Coopersmith (1):
+ Fix configure to work with Solaris Studio compilers
+
+Behdad Esfahbod (3):
+ Fix symbol cmap handling
+ Remove dead code after previous commit
+ Simplify some more
+
+Michael Haubenwallner (1):
+ Ensure config.h is included first, bug#89336.
+
+2.11.92 (2.12 RC2)
+
+Akira TAGOH (1):
+ Add missing docs
+
+2.11.91 (2.12 RC1)
+
+Akira TAGOH (28):
+ Bug 71287 - size specific design selection support in OS/2 table version 5
+ Fix a build issue with freetype <2.5.1
+ Fix missing docs
+ Fix a typo
+ Fix fc-cache fail with -r
+ Rebase ja.orth against Joyo kanji characters
+ Allow the modification on FcTypeVoid with FcTypeLangSet and FcTypeCharSet
+ Workaround another race condition issue
+ Read the config files and fonts on the sysroot when --sysroot is given to fc-cache
+ Fix a segfault
+ Update CaseFolding.txt to Unicode 7.0
+ Don't read/write from/to the XDG dirs if the home directory is disabled
+ Rework for 5004e8e01f5de30ad01904e57ea0eda006ab3a0c
+ Fix a crash when no sysroot is given and failed to load the default fonts.conf
+ Fix a gcc warning
+ Don't add duplicate lang
+ fallback to the another method to lock when link() failed
+ Increase the refcount in FcConfigSetCurrent()
+ Fix the memory leak in fc-cat
+ Note FcConfigSetCurrent() increases the refcount in document
+ Add FcRangeGetDouble()
+ Revert "Bug 73291 - poppler does not show fl ligature"
+ Update aliases for new URW fonts
+ Returns False if no fonts found
+ fc-cache: make a fail if no fonts processed on a given path
+ fc-cache: Add an option to raise an error if no fonts found
+ Bump the cache version to 5
+ Fix a typo
+
+Behdad Esfahbod (39):
+ Remove unused code
+ Simplify hash code
+ Further simplify hash code
+ Rewrite hashing to use FT_Stream directly
+ Allow passing NULL for file to FcFreeTypeQueryFace()
+ [ko.orth] Remove U+3164 HANGUL FILLER
+ Deprecate FC_HASH and don't compute it
+ Remove unused FcHash code now that FC_HASH is deprecated
+ Update list of blanks to Unicode 6.3.0
+ Update blanks to Unicode 7.0
+ Change charset parse/unparse format to be human readable
+ Minor
+ Fix charset unparse after recent changes
+ Comments
+ Remove HASH from matching priorities
+ Fixup previous commit
+ Update mingw32 MemoryBarrier from HarfBuzz
+ More mingw32 MemoryBarrier() fixup
+ Symlinks fix for DESTDIR
+ Revert "Symlinks fix for DESTDIR"
+ Call FcInitDebug from FcFreeTypeQueryFace
+ Decode MacRoman encoding in name table without iconv
+ Ouch, fix buffer
+ Use lang=und instead of lang=xx for "undetermined"
+ Remove unused regex code
+ Improve / cleanup namelang matching
+ Add FC_WEIGHT_DEMILIGHT
+ Change DemiLight from 65 to 55
+ Linearly interpolate weight values
+ Export recently added API
+ Remove unneeded FcPublic
+ Fix assertion failure
+ If OS/2 table says weight is 1 to 9, multiply by 100
+ Trebuchet MS is a sans-serif font, not serif
+ Fix previous commit
+ Revert "[fcmatch] When matching, reserve score 0 for when elements don't exist"
+ Fix buffer overflow in copying PS name
+ Add FC_COLOR
+ Treat color fonts as scalable
+
+Nick Alcock (1):
+ Generate documentation for FcWeight* functions.
+
+2.11.1
+
+Akira TAGOH (31):
+ do not build test-migration for Win32
+ Fix build issue on Debian/kFreeBSD 7.0
+ Update ax_pthread.m4 to the latest version
+ Fix the dynamic loading issue on NetBSD
+ Use stat() if there are no d_type in struct dirent
+ Fix a build issue on Solaris 10
+ Change the default weight on match to FC_WEIGHT_NORMAL
+ Warn if no <test> nor <edit> elements in <match>
+ Correct DTD
+ Re-scan font directories only when it contains subdirs
+ Fix typo
+ Bug 72086 - Check for gperf in autogen.sh
+ Simplify to validate the availability of posix_fadvise
+ Simplify to validate the availability of scandir
+ Fix a typo
+ Fix a build issue on platforms where doesn't support readlink()
+ Improve the performance issue on rescanning directories
+ Bug 73686 - confdir is not set correctly in fontconfig.pc
+ Update zh_hk.orth
+ clean up the unused files
+ Add missing license headers
+ Update the use of autotools' macro
+ Fix a crash issue when empty strings are set to the BDF properties
+ Add a doc for FcDirCacheRescan
+ Add missing #include <sys/statvfs.h> in fcstat.c
+ Fix incompatible API on AIX with random_r and initstate_r
+ Fallback to lstat() in case the filesystem doesn't support d_type in struct dirent
+ Update doc to include the version info of `since when'
+ Bug 73291 - poppler does not show fl ligature
+ Add README describes the criteria to add/modify the orthography files
+ Fix autoconf warning, warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+
+Alan Coopersmith (3):
+ Leave room for null terminators in arrays
+ Avoid memory leak when NULL path passed to FcStrBuildFilename
+ Avoid null pointer dereference in FcNameParse if malloc fails
+
+Behdad Esfahbod (1):
+ Bug 72380 - Never drop first font when trimming
+
+Frederic Crozat (2):
+ Fix inversion between Tinos and Cousine in the comment
+ Add metric aliases for additional Google ChromeOS fonts
+
+Jehan (1):
+ Defaulting <cachedir> to LOCAL_APPDATA_FONTCONFIG_CACHE for Win32 build
+
+Ross Burton (1):
+ fc-cache: --sysroot option takes an argument
+
2.11
Akira TAGOH (15):
diff --git a/chromium/third_party/fontconfig/src/autogen.sh b/chromium/third_party/fontconfig/src/autogen.sh
index 1482e401c51..07c59a4714f 100755
--- a/chromium/third_party/fontconfig/src/autogen.sh
+++ b/chromium/third_party/fontconfig/src/autogen.sh
@@ -1,4 +1,26 @@
#!/bin/sh
+# fontconfig/autogen.sh
+#
+# Copyright © 2000 Keith Packard
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of the author(s) not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. The authors make no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
# Run this to generate all the initial makefiles, etc.
set -e
@@ -24,10 +46,28 @@ LIBTOOLIZE=${LIBTOOLIZE-libtoolize}
AUTOMAKE=${AUTOMAKE-automake}
AUTOHEADER=${AUTOHEADER-autoheader}
AUTOCONF=${AUTOCONF-autoconf}
+GPERF=${GPERF-gperf}
+PYTHON=${PYTHON-python}
LIBTOOLIZE_FLAGS="--copy --force"
DIE=0
+($GPERF --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have gperf installed to compile $PROJECT."
+ echo "Install the appropriate package for your distribution."
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+($PYTHON --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have python installed to compile $PROJECT."
+ echo "Install the appropriate package for your distribution."
+ echo "or get the source tarball at https://www.python.org/downloads/source/"
+ DIE=1
+}
+
have_libtool=false
if $LIBTOOLIZE --version < /dev/null > /dev/null 2>&1 ; then
libtool_version=`$LIBTOOLIZE --version | sed 's/^.* \([0-9][.][0-9.]*\)[^ ]*$/\1/'`
diff --git a/chromium/third_party/fontconfig/src/conf.d/10-hinting-full.conf b/chromium/third_party/fontconfig/src/conf.d/10-hinting-full.conf
new file mode 100644
index 00000000000..27d8229195c
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/conf.d/10-hinting-full.conf
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <match target="pattern">
+ <!--
+ This configuration is available on the major desktop environments.
+ We shouldn't overwrite it with "assign" unconditionally.
+ Most clients may picks up the first value only. so using "append"
+ may simply works to avoid it.
+ -->
+ <edit name="hintstyle" mode="append"><const>hintfull</const></edit>
+ </match>
+</fontconfig>
diff --git a/chromium/third_party/fontconfig/src/conf.d/10-hinting-medium.conf b/chromium/third_party/fontconfig/src/conf.d/10-hinting-medium.conf
new file mode 100644
index 00000000000..e34ab5b344d
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/conf.d/10-hinting-medium.conf
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <match target="pattern">
+ <!--
+ This configuration is available on the major desktop environments.
+ We shouldn't overwrite it with "assign" unconditionally.
+ Most clients may picks up the first value only. so using "append"
+ may simply works to avoid it.
+ -->
+ <edit name="hintstyle" mode="append"><const>hintmedium</const></edit>
+ </match>
+</fontconfig>
diff --git a/chromium/third_party/fontconfig/src/conf.d/10-hinting-none.conf b/chromium/third_party/fontconfig/src/conf.d/10-hinting-none.conf
new file mode 100644
index 00000000000..0b3810d9485
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/conf.d/10-hinting-none.conf
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <match target="pattern">
+ <!--
+ This configuration is available on the major desktop environments.
+ We shouldn't overwrite it with "assign" unconditionally.
+ Most clients may picks up the first value only. so using "append"
+ may simply works to avoid it.
+ -->
+ <edit name="hintstyle" mode="append"><const>hintnone</const></edit>
+ </match>
+</fontconfig>
diff --git a/chromium/third_party/fontconfig/src/conf.d/10-hinting-slight.conf b/chromium/third_party/fontconfig/src/conf.d/10-hinting-slight.conf
new file mode 100644
index 00000000000..c244ac0b0e8
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/conf.d/10-hinting-slight.conf
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <match target="pattern">
+ <!--
+ This configuration is available on the major desktop environments.
+ We shouldn't overwrite it with "assign" unconditionally.
+ Most clients may picks up the first value only. so using "append"
+ may simply works to avoid it.
+ -->
+ <edit name="hintstyle" mode="append"><const>hintslight</const></edit>
+ </match>
+</fontconfig>
diff --git a/chromium/third_party/fontconfig/src/conf.d/10-no-sub-pixel.conf b/chromium/third_party/fontconfig/src/conf.d/10-no-sub-pixel.conf
index cf124656176..635847c4044 100644
--- a/chromium/third_party/fontconfig/src/conf.d/10-no-sub-pixel.conf
+++ b/chromium/third_party/fontconfig/src/conf.d/10-no-sub-pixel.conf
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
-<!-- Enable sub-pixel rendering -->
+<!-- Disable sub-pixel rendering -->
<match target="pattern">
<!--
This configuration is available on the major desktop environments.
diff --git a/chromium/third_party/fontconfig/src/conf.d/10-scale-bitmap-fonts.conf b/chromium/third_party/fontconfig/src/conf.d/10-scale-bitmap-fonts.conf
index e3bcd46cdc0..b4e9cb4f233 100644
--- a/chromium/third_party/fontconfig/src/conf.d/10-scale-bitmap-fonts.conf
+++ b/chromium/third_party/fontconfig/src/conf.d/10-scale-bitmap-fonts.conf
@@ -2,8 +2,13 @@
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
+<!--
+ If font is bitmap, calculate scale factor.
+ Note that color bitmap fonts have scalable=true, while
+ non-color ones have scalable=false. Both groups have outline=false.
+ -->
<match target="font">
- <test name="scalable" compare="eq">
+ <test name="outline" compare="eq">
<bool>false</bool>
</test>
<edit name="pixelsizefixupfactor" mode="assign">
@@ -13,10 +18,20 @@
</divide>
</edit>
</match>
+<!--
+ For non-scalable bitmap fonts (ie. non-color), skip
+ minor scaling if hinting is enabled.
+ -->
<match target="font">
+ <test name="outline" compare="eq">
+ <bool>false</bool>
+ </test>
<test name="scalable" compare="eq">
<bool>false</bool>
</test>
+ <test name="hinting" compare="eq">
+ <bool>true</bool>
+ </test>
<edit name="scalingnotneeded" mode="assign">
<and>
<less>
@@ -30,20 +45,7 @@
</and>
</edit>
</match>
-<!--
- So far we determined the scale factor. Now, check and if
- scaling is NOT desirable, just reset the scale factor to 1.0.
- -->
<match target="font">
- <test name="scalable" compare="eq">
- <bool>false</bool>
- </test>
- <test name="pixelsize" target="pattern" compare="less">
- <double>64</double>
- </test>
- <test name="hinting" compare="eq">
- <bool>true</bool>
- </test>
<test name="scalingnotneeded" compare="eq">
<bool>true</bool>
</test>
@@ -55,7 +57,7 @@
If we *are* going to scale, go ahead and do it.
-->
<match target="font">
- <test name="scalable" compare="eq">
+ <test name="outline" compare="eq">
<bool>false</bool>
</test>
<test name="pixelsizefixupfactor" compare="not_eq">
diff --git a/chromium/third_party/fontconfig/src/conf.d/30-metric-aliases.conf b/chromium/third_party/fontconfig/src/conf.d/30-metric-aliases.conf
index d0d9ea2e0eb..1f0778d68c4 100644
--- a/chromium/third_party/fontconfig/src/conf.d/30-metric-aliases.conf
+++ b/chromium/third_party/fontconfig/src/conf.d/30-metric-aliases.conf
@@ -6,24 +6,27 @@
Alias similar/metric-compatible families from various sources:
-PostScript fonts: URW fonts: GUST fonts: Windows fonts:
-====================== ==================== ================= ==================
-Helvetica Nimbus Sans L TeX Gyre Heros
-Helvetica Condensed TeX Gyre Heros Cn
-Times Nimbus Roman No9 L TeX Gyre Termes
-Courier Nimbus Mono L TeX Gyre Cursor
-ITC Avant Garde Gothic URW Gothic L TeX Gyre Adventor
-ITC Bookman URW Bookman L TeX Gyre Bonum Bookman Old Style
-ITC Zapf Chancery URW Chancery L TeX Gyre Chorus
-Palatino URW Palladio L TeX Gyre Pagella Palatino Linotype
-New Century Schoolbook Century Schoolbook L TeX Gyre Schola Century Schoolbook
+PostScript fonts: URW fonts: GUST fonts: Windows fonts:
+====================== ================== ================= ==================
+Helvetica Nimbus Sans TeX Gyre Heros
+Helvetica Narrow Nimbus Sans Narrow TeX Gyre Heros Cn
+Times Nimbus Roman TeX Gyre Termes
+Courier Nimbus Mono PS TeX Gyre Cursor
+ITC Avant Garde Gothic URW Gothic TeX Gyre Adventor
+ITC Bookman URW Bookman TeX Gyre Bonum Bookman Old Style
+ITC Zapf Chancery Z003 TeX Gyre Chorus
+Palatino P052 TeX Gyre Pagella Palatino Linotype
+New Century Schoolbook C059 TeX Gyre Schola Century Schoolbook
Microsoft fonts: Liberation fonts: Google CrOS core fonts: StarOffice fonts: AMT fonts:
================ ====================== ======================= ================= ==============
Arial Liberation Sans Arimo Albany Albany AMT
Arial Narrow Liberation Sans Narrow
-Times New Roman Liberation Serif Cousine Thorndale Thorndale AMT
-Courier New Liberation Mono Tinos Cumberland Cumberland AMT
+Times New Roman Liberation Serif Tinos Thorndale Thorndale AMT
+Courier New Liberation Mono Cousine Cumberland Cumberland AMT
+Cambria Caladea
+Calibri Carlito
+Symbol SymbolNeu
Microsoft fonts: Other fonts:
================ ============
@@ -54,6 +57,13 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Nimbus Sans</family>
+ <default>
+ <family>Helvetica</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Heros</family>
<default>
<family>Helvetica</family>
@@ -61,9 +71,16 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Nimbus Sans Narrow</family>
+ <default>
+ <family>Helvetica Narrow</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Heros Cn</family>
<default>
- <family>Helvetica Condensed</family>
+ <family>Helvetica Narrow</family>
</default>
</alias>
@@ -75,6 +92,13 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Nimbus Roman</family>
+ <default>
+ <family>Times</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Termes</family>
<default>
<family>Times</family>
@@ -89,6 +113,20 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Nimbus Mono</family>
+ <default>
+ <family>Courier</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
+ <family>Nimbus Mono PS</family>
+ <default>
+ <family>Courier</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Cursor</family>
<default>
<family>Courier</family>
@@ -110,6 +148,13 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>URW Gothic</family>
+ <default>
+ <family>ITC Avant Garde Gothic</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Adventor</family>
<default>
<family>ITC Avant Garde Gothic</family>
@@ -131,6 +176,20 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Bookman URW</family>
+ <default>
+ <family>ITC Bookman</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
+ <family>URW Bookman</family>
+ <default>
+ <family>ITC Bookman</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Bonum</family>
<default>
<family>ITC Bookman</family>
@@ -159,6 +218,20 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Chancery URW</family>
+ <default>
+ <family>ITC Zapf Chancery</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
+ <family>Z003</family>
+ <default>
+ <family>ITC Zapf Chancery</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Chorus</family>
<default>
<family>ITC Zapf Chancery</family>
@@ -173,6 +246,20 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Palladio URW</family>
+ <default>
+ <family>Palatino</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
+ <family>P052</family>
+ <default>
+ <family>Palatino</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Pagella</family>
<default>
<family>Palatino</family>
@@ -194,6 +281,20 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias binding="same">
+ <family>Century SchoolBook URW</family>
+ <default>
+ <family>New Century Schoolbook</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
+ <family>C059</family>
+ <default>
+ <family>New Century Schoolbook</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
<family>TeX Gyre Schola</family>
<default>
<family>New Century Schoolbook</family>
@@ -307,7 +408,26 @@ but in an order preferring similar designs first. We do this in three steps:
</default>
</alias>
+ <alias binding="same">
+ <family>Caladea</family>
+ <default>
+ <family>Cambria</family>
+ </default>
+ </alias>
+
+ <alias binding="same">
+ <family>Carlito</family>
+ <default>
+ <family>Calibri</family>
+ </default>
+ </alias>
+ <alias binding="same">
+ <family>SymbolNeu</family>
+ <default>
+ <family>Symbol</family>
+ </default>
+ </alias>
<!-- Accept the other group as fallback -->
@@ -320,7 +440,7 @@ but in an order preferring similar designs first. We do this in three steps:
</alias>
<alias>
- <family>Helvetica Condensed</family>
+ <family>Helvetica Narrow</family>
<default>
<family>Arial Narrow</family>
</default>
@@ -352,7 +472,7 @@ but in an order preferring similar designs first. We do this in three steps:
<alias>
<family>Arial Narrow</family>
<default>
- <family>Helvetica Condensed</family>
+ <family>Helvetica Narrow</family>
</default>
</alias>
@@ -379,14 +499,16 @@ but in an order preferring similar designs first. We do this in three steps:
<family>Helvetica</family>
<accept>
<family>TeX Gyre Heros</family>
+ <family>Nimbus Sans</family>
<family>Nimbus Sans L</family>
</accept>
</alias>
<alias binding="same">
- <family>Helvetica Condensed</family>
+ <family>Helvetica Narrow</family>
<accept>
<family>TeX Gyre Heros Cn</family>
+ <family>Nimbus Sans Narrow</family>
</accept>
</alias>
@@ -394,6 +516,7 @@ but in an order preferring similar designs first. We do this in three steps:
<family>Times</family>
<accept>
<family>TeX Gyre Termes</family>
+ <family>Nimbus Roman</family>
<family>Nimbus Roman No9 L</family>
</accept>
</alias>
@@ -402,6 +525,8 @@ but in an order preferring similar designs first. We do this in three steps:
<family>Courier</family>
<accept>
<family>TeX Gyre Cursor</family>
+ <family>Nimbus Mono PS</family>
+ <family>Nimbus Mono</family>
<family>Nimbus Mono L</family>
</accept>
</alias>
@@ -410,6 +535,7 @@ but in an order preferring similar designs first. We do this in three steps:
<family>ITC Avant Garde Gothic</family>
<accept>
<family>TeX Gyre Adventor</family>
+ <family>URW Gothic</family>
<family>URW Gothic L</family>
</accept>
</alias>
@@ -419,6 +545,8 @@ but in an order preferring similar designs first. We do this in three steps:
<accept>
<family>Bookman Old Style</family>
<family>TeX Gyre Bonum</family>
+ <family>URW Bookman</family>
+ <family>Bookman URW</family>
<family>URW Bookman L</family>
</accept>
</alias>
@@ -427,6 +555,8 @@ but in an order preferring similar designs first. We do this in three steps:
<family>ITC Zapf Chancery</family>
<accept>
<family>TeX Gyre Chorus</family>
+ <family>Z003</family>
+ <family>Chancery URW</family>
<family>URW Chancery L</family>
</accept>
</alias>
@@ -436,6 +566,8 @@ but in an order preferring similar designs first. We do this in three steps:
<accept>
<family>Palatino Linotype</family>
<family>TeX Gyre Pagella</family>
+ <family>P052</family>
+ <family>Palladio URW</family>
<family>URW Palladio L</family>
</accept>
</alias>
@@ -445,6 +577,8 @@ but in an order preferring similar designs first. We do this in three steps:
<accept>
<family>Century Schoolbook</family>
<family>TeX Gyre Schola</family>
+ <family>C059</family>
+ <family>Century SchoolBook URW</family>
<family>Century Schoolbook L</family>
</accept>
</alias>
@@ -494,4 +628,25 @@ but in an order preferring similar designs first. We do this in three steps:
</accept>
</alias>
+ <alias binding="same">
+ <family>Cambria</family>
+ <accept>
+ <family>Caladea</family>
+ </accept>
+ </alias>
+
+ <alias binding="same">
+ <family>Calibri</family>
+ <accept>
+ <family>Carlito</family>
+ </accept>
+ </alias>
+
+ <alias binding="same">
+ <family>Symbol</family>
+ <accept>
+ <family>SymbolNeu</family>
+ </accept>
+ </alias>
+
</fontconfig>
diff --git a/chromium/third_party/fontconfig/src/conf.d/30-urw-aliases.conf b/chromium/third_party/fontconfig/src/conf.d/30-urw-aliases.conf
index e0d45da8760..cfde071fbff 100644
--- a/chromium/third_party/fontconfig/src/conf.d/30-urw-aliases.conf
+++ b/chromium/third_party/fontconfig/src/conf.d/30-urw-aliases.conf
@@ -7,17 +7,26 @@
-->
<alias binding="same">
<family>Zapf Dingbats</family>
- <accept><family>Dingbats</family></accept>
+ <accept>
+ <family>D050000L</family>
+ <family>Dingbats</family>
+ </accept>
</alias>
<alias binding="same">
<family>ITC Zapf Dingbats</family>
- <accept><family>Dingbats</family></accept>
+ <accept>
+ <family>D050000L</family>
+ <family>Dingbats</family>
+ </accept>
</alias>
<match target="pattern">
<test name="family" compare="eq" ignore-blanks="true">
<string>Symbol</string>
</test>
<edit name="family" mode="append" binding="same">
+ <string>Standard Symbols PS</string>
+ </edit>
+ <edit name="family" mode="append" binding="same">
<string>Standard Symbols L</string>
</edit>
</match>
diff --git a/chromium/third_party/fontconfig/src/conf.d/45-latin.conf b/chromium/third_party/fontconfig/src/conf.d/45-latin.conf
index aa62ed42e7f..c6696f8d6f2 100644
--- a/chromium/third_party/fontconfig/src/conf.d/45-latin.conf
+++ b/chromium/third_party/fontconfig/src/conf.d/45-latin.conf
@@ -14,23 +14,31 @@
<default><family>serif</family></default>
</alias>
<alias>
+ <family>Cambria</family>
+ <default><family>serif</family></default>
+ </alias>
+ <alias>
+ <family>Constantia</family>
+ <default><family>serif</family></default>
+ </alias>
+ <alias>
<family>DejaVu Serif</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Liberation Serif</family>
+ <family>Elephant</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Times New Roman</family>
+ <family>Garamond</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Times</family>
+ <family>Georgia</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Nimbus Roman No9 L</family>
+ <family>Liberation Serif</family>
<default><family>serif</family></default>
</alias>
<alias>
@@ -38,42 +46,50 @@
<default><family>serif</family></default>
</alias>
<alias>
- <family>Thorndale AMT</family>
+ <family>MS Serif</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Thorndale</family>
+ <family>Nimbus Roman No9 L</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Georgia</family>
+ <family>Nimbus Roman</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Garamond</family>
+ <family>Palatino Linotype</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Palatino Linotype</family>
+ <family>Thorndale AMT</family>
<default><family>serif</family></default>
</alias>
<alias>
- <family>Trebuchet MS</family>
+ <family>Thorndale</family>
+ <default><family>serif</family></default>
+ </alias>
+ <alias>
+ <family>Times New Roman</family>
+ <default><family>serif</family></default>
+ </alias>
+ <alias>
+ <family>Times</family>
<default><family>serif</family></default>
</alias>
<!--
Sans-serif faces
-->
<alias>
- <family>Bitstream Vera Sans</family>
+ <family>Albany AMT</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
- <family>DejaVu Sans</family>
+ <family>Albany</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
- <family>Liberation Sans</family>
+ <family>Arial Unicode MS</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
@@ -81,19 +97,47 @@
<default><family>sans-serif</family></default>
</alias>
<alias>
+ <family>Bitstream Vera Sans</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Britannic</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Calibri</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Candara</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Century Gothic</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Corbel</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>DejaVu Sans</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
<family>Helvetica</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
- <family>Verdana</family>
+ <family>Haettenschweiler</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
- <family>Albany AMT</family>
+ <family>Liberation Sans</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
- <family>Albany</family>
+ <family>MS Sans Serif</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
@@ -101,88 +145,128 @@
<default><family>sans-serif</family></default>
</alias>
<alias>
+ <family>Nimbus Sans</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
<family>Luxi Sans</family>
<default><family>sans-serif</family></default>
</alias>
+ <alias>
+ <family>Tahoma</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Trebuchet MS</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Twentieth Century</family>
+ <default><family>sans-serif</family></default>
+ </alias>
+ <alias>
+ <family>Verdana</family>
+ <default><family>sans-serif</family></default>
+ </alias>
<!--
Monospace faces
-->
+ <alias>
+ <family>Andale Mono</family>
+ <default><family>monospace</family></default>
+ </alias>
<alias>
<family>Bitstream Vera Sans Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>DejaVu Sans Mono</family>
+ <family>Consolas</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Liberation Mono</family>
+ <family>Courier New</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Inconsolata</family>
+ <family>Courier</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Courier New</family>
+ <family>Cumberland AMT</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Courier</family>
+ <family>Cumberland</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Andale Mono</family>
+ <family>DejaVu Sans Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Luxi Mono</family>
+ <family>Fixedsys</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Cumberland AMT</family>
+ <family>Inconsolata</family>
<default><family>monospace</family></default>
</alias>
<alias>
- <family>Cumberland</family>
+ <family>Liberation Mono</family>
+ <default><family>monospace</family></default>
+ </alias>
+ <alias>
+ <family>Luxi Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Nimbus Mono L</family>
<default><family>monospace</family></default>
</alias>
+ <alias>
+ <family>Nimbus Mono</family>
+ <default><family>monospace</family></default>
+ </alias>
+ <alias>
+ <family>Nimbus Mono PS</family>
+ <default><family>monospace</family></default>
+ </alias>
+ <alias>
+ <family>Terminal</family>
+ <default><family>monospace</family></default>
+ </alias>
<!--
Fantasy faces
-->
- <alias>
- <family>Impact</family>
+ <alias>
+ <family>Bauhaus Std</family>
<default><family>fantasy</family></default>
</alias>
<alias>
- <family>Copperplate Gothic Std</family>
+ <family>Cooper Std</family>
<default><family>fantasy</family></default>
</alias>
<alias>
- <family>Cooper Std</family>
+ <family>Copperplate Gothic Std</family>
<default><family>fantasy</family></default>
</alias>
<alias>
- <family>Bauhaus Std</family>
+ <family>Impact</family>
<default><family>fantasy</family></default>
</alias>
<!--
Cursive faces
-->
<alias>
- <family>ITC Zapf Chancery Std</family>
+ <family>Comic Sans MS</family>
<default><family>cursive</family></default>
</alias>
<alias>
- <family>Zapfino</family>
+ <family>ITC Zapf Chancery Std</family>
<default><family>cursive</family></default>
</alias>
<alias>
- <family>Comic Sans MS</family>
+ <family>Zapfino</family>
<default><family>cursive</family></default>
</alias>
diff --git a/chromium/third_party/fontconfig/src/conf.d/60-latin.conf b/chromium/third_party/fontconfig/src/conf.d/60-latin.conf
index 2107e31e4b4..23ee91b253f 100644
--- a/chromium/third_party/fontconfig/src/conf.d/60-latin.conf
+++ b/chromium/third_party/fontconfig/src/conf.d/60-latin.conf
@@ -10,6 +10,7 @@
<family>Thorndale AMT</family>
<family>Luxi Serif</family>
<family>Nimbus Roman No9 L</family>
+ <family>Nimbus Roman</family>
<family>Times</family>
</prefer>
</alias>
@@ -23,6 +24,7 @@
<family>Albany AMT</family>
<family>Luxi Sans</family>
<family>Nimbus Sans L</family>
+ <family>Nimbus Sans</family>
<family>Helvetica</family>
<family>Lucida Sans Unicode</family>
<family>BPG Glaho International</family> <!-- lat,cyr,arab,geor -->
@@ -40,6 +42,8 @@
<family>Cumberland AMT</family>
<family>Luxi Mono</family>
<family>Nimbus Mono L</family>
+ <family>Nimbus Mono</family>
+ <family>Nimbus Mono PS</family>
<family>Courier</family>
</prefer>
</alias>
diff --git a/chromium/third_party/fontconfig/src/conf.d/Makefile.am b/chromium/third_party/fontconfig/src/conf.d/Makefile.am
index d61756b816c..ac68cd15dc4 100644
--- a/chromium/third_party/fontconfig/src/conf.d/Makefile.am
+++ b/chromium/third_party/fontconfig/src/conf.d/Makefile.am
@@ -26,6 +26,7 @@ DOC_SOURCES = README.in
DOC_FILES = $(DOC_SOURCES:.in=)
CONF_LINKS = \
+ 10-hinting-$(PREFERRED_HINTING).conf \
10-scale-bitmap-fonts.conf \
20-unhint-small-vera.conf \
30-urw-aliases.conf \
@@ -51,6 +52,10 @@ config_DATA = $(DOC_FILES)
templatedir = $(TEMPLATEDIR)
template_DATA = \
10-autohint.conf \
+ 10-hinting-full.conf \
+ 10-hinting-medium.conf \
+ 10-hinting-none.conf \
+ 10-hinting-slight.conf \
10-no-sub-pixel.conf \
10-scale-bitmap-fonts.conf \
10-sub-pixel-bgr.conf \
diff --git a/chromium/third_party/fontconfig/src/config/Makedefs.in b/chromium/third_party/fontconfig/src/config/Makedefs.in
deleted file mode 100644
index ae75aff4911..00000000000
--- a/chromium/third_party/fontconfig/src/config/Makedefs.in
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# fontconfig/config/Makedefs.in
-#
-# Copyright © 2002 Keith Packard
-#
-# Permission to use, copy, modify, distribute, and sell this software and its
-# documentation for any purpose is hereby granted without fee, provided that
-# the above copyright notice appear in all copies and that both that
-# copyright notice and this permission notice appear in supporting
-# documentation, and that the name of the author(s) not be used in
-# advertising or publicity pertaining to distribution of the software without
-# specific, written prior permission. The authors make no
-# representations about the suitability of this software for any purpose. It
-# is provided "as is" without express or implied warranty.
-#
-# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-# PERFORMANCE OF THIS SOFTWARE.
-#
-
-SHELL = @SHELL@
-
-srcdir=@srcdir@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-bindir=@bindir@
-datadir=@datadir@
-includedir=@includedir@
-sysconfdir=@sysconfdir@
-confdir=@confdir@
-
-DSO_LDOPTS=@DSO_LDOPTS@
-DSO_CFLAGS=@DSO_CFLAGS@
-DSO_PIC_CFLAGS=@DSO_PIC_CFLAGS@
-
-INSTALL=@INSTALL@
-INSTALL_PROGRAM=@INSTALL_PROGRAM@
-INSTALL_SCRIPT=@INSTALL_SCRIPT@
-INSTALL_DATA=@INSTALL_DATA@
-MKSHLIB=@MKSHLIB@
-LN_S=@LN_S@
-
-# shared libraries
-LIBDIR=$(libdir)
-# programs
-BINDIR=$(bindir)
-# font configuration files
-CONFDIR=@CONFDIR@
-# include files
-INCLUDEDIR=$(includedir)/fontconfig
-
-X_FONT_DIR=@X_FONT_DIR@
-FC_DEFAULT_FONTS=@FC_DEFAULT_FONTS@
-FCPATH_DEF=-DFONTCONFIG_PATH=\"$(CONFDIR)\"
-
-CDEBUGFLAGS=@CFLAGS@
-
-INCLUDES=-I$(TOPDIR) -I$(srcdir) @CPPFLAGS@
-
-CFLAGS=$(CDEBUGFLAGS) @DEFS@ $(FCPATH_DEF) $(INCLUDES)
-
-LIBBASE=libfontconfig.so
-LIBFILE=$(LIBBASE).@PACKAGE_MAJOR@.@PACKAGE_MINOR@
-LIBMAJOR=$(LIBBASE).@PACKAGE_MAJOR@
-
-LIBFONTCONFIG=-L$(SRCDIR) -lfontconfig
-
-SRCDIR=$(TOPDIR)/src
-
-INCDIR=$(TOPDIR)/fontconfig
-HEADERS=$(INCDIR)/fontconfig.h $(INCDIR)/fcfreetype.h $(INCDIR)/fcprivate.h
diff --git a/chromium/third_party/fontconfig/src/config/config-subst b/chromium/third_party/fontconfig/src/config/config-subst
deleted file mode 100644
index 5907e03286a..00000000000
--- a/chromium/third_party/fontconfig/src/config/config-subst
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-script=config-subst.$$
-trap "rm $script" 0
-rm -f $script
-for i in ${1+"$@"}; do
- var="`echo "$i" | sed 's/=.*$//'`"
- val="`echo "$i" | sed 's/^[^=]*=//'`"
- echo "s;@$var@;$val;" >> $script
-done
-sed -f $script
diff --git a/chromium/third_party/fontconfig/src/config/config.guess b/chromium/third_party/fontconfig/src/config/config.guess
deleted file mode 100644
index c38553dc74b..00000000000
--- a/chromium/third_party/fontconfig/src/config/config.guess
+++ /dev/null
@@ -1,1497 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2006-02-23'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help" >&2
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-if test $# != 0; then
- echo "$me: too many arguments$help" >&2
- exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:NetBSD:*:*)
- # NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
- # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
- # switched to ELF, *-*-netbsd* would select the old
- # object file format. This provides both forward
- # compatibility and a consistent mechanism for selecting the
- # object file format.
- #
- # Note: NetBSD doesn't particularly care about the vendor
- # portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
- armeb) machine=armeb-unknown ;;
- arm*) machine=arm-unknown ;;
- sh3el) machine=shl-unknown ;;
- sh3eb) machine=sh-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
- esac
- # The Operating System including object format, if it has switched
- # to ELF recently, or will in the future.
- case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
- if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
- then
- # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
- # Return netbsd for either. FIX?
- os=netbsd
- else
- os=netbsdelf
- fi
- ;;
- *)
- os=netbsd
- ;;
- esac
- # The OS release
- # Debian GNU/NetBSD machines have a different userland, and
- # thus, need a distinct triplet. However, they do not need
- # kernel version information, so it can be replaced with a
- # suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
- Debian*)
- release='-gnu'
- ;;
- *)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- ;;
- esac
- # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
- # contains redundant information, the shorter form:
- # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
- exit ;;
- *:OpenBSD:*:*)
- UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
- exit ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit ;;
- *:SolidBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
- exit ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- alpha:OSF1:*:*)
- case $UNAME_RELEASE in
- *4.0)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- ;;
- *5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
- ;;
- esac
- # According to Compaq, /usr/sbin/psrinfo has been available on
- # OSF/1 and Tru64 systems produced since 1995. I hope that
- # covers most systems running today. This code pipes the CPU
- # types through head -n 1, so we only detect the type of CPU 0.
- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
- "EV4 (21064)")
- UNAME_MACHINE="alpha" ;;
- "EV4.5 (21064)")
- UNAME_MACHINE="alpha" ;;
- "LCA4 (21066/21068)")
- UNAME_MACHINE="alpha" ;;
- "EV5 (21164)")
- UNAME_MACHINE="alphaev5" ;;
- "EV5.6 (21164A)")
- UNAME_MACHINE="alphaev56" ;;
- "EV5.6 (21164PC)")
- UNAME_MACHINE="alphapca56" ;;
- "EV5.7 (21164PC)")
- UNAME_MACHINE="alphapca57" ;;
- "EV6 (21264)")
- UNAME_MACHINE="alphaev6" ;;
- "EV6.7 (21264A)")
- UNAME_MACHINE="alphaev67" ;;
- "EV6.8CB (21264C)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8AL (21264B)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8CX (21264D)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.9A (21264/EV69A)")
- UNAME_MACHINE="alphaev69" ;;
- "EV7 (21364)")
- UNAME_MACHINE="alphaev7" ;;
- "EV7.9 (21364A)")
- UNAME_MACHINE="alphaev79" ;;
- esac
- # A Pn.n version is a patched version.
- # A Vn.n version is a released version.
- # A Tn.n version is a released field test version.
- # A Xn.n version is an unreleased experimental baselevel.
- # 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
- Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
- # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
- DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
- case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit ;;
- sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
- case "`/bin/arch`" in
- sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
- ;;
- sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
- ;;
- esac
- exit ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit ;;
- # The situation for MiNT is a little confusing. The machine name
- # can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
- # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
- # to the lowercase version "mint" (or "freemint"). Finally
- # the system name "TOS" denotes a system which is actually not
- # MiNT. But MiNT is downward compatible to TOS, so this should
- # be no problem.
- atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit ;;
- mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
- #if defined (host_mips) && defined (MIPSEB)
- #if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
- #endif
- #endif
- exit (-1);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
- exit ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
- AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
- then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
- then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else
- echo i586-dg-dgux${UNAME_RELEASE}
- fi
- exit ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
- ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
- then
- echo "$SYSTEM_NAME"
- else
- echo rs6000-ibm-aix3.2.5
- fi
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit ;;
- *:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
- 9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
- fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
-
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
-
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
-EOF
- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
- test -z "$HP_ARCH" && HP_ARCH=hppa
- fi ;;
- esac
- if [ ${HP_ARCH} = "hppa2.0w" ]
- then
- eval $set_cc_for_build
-
- # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
- # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
- # generating 64-bit code. GNU and HP use different nomenclature:
- #
- # $ CC_FOR_BUILD=cc ./config.guess
- # => hppa2.0w-hp-hpux11.23
- # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
- # => hppa64-hp-hpux11.23
-
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit ;;
- 3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
- | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
- -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- 5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:FreeBSD:*:*)
- case ${UNAME_MACHINE} in
- pc98)
- echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
- *)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
- esac
- exit ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:MSYS_NT-*:*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
- exit ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit ;;
- x86:Interix*:[345]*)
- echo i586-pc-interix${UNAME_RELEASE}
- exit ;;
- EM64T:Interix*:[345]*)
- echo x86_64-unknown-interix${UNAME_RELEASE}
- exit ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit ;;
- amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit ;;
- *:GNU/*:*:*)
- # other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- mips:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
- #endif
-EOF
- eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
- /^CPU/{
- s: ::g
- p
- }'`"
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
- /^CPU/{
- s: ::g
- p
- }'`"
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit ;;
- parisc:Linux:*:* | hppa:Linux:*:*)
- # Look for CPU level
- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
- esac
- exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- vax:Linux:*:*)
- echo ${UNAME_MACHINE}-dec-linux-gnu
- exit ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun)
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
- /^LIBC/{
- s: ::g
- p
- }'`"
- test x"${LIBC}" != x && {
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
- exit
- }
- test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
- ;;
- i*86:DYNIX/ptx:4*:*)
- # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
- # earlier versions are messed up and put the nodename in both
- # sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
- i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
- # I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
- fi
- exit ;;
- i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
- case `/bin/uname -X | grep "^Machine"` in
- *486*) UNAME_MACHINE=i486 ;;
- *Pentium) UNAME_MACHINE=i586 ;;
- *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
- esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit ;;
- i*86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
- (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
- && UNAME_MACHINE=i686
- (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
- && UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-pc-sysv32
- fi
- exit ;;
- pc:*:*:*)
- # Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
- OS_REL=''
- test -r /etc/.relid \
- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
- R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
- else
- echo mips-unknown-sysv${UNAME_RELEASE}
- fi
- exit ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit ;;
- *:procnto*:*:* | *:QNX:[0123456789]*:*)
- UNAME_PROCESSOR=`uname -p`
- if test "$UNAME_PROCESSOR" = "x86"; then
- UNAME_PROCESSOR=i386
- UNAME_MACHINE=pc
- fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit ;;
- *:Plan9:*:*)
- # "uname -m" is not consistent, so use $cputype instead. 386
- # is converted to i386 for consistency with other x86
- # operating systems.
- if test "$cputype" = "386"; then
- UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
- fi
- echo ${UNAME_MACHINE}-unknown-plan9
- exit ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
- i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
- exit ;;
- i*86:rdos:*:*)
- echo ${UNAME_MACHINE}-pc-rdos
- exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo = `(hostinfo) 2>/dev/null`
-/bin/universe = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/chromium/third_party/fontconfig/src/config/config.sub b/chromium/third_party/fontconfig/src/config/config.sub
deleted file mode 100644
index ad9f3957118..00000000000
--- a/chromium/third_party/fontconfig/src/config/config.sub
+++ /dev/null
@@ -1,1608 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2006-02-23'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help"
- exit 1 ;;
-
- *local*)
- # First pass through any local machine types.
- echo $1
- exit ;;
-
- * )
- break ;;
- esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
- exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
- exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
- uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
- storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray)
- os=
- basic_machine=$1
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco6)
- os=-sco5v6
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco5v6*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | bfin \
- | c4x | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64vr | mips64vrel \
- | mips64orion | mips64orionel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | mt \
- | msp430 \
- | nios | nios2 \
- | ns16k | ns32k \
- | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
- | v850 | v850e \
- | we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k)
- basic_machine=$basic_machine-unknown
- ;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
- ;;
- ms1)
- basic_machine=mt-unknown
- ;;
-
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | mt-* \
- | msp430-* \
- | nios-* | nios2-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tron-* \
- | v850-* | v850e-* | vax-* \
- | we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
- | xstormy16-* | xtensa-* \
- | ymp-* \
- | z8k-*)
- ;;
- m32c-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-unknown
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16c)
- basic_machine=cr16c-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- i386-vsta | vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- mingw32)
- basic_machine=i386-pc
- os=-mingw32
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- ms1-*)
- basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- nsr-tandem)
- basic_machine=nsr-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pc98)
- basic_machine=i386-pc
- ;;
- pc98-*)
- basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rdos)
- basic_machine=i386-pc
- os=-rdos
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
- | -openbsd* | -solidbsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
- | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=-nto$os
- ;;
- esac
- ;;
- -nto-qnx*)
- ;;
- -nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -aros*)
- os=-aros
- ;;
- -kaos*)
- os=-kaos
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-rebel)
- os=-linux
- ;;
- arm*-semi)
- os=-aout
- ;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
- # This must come before the *-dec entry.
- pdp10-*)
- os=-tops20
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- m68*-cisco)
- os=-aout
- ;;
- mips*-cisco)
- os=-elf
- ;;
- mips*-*)
- os=-elf
- ;;
- or32-*)
- os=-coff
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-be)
- os=-beos
- ;;
- *-haiku)
- os=-haiku
- ;;
- *-ibm)
- os=-aix
- ;;
- *-knuth)
- os=-mmixware
- ;;
- *-wec)
- os=-proelf
- ;;
- *-winbond)
- os=-proelf
- ;;
- *-oki)
- os=-proelf
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
- ;;
- *-rom68k)
- os=-coff
- ;;
- *-*bug)
- os=-coff
- ;;
- *-apple)
- os=-macos
- ;;
- *-atari*)
- os=-mint
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -beos*)
- vendor=be
- ;;
- -hpux*)
- vendor=hp
- ;;
- -mpeix*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
- vendor=stratus
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/chromium/third_party/fontconfig/src/config/install.sh b/chromium/third_party/fontconfig/src/config/install.sh
deleted file mode 100644
index ddbcef3d91d..00000000000
--- a/chromium/third_party/fontconfig/src/config/install.sh
+++ /dev/null
@@ -1,240 +0,0 @@
-#! /bin/sh
-#
-# fontconfig/config/install.sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-tranformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/chromium/third_party/fontconfig/src/configure.ac b/chromium/third_party/fontconfig/src/configure.ac
index c3743f43589..49488162ece 100644
--- a/chromium/third_party/fontconfig/src/configure.ac
+++ b/chromium/third_party/fontconfig/src/configure.ac
@@ -33,30 +33,10 @@ dnl This is the package version number, not the shared library
dnl version. This same version number must appear in fontconfig/fontconfig.h
dnl Yes, it is a pain to synchronize version numbers. Unfortunately, it's
dnl not possible to extract the version number here from fontconfig.h
-AC_INIT([fontconfig], [2.11.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig])
+AC_INIT([fontconfig], [2.12.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig])
AM_INIT_AUTOMAKE([1.11 parallel-tests dist-bzip2])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
-dnl libtool versioning
-
-dnl bump revision when fixing bugs
-dnl bump current and age, reset revision to zero when adding APIs
-dnl bump current, leave age, reset revision to zero when changing/removing APIS
-LIBT_CURRENT=9
-LIBT_REVISION=0
-AC_SUBST(LIBT_CURRENT)
-AC_SUBST(LIBT_REVISION)
-LIBT_AGE=8
-
-LIBT_VERSION_INFO="$LIBT_CURRENT:$LIBT_REVISION:$LIBT_AGE"
-AC_SUBST(LIBT_VERSION_INFO)
-
-LIBT_CURRENT_MINUS_AGE=`expr $LIBT_CURRENT - $LIBT_AGE`
-AC_SUBST(LIBT_CURRENT_MINUS_AGE)
-
-PKGCONFIG_REQUIRES=
-PKGCONFIG_REQUIRES_PRIVATELY=
-
dnl ==========================================================================
AC_CONFIG_HEADERS(config.h)
@@ -67,14 +47,14 @@ AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
AC_PROG_INSTALL
AC_PROG_LN_S
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
AM_MISSING_PROG([GIT], [git])
AM_MISSING_PROG([GPERF], [gperf])
+AM_PATH_PYTHON(,, [:])
+AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
AC_MSG_CHECKING([for RM macro])
_predefined_rm=`make -p -f /dev/null 2>/dev/null|grep '^RM ='|sed -e 's/^RM = //'`
@@ -85,6 +65,30 @@ else
AC_MSG_RESULT($_predefined_rm)
fi
+dnl Initialize libtool
+LT_PREREQ([2.2])
+LT_INIT([disable-static win32-dll])
+
+dnl libtool versioning
+
+dnl bump revision when fixing bugs
+dnl bump current and age, reset revision to zero when adding APIs
+dnl bump current, leave age, reset revision to zero when changing/removing APIS
+LIBT_CURRENT=10
+LIBT_REVISION=2
+AC_SUBST(LIBT_CURRENT)
+AC_SUBST(LIBT_REVISION)
+LIBT_AGE=9
+
+LIBT_VERSION_INFO="$LIBT_CURRENT:$LIBT_REVISION:$LIBT_AGE"
+AC_SUBST(LIBT_VERSION_INFO)
+
+LIBT_CURRENT_MINUS_AGE=`expr $LIBT_CURRENT - $LIBT_AGE`
+AC_SUBST(LIBT_CURRENT_MINUS_AGE)
+
+PKGCONFIG_REQUIRES=
+PKGCONFIG_REQUIRES_PRIVATELY=
+
dnl ==========================================================================
case "$host" in
@@ -101,11 +105,19 @@ if test "$os_win32" = "yes"; then
fi
AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)
+AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
WARN_CFLAGS=""
+WARNING_CPP_DIRECTIVE="no"
if test "x$GCC" = "xyes"; then
WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations \
-Wnested-externs -fno-strict-aliasing"
+ WARNING_CPP_DIRECTIVE="yes"
+elif test "x$SUNCC" = "xyes"; then
+ WARN_CFLAGS="-v -fd"
+ WARNING_CPP_DIRECTIVE="yes"
+fi
+if test "x$WARNING_CPP_DIRECTIVE" = "xyes"; then
AC_DEFINE_UNQUOTED(HAVE_WARNING_CPP_DIRECTIVE,1,
[Can use #warning in C files])
fi
@@ -136,7 +148,7 @@ dnl ==========================================================================
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h regex.h stdlib.h string.h unistd.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h])
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h sys/statvfs.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h])
AX_CREATE_STDINT_H([src/fcstdint.h])
# Checks for typedefs, structures, and compiler characteristics.
@@ -148,54 +160,15 @@ AC_TYPE_PID_T
# Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_MMAP
-AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r regcomp regerror regexec regfree fstatvfs fstatfs lstat])
+AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink fstatvfs fstatfs lstat])
dnl AC_CHECK_FUNCS doesn't check for header files.
dnl posix_fadvise() may be not available in older libc.
-fc_saved_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $WARN_CFLAGS -Werror"
-AC_MSG_CHECKING([for posix_fadvise])
-AC_LINK_IFELSE([AC_LANG_SOURCE([[
- #include <fcntl.h>
- int main(void) {
- return posix_fadvise(0, 0, 0, 0);
- }
- ]])],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_POSIX_FADVISE], [1], [Define to 1 if you have the 'posix_fadvise' function.])
- ],[AC_MSG_RESULT([no])])
-if test "$os_win32" = "no"; then
- AC_MSG_CHECKING([for scandir])
- AC_LINK_IFELSE([AC_LANG_SOURCE([[
- #include <dirent.h>
- int comp(const struct dirent **, const struct dirent **);
- int comp(const struct dirent **a, const struct dirent **b) { return 0; }
- int main(void) {
- struct dirent **d;
- return scandir(".", &d, 0, &comp) >= 0;
- }
- ]])],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_SCANDIR], [1], [Define to 1 if you have the 'scandir' function.])
- ],[
- AC_LINK_IFELSE([AC_LANG_SOURCE([[
- #include <dirent.h>
- int comp(const void *, const void *);
- int comp(const void *a, const void *b) { return 0; }
- int main(void) {
- struct dirent **d;
- return scandir(".", &d, 0, &comp) >= 0;
- }
- ]])],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_SCANDIR_VOID_P], [1], [Define to 1 if you have the 'scandir' function with int (* compar)(const void *, const void *)])
- ],[
- AC_MSG_ERROR([
-*** No scandir function available.])
- ])
- ])
-fi
-CFLAGS="$fc_saved_CFLAGS"
+AC_CHECK_SYMBOL([posix_fadvise], [fcntl.h], [fc_func_posix_fadvise=1], [fc_func_posix_fadvise=0])
+AC_DEFINE_UNQUOTED([HAVE_POSIX_FADVISE], [$fc_func_posix_fadvise], [Define to 1 if you have the 'posix_fadvise' function.])
+
+#
+AC_CHECK_MEMBERS([struct stat.st_mtim],,, [#include <sys/stat.h>])
#
if test "x$ac_cv_func_fstatvfs" = "xyes"; then
@@ -219,12 +192,6 @@ if test "x$ac_cv_func_fstatfs" = "xyes"; then
fi
AC_CHECK_MEMBERS([struct dirent.d_type],,,
[#include <dirent.h>])
-#
-# regex
-#
-if test "x$ac_cv_func_regcomp" = "xyes" -a "x$ac_cv_func_regerror" = "xyes" -a "x$ac_cv_func_regexec" = "xyes" -a "x$ac_cv_func_regfree"; then
- AC_DEFINE(USE_REGEX,,[Use regex])
-fi
#
# Checks for iconv
@@ -329,6 +296,10 @@ AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
#include FT_FREETYPE_H])
AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
[FT_Bitmap_Size structure includes y_ppem field])
+AC_CHECK_MEMBERS([TT_OS2.usLowerOpticalPointSize, TT_OS2.usUpperOpticalPointSize], [], [], [[
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TRUETYPE_TABLES_H]])
CFLAGS="$fontconfig_save_cflags"
LIBS="$fontconfig_save_libs"
@@ -435,6 +406,25 @@ if test "$enable_libxml2" = "yes"; then
fi
#
+# Set default hinting
+#
+
+AC_ARG_WITH(default-hinting,
+ [AC_HELP_STRING([--with-default-hinting=NAME],
+ [Enable your preferred hinting configuration (none/slight/medium/full) [default=slight]])],
+ preferred_hinting="$withval", preferred_hinting=slight)
+
+case "$preferred_hinting" in
+none|slight|medium|full)
+ PREFERRED_HINTING="$preferred_hinting"
+ AC_SUBST(PREFERRED_HINTING)
+ ;;
+*)
+ AC_MSG_ERROR([Invalid hinting. please choose one of none, slight, medium, or full])
+ ;;
+esac
+
+#
# Set default font directory
#
@@ -531,7 +521,7 @@ AC_ARG_WITH(cache-dir,
case $fc_cachedir in
no|yes)
if test "$os_win32" = "yes"; then
- fc_cachedir="WINDOWSTEMPDIR_FONTCONFIG_CACHE"
+ fc_cachedir="LOCAL_APPDATA_FONTCONFIG_CACHE"
else
fc_cachedir='${localstatedir}/cache/${PACKAGE}'
fi
@@ -714,6 +704,7 @@ dnl Figure out what cache format suffix to use for this architecture
AC_C_BIGENDIAN
AC_CHECK_SIZEOF([void *])
AC_CHECK_ALIGNOF([double])
+AC_CHECK_ALIGNOF([void *])
dnl include the header file for workaround of miscalculating size on autoconf
dnl particularly for fat binaries
@@ -730,6 +721,7 @@ Makefile
fontconfig/Makefile
fc-lang/Makefile
fc-glyphname/Makefile
+fc-blanks/Makefile
fc-case/Makefile
src/Makefile
conf.d/Makefile
diff --git a/chromium/third_party/fontconfig/src/doc/Makefile.am b/chromium/third_party/fontconfig/src/doc/Makefile.am
index 78a7cdbf1e2..9141ab2364f 100644
--- a/chromium/third_party/fontconfig/src/doc/Makefile.am
+++ b/chromium/third_party/fontconfig/src/doc/Makefile.am
@@ -81,9 +81,11 @@ DOC_FUNCS_FNCS = \
fcobjectset.fncs \
fcobjecttype.fncs \
fcpattern.fncs \
+ fcrange.fncs \
fcstring.fncs \
fcstrset.fncs \
fcvalue.fncs \
+ fcweight.fncs \
$(NULL)
SGML_FILES = \
fontconfig-user.sgml \
diff --git a/chromium/third_party/fontconfig/src/doc/fccache.fncs b/chromium/third_party/fontconfig/src/doc/fccache.fncs
index ca8ffa03c0d..34ce63f2780 100644
--- a/chromium/third_party/fontconfig/src/doc/fccache.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fccache.fncs
@@ -74,6 +74,7 @@ FcCacheCopySet.
@PURPOSE@
This tries to clean up the cache directory of <parameter>cache_dir</parameter>.
This returns FcTrue if the operation is successfully complete. otherwise FcFalse.
+@SINCE@ 2.9.91
@@
@RET@ void
@@ -83,4 +84,5 @@ This returns FcTrue if the operation is successfully complete. otherwise FcFalse
@DESC@
This tries to create CACHEDIR.TAG file at the cache directory registered
to <parameter>config</parameter>.
+@SINCE@ 2.9.91
@@
diff --git a/chromium/third_party/fontconfig/src/doc/fccharset.fncs b/chromium/third_party/fontconfig/src/doc/fccharset.fncs
index efcd0ccf15d..7245a2a0ee5 100644
--- a/chromium/third_party/fontconfig/src/doc/fccharset.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fccharset.fncs
@@ -60,6 +60,7 @@ running out of memory.
<function>FcCharSetDelChar</function> deletes a single Unicode char from the set,
returning FcFalse on failure, either as a result of a constant set or from
running out of memory.
+@SINCE@ 2.9.0
@@
@RET@ FcCharSet *
diff --git a/chromium/third_party/fontconfig/src/doc/fcconfig.fncs b/chromium/third_party/fontconfig/src/doc/fcconfig.fncs
index 0491a566f48..a2ce5c84db2 100644
--- a/chromium/third_party/fontconfig/src/doc/fcconfig.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fcconfig.fncs
@@ -59,7 +59,8 @@ cause a new configuration to be created for use as current configuration.
@PURPOSE@ Set configuration as default
@DESC@
Sets the current default configuration to <parameter>config</parameter>. Implicitly calls
-FcConfigBuildFonts if necessary, returning FcFalse if that call fails.
+FcConfigBuildFonts if necessary, and FcConfigReference() to inrease the reference count
+in <parameter>config</parameter> since 2.12.0, returning FcFalse if that call fails.
@@
@RET@ FcConfig *
@@ -218,8 +219,9 @@ If <parameter>config</parameter> is NULL, the current configuration is used.
@PURPOSE@ Add font file to font database
@DESC@
Adds an application-specific font to the configuration. Returns FcFalse
-if the fonts cannot be added (due to allocation failure). Otherwise returns FcTrue.
-If <parameter>config</parameter> is NULL, the current configuration is used.
+if the fonts cannot be added (due to allocation failure or no fonts found).
+Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
+the current configuration is used.
@@
@RET@ FcBool
@@ -230,8 +232,9 @@ If <parameter>config</parameter> is NULL, the current configuration is used.
@DESC@
Scans the specified directory for fonts, adding each one found to the
application-specific set of fonts. Returns FcFalse
-if the fonts cannot be added (due to allocation failure). Otherwise returns FcTrue.
-If <parameter>config</parameter> is NULL, the current configuration is used.
+if the fonts cannot be added (due to allocation failure).
+Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
+the current configuration is used.
@@
@RET@ void
@@ -378,6 +381,7 @@ parse error, semantic error or allocation failure. Otherwise returns FcTrue.
@PURPOSE@ Obtain the system root directory
@DESC@
Obtrains the system root directory in 'config' if available.
+@SINCE@ 2.10.92
@@
@RET@ void
@@ -390,5 +394,6 @@ Set 'sysroot' as the system root directory. fontconfig prepend 'sysroot'
to the cache directories in order to allow people to generate caches at
the build time. Note that this causes changing current config. i.e.
this function calls FcConfigSetCurrent() internally.
+@SINCE@ 2.10.92
@@
diff --git a/chromium/third_party/fontconfig/src/doc/fcdircache.fncs b/chromium/third_party/fontconfig/src/doc/fcdircache.fncs
index 24dea8bc56b..faeba292802 100644
--- a/chromium/third_party/fontconfig/src/doc/fcdircache.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fcdircache.fncs
@@ -55,6 +55,17 @@ FcDirCacheRead.
@@
@RET@ FcCache *
+@FUNC@ FcDirCacheRescan
+@TYPE1@ const FcChar8 * @ARG1@ dir
+@TYPE2@ FcConfig * @ARG2@ config
+@PURPOSE@ Re-scan a directory cache
+@DESC@
+Re-scan directories only at <parameter>dir</parameter> and update the cache.
+returns NULL if failed.
+@SINCE@ 2.11.1
+@@
+
+@RET@ FcCache *
@FUNC@ FcDirCacheRead
@TYPE1@ const FcChar8 * @ARG1@ dir
@TYPE2@ FcBool% @ARG2@ force
diff --git a/chromium/third_party/fontconfig/src/doc/fcformat.fncs b/chromium/third_party/fontconfig/src/doc/fcformat.fncs
index c136e8cf27c..71b866b88a7 100644
--- a/chromium/third_party/fontconfig/src/doc/fcformat.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fcformat.fncs
@@ -305,4 +305,5 @@ For example, the format "%{family|downcase|delete( )}\n" will expand
to the values of the family element in <parameter>pattern</parameter>,
lower-cased and with spaces removed.
+@SINCE@ 2.9.0
@@
diff --git a/chromium/third_party/fontconfig/src/doc/fclangset.fncs b/chromium/third_party/fontconfig/src/doc/fclangset.fncs
index c08d60c7096..c7ed83b3448 100644
--- a/chromium/third_party/fontconfig/src/doc/fclangset.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fclangset.fncs
@@ -68,6 +68,7 @@ two or three letter language from ISO 639 and Tt is a territory from ISO
<parameter>lang</parameter> should be of the form Ll-Tt where Ll is a
two or three letter language from ISO 639 and Tt is a territory from ISO
3166.
+@SINCE@ 2.9.0
@@
@RET@ FcLangSet *
@@ -77,6 +78,7 @@ two or three letter language from ISO 639 and Tt is a territory from ISO
@PURPOSE@ Add langsets
@DESC@
Returns a set including only those languages found in either <parameter>ls_a</parameter> or <parameter>ls_b</parameter>.
+@SINCE@ 2.9.0
@@
@RET@ FcLangSet *
@@ -86,6 +88,7 @@ Returns a set including only those languages found in either <parameter>ls_a</pa
@PURPOSE@ Subtract langsets
@DESC@
Returns a set including only those languages found in <parameter>ls_a</parameter> but not in <parameter>ls_b</parameter>.
+@SINCE@ 2.9.0
@@
@RET@ FcLangResult
@@ -161,6 +164,8 @@ has no matching language, this function returns FcLangDifferentLang.
Returns a string set of the default languages according to the environment variables on the system.
This function looks for them in order of FC_LANG, LC_ALL, LC_CTYPE and LANG then.
If there are no valid values in those environment variables, "en" will be set as fallback.
+@SINCE@ 2.9.91
+@@
@RET@ FcStrSet *
@FUNC@ FcLangSetGetLangs
@@ -184,6 +189,7 @@ Returns a string set of all known languages.
@PURPOSE@ Normalize the language string
@DESC@
Returns a string to make <parameter>lang</parameter> suitable on fontconfig.
+@SINCE@ 2.10.91
@@
@RET@ const FcCharSet *
diff --git a/chromium/third_party/fontconfig/src/doc/fcpattern.fncs b/chromium/third_party/fontconfig/src/doc/fcpattern.fncs
index 1df1c4f6184..1049d77af07 100644
--- a/chromium/third_party/fontconfig/src/doc/fcpattern.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fcpattern.fncs
@@ -181,12 +181,21 @@ values added to the list have binding <parameter>weak</parameter> instead of <pa
@TYPE2+++++++@ const char * @ARG2+++++++@ object
@TYPE3+++++++@ const FcLangSet * @ARG3+++++++@ l
+@PROTOTYPE++++++++@
+@RET++++++++@ FcBool
+@FUNC++++++++@ FcPatternAddRange
+@TYPE1++++++++@ FcPattern * @ARG1++++++++@ p
+@TYPE2++++++++@ const char * @ARG2++++++++@ object
+@TYPE3++++++++@ const FcRange * @ARG3++++++++@ r
+
@PURPOSE@ Add a typed value to a pattern
@DESC@
These are all convenience functions that insert objects of the specified
type into the pattern. Use these in preference to FcPatternAdd as they
will provide compile-time typechecking. These all append values to
any existing list of values.
+
+<function>FcPatternAddRange</function> are available since 2.11.91.
@@
@RET@ FcResult
@@ -257,16 +266,24 @@ within the pattern directly. Applications must not free this value.
@FUNC++++++@ FcPatternGetFTFace
@TYPE1++++++@ FcPattern * @ARG1++++++@ p
@TYPE2++++++@ const char * @ARG2++++++@ object
-@TYPE3+++++@ int% @ARG3+++++@ n
-@TYPE3++++++@ FT_Face * @ARG3++++++@ f
+@TYPE3++++++@ int% @ARG3++++++@ n
+@TYPE4++++++@ FT_Face * @ARG4++++++@ f
@PROTOTYPE+++++++@
@RET+++++++@ FcResult
@FUNC+++++++@ FcPatternGetLangSet
@TYPE1+++++++@ FcPattern * @ARG1+++++++@ p
@TYPE2+++++++@ const char * @ARG2+++++++@ object
-@TYPE3+++++@ int% @ARG3+++++@ n
-@TYPE3+++++++@ FcLangSet ** @ARG3+++++++@ l
+@TYPE3+++++++@ int% @ARG3+++++++@ n
+@TYPE4+++++++@ FcLangSet ** @ARG4+++++++@ l
+
+@PROTOTYPE++++++++@
+@RET++++++++@ FcResult
+@FUNC++++++++@ FcPatternGetRange
+@TYPE1++++++++@ FcPattern * @ARG1++++++++@ p
+@TYPE2++++++++@ const char * @ARG2++++++++@ object
+@TYPE3++++++++@ int% @ARG3++++++++@ n
+@TYPE4++++++++@ FcRange ** @ARG4++++++++@ r
@PURPOSE@ Return a typed value from a pattern
@DESC@
@@ -275,6 +292,8 @@ returned data is of the expected type. They return FcResultTypeMismatch if
this is not the case. Note that these (like FcPatternGet) do not make a
copy of any data structure referenced by the return value. Use these
in preference to FcPatternGet to provide compile-time typechecking.
+
+<function>FcPatternGetRange</function> are available since 2.11.91.
@@
@RET@ FcPattern *
diff --git a/chromium/third_party/fontconfig/src/doc/fcrange.fncs b/chromium/third_party/fontconfig/src/doc/fcrange.fncs
new file mode 100644
index 00000000000..ba76f65b284
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/doc/fcrange.fncs
@@ -0,0 +1,75 @@
+/*
+ * fontconfig/doc/fcrange.fncs
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+@RET@ FcRange *
+@FUNC@ FcRangeCopy
+@TYPE1@ const FcRange * @ARG1@ range
+@PURPOSE@ Copy a range object
+@DESC@
+<function>FcRangeCopy</function> creates a new FcRange object and
+populates it with the contents of <parameter>range</parameter>.
+@SINCE@ 2.11.91
+@@
+
+@RET@ FcRange *
+@FUNC@ FcRangeCreateDouble
+@TYPE1@ double @ARG1@ begin
+@TYPE2@ double @ARG2@ end
+@PURPOSE@ create a range object for double
+@DESC@
+<function>FcRangeCreateDouble</function> creates a new FcRange object with
+double sized value.
+@SINCE@ 2.11.91
+@@
+
+@RET@ FcRange *
+@FUNC@ FcRangeCreateInteger
+@TYPE1@ int @ARG1@ begin
+@TYPE2@ int @ARG2@ end
+@PURPOSE@ create a range object for integer
+@DESC@
+<function>FcRangeCreateInteger</function> creates a new FcRange object with
+integer sized value.
+@SINCE@ 2.11.91
+@@
+
+@RET@ void
+@FUNC@ FcRangeDestroy
+@TYPE1@ FcRange * @ARG1@ range
+@PURPOSE@ destroy a range object
+@DESC@
+<function>FcRangeDestroy</function> destroys a FcRange object, freeing
+all memory associated with it.
+@SINCE@ 2.11.91
+@@
+
+@RET@ FcBool
+@FUNC@ FcRangeGetDouble
+@TYPE1@ const FcRange * @ARG1@ range
+@TYPE2@ double * @ARG2@ begin
+@TYPE3@ double * @ARG3@ end
+@PURPOSE@ Get the range in double
+@DESC@
+Returns in <parameter>begin</parameter> and <parameter>end</parameter> as the range.
+@SINCE@ 2.11.91
+@@
diff --git a/chromium/third_party/fontconfig/src/doc/fcstrset.fncs b/chromium/third_party/fontconfig/src/doc/fcstrset.fncs
index b96489a43f6..67aa61ac021 100644
--- a/chromium/third_party/fontconfig/src/doc/fcstrset.fncs
+++ b/chromium/third_party/fontconfig/src/doc/fcstrset.fncs
@@ -104,6 +104,7 @@ Creates an iterator to list the strings in <parameter>set</parameter>.
@PURPOSE@ get first string in iteration
@DESC@
Returns the first string in <parameter>list</parameter>.
+@SINCE@ 2.11.0
@@
@RET@ FcChar8 *
diff --git a/chromium/third_party/fontconfig/src/doc/fcweight.fncs b/chromium/third_party/fontconfig/src/doc/fcweight.fncs
new file mode 100644
index 00000000000..2872dd66cb0
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/doc/fcweight.fncs
@@ -0,0 +1,47 @@
+/*
+ * fontconfig/doc/fcweight.fncs
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+@RET@ int
+@FUNC@ FcWeightFromOpenType
+@TYPE1@ int @ARG1@ ot_weight
+@PURPOSE@ Convert from OpenType weight values to fontconfig ones
+@DESC@
+<function>FcWeightFromOpenType</function> returns an integer value
+to use with FC_WEIGHT, from an integer in the 1..1000 range, resembling
+the numbers from OpenType specification's OS/2 usWeight numbers, which
+are also similar to CSS font-weight numbers. If input is negative,
+zero, or greater than 1000, returns -1. This function linearly interpolates
+between various FC_WEIGHT_* constants. As such, the returned value does not
+necessarily match any of the predefined constants.
+@SINCE@ 2.11.91
+@@
+
+@RET@ int
+@FUNC@ FcWeightToOpenType
+@TYPE1@ int @ARG1@ ot_weight
+@PURPOSE@ Convert from fontconfig weight values to OpenType ones
+@DESC@
+<function>FcWeightToOpenType</function> is the inverse of
+<function>FcWeightFromOpenType</function>. If the input is less than
+FC_WEIGHT_THIN or greater than FC_WEIGHT_EXTRABLACK, returns -1. Otherwise
+returns a number in the range 1 to 1000.
+@SINCE@ 2.11.91
+@@
diff --git a/chromium/third_party/fontconfig/src/doc/fontconfig-devel.sgml b/chromium/third_party/fontconfig/src/doc/fontconfig-devel.sgml
index 7306d79247a..d0ec8a579f6 100644
--- a/chromium/third_party/fontconfig/src/doc/fontconfig-devel.sgml
+++ b/chromium/third_party/fontconfig/src/doc/fontconfig-devel.sgml
@@ -16,9 +16,11 @@
<!ENTITY fcobjectset SYSTEM "fcobjectset.sgml">
<!ENTITY fcobjecttype SYSTEM "fcobjecttype.sgml">
<!ENTITY fcpattern SYSTEM "fcpattern.sgml">
+<!ENTITY fcrange SYSTEM "fcrange.sgml">
<!ENTITY fcstring SYSTEM "fcstring.sgml">
<!ENTITY fcstrset SYSTEM "fcstrset.sgml">
<!ENTITY fcvalue SYSTEM "fcvalue.sgml">
+<!ENTITY fcweight SYSTEM "fcweight.sgml">
<!ENTITY version SYSTEM "version.sgml">
]>
<!--
@@ -174,7 +176,9 @@ convenience for the application's rendering mechanism.
outline FC_OUTLINE Bool Whether the glyphs are outlines
scalable FC_SCALABLE Bool Whether glyphs can be scaled
scale FC_SCALE Double Scale factor for point->pixel
- conversions
+ conversions (deprecated)
+ symbol FC_SYMBOL Bool Whether font uses MS symbol-font encoding
+ color FC_COLOR Bool Whether any glyphs have color
dpi FC_DPI Double Target dots per inch
rgba FC_RGBA Int unknown, rgb, bgr, vrgb,
vbgr, none - subpixel geometry
@@ -188,8 +192,13 @@ convenience for the application's rendering mechanism.
fontversion FC_FONTVERSION Int Version number of the font
capability FC_CAPABILITY String List of layout capabilities in
the font
+ fontformat FC_FONTFORMAT String String name of the font format
embolden FC_EMBOLDEN Bool Rasterizer should
synthetically embolden the font
+ embeddedbitmap FC_EMBEDDED_BITMAP Bool Use the embedded bitmap instead
+ of the outline
+ decorative FC_DECORATIVE Bool Whether the style is a decorative
+ variant
fontfeatures FC_FONT_FEATURES String List of extra feature tags in
OpenType to be enabled
namelang FC_NAMELANG String Language name to be used for the
@@ -197,7 +206,7 @@ convenience for the application's rendering mechanism.
stylelang and fullnamelang
prgname FC_PRGNAME String Name of the running program
hash FC_HASH String SHA256 hash value of the font data
- with "sha256:" prefix.
+ with "sha256:" prefix (deprecated)
postscriptname FC_POSTSCRIPT_NAME String Font name in PostScript
</programlisting>
</sect2>
@@ -508,6 +517,12 @@ FcMatrix structures hold an affine transformation in matrix form.
</para>
&fcmatrix;
</sect2>
+ <sect2><title>FcRange</title>
+ <para>
+An FcRange holds two variables to indicate a range in between.
+ </para>
+ &fcrange;
+ </sect2>
<sect2><title>FcConfig</title>
<para>
An FcConfig object holds the internal representation of a configuration.
@@ -529,6 +544,12 @@ Provides for application-specified symbolic constants for font names.
</para>
&fcconstant;
</sect2>
+ <sect2><title>FcWeight</title>
+ <para>
+Maps weights to and from OpenType weights.
+ </para>
+ &fcweight;
+ </sect2>
<sect2><title>FcBlanks</title>
<para>
An FcBlanks object holds a list of Unicode chars which are expected to
diff --git a/chromium/third_party/fontconfig/src/doc/fontconfig-user.sgml b/chromium/third_party/fontconfig/src/doc/fontconfig-user.sgml
index 775d1f725c2..30e7b871af1 100644
--- a/chromium/third_party/fontconfig/src/doc/fontconfig-user.sgml
+++ b/chromium/third_party/fontconfig/src/doc/fontconfig-user.sgml
@@ -119,7 +119,8 @@ convenience for the applications' rendering mechanism.
rasterizer String Which rasterizer is in use (deprecated)
outline Bool Whether the glyphs are outlines
scalable Bool Whether glyphs can be scaled
- scale Double Scale factor for point->pixel conversions
+ color Bool Whether any glyphs have color
+ scale Double Scale factor for point->pixel conversions (deprecated)
dpi Double Target dots per inch
rgba Int unknown, rgb, bgr, vrgb, vbgr,
none - subpixel geometry
@@ -130,9 +131,15 @@ convenience for the applications' rendering mechanism.
font supports
fontversion Int Version number of the font
capability String List of layout capabilities in the font
+ fontformat String String name of the font format
embolden Bool Rasterizer should synthetically embolden the font
+ embeddedbitmap Bool Use the embedded bitmap instead of the outline
+ decorative Bool Whether the style is a decorative variant
fontfeatures String List of the feature tags in OpenType to be enabled
+ namelang String Language name to be used for the default value of
+ familylang, stylelang, and fullnamelang
prgname String String Name of the running program
+ postscriptname String Font family name in PostScript
</programlisting>
</refsect2>
<refsect2>
@@ -251,7 +258,7 @@ debugging messages.
MEMORY 512 Monitor fontconfig memory usage
CONFIG 1024 Monitor which config files are loaded
LANGSET 2048 Dump char sets used to construct lang values
- OBJTYPES 4096 Display message when value typechecks fail
+ MATCH2 4096 Display font-matching transformation in patterns
</programlisting>
<para>
Add the value of the desired debug levels together and assign that (in
@@ -314,9 +321,9 @@ the configuration file, the directory that can be accessed first in the list
will be used to store the cache files. If it starts with '~', it refers to
a directory in the users home directory. If 'prefix' is set to "xdg", the value in the XDG_CACHE_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details.
The default directory is ``$XDG_CACHE_HOME/fontconfig'' and it contains the cache files
-named ``<literal>&lt;hash value&gt;</literal>-<literal>&lt;architecture&gt;</literal>.cache-<literal>&lt;version</literal>'',
-where <literal>&lt;version&gt;</literal> is the font configureation file
-version number (currently 3).
+named ``<literal>&lt;hash value&gt;</literal>-<literal>&lt;architecture&gt;</literal>.cache-<literal>&lt;version&gt;</literal>'',
+where <literal>&lt;version&gt;</literal> is the fontconfig cache file
+version number (currently 7).
</para></refsect2>
<refsect2><title><literal>&lt;include ignore_missing="no" prefix="default"&gt;</literal></title><para>
This element contains the name of an additional configuration file or
@@ -473,6 +480,8 @@ symbolic names for common font values:
extralight weight 40
ultralight weight 40
light weight 50
+ demilight weight 55
+ semilight weight 55
book weight 75
regular weight 80
normal weight 80
@@ -778,6 +787,10 @@ is used to override the default configuration directory.
is used to output the detailed debugging messages. see <link linkend="debug">Debugging Applications</link> section for more details.
</para>
<para>
+<emphasis>FC_DBG_MATCH_FILTER</emphasis>
+is used to filter out the patterns. this takes a comma-separated list of object names and effects only when FC_DEBUG has MATCH2. see <link linkend="debug">Debugging Applications</link> section for more details.
+ </para>
+ <para>
<emphasis>FONTCONFIG_USE_MMAP</emphasis>
is used to control the use of mmap(2) for the cache files if available. this take a boolean value. fontconfig will checks if the cache files are stored on the filesystem that is safe to use mmap(2). explicitly setting this environment variable will causes skipping this check and enforce to use or not use mmap(2) anyway.
</para>
diff --git a/chromium/third_party/fontconfig/src/doc/func.sgml b/chromium/third_party/fontconfig/src/doc/func.sgml
index 73e7761ce39..f076baff291 100644
--- a/chromium/third_party/fontconfig/src/doc/func.sgml
+++ b/chromium/third_party/fontconfig/src/doc/func.sgml
@@ -33,6 +33,7 @@
<refentrytitle>@FUNC@</refentrytitle>
@;@
<manvolnum>3</manvolnum>
+ <refmiscinfo class="software">Fontconfig &version;</refmiscinfo>
</refmeta>
<refnamediv>
@{PROTOTYPE@
@@ -82,9 +83,9 @@
@DESC@
</para>
</refsect1>
- <refsect1><title>Version</title>
- <para>
-Fontconfig version &version;
- </para>
+@?SINCE@
+ <refsect1><title>Since</title>
+ <para>version @SINCE@</para>
</refsect1>
+@;@
</refentry>
diff --git a/chromium/third_party/fontconfig/src/fc-blanks/Makefile.am b/chromium/third_party/fontconfig/src/fc-blanks/Makefile.am
new file mode 100644
index 00000000000..2b2075f8b1f
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/fc-blanks/Makefile.am
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+#
+# Copyright © 2003 Keith Packard
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of the author(s) not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. The authors make no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+NULL =
+BLANKSPY = fc-blanks.py
+BLANKS_H = fcblanks.h
+TMPL = fcblanks.tmpl.h
+noinst_SCRIPTS = $(BLANKSPY)
+noinst_HEADERS = $(BLANKS_H)
+
+$(BLANKS_H): $(TMPL) $(BLANKSPY)
+if HAVE_PYTHON
+ $(AM_V_GEN) $(PYTHON) $(srcdir)/$(BLANKSPY) < $< > $(BLANKS_H).tmp && \
+ mv $(BLANKS_H).tmp $(BLANKS_H) || ($(RM) $(BLANKS_H).tmp && false)
+else
+ @echo "No python installed. please install python to build $(BLANKS_H)."
+ @false
+endif
+
+EXTRA_DIST = \
+ $(BLANKSPY) \
+ $(BLANKS_H) \
+ $(TMPL) \
+ $(NULL)
+DISTCLEANFILES = $(BLANKS_H)
+
+-include $(top_srcdir)/git.mk
diff --git a/chromium/third_party/fontconfig/src/fc-blanks/fc-blanks.py b/chromium/third_party/fontconfig/src/fc-blanks/fc-blanks.py
new file mode 100755
index 00000000000..cc23cde2d6f
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/fc-blanks/fc-blanks.py
@@ -0,0 +1,156 @@
+#! /usr/bin/python
+
+from __future__ import absolute_import
+from __future__ import print_function
+try:
+ from urllib2 import urlopen
+ from urllib2 import URLError
+except ImportError:
+ from urllib.request import urlopen
+ from urllib.error import URLError
+
+import sys
+import os
+from lxml import html
+from six.moves import range
+
+datafile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'list-unicodeset.html')
+try:
+ fp = urlopen('http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3AGC%3DZs%3A][%3ADI%3A]&abb=on&ucd=on&esc=on&g')
+ data = fp.read()
+ fp.close()
+ fp = open(datafile, 'wb');
+ fp.write(data);
+ fp.close();
+except URLError:
+ # fall back reading the static data in repo
+ try:
+ fp = open(datafile)
+ data = fp.read()
+ fp.close()
+ except IOError:
+ sys.stderr.write("Error: No static data to generate the blank data. please make sure the network connection is reachable to Unicode.org\n")
+ sys.exit(1)
+
+dom = html.fromstring(data)
+x = dom.xpath('/html/body/form/p/text()')
+p = x[1]
+if p[0] == '[' and p[-1] == ']':
+ p = p.replace('[', '').replace(']', '')
+else:
+ sys.exit(1)
+fescape = False
+funicode = False
+frange = False
+fprocess = False
+v = 0
+vbegin = 0
+vend = 0
+n = 0
+l = []
+
+def insert(db, begin, end):
+ db.append([begin, end])
+
+for i in p:
+ if i == '\\':
+ if n > 0:
+ if frange == True and funicode == True:
+ vend = v
+ insert(l, vbegin, vend)
+ fprocess = True
+ elif funicode == True:
+ vbegin = v
+ vend = v
+ insert(l, vbegin, vend)
+ fprocess = True
+ funicode = False
+ fescape = True
+ elif i.lower() == 'u' and fescape == True:
+ funicode = True
+ fescape = False
+ elif i >= '0' and i <= '9' or i.lower() >= 'a' and i.lower() <= 'f':
+ if fescape == True:
+ raise RuntimeError("Unexpected escape code")
+ if funicode == True:
+ v <<= 4
+ v += int(i, 16)
+ else:
+ raise RuntimeError("Unable to parse Unicode")
+ elif i == ' ':
+ if fescape == True:
+ funicode = True
+ fescape = False
+ v = 0x20
+ if frange == True and funicode == True:
+ vend = v
+ insert(l, vbegin, vend)
+ fprocess = True
+ elif funicode == True:
+ vbegin = v
+ vend = v
+ insert(l, vbegin, vend)
+ fprocess = True
+ funicode = False
+ frange = False
+ elif i == '-':
+ if fescape == True:
+ raise RuntimeError("Unexpected escape code")
+ vbegin = v
+ v = 0
+ funicode = False
+ frange = True
+ else:
+ raise RuntimeError("Unable to parse Unicode: %s" % i)
+
+ if fprocess == True:
+ vbegin = 0
+ vend = 0
+ v = 0
+ fprocess = False
+ funicode = False
+ frange = False
+ n += 1
+
+if frange == True and funicode == True:
+ vend = v
+ insert(l, vbegin, vend)
+elif funicode == True:
+ vbegin = vend = v
+ insert(l, vbegin, vend)
+
+ncode = 0
+for i in l:
+ ncode += (i[1] - i[0] + 1)
+
+a = int(x[0].split(' ')[0].replace(',', ''))
+if a != ncode:
+ sys.stderr.write("Unexpected the amount of code points: %d (expected %d)\n" % (ncode, a))
+ sys.exit(1)
+
+# exception; BRAILLE PATTERN BLANK
+insert(l, 0x2800, 0x2800)
+
+while True:
+ s = sys.stdin.readline().rstrip()
+ if s == "@@@":
+ break
+ print(s)
+
+print("static FcChar32 _fcBlanks[%s] = {" % (ncode + 1))
+k = 0
+for i in sorted(l, key=lambda a: a[0]):
+ for j in range(i[0], i[1] + 1):
+ if k != 0:
+ print(",")
+ print(" 0x%04x" % j, end=' ')
+ k += 1
+
+print("};")
+print('''
+static FcBlanks fcBlanks = {
+ %s,
+ -1,
+ _fcBlanks
+};
+''' % (ncode + 1))
diff --git a/chromium/third_party/fontconfig/src/fc-blanks/fcblanks.tmpl.h b/chromium/third_party/fontconfig/src/fc-blanks/fcblanks.tmpl.h
new file mode 100644
index 00000000000..2bcaa21d6c1
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/fc-blanks/fcblanks.tmpl.h
@@ -0,0 +1,25 @@
+/*
+ * fontconfig/fc-blanks/fcblanks.tmpl.h
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+@@@
diff --git a/chromium/third_party/fontconfig/src/fc-blanks/list-unicodeset.html b/chromium/third_party/fontconfig/src/fc-blanks/list-unicodeset.html
new file mode 100644
index 00000000000..6e95efaf0e8
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/fc-blanks/list-unicodeset.html
@@ -0,0 +1,119 @@
+<html>
+<head>
+<meta http-equiv="Content-Language" content="en-us">
+<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
+<meta name="ProgId" content="FrontPage.Editor.Document">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link rel="stylesheet" type="text/css" href="index.css">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<title>Unicode Utilities: UnicodeSet</title>
+</head>
+<body>
+
+<h1>Unicode Utilities: UnicodeSet </h1>
+<p><a target="help" href="http://cldr.unicode.org/unicode-utilities/list-unicodeset"><b>help</b></a> | <a target="character" href="character.jsp">character</a>
+ | <a target="properties" href="properties.jsp">properties</a>
+ | <a target="confusables" href="confusables.jsp">confusables</a>
+ | <a target="list" href="list-unicodeset.jsp">unicode-set</a>
+ | <a target="compare" href="unicodeset.jsp">compare-sets</a>
+ | <a target="regex" href="regex.jsp">regex</a>
+ | <a target="bnf" href="bnf.jsp">bnf-regex</a>
+ | <a target="breaks" href="breaks.jsp">breaks</a>
+ | <a target="transform" href="transform.jsp">transform</a>
+ | <a target="bidi" href="bidi.jsp">bidi</a>
+ | <a target="idna" href="idna.jsp">idna</a>
+ | <a target="languageid" href="languageid.jsp">languageid</a></p>
+<form name="myform">
+ <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width:100%">
+ <tr>
+ <th style="width: 50%">Input</th>
+ </tr>
+ <tr>
+ <td><textarea name="a" rows="8" cols="10" style="width: 100%">[:GC=Zs:][:DI:]</textarea></td>
+ </tr>
+ <tr>
+ <td>
+ <input id='main' type="submit" value="Show Set" onClick="window.location.href='list-unicodeset.jsp?a='+document.getElementById('main').value"/>&nbsp;&nbsp;
+ <input type="checkbox" checked name="abb"><label for="abb">Abbreviate</label>&nbsp;&nbsp;
+ <input type="checkbox" name="c"><label for="c">Collate</label>&nbsp;&nbsp;
+ <input type="checkbox" checked name="ucd"><label for="ucd">UCD format</label>&nbsp;&nbsp;
+ <input type="checkbox" checked name="esc"><label for="esc">Escape</label>&nbsp;&nbsp;
+ <label for="g">Group by:</label>
+ <input type="text" checked name="g" size="25" value="">
+ <label for="i">Info:</label>
+ <input type="text" checked name="i" size="25" value="">
+ </td>
+ </tr>
+</table>
+ <p>4,190 Code Points</p>
+ <hr>
+ <p>[\ \u00A0\u00AD\u034F\u061C\u115F\u1160\u1680\u17B4\u17B5\u180B-\u180E\u2000-\u200F\u202A-\u202F\u205F-\u206F\u3000\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8\U0001BCA0-\U0001BCA3\U0001D173-\U0001D17A\U000E0000-\U000E0FFF]</p>
+ <hr>
+ <table width='100%'><tr><td colSpan='4'><tr><td class='charCell' width='3m'>   </td><td width='7m'><code><a target='c' href='character.jsp?a=0020'>0020</a></code></td><td>SPACE</td></tr>
+<tr><td class='charCell' width='3m'>   </td><td width='7m'><code><a target='c' href='character.jsp?a=00A0'>00A0</a></code></td><td>NO-BREAK SPACE</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=00AD'>00AD</a></code></td><td>SOFT HYPHEN</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=034F'>034F</a></code></td><td>COMBINING GRAPHEME JOINER</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=061C'>061C</a></code></td><td>ARABIC LETTER MARK</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=115F'>115F</a></code></td><td>HANGUL CHOSEONG FILLER</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=1160'>1160</a></code></td><td>HANGUL JUNGSEONG FILLER</td></tr>
+<tr><td class='charCell' width='3m'>   </td><td width='7m'><code><a target='c' href='character.jsp?a=1680'>1680</a></code></td><td>OGHAM SPACE MARK</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=17B4'>17B4</a></code></td><td>KHMER VOWEL INHERENT AQ</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=17B5'>17B5</a></code></td><td>KHMER VOWEL INHERENT AA</td></tr>
+<code><a target='c' href='character.jsp?a=180B'>180B</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=180E'>180E</a></code></td><td>MONGOLIAN VOWEL SEPARATOR</td></tr>
+<code><a target='c' href='character.jsp?a=2000'>2000</a></code>..<tr><td class='charCell' width='3m'> ‎‏‎ </td><td width='7m'><code><a target='c' href='character.jsp?a=200F'>200F</a></code></td><td>RIGHT-TO-LEFT MARK</td></tr>
+<code><a target='c' href='character.jsp?a=202A'>202A</a></code>..<tr><td class='charCell' width='3m'>   </td><td width='7m'><code><a target='c' href='character.jsp?a=202F'>202F</a></code></td><td>NARROW NO-BREAK SPACE</td></tr>
+<code><a target='c' href='character.jsp?a=205F'>205F</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=206F'>206F</a></code></td><td>NOMINAL DIGIT SHAPES</td></tr>
+<tr><td class='charCell' width='3m'>   </td><td width='7m'><code><a target='c' href='character.jsp?a=3000'>3000</a></code></td><td>IDEOGRAPHIC SPACE</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=3164'>3164</a></code></td><td>HANGUL FILLER</td></tr>
+<code><a target='c' href='character.jsp?a=FE00'>FE00</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=FE0F'>FE0F</a></code></td><td>VARIATION SELECTOR-16</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=FEFF'>FEFF</a></code></td><td>ZERO WIDTH NO-BREAK SPACE</td></tr>
+<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=FFA0'>FFA0</a></code></td><td>HALFWIDTH HANGUL FILLER</td></tr>
+<code><a target='c' href='character.jsp?a=FFF0'>FFF0</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=FFF8'>FFF8</a></code></td><td><i>&lt;unassigned-FFF8&gt;</i></td></tr>
+<code><a target='c' href='character.jsp?a=1BCA0'>1BCA0</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=1BCA3'>1BCA3</a></code></td><td>SHORTHAND FORMAT UP STEP</td></tr>
+<code><a target='c' href='character.jsp?a=1D173'>1D173</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=1D17A'>1D17A</a></code></td><td>MUSICAL SYMBOL END PHRASE</td></tr>
+<code><a target='c' href='character.jsp?a=E0000'>E0000</a></code>..<tr><td class='charCell' width='3m'>  </td><td width='7m'><code><a target='c' href='character.jsp?a=E0FFF'>E0FFF</a></code></td><td><i>&lt;unassigned-E0FFF&gt;</i></td></tr>
+</td></tr></table>
+</form>
+<hr>
+<p style="font-size:80%"><b><a name="fonts">Fonts and Display.</a></b> If you don't have a good set of Unicode fonts (and modern browser),
+you may not be able to read some of the characters.
+Some suggested fonts that you can add for coverage are:
+<a href="http://greekfonts.teilar.gr/" target="_blank">Unicode Fonts for Ancient Scripts</a>,
+<a href="https://www.google.com/get/noto/" target="_blank">Noto Fonts site</a>,
+<a href="http://www.alanwood.net/unicode/fonts.html" target="_blank">Large, multi-script Unicode fonts</a>.
+See also: <a href="http://www.unicode.org/help/display_problems.html" target="_blank">Unicode Display Problems</a>.</p>
+<p style="font-size:80%">Version 3.7;
+ICU version: 57.0.1.0;
+Unicode version: 8.0.0.0
+</p>
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-8314904-1");
+pageTracker._trackPageview();
+} catch(err) {}
+</script>
+<hr>
+</body>
+</html>
diff --git a/chromium/third_party/fontconfig/src/fc-cache/fc-cache.c b/chromium/third_party/fontconfig/src/fc-cache/fc-cache.c
index af7ba6dd6a9..0336073a347 100644
--- a/chromium/third_party/fontconfig/src/fc-cache/fc-cache.c
+++ b/chromium/third_party/fontconfig/src/fc-cache/fc-cache.c
@@ -65,9 +65,10 @@
#define _GNU_SOURCE
#include <getopt.h>
const struct option longopts[] = {
+ {"error-on-no-fonts", 0, 0, 'E'},
{"force", 0, 0, 'f'},
{"really-force", 0, 0, 'r'},
- {"sysroot", 0, 0, 'y'},
+ {"sysroot", required_argument, 0, 'y'},
{"system-only", 0, 0, 's'},
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
@@ -86,16 +87,17 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
+ fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [--error-on-no-fonts] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
program);
#else
- fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [dirs]\n",
+ fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [dirs]\n",
program);
#endif
fprintf (file, "Build font information caches in [dirs]\n"
"(all directories in font configuration by default).\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
+ fprintf (file, " -E, --error-on-no-fonts raise an error if no fonts in a directory\n");
fprintf (file, " -f, --force scan directories with apparently valid caches\n");
fprintf (file, " -r, --really-force erase all existing caches, then rescan\n");
fprintf (file, " -s, --system-only scan system-wide directories only\n");
@@ -104,6 +106,8 @@ usage (char *program, int error)
fprintf (file, " -V, --version display font config version and exit\n");
fprintf (file, " -h, --help display this help and exit\n");
#else
+ fprintf (file, " -E (error-on-no-fonts)\n");
+ fprintf (file, " raise an error if no fonts in a directory\n");
fprintf (file, " -f (force) scan directories with apparently valid caches\n");
fprintf (file, " -r, (really force) erase all existing caches, then rescan\n");
fprintf (file, " -s (system) scan system-wide directories only\n");
@@ -118,7 +122,7 @@ usage (char *program, int error)
static FcStrSet *processed_dirs;
static int
-scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, int *changed)
+scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool error_on_no_fonts, int *changed)
{
int ret = 0;
const FcChar8 *dir;
@@ -126,9 +130,10 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
FcStrList *sublist;
FcCache *cache;
struct stat statb;
- FcBool was_valid;
+ FcBool was_valid, was_processed = FcFalse;
int i;
-
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+
/*
* Now scan all of the directories into separate databases
* and write out the results
@@ -137,11 +142,13 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
{
if (verbose)
{
+ if (sysroot)
+ printf ("[%s]", sysroot);
printf ("%s: ", dir);
fflush (stdout);
}
- if (recursive && FcStrSetMember (processed_dirs, dir))
+ if (FcStrSetMember (processed_dirs, dir))
{
if (verbose)
printf ("skipping, looped directory detected\n");
@@ -170,6 +177,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
fprintf (stderr, "\"%s\": not a directory, skipping\n", dir);
continue;
}
+ was_processed = FcTrue;
if (really_force)
FcDirCacheUnlink (dir, config);
@@ -214,36 +222,33 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
}
}
- if (recursive)
+ subdirs = FcStrSetCreate ();
+ if (!subdirs)
{
- subdirs = FcStrSetCreate ();
- if (!subdirs)
- {
- fprintf (stderr, "%s: Can't create subdir set\n", dir);
- ret++;
- FcDirCacheUnload (cache);
- continue;
- }
- for (i = 0; i < FcCacheNumSubdir (cache); i++)
- FcStrSetAdd (subdirs, FcCacheSubdir (cache, i));
-
+ fprintf (stderr, "%s: Can't create subdir set\n", dir);
+ ret++;
FcDirCacheUnload (cache);
+ continue;
+ }
+ for (i = 0; i < FcCacheNumSubdir (cache); i++)
+ FcStrSetAdd (subdirs, FcCacheSubdir (cache, i));
- sublist = FcStrListCreate (subdirs);
- FcStrSetDestroy (subdirs);
- if (!sublist)
- {
- fprintf (stderr, "%s: Can't create subdir list\n", dir);
- ret++;
- continue;
- }
- FcStrSetAdd (processed_dirs, dir);
- ret += scanDirs (sublist, config, force, really_force, verbose, recursive, changed);
- FcStrListDone (sublist);
+ FcDirCacheUnload (cache);
+
+ sublist = FcStrListCreate (subdirs);
+ FcStrSetDestroy (subdirs);
+ if (!sublist)
+ {
+ fprintf (stderr, "%s: Can't create subdir list\n", dir);
+ ret++;
+ continue;
}
- else
- FcDirCacheUnload (cache);
+ FcStrSetAdd (processed_dirs, dir);
+ ret += scanDirs (sublist, config, force, really_force, verbose, error_on_no_fonts, changed);
+ FcStrListDone (sublist);
}
+ if (error_on_no_fonts && !was_processed)
+ ret++;
return ret;
}
@@ -277,6 +282,7 @@ main (int argc, char **argv)
FcBool force = FcFalse;
FcBool really_force = FcFalse;
FcBool systemOnly = FcFalse;
+ FcBool error_on_no_fonts = FcFalse;
FcConfig *config;
FcChar8 *sysroot = NULL;
int i;
@@ -286,12 +292,15 @@ main (int argc, char **argv)
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "frsy:Vvh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "Efrsy:Vvh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "frsy:Vvh")) != -1)
+ while ((c = getopt (argc, argv, "Efrsy:Vvh")) != -1)
#endif
{
switch (c) {
+ case 'E':
+ error_on_no_fonts = FcTrue;
+ break;
case 'r':
really_force = FcTrue;
/* fall through */
@@ -369,12 +378,9 @@ main (int argc, char **argv)
fprintf(stderr, "Cannot malloc\n");
return 1;
}
-
+
changed = 0;
- ret = scanDirs (list, config, force, really_force, verbose, FcTrue, &changed);
- /* Update the directory cache again to avoid the race condition as much as possible */
- FcStrListFirst (list);
- ret += scanDirs (list, config, FcTrue, really_force, verbose, FcFalse, &changed);
+ ret = scanDirs (list, config, force, really_force, verbose, error_on_no_fonts, &changed);
FcStrListDone (list);
/*
diff --git a/chromium/third_party/fontconfig/src/fc-cache/fc-cache.sgml b/chromium/third_party/fontconfig/src/fc-cache/fc-cache.sgml
index 3740be77f66..5ae01076582 100644
--- a/chromium/third_party/fontconfig/src/fc-cache/fc-cache.sgml
+++ b/chromium/third_party/fontconfig/src/fc-cache/fc-cache.sgml
@@ -63,9 +63,14 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
- <arg><option>-frsvVh</option></arg>
+ <arg><option>-EfrsvVh</option></arg>
+ <arg><option>--error-on-no-fonts</option></arg>
<arg><option>--force</option></arg>
<arg><option>--really-force</option></arg>
+ <group>
+ <arg><option>-y</option> <option><replaceable>dir</replaceable></option></arg>
+ <arg><option>--sysroot</option> <option><replaceable>dir</replaceable></option></arg>
+ </group>
<arg><option>--system-only</option></arg>
<arg><option>--verbose</option></arg>
<arg><option>--version</option></arg>
@@ -103,6 +108,16 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
+ <term><option>-E</option>
+ <option>--error-on-no-fonts</option>
+ </term>
+ <listitem>
+ <para>Raise an error if there are no fonts in
+ <option><replaceable>dir</replaceable></option> or directories
+ in the configuration if not given.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-f</option>
<option>--force</option>
</term>
@@ -137,6 +152,15 @@ manpage.1: manpage.sgml
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-y</option>
+ <option>-sysroot</option>
+ <option><replaceable>dir</replaceable></option>
+ </term>
+ <listitem>
+ <para>Prepend <option><replaceable>dir</replaceable></option> to all paths for scanning.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-h</option>
<option>--help</option>
</term>
@@ -163,10 +187,15 @@ manpage.1: manpage.sgml
</refsect1>
<refsect1>
+ <title>RETURN CODES</title>
+ <para><command>fc-cache</command> returns zero if the caches successfully generated. otherwise non-zero.</para>
+ </refsect1>
+
+ <refsect1>
<title>FILES</title>
<variablelist>
<varlistentry>
- <term><filename><replaceable>%cachdir%</replaceable>/*-<replaceable>%arch%</replaceable>.cache-2</filename></term>
+ <term><filename><replaceable>%cachedir%</replaceable>/*-<replaceable>%arch%</replaceable>.cache-%version%</filename></term>
<listitem>
<para>These files are generated by <command>&dhpackage;</command>
and contain maps from file names to font properties. They are
diff --git a/chromium/third_party/fontconfig/src/fc-case/CaseFolding.txt b/chromium/third_party/fontconfig/src/fc-case/CaseFolding.txt
index cf5779f4075..372ee68bd81 100644
--- a/chromium/third_party/fontconfig/src/fc-case/CaseFolding.txt
+++ b/chromium/third_party/fontconfig/src/fc-case/CaseFolding.txt
@@ -1,10 +1,11 @@
-# CaseFolding-6.3.0.txt
-# Date: 2012-12-20, 22:14:35 GMT [MD]
+# CaseFolding-9.0.0.txt
+# Date: 2016-03-02, 18:54:54 GMT
+# © 2016 Unicode®, Inc.
+# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
+# For terms of use, see http://www.unicode.org/terms_of_use.html
#
# Unicode Character Database
-# Copyright (c) 1991-2013 Unicode, Inc.
-# For terms of use, see http://www.unicode.org/terms_of_use.html
-# For documentation, see http://www.unicode.org/reports/tr44/
+# For documentation, see http://www.unicode.org/reports/tr44/
#
# Case Folding Properties
#
@@ -25,7 +26,7 @@
#
# For information on case folding, including how to have case folding
# preserve normalization formats, see Section 3.13 Default Case Algorithms in
-# The Unicode Standard, Version 5.0.
+# The Unicode Standard.
#
# ================================================================================
# Format
@@ -58,8 +59,6 @@
# All code points not explicitly listed for Case_Folding
# have the value C for the status field, and the code point itself for the mapping field.
-# @missing: 0000..10FFFF; C; <code point>
-
# =================================================================
0041; C; 0061; # LATIN CAPITAL LETTER A
0042; C; 0062; # LATIN CAPITAL LETTER B
@@ -298,6 +297,7 @@
0370; C; 0371; # GREEK CAPITAL LETTER HETA
0372; C; 0373; # GREEK CAPITAL LETTER ARCHAIC SAMPI
0376; C; 0377; # GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA
+037F; C; 03F3; # GREEK CAPITAL LETTER YOT
0386; C; 03AC; # GREEK CAPITAL LETTER ALPHA WITH TONOS
0388; C; 03AD; # GREEK CAPITAL LETTER EPSILON WITH TONOS
0389; C; 03AE; # GREEK CAPITAL LETTER ETA WITH TONOS
@@ -505,6 +505,10 @@
0522; C; 0523; # CYRILLIC CAPITAL LETTER EN WITH MIDDLE HOOK
0524; C; 0525; # CYRILLIC CAPITAL LETTER PE WITH DESCENDER
0526; C; 0527; # CYRILLIC CAPITAL LETTER SHHA WITH DESCENDER
+0528; C; 0529; # CYRILLIC CAPITAL LETTER EN WITH LEFT HOOK
+052A; C; 052B; # CYRILLIC CAPITAL LETTER DZZHE
+052C; C; 052D; # CYRILLIC CAPITAL LETTER DCHE
+052E; C; 052F; # CYRILLIC CAPITAL LETTER EL WITH DESCENDER
0531; C; 0561; # ARMENIAN CAPITAL LETTER AYB
0532; C; 0562; # ARMENIAN CAPITAL LETTER BEN
0533; C; 0563; # ARMENIAN CAPITAL LETTER GIM
@@ -584,6 +588,21 @@
10C5; C; 2D25; # GEORGIAN CAPITAL LETTER HOE
10C7; C; 2D27; # GEORGIAN CAPITAL LETTER YN
10CD; C; 2D2D; # GEORGIAN CAPITAL LETTER AEN
+13F8; C; 13F0; # CHEROKEE SMALL LETTER YE
+13F9; C; 13F1; # CHEROKEE SMALL LETTER YI
+13FA; C; 13F2; # CHEROKEE SMALL LETTER YO
+13FB; C; 13F3; # CHEROKEE SMALL LETTER YU
+13FC; C; 13F4; # CHEROKEE SMALL LETTER YV
+13FD; C; 13F5; # CHEROKEE SMALL LETTER MV
+1C80; C; 0432; # CYRILLIC SMALL LETTER ROUNDED VE
+1C81; C; 0434; # CYRILLIC SMALL LETTER LONG-LEGGED DE
+1C82; C; 043E; # CYRILLIC SMALL LETTER NARROW O
+1C83; C; 0441; # CYRILLIC SMALL LETTER WIDE ES
+1C84; C; 0442; # CYRILLIC SMALL LETTER TALL TE
+1C85; C; 0442; # CYRILLIC SMALL LETTER THREE-LEGGED TE
+1C86; C; 044A; # CYRILLIC SMALL LETTER TALL HARD SIGN
+1C87; C; 0463; # CYRILLIC SMALL LETTER TALL YAT
+1C88; C; A64B; # CYRILLIC SMALL LETTER UNBLENDED UK
1E00; C; 1E01; # LATIN CAPITAL LETTER A WITH RING BELOW
1E02; C; 1E03; # LATIN CAPITAL LETTER B WITH DOT ABOVE
1E04; C; 1E05; # LATIN CAPITAL LETTER B WITH DOT BELOW
@@ -1088,6 +1107,8 @@ A690; C; A691; # CYRILLIC CAPITAL LETTER TSSE
A692; C; A693; # CYRILLIC CAPITAL LETTER TCHE
A694; C; A695; # CYRILLIC CAPITAL LETTER HWE
A696; C; A697; # CYRILLIC CAPITAL LETTER SHWE
+A698; C; A699; # CYRILLIC CAPITAL LETTER DOUBLE O
+A69A; C; A69B; # CYRILLIC CAPITAL LETTER CROSSED O
A722; C; A723; # LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF
A724; C; A725; # LATIN CAPITAL LETTER EGYPTOLOGICAL AIN
A726; C; A727; # LATIN CAPITAL LETTER HENG
@@ -1138,12 +1159,107 @@ A78B; C; A78C; # LATIN CAPITAL LETTER SALTILLO
A78D; C; 0265; # LATIN CAPITAL LETTER TURNED H
A790; C; A791; # LATIN CAPITAL LETTER N WITH DESCENDER
A792; C; A793; # LATIN CAPITAL LETTER C WITH BAR
+A796; C; A797; # LATIN CAPITAL LETTER B WITH FLOURISH
+A798; C; A799; # LATIN CAPITAL LETTER F WITH STROKE
+A79A; C; A79B; # LATIN CAPITAL LETTER VOLAPUK AE
+A79C; C; A79D; # LATIN CAPITAL LETTER VOLAPUK OE
+A79E; C; A79F; # LATIN CAPITAL LETTER VOLAPUK UE
A7A0; C; A7A1; # LATIN CAPITAL LETTER G WITH OBLIQUE STROKE
A7A2; C; A7A3; # LATIN CAPITAL LETTER K WITH OBLIQUE STROKE
A7A4; C; A7A5; # LATIN CAPITAL LETTER N WITH OBLIQUE STROKE
A7A6; C; A7A7; # LATIN CAPITAL LETTER R WITH OBLIQUE STROKE
A7A8; C; A7A9; # LATIN CAPITAL LETTER S WITH OBLIQUE STROKE
A7AA; C; 0266; # LATIN CAPITAL LETTER H WITH HOOK
+A7AB; C; 025C; # LATIN CAPITAL LETTER REVERSED OPEN E
+A7AC; C; 0261; # LATIN CAPITAL LETTER SCRIPT G
+A7AD; C; 026C; # LATIN CAPITAL LETTER L WITH BELT
+A7AE; C; 026A; # LATIN CAPITAL LETTER SMALL CAPITAL I
+A7B0; C; 029E; # LATIN CAPITAL LETTER TURNED K
+A7B1; C; 0287; # LATIN CAPITAL LETTER TURNED T
+A7B2; C; 029D; # LATIN CAPITAL LETTER J WITH CROSSED-TAIL
+A7B3; C; AB53; # LATIN CAPITAL LETTER CHI
+A7B4; C; A7B5; # LATIN CAPITAL LETTER BETA
+A7B6; C; A7B7; # LATIN CAPITAL LETTER OMEGA
+AB70; C; 13A0; # CHEROKEE SMALL LETTER A
+AB71; C; 13A1; # CHEROKEE SMALL LETTER E
+AB72; C; 13A2; # CHEROKEE SMALL LETTER I
+AB73; C; 13A3; # CHEROKEE SMALL LETTER O
+AB74; C; 13A4; # CHEROKEE SMALL LETTER U
+AB75; C; 13A5; # CHEROKEE SMALL LETTER V
+AB76; C; 13A6; # CHEROKEE SMALL LETTER GA
+AB77; C; 13A7; # CHEROKEE SMALL LETTER KA
+AB78; C; 13A8; # CHEROKEE SMALL LETTER GE
+AB79; C; 13A9; # CHEROKEE SMALL LETTER GI
+AB7A; C; 13AA; # CHEROKEE SMALL LETTER GO
+AB7B; C; 13AB; # CHEROKEE SMALL LETTER GU
+AB7C; C; 13AC; # CHEROKEE SMALL LETTER GV
+AB7D; C; 13AD; # CHEROKEE SMALL LETTER HA
+AB7E; C; 13AE; # CHEROKEE SMALL LETTER HE
+AB7F; C; 13AF; # CHEROKEE SMALL LETTER HI
+AB80; C; 13B0; # CHEROKEE SMALL LETTER HO
+AB81; C; 13B1; # CHEROKEE SMALL LETTER HU
+AB82; C; 13B2; # CHEROKEE SMALL LETTER HV
+AB83; C; 13B3; # CHEROKEE SMALL LETTER LA
+AB84; C; 13B4; # CHEROKEE SMALL LETTER LE
+AB85; C; 13B5; # CHEROKEE SMALL LETTER LI
+AB86; C; 13B6; # CHEROKEE SMALL LETTER LO
+AB87; C; 13B7; # CHEROKEE SMALL LETTER LU
+AB88; C; 13B8; # CHEROKEE SMALL LETTER LV
+AB89; C; 13B9; # CHEROKEE SMALL LETTER MA
+AB8A; C; 13BA; # CHEROKEE SMALL LETTER ME
+AB8B; C; 13BB; # CHEROKEE SMALL LETTER MI
+AB8C; C; 13BC; # CHEROKEE SMALL LETTER MO
+AB8D; C; 13BD; # CHEROKEE SMALL LETTER MU
+AB8E; C; 13BE; # CHEROKEE SMALL LETTER NA
+AB8F; C; 13BF; # CHEROKEE SMALL LETTER HNA
+AB90; C; 13C0; # CHEROKEE SMALL LETTER NAH
+AB91; C; 13C1; # CHEROKEE SMALL LETTER NE
+AB92; C; 13C2; # CHEROKEE SMALL LETTER NI
+AB93; C; 13C3; # CHEROKEE SMALL LETTER NO
+AB94; C; 13C4; # CHEROKEE SMALL LETTER NU
+AB95; C; 13C5; # CHEROKEE SMALL LETTER NV
+AB96; C; 13C6; # CHEROKEE SMALL LETTER QUA
+AB97; C; 13C7; # CHEROKEE SMALL LETTER QUE
+AB98; C; 13C8; # CHEROKEE SMALL LETTER QUI
+AB99; C; 13C9; # CHEROKEE SMALL LETTER QUO
+AB9A; C; 13CA; # CHEROKEE SMALL LETTER QUU
+AB9B; C; 13CB; # CHEROKEE SMALL LETTER QUV
+AB9C; C; 13CC; # CHEROKEE SMALL LETTER SA
+AB9D; C; 13CD; # CHEROKEE SMALL LETTER S
+AB9E; C; 13CE; # CHEROKEE SMALL LETTER SE
+AB9F; C; 13CF; # CHEROKEE SMALL LETTER SI
+ABA0; C; 13D0; # CHEROKEE SMALL LETTER SO
+ABA1; C; 13D1; # CHEROKEE SMALL LETTER SU
+ABA2; C; 13D2; # CHEROKEE SMALL LETTER SV
+ABA3; C; 13D3; # CHEROKEE SMALL LETTER DA
+ABA4; C; 13D4; # CHEROKEE SMALL LETTER TA
+ABA5; C; 13D5; # CHEROKEE SMALL LETTER DE
+ABA6; C; 13D6; # CHEROKEE SMALL LETTER TE
+ABA7; C; 13D7; # CHEROKEE SMALL LETTER DI
+ABA8; C; 13D8; # CHEROKEE SMALL LETTER TI
+ABA9; C; 13D9; # CHEROKEE SMALL LETTER DO
+ABAA; C; 13DA; # CHEROKEE SMALL LETTER DU
+ABAB; C; 13DB; # CHEROKEE SMALL LETTER DV
+ABAC; C; 13DC; # CHEROKEE SMALL LETTER DLA
+ABAD; C; 13DD; # CHEROKEE SMALL LETTER TLA
+ABAE; C; 13DE; # CHEROKEE SMALL LETTER TLE
+ABAF; C; 13DF; # CHEROKEE SMALL LETTER TLI
+ABB0; C; 13E0; # CHEROKEE SMALL LETTER TLO
+ABB1; C; 13E1; # CHEROKEE SMALL LETTER TLU
+ABB2; C; 13E2; # CHEROKEE SMALL LETTER TLV
+ABB3; C; 13E3; # CHEROKEE SMALL LETTER TSA
+ABB4; C; 13E4; # CHEROKEE SMALL LETTER TSE
+ABB5; C; 13E5; # CHEROKEE SMALL LETTER TSI
+ABB6; C; 13E6; # CHEROKEE SMALL LETTER TSO
+ABB7; C; 13E7; # CHEROKEE SMALL LETTER TSU
+ABB8; C; 13E8; # CHEROKEE SMALL LETTER TSV
+ABB9; C; 13E9; # CHEROKEE SMALL LETTER WA
+ABBA; C; 13EA; # CHEROKEE SMALL LETTER WE
+ABBB; C; 13EB; # CHEROKEE SMALL LETTER WI
+ABBC; C; 13EC; # CHEROKEE SMALL LETTER WO
+ABBD; C; 13ED; # CHEROKEE SMALL LETTER WU
+ABBE; C; 13EE; # CHEROKEE SMALL LETTER WV
+ABBF; C; 13EF; # CHEROKEE SMALL LETTER YA
FB00; F; 0066 0066; # LATIN SMALL LIGATURE FF
FB01; F; 0066 0069; # LATIN SMALL LIGATURE FI
FB02; F; 0066 006C; # LATIN SMALL LIGATURE FL
@@ -1222,5 +1338,158 @@ FF3A; C; FF5A; # FULLWIDTH LATIN CAPITAL LETTER Z
10425; C; 1044D; # DESERET CAPITAL LETTER ENG
10426; C; 1044E; # DESERET CAPITAL LETTER OI
10427; C; 1044F; # DESERET CAPITAL LETTER EW
+104B0; C; 104D8; # OSAGE CAPITAL LETTER A
+104B1; C; 104D9; # OSAGE CAPITAL LETTER AI
+104B2; C; 104DA; # OSAGE CAPITAL LETTER AIN
+104B3; C; 104DB; # OSAGE CAPITAL LETTER AH
+104B4; C; 104DC; # OSAGE CAPITAL LETTER BRA
+104B5; C; 104DD; # OSAGE CAPITAL LETTER CHA
+104B6; C; 104DE; # OSAGE CAPITAL LETTER EHCHA
+104B7; C; 104DF; # OSAGE CAPITAL LETTER E
+104B8; C; 104E0; # OSAGE CAPITAL LETTER EIN
+104B9; C; 104E1; # OSAGE CAPITAL LETTER HA
+104BA; C; 104E2; # OSAGE CAPITAL LETTER HYA
+104BB; C; 104E3; # OSAGE CAPITAL LETTER I
+104BC; C; 104E4; # OSAGE CAPITAL LETTER KA
+104BD; C; 104E5; # OSAGE CAPITAL LETTER EHKA
+104BE; C; 104E6; # OSAGE CAPITAL LETTER KYA
+104BF; C; 104E7; # OSAGE CAPITAL LETTER LA
+104C0; C; 104E8; # OSAGE CAPITAL LETTER MA
+104C1; C; 104E9; # OSAGE CAPITAL LETTER NA
+104C2; C; 104EA; # OSAGE CAPITAL LETTER O
+104C3; C; 104EB; # OSAGE CAPITAL LETTER OIN
+104C4; C; 104EC; # OSAGE CAPITAL LETTER PA
+104C5; C; 104ED; # OSAGE CAPITAL LETTER EHPA
+104C6; C; 104EE; # OSAGE CAPITAL LETTER SA
+104C7; C; 104EF; # OSAGE CAPITAL LETTER SHA
+104C8; C; 104F0; # OSAGE CAPITAL LETTER TA
+104C9; C; 104F1; # OSAGE CAPITAL LETTER EHTA
+104CA; C; 104F2; # OSAGE CAPITAL LETTER TSA
+104CB; C; 104F3; # OSAGE CAPITAL LETTER EHTSA
+104CC; C; 104F4; # OSAGE CAPITAL LETTER TSHA
+104CD; C; 104F5; # OSAGE CAPITAL LETTER DHA
+104CE; C; 104F6; # OSAGE CAPITAL LETTER U
+104CF; C; 104F7; # OSAGE CAPITAL LETTER WA
+104D0; C; 104F8; # OSAGE CAPITAL LETTER KHA
+104D1; C; 104F9; # OSAGE CAPITAL LETTER GHA
+104D2; C; 104FA; # OSAGE CAPITAL LETTER ZA
+104D3; C; 104FB; # OSAGE CAPITAL LETTER ZHA
+10C80; C; 10CC0; # OLD HUNGARIAN CAPITAL LETTER A
+10C81; C; 10CC1; # OLD HUNGARIAN CAPITAL LETTER AA
+10C82; C; 10CC2; # OLD HUNGARIAN CAPITAL LETTER EB
+10C83; C; 10CC3; # OLD HUNGARIAN CAPITAL LETTER AMB
+10C84; C; 10CC4; # OLD HUNGARIAN CAPITAL LETTER EC
+10C85; C; 10CC5; # OLD HUNGARIAN CAPITAL LETTER ENC
+10C86; C; 10CC6; # OLD HUNGARIAN CAPITAL LETTER ECS
+10C87; C; 10CC7; # OLD HUNGARIAN CAPITAL LETTER ED
+10C88; C; 10CC8; # OLD HUNGARIAN CAPITAL LETTER AND
+10C89; C; 10CC9; # OLD HUNGARIAN CAPITAL LETTER E
+10C8A; C; 10CCA; # OLD HUNGARIAN CAPITAL LETTER CLOSE E
+10C8B; C; 10CCB; # OLD HUNGARIAN CAPITAL LETTER EE
+10C8C; C; 10CCC; # OLD HUNGARIAN CAPITAL LETTER EF
+10C8D; C; 10CCD; # OLD HUNGARIAN CAPITAL LETTER EG
+10C8E; C; 10CCE; # OLD HUNGARIAN CAPITAL LETTER EGY
+10C8F; C; 10CCF; # OLD HUNGARIAN CAPITAL LETTER EH
+10C90; C; 10CD0; # OLD HUNGARIAN CAPITAL LETTER I
+10C91; C; 10CD1; # OLD HUNGARIAN CAPITAL LETTER II
+10C92; C; 10CD2; # OLD HUNGARIAN CAPITAL LETTER EJ
+10C93; C; 10CD3; # OLD HUNGARIAN CAPITAL LETTER EK
+10C94; C; 10CD4; # OLD HUNGARIAN CAPITAL LETTER AK
+10C95; C; 10CD5; # OLD HUNGARIAN CAPITAL LETTER UNK
+10C96; C; 10CD6; # OLD HUNGARIAN CAPITAL LETTER EL
+10C97; C; 10CD7; # OLD HUNGARIAN CAPITAL LETTER ELY
+10C98; C; 10CD8; # OLD HUNGARIAN CAPITAL LETTER EM
+10C99; C; 10CD9; # OLD HUNGARIAN CAPITAL LETTER EN
+10C9A; C; 10CDA; # OLD HUNGARIAN CAPITAL LETTER ENY
+10C9B; C; 10CDB; # OLD HUNGARIAN CAPITAL LETTER O
+10C9C; C; 10CDC; # OLD HUNGARIAN CAPITAL LETTER OO
+10C9D; C; 10CDD; # OLD HUNGARIAN CAPITAL LETTER NIKOLSBURG OE
+10C9E; C; 10CDE; # OLD HUNGARIAN CAPITAL LETTER RUDIMENTA OE
+10C9F; C; 10CDF; # OLD HUNGARIAN CAPITAL LETTER OEE
+10CA0; C; 10CE0; # OLD HUNGARIAN CAPITAL LETTER EP
+10CA1; C; 10CE1; # OLD HUNGARIAN CAPITAL LETTER EMP
+10CA2; C; 10CE2; # OLD HUNGARIAN CAPITAL LETTER ER
+10CA3; C; 10CE3; # OLD HUNGARIAN CAPITAL LETTER SHORT ER
+10CA4; C; 10CE4; # OLD HUNGARIAN CAPITAL LETTER ES
+10CA5; C; 10CE5; # OLD HUNGARIAN CAPITAL LETTER ESZ
+10CA6; C; 10CE6; # OLD HUNGARIAN CAPITAL LETTER ET
+10CA7; C; 10CE7; # OLD HUNGARIAN CAPITAL LETTER ENT
+10CA8; C; 10CE8; # OLD HUNGARIAN CAPITAL LETTER ETY
+10CA9; C; 10CE9; # OLD HUNGARIAN CAPITAL LETTER ECH
+10CAA; C; 10CEA; # OLD HUNGARIAN CAPITAL LETTER U
+10CAB; C; 10CEB; # OLD HUNGARIAN CAPITAL LETTER UU
+10CAC; C; 10CEC; # OLD HUNGARIAN CAPITAL LETTER NIKOLSBURG UE
+10CAD; C; 10CED; # OLD HUNGARIAN CAPITAL LETTER RUDIMENTA UE
+10CAE; C; 10CEE; # OLD HUNGARIAN CAPITAL LETTER EV
+10CAF; C; 10CEF; # OLD HUNGARIAN CAPITAL LETTER EZ
+10CB0; C; 10CF0; # OLD HUNGARIAN CAPITAL LETTER EZS
+10CB1; C; 10CF1; # OLD HUNGARIAN CAPITAL LETTER ENT-SHAPED SIGN
+10CB2; C; 10CF2; # OLD HUNGARIAN CAPITAL LETTER US
+118A0; C; 118C0; # WARANG CITI CAPITAL LETTER NGAA
+118A1; C; 118C1; # WARANG CITI CAPITAL LETTER A
+118A2; C; 118C2; # WARANG CITI CAPITAL LETTER WI
+118A3; C; 118C3; # WARANG CITI CAPITAL LETTER YU
+118A4; C; 118C4; # WARANG CITI CAPITAL LETTER YA
+118A5; C; 118C5; # WARANG CITI CAPITAL LETTER YO
+118A6; C; 118C6; # WARANG CITI CAPITAL LETTER II
+118A7; C; 118C7; # WARANG CITI CAPITAL LETTER UU
+118A8; C; 118C8; # WARANG CITI CAPITAL LETTER E
+118A9; C; 118C9; # WARANG CITI CAPITAL LETTER O
+118AA; C; 118CA; # WARANG CITI CAPITAL LETTER ANG
+118AB; C; 118CB; # WARANG CITI CAPITAL LETTER GA
+118AC; C; 118CC; # WARANG CITI CAPITAL LETTER KO
+118AD; C; 118CD; # WARANG CITI CAPITAL LETTER ENY
+118AE; C; 118CE; # WARANG CITI CAPITAL LETTER YUJ
+118AF; C; 118CF; # WARANG CITI CAPITAL LETTER UC
+118B0; C; 118D0; # WARANG CITI CAPITAL LETTER ENN
+118B1; C; 118D1; # WARANG CITI CAPITAL LETTER ODD
+118B2; C; 118D2; # WARANG CITI CAPITAL LETTER TTE
+118B3; C; 118D3; # WARANG CITI CAPITAL LETTER NUNG
+118B4; C; 118D4; # WARANG CITI CAPITAL LETTER DA
+118B5; C; 118D5; # WARANG CITI CAPITAL LETTER AT
+118B6; C; 118D6; # WARANG CITI CAPITAL LETTER AM
+118B7; C; 118D7; # WARANG CITI CAPITAL LETTER BU
+118B8; C; 118D8; # WARANG CITI CAPITAL LETTER PU
+118B9; C; 118D9; # WARANG CITI CAPITAL LETTER HIYO
+118BA; C; 118DA; # WARANG CITI CAPITAL LETTER HOLO
+118BB; C; 118DB; # WARANG CITI CAPITAL LETTER HORR
+118BC; C; 118DC; # WARANG CITI CAPITAL LETTER HAR
+118BD; C; 118DD; # WARANG CITI CAPITAL LETTER SSUU
+118BE; C; 118DE; # WARANG CITI CAPITAL LETTER SII
+118BF; C; 118DF; # WARANG CITI CAPITAL LETTER VIYO
+1E900; C; 1E922; # ADLAM CAPITAL LETTER ALIF
+1E901; C; 1E923; # ADLAM CAPITAL LETTER DAALI
+1E902; C; 1E924; # ADLAM CAPITAL LETTER LAAM
+1E903; C; 1E925; # ADLAM CAPITAL LETTER MIIM
+1E904; C; 1E926; # ADLAM CAPITAL LETTER BA
+1E905; C; 1E927; # ADLAM CAPITAL LETTER SINNYIIYHE
+1E906; C; 1E928; # ADLAM CAPITAL LETTER PE
+1E907; C; 1E929; # ADLAM CAPITAL LETTER BHE
+1E908; C; 1E92A; # ADLAM CAPITAL LETTER RA
+1E909; C; 1E92B; # ADLAM CAPITAL LETTER E
+1E90A; C; 1E92C; # ADLAM CAPITAL LETTER FA
+1E90B; C; 1E92D; # ADLAM CAPITAL LETTER I
+1E90C; C; 1E92E; # ADLAM CAPITAL LETTER O
+1E90D; C; 1E92F; # ADLAM CAPITAL LETTER DHA
+1E90E; C; 1E930; # ADLAM CAPITAL LETTER YHE
+1E90F; C; 1E931; # ADLAM CAPITAL LETTER WAW
+1E910; C; 1E932; # ADLAM CAPITAL LETTER NUN
+1E911; C; 1E933; # ADLAM CAPITAL LETTER KAF
+1E912; C; 1E934; # ADLAM CAPITAL LETTER YA
+1E913; C; 1E935; # ADLAM CAPITAL LETTER U
+1E914; C; 1E936; # ADLAM CAPITAL LETTER JIIM
+1E915; C; 1E937; # ADLAM CAPITAL LETTER CHI
+1E916; C; 1E938; # ADLAM CAPITAL LETTER HA
+1E917; C; 1E939; # ADLAM CAPITAL LETTER QAAF
+1E918; C; 1E93A; # ADLAM CAPITAL LETTER GA
+1E919; C; 1E93B; # ADLAM CAPITAL LETTER NYA
+1E91A; C; 1E93C; # ADLAM CAPITAL LETTER TU
+1E91B; C; 1E93D; # ADLAM CAPITAL LETTER NHA
+1E91C; C; 1E93E; # ADLAM CAPITAL LETTER VA
+1E91D; C; 1E93F; # ADLAM CAPITAL LETTER KHA
+1E91E; C; 1E940; # ADLAM CAPITAL LETTER GBE
+1E91F; C; 1E941; # ADLAM CAPITAL LETTER ZAL
+1E920; C; 1E942; # ADLAM CAPITAL LETTER KPO
+1E921; C; 1E943; # ADLAM CAPITAL LETTER SHA
#
# EOF
diff --git a/chromium/third_party/fontconfig/src/fc-case/Makefile.am b/chromium/third_party/fontconfig/src/fc-case/Makefile.am
index 662f771af6d..4c30a1eedc9 100644
--- a/chromium/third_party/fontconfig/src/fc-case/Makefile.am
+++ b/chromium/third_party/fontconfig/src/fc-case/Makefile.am
@@ -28,6 +28,9 @@ DEPS = $(srcdir)/CaseFolding.txt
ARGS = $(srcdir)/CaseFolding.txt
DIST = $(srcdir)/CaseFolding.txt
+update:
+ curl -s -o $(srcdir)/CaseFolding.txt http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
+
include $(top_srcdir)/Tools.mk
-include $(top_srcdir)/git.mk
diff --git a/chromium/third_party/fontconfig/src/fc-cat/fc-cat.c b/chromium/third_party/fontconfig/src/fc-cat/fc-cat.c
index 9a2abb3fa31..a1dc848b8b1 100644
--- a/chromium/third_party/fontconfig/src/fc-cat/fc-cat.c
+++ b/chromium/third_party/fontconfig/src/fc-cat/fc-cat.c
@@ -298,6 +298,7 @@ main (int argc, char **argv)
return 1;
}
FcConfigSetCurrent (config);
+ FcConfigDestroy (config);
args = FcStrSetCreate ();
if (!args)
@@ -315,12 +316,6 @@ main (int argc, char **argv)
return 1;
}
}
- arglist = FcStrListCreate (args);
- if (!arglist)
- {
- fprintf (stderr, "%s: malloc failure\n", argv[0]);
- return 1;
- }
}
else
{
@@ -340,20 +335,26 @@ main (int argc, char **argv)
fprintf (stderr, "%s: malloc failure\n", argv[0]);
return 1;
}
+ FcStrSetDestroy (args);
while ((arg = FcStrListNext (arglist)))
{
int j;
FcChar8 *cache_file = NULL;
struct stat file_stat;
-
+
+ /* reset errno */
+ errno = 0;
if (FcFileIsDir (arg))
cache = FcDirCacheLoad (arg, config, &cache_file);
else
cache = FcDirCacheLoadFile (arg, &file_stat);
if (!cache)
{
- perror ((char *) arg);
+ if (errno != 0)
+ perror ((char *) arg);
+ else
+ fprintf (stderr, "%s: Unable to load the cache: %s\n", argv[0], arg);
ret++;
continue;
}
@@ -384,6 +385,7 @@ main (int argc, char **argv)
if (cache_file)
FcStrFree (cache_file);
}
+ FcStrListDone (arglist);
FcFini ();
return 0;
diff --git a/chromium/third_party/fontconfig/src/fc-cat/fc-cat.sgml b/chromium/third_party/fontconfig/src/fc-cat/fc-cat.sgml
index ce4736de5e8..a51325433cd 100644
--- a/chromium/third_party/fontconfig/src/fc-cat/fc-cat.sgml
+++ b/chromium/third_party/fontconfig/src/fc-cat/fc-cat.sgml
@@ -70,7 +70,7 @@ manpage.1: manpage.sgml
<arg><option>--help</option></arg>
<sbr>
<group rep="repeat">
- <arg><option><replaceable>fonts-cache-2-files</replaceable></option></arg>
+ <arg><option><replaceable>fonts-cache-%version%-files</replaceable></option></arg>
<arg><option><replaceable>dirs</replaceable></option></arg>
</group>
diff --git a/chromium/third_party/fontconfig/src/fc-glyphname/fc-glyphname.c b/chromium/third_party/fontconfig/src/fc-glyphname/fc-glyphname.c
index 84027816430..078490ae442 100644
--- a/chromium/third_party/fontconfig/src/fc-glyphname/fc-glyphname.c
+++ b/chromium/third_party/fontconfig/src/fc-glyphname/fc-glyphname.c
@@ -233,7 +233,7 @@ dump (FcGlyphName * const *table, const char *name)
int
main (int argc FC_UNUSED, char **argv)
{
- char *files[MAX_GLYPHFILE];
+ char *files[MAX_GLYPHFILE + 1];
char line[1024];
FILE *f;
int i;
diff --git a/chromium/third_party/fontconfig/src/fc-lang/README b/chromium/third_party/fontconfig/src/fc-lang/README
new file mode 100644
index 00000000000..4aef7d1165f
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/fc-lang/README
@@ -0,0 +1,28 @@
+Requirements for adding new orth file:
+
+* we are following up to the locale name, 2 or 3 letter code
+ in ISO 639 and ISO 3166-1 alpha-2 code to determine a
+ filename. if it's not yet available, in advance, you
+ should get it fixed in glibc or so.
+
+* Please add a reference URL (written in English as far as
+ possible) into the orth file that explains the code
+ coverage for the certain language. this would helps to
+ review if it has enough coverage.
+
+* no need to add all of the codepoints for the certain
+ language. good enough if it covers most frequently used
+ codepoints in it.
+
+To update existing orth files:
+
+* Please make sure how the changes affects to the existing
+ fonts and no regressions except it is expected behavior.
+
+* Please add any reference URL in bugzilla or any
+ explanation why it needs to be added/removed and also why
+ current orth file doesn't work.
+
+* Please provide a test case what fonts are supposed to be
+ accepted against the change and what fonts aren't.
+
diff --git a/chromium/third_party/fontconfig/src/fc-lang/fc-lang.c b/chromium/third_party/fontconfig/src/fc-lang/fc-lang.c
index 0f4217f78f5..38fc6973558 100644
--- a/chromium/third_party/fontconfig/src/fc-lang/fc-lang.c
+++ b/chromium/third_party/fontconfig/src/fc-lang/fc-lang.c
@@ -254,7 +254,7 @@ static int compare (const void *a, const void *b)
int
main (int argc FC_UNUSED, char **argv)
{
- static Entry entries[MAX_LANG];
+ static Entry entries[MAX_LANG + 1];
static FcCharSet *sets[MAX_LANG];
static int duplicate[MAX_LANG];
static int country[MAX_LANG];
diff --git a/chromium/third_party/fontconfig/src/fc-lang/ja.orth b/chromium/third_party/fontconfig/src/fc-lang/ja.orth
index e87269b85d0..dbc16d4d719 100644
--- a/chromium/third_party/fontconfig/src/fc-lang/ja.orth
+++ b/chromium/third_party/fontconfig/src/fc-lang/ja.orth
@@ -21,13 +21,14 @@
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
-# Coverage from JIS X 0208 (1990)
+# Coverage from JIS X 0208 (1997) for non kanji characters, and
+# Joyo Kanji List (2010, cabinet notification of regular-use chinese characters)
#
0x3000 # IDEOGRAPHIC SPACE
0x3001 # IDEOGRAPHIC COMMA
0x3002 # IDEOGRAPHIC FULL STOP
0x3005 # IDEOGRAPHIC ITERATION MARK
-0x3006 # IDEOGRAPHIC CLOSING MARK
+#0x3006 # IDEOGRAPHIC CLOSING MARK # not in Sawarabi Gothic
0x3007 # IDEOGRAPHIC NUMBER ZERO
0x3041 # HIRAGANA LETTER SMALL A
0x3042 # HIRAGANA LETTER A
@@ -216,171 +217,88 @@
0x4E0B # <CJK>
0x4E0D # <CJK>
0x4E0E # <CJK>
-0x4E10 # <CJK>
-0x4E11 # <CJK>
0x4E14 # <CJK>
-0x4E15 # <CJK>
0x4E16 # <CJK>
-0x4E17 # <CJK>
0x4E18 # <CJK>
0x4E19 # <CJK>
-0x4E1E # <CJK>
0x4E21 # <CJK>
0x4E26 # <CJK>
-0x4E2A # <CJK>
0x4E2D # <CJK>
-0x4E31 # <CJK>
0x4E32 # <CJK>
-0x4E36 # <CJK>
0x4E38 # <CJK>
0x4E39 # <CJK>
0x4E3B # <CJK>
0x4E3C # <CJK>
-0x4E3F # <CJK>
-0x4E42 # <CJK>
-0x4E43 # <CJK>
0x4E45 # <CJK>
-0x4E4B # <CJK>
-0x4E4D # <CJK>
-0x4E4E # <CJK>
0x4E4F # <CJK>
-0x4E55 # <CJK>
-0x4E56 # <CJK>
0x4E57 # <CJK>
-0x4E58 # <CJK>
0x4E59 # <CJK>
0x4E5D # <CJK>
0x4E5E # <CJK>
-0x4E5F # <CJK>
-0x4E62 # <CJK>
0x4E71 # <CJK>
0x4E73 # <CJK>
0x4E7E # <CJK>
0x4E80 # <CJK>
-0x4E82 # <CJK>
-0x4E85 # <CJK>
0x4E86 # <CJK>
0x4E88 # <CJK>
0x4E89 # <CJK>
-0x4E8A # <CJK>
0x4E8B # <CJK>
0x4E8C # <CJK>
-0x4E8E # <CJK>
-0x4E91 # <CJK>
0x4E92 # <CJK>
0x4E94 # <CJK>
0x4E95 # <CJK>
-0x4E98 # <CJK>
-0x4E99 # <CJK>
-0x4E9B # <CJK>
0x4E9C # <CJK>
-0x4E9E # <CJK>
-0x4E9F # <CJK>
-0x4EA0 # <CJK>
0x4EA1 # <CJK>
-0x4EA2 # <CJK>
0x4EA4 # <CJK>
-0x4EA5 # <CJK>
-0x4EA6 # <CJK>
-0x4EA8 # <CJK>
0x4EAB # <CJK>
0x4EAC # <CJK>
0x4EAD # <CJK>
-0x4EAE # <CJK>
-0x4EB0 # <CJK>
-0x4EB3 # <CJK>
-0x4EB6 # <CJK>
0x4EBA # <CJK>
-0x4EC0 # <CJK>
0x4EC1 # <CJK>
-0x4EC2 # <CJK>
-0x4EC4 # <CJK>
-0x4EC6 # <CJK>
-0x4EC7 # <CJK>
0x4ECA # <CJK>
0x4ECB # <CJK>
-0x4ECD # <CJK>
-0x4ECE # <CJK>
0x4ECF # <CJK>
-0x4ED4 # <CJK>
0x4ED5 # <CJK>
0x4ED6 # <CJK>
-0x4ED7 # <CJK>
0x4ED8 # <CJK>
0x4ED9 # <CJK>
-0x4EDD # <CJK>
-0x4EDE # <CJK>
-0x4EDF # <CJK>
0x4EE3 # <CJK>
0x4EE4 # <CJK>
0x4EE5 # <CJK>
-0x4EED # <CJK>
0x4EEE # <CJK>
0x4EF0 # <CJK>
0x4EF2 # <CJK>
0x4EF6 # <CJK>
-0x4EF7 # <CJK>
0x4EFB # <CJK>
0x4F01 # <CJK>
-0x4F09 # <CJK>
-0x4F0A # <CJK>
-0x4F0D # <CJK>
0x4F0E # <CJK>
0x4F0F # <CJK>
0x4F10 # <CJK>
0x4F11 # <CJK>
0x4F1A # <CJK>
-0x4F1C # <CJK>
0x4F1D # <CJK>
0x4F2F # <CJK>
-0x4F30 # <CJK>
0x4F34 # <CJK>
-0x4F36 # <CJK>
0x4F38 # <CJK>
0x4F3A # <CJK>
0x4F3C # <CJK>
-0x4F3D # <CJK>
-0x4F43 # <CJK>
0x4F46 # <CJK>
-0x4F47 # <CJK>
0x4F4D # <CJK>
0x4F4E # <CJK>
0x4F4F # <CJK>
0x4F50 # <CJK>
-0x4F51 # <CJK>
0x4F53 # <CJK>
0x4F55 # <CJK>
-0x4F57 # <CJK>
0x4F59 # <CJK>
-0x4F5A # <CJK>
-0x4F5B # <CJK>
0x4F5C # <CJK>
-0x4F5D # <CJK>
-0x4F5E # <CJK>
-0x4F69 # <CJK>
-0x4F6F # <CJK>
-0x4F70 # <CJK>
0x4F73 # <CJK>
0x4F75 # <CJK>
-0x4F76 # <CJK>
-0x4F7B # <CJK>
-0x4F7C # <CJK>
0x4F7F # <CJK>
-0x4F83 # <CJK>
-0x4F86 # <CJK>
-0x4F88 # <CJK>
0x4F8B # <CJK>
0x4F8D # <CJK>
-0x4F8F # <CJK>
-0x4F91 # <CJK>
-0x4F96 # <CJK>
-0x4F98 # <CJK>
0x4F9B # <CJK>
0x4F9D # <CJK>
-0x4FA0 # <CJK>
0x4FA1 # <CJK>
-0x4FAB # <CJK>
-0x4FAD # <CJK>
0x4FAE # <CJK>
0x4FAF # <CJK>
0x4FB5 # <CJK>
@@ -388,364 +306,165 @@
0x4FBF # <CJK>
0x4FC2 # <CJK>
0x4FC3 # <CJK>
-0x4FC4 # <CJK>
0x4FCA # <CJK>
-0x4FCE # <CJK>
-0x4FD0 # <CJK>
-0x4FD1 # <CJK>
-0x4FD4 # <CJK>
0x4FD7 # <CJK>
-0x4FD8 # <CJK>
-0x4FDA # <CJK>
-0x4FDB # <CJK>
0x4FDD # <CJK>
-0x4FDF # <CJK>
0x4FE1 # <CJK>
-0x4FE3 # <CJK>
-0x4FE4 # <CJK>
-0x4FE5 # <CJK>
0x4FEE # <CJK>
-0x4FEF # <CJK>
0x4FF3 # <CJK>
0x4FF5 # <CJK>
-0x4FF6 # <CJK>
0x4FF8 # <CJK>
0x4FFA # <CJK>
-0x4FFE # <CJK>
-0x5005 # <CJK>
-0x5006 # <CJK>
0x5009 # <CJK>
0x500B # <CJK>
0x500D # <CJK>
-0x500F # <CJK>
-0x5011 # <CJK>
0x5012 # <CJK>
-0x5014 # <CJK>
-0x5016 # <CJK>
0x5019 # <CJK>
-0x501A # <CJK>
0x501F # <CJK>
-0x5021 # <CJK>
0x5023 # <CJK>
0x5024 # <CJK>
-0x5025 # <CJK>
-0x5026 # <CJK>
-0x5028 # <CJK>
-0x5029 # <CJK>
-0x502A # <CJK>
0x502B # <CJK>
-0x502C # <CJK>
-0x502D # <CJK>
-0x5036 # <CJK>
0x5039 # <CJK>
-0x5043 # <CJK>
-0x5047 # <CJK>
-0x5048 # <CJK>
0x5049 # <CJK>
0x504F # <CJK>
-0x5050 # <CJK>
-0x5055 # <CJK>
-0x5056 # <CJK>
-0x505A # <CJK>
0x505C # <CJK>
0x5065 # <CJK>
-0x506C # <CJK>
-0x5072 # <CJK>
0x5074 # <CJK>
0x5075 # <CJK>
0x5076 # <CJK>
-0x5078 # <CJK>
0x507D # <CJK>
-0x5080 # <CJK>
-0x5085 # <CJK>
0x508D # <CJK>
0x5091 # <CJK>
0x5098 # <CJK>
0x5099 # <CJK>
-0x509A # <CJK>
0x50AC # <CJK>
-0x50AD # <CJK>
0x50B2 # <CJK>
-0x50B3 # <CJK>
-0x50B4 # <CJK>
0x50B5 # <CJK>
0x50B7 # <CJK>
0x50BE # <CJK>
-0x50C2 # <CJK>
0x50C5 # <CJK>
-0x50C9 # <CJK>
-0x50CA # <CJK>
0x50CD # <CJK>
0x50CF # <CJK>
-0x50D1 # <CJK>
0x50D5 # <CJK>
-0x50D6 # <CJK>
0x50DA # <CJK>
-0x50DE # <CJK>
-0x50E3 # <CJK>
-0x50E5 # <CJK>
0x50E7 # <CJK>
-0x50ED # <CJK>
-0x50EE # <CJK>
-0x50F5 # <CJK>
-0x50F9 # <CJK>
-0x50FB # <CJK>
0x5100 # <CJK>
-0x5101 # <CJK>
-0x5102 # <CJK>
0x5104 # <CJK>
-0x5109 # <CJK>
0x5112 # <CJK>
-0x5114 # <CJK>
-0x5115 # <CJK>
-0x5116 # <CJK>
-0x5118 # <CJK>
-0x511A # <CJK>
0x511F # <CJK>
-0x5121 # <CJK>
0x512A # <CJK>
-0x5132 # <CJK>
-0x5137 # <CJK>
-0x513A # <CJK>
-0x513B # <CJK>
-0x513C # <CJK>
-0x513F # <CJK>
-0x5140 # <CJK>
-0x5141 # <CJK>
0x5143 # <CJK>
0x5144 # <CJK>
0x5145 # <CJK>
0x5146 # <CJK>
-0x5147 # <CJK>
0x5148 # <CJK>
0x5149 # <CJK>
0x514B # <CJK>
-0x514C # <CJK>
0x514D # <CJK>
-0x514E # <CJK>
0x5150 # <CJK>
-0x5152 # <CJK>
-0x5154 # <CJK>
0x515A # <CJK>
-0x515C # <CJK>
-0x5162 # <CJK>
0x5165 # <CJK>
0x5168 # <CJK>
-0x5169 # <CJK>
-0x516A # <CJK>
0x516B # <CJK>
0x516C # <CJK>
0x516D # <CJK>
-0x516E # <CJK>
0x5171 # <CJK>
0x5175 # <CJK>
-0x5176 # <CJK>
0x5177 # <CJK>
0x5178 # <CJK>
0x517C # <CJK>
-0x5180 # <CJK>
-0x5182 # <CJK>
0x5185 # <CJK>
0x5186 # <CJK>
-0x5189 # <CJK>
0x518A # <CJK>
-0x518C # <CJK>
0x518D # <CJK>
-0x518F # <CJK>
-0x5190 # <CJK>
-0x5191 # <CJK>
0x5192 # <CJK>
-0x5193 # <CJK>
-0x5195 # <CJK>
-0x5196 # <CJK>
0x5197 # <CJK>
0x5199 # <CJK>
0x51A0 # <CJK>
-0x51A2 # <CJK>
-0x51A4 # <CJK>
0x51A5 # <CJK>
-0x51A6 # <CJK>
-0x51A8 # <CJK>
-0x51A9 # <CJK>
-0x51AA # <CJK>
-0x51AB # <CJK>
0x51AC # <CJK>
-0x51B0 # <CJK>
-0x51B1 # <CJK>
-0x51B2 # <CJK>
-0x51B3 # <CJK>
-0x51B4 # <CJK>
-0x51B5 # <CJK>
0x51B6 # <CJK>
0x51B7 # <CJK>
-0x51BD # <CJK>
0x51C4 # <CJK>
-0x51C5 # <CJK>
0x51C6 # <CJK>
-0x51C9 # <CJK>
-0x51CB # <CJK>
-0x51CC # <CJK>
0x51CD # <CJK>
-0x51D6 # <CJK>
-0x51DB # <CJK>
-#0x51DC # <CJK> # not in kochi fonts
0x51DD # <CJK>
-0x51E0 # <CJK>
0x51E1 # <CJK>
0x51E6 # <CJK>
-0x51E7 # <CJK>
-0x51E9 # <CJK>
-0x51EA # <CJK>
-0x51ED # <CJK>
-0x51F0 # <CJK>
-0x51F1 # <CJK>
-0x51F5 # <CJK>
0x51F6 # <CJK>
0x51F8 # <CJK>
0x51F9 # <CJK>
0x51FA # <CJK>
-0x51FD # <CJK>
-0x51FE # <CJK>
0x5200 # <CJK>
0x5203 # <CJK>
-0x5204 # <CJK>
0x5206 # <CJK>
0x5207 # <CJK>
0x5208 # <CJK>
0x520A # <CJK>
-0x520B # <CJK>
-0x520E # <CJK>
0x5211 # <CJK>
-0x5214 # <CJK>
0x5217 # <CJK>
0x521D # <CJK>
0x5224 # <CJK>
0x5225 # <CJK>
-0x5227 # <CJK>
0x5229 # <CJK>
-0x522A # <CJK>
-0x522E # <CJK>
0x5230 # <CJK>
-0x5233 # <CJK>
0x5236 # <CJK>
0x5237 # <CJK>
0x5238 # <CJK>
0x5239 # <CJK>
0x523A # <CJK>
0x523B # <CJK>
-0x5243 # <CJK>
-0x5244 # <CJK>
0x5247 # <CJK>
0x524A # <CJK>
-0x524B # <CJK>
-0x524C # <CJK>
0x524D # <CJK>
-0x524F # <CJK>
-0x5254 # <CJK>
0x5256 # <CJK>
0x525B # <CJK>
-0x525E # <CJK>
+#0x525D # <CJK> # not in sazanami gothic/mincho, DroidSansJapanese
0x5263 # <CJK>
0x5264 # <CJK>
-0x5265 # <CJK>
-0x5269 # <CJK>
-0x526A # <CJK>
0x526F # <CJK>
0x5270 # <CJK>
-0x5271 # <CJK>
0x5272 # <CJK>
-0x5273 # <CJK>
-0x5274 # <CJK>
0x5275 # <CJK>
-0x527D # <CJK>
-0x527F # <CJK>
-0x5283 # <CJK>
0x5287 # <CJK>
-0x5288 # <CJK>
-0x5289 # <CJK>
-0x528D # <CJK>
-0x5291 # <CJK>
-0x5292 # <CJK>
-0x5294 # <CJK>
0x529B # <CJK>
0x529F # <CJK>
0x52A0 # <CJK>
0x52A3 # <CJK>
0x52A9 # <CJK>
0x52AA # <CJK>
-0x52AB # <CJK>
-0x52AC # <CJK>
-0x52AD # <CJK>
0x52B1 # <CJK>
0x52B4 # <CJK>
-0x52B5 # <CJK>
0x52B9 # <CJK>
-0x52BC # <CJK>
0x52BE # <CJK>
-0x52C1 # <CJK>
0x52C3 # <CJK>
0x52C5 # <CJK>
0x52C7 # <CJK>
0x52C9 # <CJK>
-0x52CD # <CJK>
-0x52D2 # <CJK>
0x52D5 # <CJK>
-0x52D7 # <CJK>
0x52D8 # <CJK>
0x52D9 # <CJK>
0x52DD # <CJK>
-0x52DE # <CJK>
0x52DF # <CJK>
-0x52E0 # <CJK>
0x52E2 # <CJK>
-0x52E3 # <CJK>
0x52E4 # <CJK>
-0x52E6 # <CJK>
0x52E7 # <CJK>
0x52F2 # <CJK>
-0x52F3 # <CJK>
-0x52F5 # <CJK>
-0x52F8 # <CJK>
-0x52F9 # <CJK>
-0x52FA # <CJK>
0x52FE # <CJK>
-0x52FF # <CJK>
-0x5301 # <CJK>
0x5302 # <CJK>
0x5305 # <CJK>
-0x5306 # <CJK>
-0x5308 # <CJK>
-0x530D # <CJK>
-0x530F # <CJK>
-0x5310 # <CJK>
-0x5315 # <CJK>
0x5316 # <CJK>
0x5317 # <CJK>
-0x5319 # <CJK>
-0x531A # <CJK>
-0x531D # <CJK>
0x5320 # <CJK>
-0x5321 # <CJK>
-0x5323 # <CJK>
-0x532A # <CJK>
-0x532F # <CJK>
-0x5331 # <CJK>
-0x5333 # <CJK>
-0x5338 # <CJK>
0x5339 # <CJK>
0x533A # <CJK>
0x533B # <CJK>
0x533F # <CJK>
-0x5340 # <CJK>
0x5341 # <CJK>
0x5343 # <CJK>
-0x5345 # <CJK>
-0x5346 # <CJK>
0x5347 # <CJK>
0x5348 # <CJK>
-0x5349 # <CJK>
0x534A # <CJK>
-0x534D # <CJK>
0x5351 # <CJK>
0x5352 # <CJK>
0x5353 # <CJK>
@@ -753,43 +472,21 @@
0x5357 # <CJK>
0x5358 # <CJK>
0x535A # <CJK>
-0x535C # <CJK>
-0x535E # <CJK>
0x5360 # <CJK>
-0x5366 # <CJK>
-0x5369 # <CJK>
-0x536E # <CJK>
-0x536F # <CJK>
0x5370 # <CJK>
0x5371 # <CJK>
0x5373 # <CJK>
0x5374 # <CJK>
0x5375 # <CJK>
-0x5377 # <CJK>
0x5378 # <CJK>
-0x537B # <CJK>
-0x537F # <CJK>
-0x5382 # <CJK>
0x5384 # <CJK>
-0x5396 # <CJK>
0x5398 # <CJK>
0x539A # <CJK>
0x539F # <CJK>
-0x53A0 # <CJK>
-0x53A5 # <CJK>
-0x53A6 # <CJK>
-0x53A8 # <CJK>
-0x53A9 # <CJK>
-0x53AD # <CJK>
-0x53AE # <CJK>
-0x53B0 # <CJK>
0x53B3 # <CJK>
-0x53B6 # <CJK>
0x53BB # <CJK>
0x53C2 # <CJK>
-0x53C3 # <CJK>
0x53C8 # <CJK>
-0x53C9 # <CJK>
0x53CA # <CJK>
0x53CB # <CJK>
0x53CC # <CJK>
@@ -799,36 +496,20 @@
0x53D6 # <CJK>
0x53D7 # <CJK>
0x53D9 # <CJK>
-0x53DB # <CJK>
-0x53DF # <CJK>
-0x53E1 # <CJK>
-0x53E2 # <CJK>
0x53E3 # <CJK>
0x53E4 # <CJK>
0x53E5 # <CJK>
-0x53E8 # <CJK>
-0x53E9 # <CJK>
-0x53EA # <CJK>
0x53EB # <CJK>
0x53EC # <CJK>
-0x53ED # <CJK>
-0x53EE # <CJK>
0x53EF # <CJK>
0x53F0 # <CJK>
-0x53F1 # <CJK>
0x53F2 # <CJK>
0x53F3 # <CJK>
-0x53F6 # <CJK>
0x53F7 # <CJK>
0x53F8 # <CJK>
-0x53FA # <CJK>
-0x5401 # <CJK>
-0x5403 # <CJK>
0x5404 # <CJK>
0x5408 # <CJK>
0x5409 # <CJK>
-0x540A # <CJK>
-0x540B # <CJK>
0x540C # <CJK>
0x540D # <CJK>
0x540E # <CJK>
@@ -836,273 +517,82 @@
0x5410 # <CJK>
0x5411 # <CJK>
0x541B # <CJK>
-0x541D # <CJK>
0x541F # <CJK>
-0x5420 # <CJK>
0x5426 # <CJK>
-0x5429 # <CJK>
0x542B # <CJK>
-0x542C # <CJK>
-0x542D # <CJK>
-0x542E # <CJK>
-0x5436 # <CJK>
0x5438 # <CJK>
0x5439 # <CJK>
-0x543B # <CJK>
-0x543C # <CJK>
-0x543D # <CJK>
-0x543E # <CJK>
-0x5440 # <CJK>
0x5442 # <CJK>
-0x5446 # <CJK>
0x5448 # <CJK>
0x5449 # <CJK>
0x544A # <CJK>
-0x544E # <CJK>
-0x5451 # <CJK>
-0x545F # <CJK>
0x5468 # <CJK>
0x546A # <CJK>
-0x5470 # <CJK>
-0x5471 # <CJK>
0x5473 # <CJK>
-0x5475 # <CJK>
-0x5476 # <CJK>
-0x5477 # <CJK>
-0x547B # <CJK>
0x547C # <CJK>
0x547D # <CJK>
-0x5480 # <CJK>
-0x5484 # <CJK>
-0x5486 # <CJK>
-0x548B # <CJK>
0x548C # <CJK>
-0x548E # <CJK>
-0x548F # <CJK>
-0x5490 # <CJK>
-0x5492 # <CJK>
-0x54A2 # <CJK>
-0x54A4 # <CJK>
-0x54A5 # <CJK>
-0x54A8 # <CJK>
-0x54AB # <CJK>
-0x54AC # <CJK>
-0x54AF # <CJK>
0x54B2 # <CJK>
-0x54B3 # <CJK>
-0x54B8 # <CJK>
-0x54BC # <CJK>
0x54BD # <CJK>
-0x54BE # <CJK>
0x54C0 # <CJK>
0x54C1 # <CJK>
-0x54C2 # <CJK>
-0x54C4 # <CJK>
-0x54C7 # <CJK>
-0x54C8 # <CJK>
-0x54C9 # <CJK>
-0x54D8 # <CJK>
0x54E1 # <CJK>
-0x54E2 # <CJK>
-0x54E5 # <CJK>
-0x54E6 # <CJK>
-0x54E8 # <CJK>
-0x54E9 # <CJK>
-0x54ED # <CJK>
-0x54EE # <CJK>
0x54F2 # <CJK>
0x54FA # <CJK>
-0x54FD # <CJK>
0x5504 # <CJK>
0x5506 # <CJK>
0x5507 # <CJK>
-0x550F # <CJK>
0x5510 # <CJK>
-0x5514 # <CJK>
-0x5516 # <CJK>
-0x552E # <CJK>
0x552F # <CJK>
0x5531 # <CJK>
-0x5533 # <CJK>
-0x5538 # <CJK>
-0x5539 # <CJK>
0x553E # <CJK>
-0x5540 # <CJK>
-0x5544 # <CJK>
-0x5545 # <CJK>
0x5546 # <CJK>
-0x554C # <CJK>
0x554F # <CJK>
0x5553 # <CJK>
-0x5556 # <CJK>
-0x5557 # <CJK>
-0x555C # <CJK>
-0x555D # <CJK>
-0x5563 # <CJK>
-0x557B # <CJK>
-0x557C # <CJK>
-0x557E # <CJK>
-0x5580 # <CJK>
-0x5583 # <CJK>
0x5584 # <CJK>
-0x5587 # <CJK>
0x5589 # <CJK>
-0x558A # <CJK>
-0x558B # <CJK>
-0x5598 # <CJK>
-0x5599 # <CJK>
0x559A # <CJK>
0x559C # <CJK>
0x559D # <CJK>
-0x559E # <CJK>
-0x559F # <CJK>
-0x55A7 # <CJK>
-0x55A8 # <CJK>
0x55A9 # <CJK>
0x55AA # <CJK>
0x55AB # <CJK>
-0x55AC # <CJK>
-0x55AE # <CJK>
-0x55B0 # <CJK>
0x55B6 # <CJK>
-0x55C4 # <CJK>
0x55C5 # <CJK>
-0x55C7 # <CJK>
-0x55D4 # <CJK>
-0x55DA # <CJK>
-0x55DC # <CJK>
-0x55DF # <CJK>
0x55E3 # <CJK>
-0x55E4 # <CJK>
-0x55F7 # <CJK>
-0x55F9 # <CJK>
-0x55FD # <CJK>
-0x55FE # <CJK>
0x5606 # <CJK>
-0x5609 # <CJK>
-0x5614 # <CJK>
-0x5616 # <CJK>
-0x5617 # <CJK>
-0x5618 # <CJK>
-0x561B # <CJK>
-0x5629 # <CJK>
-0x562F # <CJK>
0x5631 # <CJK>
0x5632 # <CJK>
-0x5634 # <CJK>
-0x5636 # <CJK>
-0x5638 # <CJK>
-0x5642 # <CJK>
-0x564C # <CJK>
-0x564E # <CJK>
-0x5650 # <CJK>
-0x565B # <CJK>
-0x5664 # <CJK>
0x5668 # <CJK>
-0x566A # <CJK>
-0x566B # <CJK>
-0x566C # <CJK>
0x5674 # <CJK>
-0x5678 # <CJK>
-0x567A # <CJK>
-0x5680 # <CJK>
-0x5686 # <CJK>
0x5687 # <CJK>
-0x568A # <CJK>
-0x568F # <CJK>
-0x5694 # <CJK>
-0x56A0 # <CJK>
-0x56A2 # <CJK>
-0x56A5 # <CJK>
-0x56AE # <CJK>
-0x56B4 # <CJK>
-0x56B6 # <CJK>
-0x56BC # <CJK>
-0x56C0 # <CJK>
-0x56C1 # <CJK>
-0x56C2 # <CJK>
-0x56C3 # <CJK>
-0x56C8 # <CJK>
-0x56CE # <CJK>
-0x56D1 # <CJK>
-0x56D3 # <CJK>
-0x56D7 # <CJK>
-0x56D8 # <CJK>
0x56DA # <CJK>
0x56DB # <CJK>
0x56DE # <CJK>
0x56E0 # <CJK>
0x56E3 # <CJK>
-0x56EE # <CJK>
0x56F0 # <CJK>
0x56F2 # <CJK>
0x56F3 # <CJK>
-0x56F9 # <CJK>
0x56FA # <CJK>
0x56FD # <CJK>
-0x56FF # <CJK>
-0x5700 # <CJK>
-0x5703 # <CJK>
-0x5704 # <CJK>
-0x5708 # <CJK>
-0x5709 # <CJK>
-0x570B # <CJK>
-0x570D # <CJK>
0x570F # <CJK>
0x5712 # <CJK>
-0x5713 # <CJK>
-0x5716 # <CJK>
-0x5718 # <CJK>
-0x571C # <CJK>
0x571F # <CJK>
-0x5726 # <CJK>
0x5727 # <CJK>
0x5728 # <CJK>
-0x572D # <CJK>
0x5730 # <CJK>
-0x5737 # <CJK>
-0x5738 # <CJK>
-0x573B # <CJK>
-0x5740 # <CJK>
0x5742 # <CJK>
0x5747 # <CJK>
0x574A # <CJK>
-0x574E # <CJK>
-0x574F # <CJK>
-0x5750 # <CJK>
0x5751 # <CJK>
-0x5761 # <CJK>
-0x5764 # <CJK>
-0x5766 # <CJK>
-0x5769 # <CJK>
0x576A # <CJK>
-0x577F # <CJK>
0x5782 # <CJK>
-0x5788 # <CJK>
-0x5789 # <CJK>
0x578B # <CJK>
-0x5793 # <CJK>
-0x57A0 # <CJK>
-0x57A2 # <CJK>
0x57A3 # <CJK>
-0x57A4 # <CJK>
-0x57AA # <CJK>
-0x57B0 # <CJK>
-0x57B3 # <CJK>
-0x57C0 # <CJK>
-0x57C3 # <CJK>
-0x57C6 # <CJK>
0x57CB # <CJK>
0x57CE # <CJK>
-0x57D2 # <CJK>
-0x57D3 # <CJK>
-0x57D4 # <CJK>
-0x57D6 # <CJK>
-0x57DC # <CJK>
0x57DF # <CJK>
-0x57E0 # <CJK>
-0x57E3 # <CJK>
-0x57F4 # <CJK>
0x57F7 # <CJK>
0x57F9 # <CJK>
0x57FA # <CJK>
@@ -1111,267 +601,111 @@
0x5802 # <CJK>
0x5805 # <CJK>
0x5806 # <CJK>
-0x580A # <CJK>
-0x580B # <CJK>
0x5815 # <CJK>
-0x5819 # <CJK>
-0x581D # <CJK>
-0x5821 # <CJK>
0x5824 # <CJK>
0x582A # <CJK>
-0x582F # <CJK>
-0x5830 # <CJK>
0x5831 # <CJK>
0x5834 # <CJK>
-0x5835 # <CJK>
-0x583A # <CJK>
-0x583D # <CJK>
0x5840 # <CJK>
0x5841 # <CJK>
0x584A # <CJK>
-0x584B # <CJK>
0x5851 # <CJK>
-0x5852 # <CJK>
0x5854 # <CJK>
0x5857 # <CJK>
-0x5858 # <CJK>
-0x5859 # <CJK>
0x585A # <CJK>
0x585E # <CJK>
-0x5862 # <CJK>
+#0x5861 # <CJK> # not in DroidSansJapanese
0x5869 # <CJK>
-0x586B # <CJK>
-0x5870 # <CJK>
-0x5872 # <CJK>
-0x5875 # <CJK>
-0x5879 # <CJK>
0x587E # <CJK>
0x5883 # <CJK>
-0x5885 # <CJK>
0x5893 # <CJK>
0x5897 # <CJK>
0x589C # <CJK>
-0x589F # <CJK>
0x58A8 # <CJK>
-0x58AB # <CJK>
-0x58AE # <CJK>
0x58B3 # <CJK>
-0x58B8 # <CJK>
-0x58B9 # <CJK>
-0x58BA # <CJK>
-0x58BB # <CJK>
0x58BE # <CJK>
0x58C1 # <CJK>
-0x58C5 # <CJK>
0x58C7 # <CJK>
0x58CA # <CJK>
0x58CC # <CJK>
-0x58D1 # <CJK>
-0x58D3 # <CJK>
-0x58D5 # <CJK>
-0x58D7 # <CJK>
-0x58D8 # <CJK>
-0x58D9 # <CJK>
-0x58DC # <CJK>
-0x58DE # <CJK>
-0x58DF # <CJK>
-0x58E4 # <CJK>
-0x58E5 # <CJK>
0x58EB # <CJK>
-0x58EC # <CJK>
0x58EE # <CJK>
-0x58EF # <CJK>
0x58F0 # <CJK>
0x58F1 # <CJK>
0x58F2 # <CJK>
-0x58F7 # <CJK>
-0x58F9 # <CJK>
-0x58FA # <CJK>
-0x58FB # <CJK>
-0x58FC # <CJK>
-0x58FD # <CJK>
-0x5902 # <CJK>
0x5909 # <CJK>
-0x590A # <CJK>
0x590F # <CJK>
-0x5910 # <CJK>
0x5915 # <CJK>
0x5916 # <CJK>
-0x5918 # <CJK>
-0x5919 # <CJK>
0x591A # <CJK>
-0x591B # <CJK>
0x591C # <CJK>
0x5922 # <CJK>
-0x5925 # <CJK>
0x5927 # <CJK>
0x5929 # <CJK>
0x592A # <CJK>
0x592B # <CJK>
-0x592C # <CJK>
-0x592D # <CJK>
0x592E # <CJK>
0x5931 # <CJK>
-0x5932 # <CJK>
-0x5937 # <CJK>
-0x5938 # <CJK>
-0x593E # <CJK>
-0x5944 # <CJK>
0x5947 # <CJK>
0x5948 # <CJK>
0x5949 # <CJK>
-0x594E # <CJK>
0x594F # <CJK>
-0x5950 # <CJK>
0x5951 # <CJK>
0x5954 # <CJK>
-0x5955 # <CJK>
-0x5957 # <CJK>
-0x5958 # <CJK>
-0x595A # <CJK>
-0x5960 # <CJK>
-0x5962 # <CJK>
0x5965 # <CJK>
-0x5967 # <CJK>
0x5968 # <CJK>
-0x5969 # <CJK>
0x596A # <CJK>
-0x596C # <CJK>
0x596E # <CJK>
0x5973 # <CJK>
0x5974 # <CJK>
-0x5978 # <CJK>
0x597D # <CJK>
-0x5981 # <CJK>
0x5982 # <CJK>
0x5983 # <CJK>
0x5984 # <CJK>
0x598A # <CJK>
-0x598D # <CJK>
-0x5993 # <CJK>
0x5996 # <CJK>
0x5999 # <CJK>
-0x599B # <CJK>
-0x599D # <CJK>
-0x59A3 # <CJK>
0x59A5 # <CJK>
0x59A8 # <CJK>
0x59AC # <CJK>
-0x59B2 # <CJK>
0x59B9 # <CJK>
0x59BB # <CJK>
-0x59BE # <CJK>
-0x59C6 # <CJK>
0x59C9 # <CJK>
0x59CB # <CJK>
-0x59D0 # <CJK>
-0x59D1 # <CJK>
0x59D3 # <CJK>
0x59D4 # <CJK>
-0x59D9 # <CJK>
-0x59DA # <CJK>
-0x59DC # <CJK>
-0x59E5 # <CJK>
-0x59E6 # <CJK>
-0x59E8 # <CJK>
-0x59EA # <CJK>
0x59EB # <CJK>
-0x59F6 # <CJK>
0x59FB # <CJK>
0x59FF # <CJK>
0x5A01 # <CJK>
-0x5A03 # <CJK>
-0x5A09 # <CJK>
-0x5A11 # <CJK>
0x5A18 # <CJK>
-0x5A1A # <CJK>
-0x5A1C # <CJK>
-0x5A1F # <CJK>
0x5A20 # <CJK>
-0x5A25 # <CJK>
-0x5A29 # <CJK>
0x5A2F # <CJK>
-0x5A35 # <CJK>
-0x5A36 # <CJK>
-0x5A3C # <CJK>
-0x5A40 # <CJK>
-0x5A41 # <CJK>
0x5A46 # <CJK>
-0x5A49 # <CJK>
0x5A5A # <CJK>
-0x5A62 # <CJK>
0x5A66 # <CJK>
-0x5A6A # <CJK>
-0x5A6C # <CJK>
0x5A7F # <CJK>
0x5A92 # <CJK>
-0x5A9A # <CJK>
0x5A9B # <CJK>
-0x5ABC # <CJK>
-0x5ABD # <CJK>
-0x5ABE # <CJK>
0x5AC1 # <CJK>
-0x5AC2 # <CJK>
0x5AC9 # <CJK>
-0x5ACB # <CJK>
0x5ACC # <CJK>
-0x5AD0 # <CJK>
-0x5AD6 # <CJK>
-0x5AD7 # <CJK>
0x5AE1 # <CJK>
-0x5AE3 # <CJK>
-0x5AE6 # <CJK>
-0x5AE9 # <CJK>
-0x5AFA # <CJK>
-0x5AFB # <CJK>
-0x5B09 # <CJK>
-0x5B0B # <CJK>
-0x5B0C # <CJK>
-0x5B16 # <CJK>
0x5B22 # <CJK>
-0x5B2A # <CJK>
-0x5B2C # <CJK>
-0x5B30 # <CJK>
-0x5B32 # <CJK>
-0x5B36 # <CJK>
-0x5B3E # <CJK>
-0x5B40 # <CJK>
-0x5B43 # <CJK>
-0x5B45 # <CJK>
0x5B50 # <CJK>
-0x5B51 # <CJK>
0x5B54 # <CJK>
-0x5B55 # <CJK>
0x5B57 # <CJK>
0x5B58 # <CJK>
-0x5B5A # <CJK>
-0x5B5B # <CJK>
-0x5B5C # <CJK>
0x5B5D # <CJK>
-0x5B5F # <CJK>
0x5B63 # <CJK>
0x5B64 # <CJK>
-0x5B65 # <CJK>
0x5B66 # <CJK>
-0x5B69 # <CJK>
0x5B6B # <CJK>
-0x5B70 # <CJK>
-0x5B71 # <CJK>
-0x5B73 # <CJK>
-0x5B75 # <CJK>
-0x5B78 # <CJK>
-0x5B7A # <CJK>
-0x5B80 # <CJK>
-0x5B83 # <CJK>
0x5B85 # <CJK>
0x5B87 # <CJK>
0x5B88 # <CJK>
0x5B89 # <CJK>
-0x5B8B # <CJK>
0x5B8C # <CJK>
-0x5B8D # <CJK>
-0x5B8F # <CJK>
-0x5B95 # <CJK>
0x5B97 # <CJK>
0x5B98 # <CJK>
0x5B99 # <CJK>
@@ -1383,47 +717,26 @@
0x5BA2 # <CJK>
0x5BA3 # <CJK>
0x5BA4 # <CJK>
-0x5BA5 # <CJK>
-0x5BA6 # <CJK>
0x5BAE # <CJK>
0x5BB0 # <CJK>
0x5BB3 # <CJK>
0x5BB4 # <CJK>
0x5BB5 # <CJK>
0x5BB6 # <CJK>
-0x5BB8 # <CJK>
0x5BB9 # <CJK>
0x5BBF # <CJK>
0x5BC2 # <CJK>
-0x5BC3 # <CJK>
0x5BC4 # <CJK>
-0x5BC5 # <CJK>
0x5BC6 # <CJK>
-0x5BC7 # <CJK>
-0x5BC9 # <CJK>
0x5BCC # <CJK>
-0x5BD0 # <CJK>
0x5BD2 # <CJK>
-0x5BD3 # <CJK>
-0x5BD4 # <CJK>
0x5BDB # <CJK>
0x5BDD # <CJK>
-0x5BDE # <CJK>
0x5BDF # <CJK>
0x5BE1 # <CJK>
-0x5BE2 # <CJK>
-0x5BE4 # <CJK>
-0x5BE5 # <CJK>
-0x5BE6 # <CJK>
0x5BE7 # <CJK>
-0x5BE8 # <CJK>
0x5BE9 # <CJK>
-0x5BEB # <CJK>
0x5BEE # <CJK>
-0x5BF0 # <CJK>
-0x5BF3 # <CJK>
-0x5BF5 # <CJK>
-0x5BF6 # <CJK>
0x5BF8 # <CJK>
0x5BFA # <CJK>
0x5BFE # <CJK>
@@ -1431,28 +744,15 @@
0x5C01 # <CJK>
0x5C02 # <CJK>
0x5C04 # <CJK>
-0x5C05 # <CJK>
0x5C06 # <CJK>
-0x5C07 # <CJK>
-0x5C08 # <CJK>
0x5C09 # <CJK>
0x5C0A # <CJK>
0x5C0B # <CJK>
-0x5C0D # <CJK>
0x5C0E # <CJK>
0x5C0F # <CJK>
0x5C11 # <CJK>
-0x5C13 # <CJK>
-0x5C16 # <CJK>
0x5C1A # <CJK>
-0x5C20 # <CJK>
-0x5C22 # <CJK>
-0x5C24 # <CJK>
-0x5C28 # <CJK>
-0x5C2D # <CJK>
0x5C31 # <CJK>
-0x5C38 # <CJK>
-0x5C39 # <CJK>
0x5C3A # <CJK>
0x5C3B # <CJK>
0x5C3C # <CJK>
@@ -1460,109 +760,31 @@
0x5C3E # <CJK>
0x5C3F # <CJK>
0x5C40 # <CJK>
-0x5C41 # <CJK>
0x5C45 # <CJK>
-0x5C46 # <CJK>
0x5C48 # <CJK>
0x5C4A # <CJK>
0x5C4B # <CJK>
-0x5C4D # <CJK>
-0x5C4E # <CJK>
-0x5C4F # <CJK>
-0x5C50 # <CJK>
-0x5C51 # <CJK>
-0x5C53 # <CJK>
0x5C55 # <CJK>
0x5C5E # <CJK>
-0x5C60 # <CJK>
-0x5C61 # <CJK>
0x5C64 # <CJK>
0x5C65 # <CJK>
-0x5C6C # <CJK>
-0x5C6E # <CJK>
0x5C6F # <CJK>
0x5C71 # <CJK>
-0x5C76 # <CJK>
-0x5C79 # <CJK>
-0x5C8C # <CJK>
0x5C90 # <CJK>
-0x5C91 # <CJK>
-0x5C94 # <CJK>
0x5CA1 # <CJK>
-0x5CA8 # <CJK>
0x5CA9 # <CJK>
-0x5CAB # <CJK>
0x5CAC # <CJK>
-0x5CB1 # <CJK>
0x5CB3 # <CJK>
-0x5CB6 # <CJK>
-0x5CB7 # <CJK>
0x5CB8 # <CJK>
-0x5CBB # <CJK>
-0x5CBC # <CJK>
-0x5CBE # <CJK>
-0x5CC5 # <CJK>
-0x5CC7 # <CJK>
-0x5CD9 # <CJK>
0x5CE0 # <CJK>
0x5CE1 # <CJK>
-0x5CE8 # <CJK>
-0x5CE9 # <CJK>
-0x5CEA # <CJK>
-0x5CED # <CJK>
-0x5CEF # <CJK>
0x5CF0 # <CJK>
0x5CF6 # <CJK>
-0x5CFA # <CJK>
-0x5CFB # <CJK>
-0x5CFD # <CJK>
0x5D07 # <CJK>
-0x5D0B # <CJK>
0x5D0E # <CJK>
-0x5D11 # <CJK>
-0x5D14 # <CJK>
-0x5D15 # <CJK>
0x5D16 # <CJK>
-0x5D17 # <CJK>
-0x5D18 # <CJK>
-0x5D19 # <CJK>
-0x5D1A # <CJK>
-0x5D1B # <CJK>
-0x5D1F # <CJK>
-0x5D22 # <CJK>
0x5D29 # <CJK>
-0x5D4B # <CJK>
-0x5D4C # <CJK>
-0x5D4E # <CJK>
0x5D50 # <CJK>
-0x5D52 # <CJK>
-0x5D5C # <CJK>
-0x5D69 # <CJK>
-0x5D6C # <CJK>
-0x5D6F # <CJK>
-0x5D73 # <CJK>
-0x5D76 # <CJK>
-0x5D82 # <CJK>
-0x5D84 # <CJK>
-0x5D87 # <CJK>
-0x5D8B # <CJK>
-0x5D8C # <CJK>
-0x5D90 # <CJK>
-0x5D9D # <CJK>
-0x5DA2 # <CJK>
-0x5DAC # <CJK>
-0x5DAE # <CJK>
-0x5DB7 # <CJK>
-0x5DBA # <CJK>
-0x5DBC # <CJK>
-0x5DBD # <CJK>
-0x5DC9 # <CJK>
-0x5DCC # <CJK>
-0x5DCD # <CJK>
-0x5DD2 # <CJK>
-0x5DD3 # <CJK>
-0x5DD6 # <CJK>
-0x5DDB # <CJK>
0x5DDD # <CJK>
0x5DDE # <CJK>
0x5DE1 # <CJK>
@@ -1571,27 +793,14 @@
0x5DE6 # <CJK>
0x5DE7 # <CJK>
0x5DE8 # <CJK>
-0x5DEB # <CJK>
0x5DEE # <CJK>
0x5DF1 # <CJK>
-0x5DF2 # <CJK>
-0x5DF3 # <CJK>
-0x5DF4 # <CJK>
-0x5DF5 # <CJK>
-0x5DF7 # <CJK>
0x5DFB # <CJK>
-0x5DFD # <CJK>
0x5DFE # <CJK>
0x5E02 # <CJK>
0x5E03 # <CJK>
0x5E06 # <CJK>
-0x5E0B # <CJK>
0x5E0C # <CJK>
-0x5E11 # <CJK>
-0x5E16 # <CJK>
-0x5E19 # <CJK>
-0x5E1A # <CJK>
-0x5E1B # <CJK>
0x5E1D # <CJK>
0x5E25 # <CJK>
0x5E2B # <CJK>
@@ -1599,738 +808,301 @@
0x5E2F # <CJK>
0x5E30 # <CJK>
0x5E33 # <CJK>
-0x5E36 # <CJK>
-0x5E37 # <CJK>
0x5E38 # <CJK>
0x5E3D # <CJK>
-0x5E40 # <CJK>
-0x5E43 # <CJK>
-0x5E44 # <CJK>
0x5E45 # <CJK>
-0x5E47 # <CJK>
-0x5E4C # <CJK>
-0x5E4E # <CJK>
-0x5E54 # <CJK>
0x5E55 # <CJK>
-0x5E57 # <CJK>
-0x5E5F # <CJK>
-0x5E61 # <CJK>
-0x5E62 # <CJK>
0x5E63 # <CJK>
-0x5E64 # <CJK>
0x5E72 # <CJK>
0x5E73 # <CJK>
0x5E74 # <CJK>
-0x5E75 # <CJK>
-0x5E76 # <CJK>
0x5E78 # <CJK>
0x5E79 # <CJK>
-0x5E7A # <CJK>
0x5E7B # <CJK>
0x5E7C # <CJK>
0x5E7D # <CJK>
0x5E7E # <CJK>
-0x5E7F # <CJK>
0x5E81 # <CJK>
0x5E83 # <CJK>
-0x5E84 # <CJK>
-0x5E87 # <CJK>
0x5E8A # <CJK>
0x5E8F # <CJK>
0x5E95 # <CJK>
-0x5E96 # <CJK>
0x5E97 # <CJK>
-0x5E9A # <CJK>
0x5E9C # <CJK>
-0x5EA0 # <CJK>
0x5EA6 # <CJK>
0x5EA7 # <CJK>
0x5EAB # <CJK>
0x5EAD # <CJK>
-0x5EB5 # <CJK>
0x5EB6 # <CJK>
0x5EB7 # <CJK>
0x5EB8 # <CJK>
-0x5EC1 # <CJK>
-0x5EC2 # <CJK>
0x5EC3 # <CJK>
-0x5EC8 # <CJK>
0x5EC9 # <CJK>
0x5ECA # <CJK>
-0x5ECF # <CJK>
-0x5ED0 # <CJK>
-0x5ED3 # <CJK>
-0x5ED6 # <CJK>
-0x5EDA # <CJK>
-0x5EDB # <CJK>
-0x5EDD # <CJK>
-0x5EDF # <CJK>
-0x5EE0 # <CJK>
-0x5EE1 # <CJK>
-0x5EE2 # <CJK>
-0x5EE3 # <CJK>
-0x5EE8 # <CJK>
-0x5EE9 # <CJK>
-0x5EEC # <CJK>
-0x5EF0 # <CJK>
-0x5EF1 # <CJK>
-0x5EF3 # <CJK>
-0x5EF4 # <CJK>
0x5EF6 # <CJK>
0x5EF7 # <CJK>
-0x5EF8 # <CJK>
0x5EFA # <CJK>
-0x5EFB # <CJK>
-0x5EFC # <CJK>
-0x5EFE # <CJK>
-0x5EFF # <CJK>
0x5F01 # <CJK>
-0x5F03 # <CJK>
0x5F04 # <CJK>
-0x5F09 # <CJK>
0x5F0A # <CJK>
-0x5F0B # <CJK>
-0x5F0C # <CJK>
-0x5F0D # <CJK>
0x5F0F # <CJK>
0x5F10 # <CJK>
-0x5F11 # <CJK>
0x5F13 # <CJK>
0x5F14 # <CJK>
0x5F15 # <CJK>
-0x5F16 # <CJK>
-0x5F17 # <CJK>
-0x5F18 # <CJK>
-0x5F1B # <CJK>
0x5F1F # <CJK>
0x5F25 # <CJK>
0x5F26 # <CJK>
0x5F27 # <CJK>
-0x5F29 # <CJK>
-0x5F2D # <CJK>
-0x5F2F # <CJK>
0x5F31 # <CJK>
0x5F35 # <CJK>
0x5F37 # <CJK>
-0x5F38 # <CJK>
-0x5F3C # <CJK>
0x5F3E # <CJK>
-0x5F41 # <CJK>
-0x5F48 # <CJK>
-0x5F4A # <CJK>
-0x5F4C # <CJK>
-0x5F4E # <CJK>
-0x5F51 # <CJK>
0x5F53 # <CJK>
-0x5F56 # <CJK>
-0x5F57 # <CJK>
0x5F59 # <CJK>
-0x5F5C # <CJK>
-0x5F5D # <CJK>
-0x5F61 # <CJK>
0x5F62 # <CJK>
-0x5F66 # <CJK>
0x5F69 # <CJK>
-0x5F6A # <CJK>
0x5F6B # <CJK>
-0x5F6C # <CJK>
-0x5F6D # <CJK>
0x5F70 # <CJK>
0x5F71 # <CJK>
-0x5F73 # <CJK>
-0x5F77 # <CJK>
0x5F79 # <CJK>
0x5F7C # <CJK>
-0x5F7F # <CJK>
0x5F80 # <CJK>
0x5F81 # <CJK>
-0x5F82 # <CJK>
-0x5F83 # <CJK>
0x5F84 # <CJK>
0x5F85 # <CJK>
-0x5F87 # <CJK>
-0x5F88 # <CJK>
-0x5F8A # <CJK>
0x5F8B # <CJK>
0x5F8C # <CJK>
0x5F90 # <CJK>
-0x5F91 # <CJK>
0x5F92 # <CJK>
0x5F93 # <CJK>
0x5F97 # <CJK>
-0x5F98 # <CJK>
-0x5F99 # <CJK>
-0x5F9E # <CJK>
-0x5FA0 # <CJK>
0x5FA1 # <CJK>
-0x5FA8 # <CJK>
0x5FA9 # <CJK>
0x5FAA # <CJK>
-0x5FAD # <CJK>
0x5FAE # <CJK>
0x5FB3 # <CJK>
0x5FB4 # <CJK>
0x5FB9 # <CJK>
-0x5FBC # <CJK>
-0x5FBD # <CJK>
0x5FC3 # <CJK>
0x5FC5 # <CJK>
0x5FCC # <CJK>
0x5FCD # <CJK>
-0x5FD6 # <CJK>
0x5FD7 # <CJK>
0x5FD8 # <CJK>
0x5FD9 # <CJK>
0x5FDC # <CJK>
-0x5FDD # <CJK>
0x5FE0 # <CJK>
-0x5FE4 # <CJK>
0x5FEB # <CJK>
-0x5FF0 # <CJK>
-0x5FF1 # <CJK>
0x5FF5 # <CJK>
-0x5FF8 # <CJK>
-0x5FFB # <CJK>
-0x5FFD # <CJK>
-0x5FFF # <CJK>
-0x600E # <CJK>
-0x600F # <CJK>
-0x6010 # <CJK>
0x6012 # <CJK>
-0x6015 # <CJK>
0x6016 # <CJK>
-0x6019 # <CJK>
-0x601B # <CJK>
-0x601C # <CJK>
0x601D # <CJK>
0x6020 # <CJK>
-0x6021 # <CJK>
0x6025 # <CJK>
-0x6026 # <CJK>
0x6027 # <CJK>
0x6028 # <CJK>
-0x6029 # <CJK>
0x602A # <CJK>
-0x602B # <CJK>
-0x602F # <CJK>
-0x6031 # <CJK>
-0x603A # <CJK>
-0x6041 # <CJK>
-0x6042 # <CJK>
-0x6043 # <CJK>
-0x6046 # <CJK>
-0x604A # <CJK>
0x604B # <CJK>
-0x604D # <CJK>
0x6050 # <CJK>
0x6052 # <CJK>
-0x6055 # <CJK>
-0x6059 # <CJK>
-0x605A # <CJK>
-0x605F # <CJK>
-0x6060 # <CJK>
-0x6062 # <CJK>
0x6063 # <CJK>
-0x6064 # <CJK>
0x6065 # <CJK>
0x6068 # <CJK>
0x6069 # <CJK>
-0x606A # <CJK>
-0x606B # <CJK>
-0x606C # <CJK>
0x606D # <CJK>
0x606F # <CJK>
-0x6070 # <CJK>
0x6075 # <CJK>
-0x6077 # <CJK>
-0x6081 # <CJK>
-0x6083 # <CJK>
-0x6084 # <CJK>
-0x6089 # <CJK>
-0x608B # <CJK>
-0x608C # <CJK>
-0x608D # <CJK>
-0x6092 # <CJK>
0x6094 # <CJK>
-0x6096 # <CJK>
-0x6097 # <CJK>
-0x609A # <CJK>
-0x609B # <CJK>
0x609F # <CJK>
0x60A0 # <CJK>
0x60A3 # <CJK>
0x60A6 # <CJK>
-0x60A7 # <CJK>
0x60A9 # <CJK>
0x60AA # <CJK>
0x60B2 # <CJK>
-0x60B3 # <CJK>
-0x60B4 # <CJK>
-0x60B5 # <CJK>
-0x60B6 # <CJK>
-0x60B8 # <CJK>
0x60BC # <CJK>
-0x60BD # <CJK>
0x60C5 # <CJK>
-0x60C6 # <CJK>
-0x60C7 # <CJK>
0x60D1 # <CJK>
-0x60D3 # <CJK>
-0x60D8 # <CJK>
-0x60DA # <CJK>
0x60DC # <CJK>
-0x60DF # <CJK>
-0x60E0 # <CJK>
-0x60E1 # <CJK>
-0x60E3 # <CJK>
0x60E7 # <CJK>
0x60E8 # <CJK>
0x60F0 # <CJK>
-0x60F1 # <CJK>
0x60F3 # <CJK>
-0x60F4 # <CJK>
-0x60F6 # <CJK>
-0x60F7 # <CJK>
-0x60F9 # <CJK>
-0x60FA # <CJK>
-0x60FB # <CJK>
-0x6100 # <CJK>
0x6101 # <CJK>
-0x6103 # <CJK>
-0x6106 # <CJK>
-0x6108 # <CJK>
0x6109 # <CJK>
-0x610D # <CJK>
-0x610E # <CJK>
0x610F # <CJK>
-0x6115 # <CJK>
0x611A # <CJK>
0x611B # <CJK>
0x611F # <CJK>
-0x6121 # <CJK>
-0x6127 # <CJK>
-0x6128 # <CJK>
-0x612C # <CJK>
-0x6134 # <CJK>
-0x613C # <CJK>
-0x613D # <CJK>
-0x613E # <CJK>
-0x613F # <CJK>
-0x6142 # <CJK>
0x6144 # <CJK>
-0x6147 # <CJK>
0x6148 # <CJK>
-0x614A # <CJK>
0x614B # <CJK>
0x614C # <CJK>
-0x614D # <CJK>
0x614E # <CJK>
-0x6153 # <CJK>
0x6155 # <CJK>
-0x6158 # <CJK>
-0x6159 # <CJK>
-0x615A # <CJK>
-0x615D # <CJK>
-0x615F # <CJK>
0x6162 # <CJK>
0x6163 # <CJK>
-0x6165 # <CJK>
-0x6167 # <CJK>
0x6168 # <CJK>
-0x616B # <CJK>
0x616E # <CJK>
-0x616F # <CJK>
0x6170 # <CJK>
-0x6171 # <CJK>
-0x6173 # <CJK>
-0x6174 # <CJK>
-0x6175 # <CJK>
0x6176 # <CJK>
-0x6177 # <CJK>
-0x617E # <CJK>
0x6182 # <CJK>
-0x6187 # <CJK>
-0x618A # <CJK>
0x618E # <CJK>
-0x6190 # <CJK>
-0x6191 # <CJK>
-0x6194 # <CJK>
-0x6196 # <CJK>
-0x6199 # <CJK>
-0x619A # <CJK>
0x61A4 # <CJK>
0x61A7 # <CJK>
0x61A9 # <CJK>
-0x61AB # <CJK>
0x61AC # <CJK>
-0x61AE # <CJK>
0x61B2 # <CJK>
0x61B6 # <CJK>
-0x61BA # <CJK>
0x61BE # <CJK>
-0x61C3 # <CJK>
-0x61C6 # <CJK>
0x61C7 # <CJK>
-0x61C8 # <CJK>
-0x61C9 # <CJK>
-0x61CA # <CJK>
-0x61CB # <CJK>
-0x61CC # <CJK>
-0x61CD # <CJK>
0x61D0 # <CJK>
-0x61E3 # <CJK>
-0x61E6 # <CJK>
0x61F2 # <CJK>
-0x61F4 # <CJK>
-0x61F6 # <CJK>
-0x61F7 # <CJK>
0x61F8 # <CJK>
-0x61FA # <CJK>
-0x61FC # <CJK>
-0x61FD # <CJK>
-0x61FE # <CJK>
-0x61FF # <CJK>
-0x6200 # <CJK>
-0x6208 # <CJK>
-0x6209 # <CJK>
-0x620A # <CJK>
-0x620C # <CJK>
-0x620D # <CJK>
-0x620E # <CJK>
0x6210 # <CJK>
0x6211 # <CJK>
0x6212 # <CJK>
-0x6214 # <CJK>
-0x6216 # <CJK>
0x621A # <CJK>
-0x621B # <CJK>
-0x621D # <CJK>
-0x621E # <CJK>
-0x621F # <CJK>
-0x6221 # <CJK>
0x6226 # <CJK>
-0x622A # <CJK>
-0x622E # <CJK>
0x622F # <CJK>
-0x6230 # <CJK>
-0x6232 # <CJK>
-0x6233 # <CJK>
0x6234 # <CJK>
0x6238 # <CJK>
0x623B # <CJK>
0x623F # <CJK>
0x6240 # <CJK>
-0x6241 # <CJK>
0x6247 # <CJK>
-0x6248 # <CJK>
0x6249 # <CJK>
0x624B # <CJK>
0x624D # <CJK>
-0x624E # <CJK>
0x6253 # <CJK>
0x6255 # <CJK>
-0x6258 # <CJK>
-0x625B # <CJK>
-0x625E # <CJK>
-0x6260 # <CJK>
-0x6263 # <CJK>
-0x6268 # <CJK>
-0x626E # <CJK>
0x6271 # <CJK>
0x6276 # <CJK>
0x6279 # <CJK>
-0x627C # <CJK>
-0x627E # <CJK>
0x627F # <CJK>
0x6280 # <CJK>
-0x6282 # <CJK>
-0x6283 # <CJK>
0x6284 # <CJK>
-0x6289 # <CJK>
0x628A # <CJK>
0x6291 # <CJK>
-0x6292 # <CJK>
-0x6293 # <CJK>
-0x6294 # <CJK>
0x6295 # <CJK>
-0x6296 # <CJK>
0x6297 # <CJK>
0x6298 # <CJK>
-0x629B # <CJK>
0x629C # <CJK>
0x629E # <CJK>
0x62AB # <CJK>
-0x62AC # <CJK>
0x62B1 # <CJK>
0x62B5 # <CJK>
0x62B9 # <CJK>
-0x62BB # <CJK>
0x62BC # <CJK>
0x62BD # <CJK>
-0x62C2 # <CJK>
0x62C5 # <CJK>
-0x62C6 # <CJK>
-0x62C7 # <CJK>
-0x62C8 # <CJK>
0x62C9 # <CJK>
-0x62CA # <CJK>
-0x62CC # <CJK>
0x62CD # <CJK>
-0x62CF # <CJK>
0x62D0 # <CJK>
-0x62D1 # <CJK>
0x62D2 # <CJK>
0x62D3 # <CJK>
-0x62D4 # <CJK>
-0x62D7 # <CJK>
0x62D8 # <CJK>
0x62D9 # <CJK>
0x62DB # <CJK>
-0x62DC # <CJK>
0x62DD # <CJK>
0x62E0 # <CJK>
0x62E1 # <CJK>
0x62EC # <CJK>
0x62ED # <CJK>
-0x62EE # <CJK>
-0x62EF # <CJK>
-0x62F1 # <CJK>
0x62F3 # <CJK>
-0x62F5 # <CJK>
0x62F6 # <CJK>
0x62F7 # <CJK>
0x62FE # <CJK>
-0x62FF # <CJK>
0x6301 # <CJK>
-0x6302 # <CJK>
0x6307 # <CJK>
-0x6308 # <CJK>
-0x6309 # <CJK>
-0x630C # <CJK>
0x6311 # <CJK>
0x6319 # <CJK>
0x631F # <CJK>
-0x6327 # <CJK>
0x6328 # <CJK>
0x632B # <CJK>
0x632F # <CJK>
-0x633A # <CJK>
-0x633D # <CJK>
-0x633E # <CJK>
0x633F # <CJK>
0x6349 # <CJK>
-0x634C # <CJK>
-0x634D # <CJK>
-0x634F # <CJK>
-0x6350 # <CJK>
0x6355 # <CJK>
0x6357 # <CJK>
0x635C # <CJK>
-0x6367 # <CJK>
0x6368 # <CJK>
-0x6369 # <CJK>
-0x636B # <CJK>
0x636E # <CJK>
-0x6372 # <CJK>
-0x6376 # <CJK>
-0x6377 # <CJK>
-0x637A # <CJK>
0x637B # <CJK>
-0x6380 # <CJK>
0x6383 # <CJK>
0x6388 # <CJK>
-0x6389 # <CJK>
0x638C # <CJK>
-0x638E # <CJK>
-0x638F # <CJK>
0x6392 # <CJK>
-0x6396 # <CJK>
0x6398 # <CJK>
0x639B # <CJK>
-0x639F # <CJK>
-0x63A0 # <CJK>
0x63A1 # <CJK>
0x63A2 # <CJK>
-0x63A3 # <CJK>
0x63A5 # <CJK>
0x63A7 # <CJK>
0x63A8 # <CJK>
-0x63A9 # <CJK>
0x63AA # <CJK>
-0x63AB # <CJK>
-0x63AC # <CJK>
0x63B2 # <CJK>
-0x63B4 # <CJK>
-0x63B5 # <CJK>
-0x63BB # <CJK>
-0x63BE # <CJK>
-0x63C0 # <CJK>
-0x63C3 # <CJK>
-0x63C4 # <CJK>
-0x63C6 # <CJK>
-0x63C9 # <CJK>
0x63CF # <CJK>
0x63D0 # <CJK>
-0x63D2 # <CJK>
-0x63D6 # <CJK>
0x63DA # <CJK>
0x63DB # <CJK>
0x63E1 # <CJK>
-0x63E3 # <CJK>
-0x63E9 # <CJK>
0x63EE # <CJK>
0x63F4 # <CJK>
-0x63F6 # <CJK>
0x63FA # <CJK>
-0x6406 # <CJK>
0x640D # <CJK>
-0x640F # <CJK>
-0x6413 # <CJK>
-0x6416 # <CJK>
-0x6417 # <CJK>
-0x641C # <CJK>
-0x6426 # <CJK>
-0x6428 # <CJK>
0x642C # <CJK>
0x642D # <CJK>
-0x6434 # <CJK>
-0x6436 # <CJK>
0x643A # <CJK>
0x643E # <CJK>
0x6442 # <CJK>
-0x644E # <CJK>
0x6458 # <CJK>
-0x6467 # <CJK>
0x6469 # <CJK>
0x646F # <CJK>
-0x6476 # <CJK>
-0x6478 # <CJK>
-0x647A # <CJK>
0x6483 # <CJK>
-0x6488 # <CJK>
-0x6492 # <CJK>
-0x6493 # <CJK>
-0x6495 # <CJK>
-0x649A # <CJK>
-0x649E # <CJK>
0x64A4 # <CJK>
-0x64A5 # <CJK>
-0x64A9 # <CJK>
-0x64AB # <CJK>
-0x64AD # <CJK>
0x64AE # <CJK>
-0x64B0 # <CJK>
0x64B2 # <CJK>
-0x64B9 # <CJK>
-0x64BB # <CJK>
-0x64BC # <CJK>
0x64C1 # <CJK>
-0x64C2 # <CJK>
-0x64C5 # <CJK>
-0x64C7 # <CJK>
0x64CD # <CJK>
-0x64D2 # <CJK>
-0x64D4 # <CJK>
-0x64D8 # <CJK>
-0x64DA # <CJK>
-0x64E0 # <CJK>
-0x64E1 # <CJK>
-0x64E2 # <CJK>
-0x64E3 # <CJK>
0x64E6 # <CJK>
-0x64E7 # <CJK>
0x64EC # <CJK>
-0x64EF # <CJK>
-0x64F1 # <CJK>
-0x64F2 # <CJK>
-0x64F4 # <CJK>
-0x64F6 # <CJK>
-0x64FA # <CJK>
-0x64FD # <CJK>
-0x64FE # <CJK>
-0x6500 # <CJK>
-0x6505 # <CJK>
-0x6518 # <CJK>
-0x651C # <CJK>
-0x651D # <CJK>
-0x6523 # <CJK>
-0x6524 # <CJK>
-0x652A # <CJK>
-0x652B # <CJK>
-0x652C # <CJK>
0x652F # <CJK>
-0x6534 # <CJK>
-0x6535 # <CJK>
-0x6536 # <CJK>
-0x6537 # <CJK>
-0x6538 # <CJK>
0x6539 # <CJK>
0x653B # <CJK>
0x653E # <CJK>
0x653F # <CJK>
0x6545 # <CJK>
-0x6548 # <CJK>
-0x654D # <CJK>
0x654F # <CJK>
0x6551 # <CJK>
-0x6555 # <CJK>
-0x6556 # <CJK>
0x6557 # <CJK>
-0x6558 # <CJK>
0x6559 # <CJK>
-0x655D # <CJK>
-0x655E # <CJK>
0x6562 # <CJK>
0x6563 # <CJK>
-0x6566 # <CJK>
0x656C # <CJK>
0x6570 # <CJK>
-0x6572 # <CJK>
0x6574 # <CJK>
0x6575 # <CJK>
0x6577 # <CJK>
-0x6578 # <CJK>
-0x6582 # <CJK>
-0x6583 # <CJK>
0x6587 # <CJK>
-0x6588 # <CJK>
0x6589 # <CJK>
-0x658C # <CJK>
0x658E # <CJK>
-0x6590 # <CJK>
0x6591 # <CJK>
0x6597 # <CJK>
0x6599 # <CJK>
-0x659B # <CJK>
0x659C # <CJK>
-0x659F # <CJK>
-0x65A1 # <CJK>
0x65A4 # <CJK>
0x65A5 # <CJK>
-0x65A7 # <CJK>
-0x65AB # <CJK>
0x65AC # <CJK>
0x65AD # <CJK>
-0x65AF # <CJK>
0x65B0 # <CJK>
-0x65B7 # <CJK>
0x65B9 # <CJK>
-0x65BC # <CJK>
0x65BD # <CJK>
-0x65C1 # <CJK>
-0x65C3 # <CJK>
-0x65C4 # <CJK>
0x65C5 # <CJK>
-0x65C6 # <CJK>
0x65CB # <CJK>
-0x65CC # <CJK>
0x65CF # <CJK>
-0x65D2 # <CJK>
0x65D7 # <CJK>
-0x65D9 # <CJK>
-0x65DB # <CJK>
-0x65E0 # <CJK>
-0x65E1 # <CJK>
0x65E2 # <CJK>
0x65E5 # <CJK>
0x65E6 # <CJK>
@@ -2338,21 +1110,12 @@
0x65E8 # <CJK>
0x65E9 # <CJK>
0x65EC # <CJK>
-0x65ED # <CJK>
-0x65F1 # <CJK>
0x65FA # <CJK>
-0x65FB # <CJK>
-0x6602 # <CJK>
-0x6603 # <CJK>
0x6606 # <CJK>
0x6607 # <CJK>
-0x660A # <CJK>
-0x660C # <CJK>
0x660E # <CJK>
-0x660F # <CJK>
0x6613 # <CJK>
0x6614 # <CJK>
-0x661C # <CJK>
0x661F # <CJK>
0x6620 # <CJK>
0x6625 # <CJK>
@@ -2360,146 +1123,59 @@
0x6628 # <CJK>
0x662D # <CJK>
0x662F # <CJK>
-0x6634 # <CJK>
-0x6635 # <CJK>
-0x6636 # <CJK>
0x663C # <CJK>
-0x663F # <CJK>
-0x6641 # <CJK>
0x6642 # <CJK>
-0x6643 # <CJK>
-0x6644 # <CJK>
-0x6649 # <CJK>
-0x664B # <CJK>
-0x664F # <CJK>
-0x6652 # <CJK>
-0x665D # <CJK>
-0x665E # <CJK>
-0x665F # <CJK>
-0x6662 # <CJK>
-0x6664 # <CJK>
-0x6666 # <CJK>
-0x6667 # <CJK>
-0x6668 # <CJK>
0x6669 # <CJK>
0x666E # <CJK>
0x666F # <CJK>
-0x6670 # <CJK>
0x6674 # <CJK>
0x6676 # <CJK>
-0x667A # <CJK>
0x6681 # <CJK>
-0x6683 # <CJK>
-0x6684 # <CJK>
0x6687 # <CJK>
-0x6688 # <CJK>
-0x6689 # <CJK>
-0x668E # <CJK>
0x6691 # <CJK>
0x6696 # <CJK>
0x6697 # <CJK>
-0x6698 # <CJK>
-0x669D # <CJK>
-0x66A2 # <CJK>
0x66A6 # <CJK>
0x66AB # <CJK>
0x66AE # <CJK>
0x66B4 # <CJK>
-0x66B8 # <CJK>
-0x66B9 # <CJK>
-0x66BC # <CJK>
-0x66BE # <CJK>
-0x66C1 # <CJK>
-0x66C4 # <CJK>
0x66C7 # <CJK>
-0x66C9 # <CJK>
0x66D6 # <CJK>
-0x66D9 # <CJK>
-0x66DA # <CJK>
0x66DC # <CJK>
-0x66DD # <CJK>
-0x66E0 # <CJK>
-0x66E6 # <CJK>
-0x66E9 # <CJK>
-0x66F0 # <CJK>
0x66F2 # <CJK>
-0x66F3 # <CJK>
0x66F4 # <CJK>
-0x66F5 # <CJK>
-0x66F7 # <CJK>
0x66F8 # <CJK>
0x66F9 # <CJK>
-0x66FC # <CJK>
0x66FD # <CJK>
-0x66FE # <CJK>
0x66FF # <CJK>
0x6700 # <CJK>
-0x6703 # <CJK>
0x6708 # <CJK>
0x6709 # <CJK>
-0x670B # <CJK>
0x670D # <CJK>
-0x670F # <CJK>
-0x6714 # <CJK>
0x6715 # <CJK>
-0x6716 # <CJK>
0x6717 # <CJK>
0x671B # <CJK>
0x671D # <CJK>
-0x671E # <CJK>
0x671F # <CJK>
-0x6726 # <CJK>
-0x6727 # <CJK>
0x6728 # <CJK>
0x672A # <CJK>
0x672B # <CJK>
0x672C # <CJK>
0x672D # <CJK>
-0x672E # <CJK>
0x6731 # <CJK>
0x6734 # <CJK>
-0x6736 # <CJK>
-0x6737 # <CJK>
-0x6738 # <CJK>
0x673A # <CJK>
0x673D # <CJK>
-0x673F # <CJK>
-0x6741 # <CJK>
-0x6746 # <CJK>
0x6749 # <CJK>
-0x674E # <CJK>
-0x674F # <CJK>
0x6750 # <CJK>
0x6751 # <CJK>
-0x6753 # <CJK>
-0x6756 # <CJK>
-0x6759 # <CJK>
-0x675C # <CJK>
-0x675E # <CJK>
0x675F # <CJK>
-0x6760 # <CJK>
0x6761 # <CJK>
-0x6762 # <CJK>
-0x6763 # <CJK>
-0x6764 # <CJK>
0x6765 # <CJK>
-0x676A # <CJK>
-0x676D # <CJK>
0x676F # <CJK>
-0x6770 # <CJK>
0x6771 # <CJK>
-0x6772 # <CJK>
-0x6773 # <CJK>
-0x6775 # <CJK>
-0x6777 # <CJK>
-0x677C # <CJK>
0x677E # <CJK>
0x677F # <CJK>
-0x6785 # <CJK>
-0x6787 # <CJK>
-0x6789 # <CJK>
-0x678B # <CJK>
-0x678C # <CJK>
0x6790 # <CJK>
0x6795 # <CJK>
0x6797 # <CJK>
@@ -2507,2836 +1183,820 @@
0x679C # <CJK>
0x679D # <CJK>
0x67A0 # <CJK>
-0x67A1 # <CJK>
0x67A2 # <CJK>
-0x67A6 # <CJK>
-0x67A9 # <CJK>
0x67AF # <CJK>
-0x67B3 # <CJK>
-0x67B4 # <CJK>
0x67B6 # <CJK>
-0x67B7 # <CJK>
-0x67B8 # <CJK>
-0x67B9 # <CJK>
-0x67C1 # <CJK>
0x67C4 # <CJK>
-0x67C6 # <CJK>
-0x67CA # <CJK>
-0x67CE # <CJK>
-0x67CF # <CJK>
0x67D0 # <CJK>
-0x67D1 # <CJK>
0x67D3 # <CJK>
0x67D4 # <CJK>
-0x67D8 # <CJK>
-0x67DA # <CJK>
-0x67DD # <CJK>
-0x67DE # <CJK>
-0x67E2 # <CJK>
-0x67E4 # <CJK>
-0x67E7 # <CJK>
-0x67E9 # <CJK>
-0x67EC # <CJK>
-0x67EE # <CJK>
-0x67EF # <CJK>
0x67F1 # <CJK>
0x67F3 # <CJK>
-0x67F4 # <CJK>
0x67F5 # <CJK>
0x67FB # <CJK>
-0x67FE # <CJK>
0x67FF # <CJK>
-0x6802 # <CJK>
0x6803 # <CJK>
0x6804 # <CJK>
0x6813 # <CJK>
-0x6816 # <CJK>
-0x6817 # <CJK>
-0x681E # <CJK>
0x6821 # <CJK>
-0x6822 # <CJK>
-0x6829 # <CJK>
0x682A # <CJK>
-0x682B # <CJK>
-0x6832 # <CJK>
-0x6834 # <CJK>
0x6838 # <CJK>
0x6839 # <CJK>
0x683C # <CJK>
0x683D # <CJK>
-0x6840 # <CJK>
0x6841 # <CJK>
-0x6842 # <CJK>
0x6843 # <CJK>
-0x6846 # <CJK>
0x6848 # <CJK>
-0x684D # <CJK>
-0x684E # <CJK>
-0x6850 # <CJK>
0x6851 # <CJK>
-0x6853 # <CJK>
-0x6854 # <CJK>
-0x6859 # <CJK>
0x685C # <CJK>
-0x685D # <CJK>
0x685F # <CJK>
-0x6863 # <CJK>
-0x6867 # <CJK>
-0x6874 # <CJK>
-0x6876 # <CJK>
-0x6877 # <CJK>
-0x687E # <CJK>
-0x687F # <CJK>
-0x6881 # <CJK>
-0x6883 # <CJK>
0x6885 # <CJK>
-0x688D # <CJK>
-0x688F # <CJK>
-0x6893 # <CJK>
-0x6894 # <CJK>
0x6897 # <CJK>
-0x689B # <CJK>
-0x689D # <CJK>
-0x689F # <CJK>
-0x68A0 # <CJK>
-0x68A2 # <CJK>
-0x68A6 # <CJK>
-0x68A7 # <CJK>
0x68A8 # <CJK>
-0x68AD # <CJK>
-0x68AF # <CJK>
0x68B0 # <CJK>
-0x68B1 # <CJK>
-0x68B3 # <CJK>
-0x68B5 # <CJK>
-0x68B6 # <CJK>
-0x68B9 # <CJK>
-0x68BA # <CJK>
-0x68BC # <CJK>
0x68C4 # <CJK>
-0x68C6 # <CJK>
-0x68C9 # <CJK>
-0x68CA # <CJK>
0x68CB # <CJK>
-0x68CD # <CJK>
0x68D2 # <CJK>
-0x68D4 # <CJK>
-0x68D5 # <CJK>
-0x68D7 # <CJK>
-0x68D8 # <CJK>
0x68DA # <CJK>
0x68DF # <CJK>
-0x68E0 # <CJK>
-0x68E1 # <CJK>
-0x68E3 # <CJK>
-0x68E7 # <CJK>
0x68EE # <CJK>
-0x68EF # <CJK>
-0x68F2 # <CJK>
-0x68F9 # <CJK>
0x68FA # <CJK>
-0x6900 # <CJK>
-0x6901 # <CJK>
-0x6904 # <CJK>
0x6905 # <CJK>
-0x6908 # <CJK>
-0x690B # <CJK>
-0x690C # <CJK>
0x690D # <CJK>
0x690E # <CJK>
-0x690F # <CJK>
-0x6912 # <CJK>
-0x6919 # <CJK>
-0x691A # <CJK>
-0x691B # <CJK>
0x691C # <CJK>
-0x6921 # <CJK>
-0x6922 # <CJK>
-0x6923 # <CJK>
-0x6925 # <CJK>
-0x6926 # <CJK>
-0x6928 # <CJK>
-0x692A # <CJK>
-0x6930 # <CJK>
-0x6934 # <CJK>
-0x6936 # <CJK>
-0x6939 # <CJK>
-0x693D # <CJK>
-0x693F # <CJK>
-0x694A # <CJK>
-0x6953 # <CJK>
-0x6954 # <CJK>
-0x6955 # <CJK>
-0x6959 # <CJK>
-0x695A # <CJK>
-0x695C # <CJK>
-0x695D # <CJK>
-0x695E # <CJK>
-0x6960 # <CJK>
-0x6961 # <CJK>
-0x6962 # <CJK>
-0x696A # <CJK>
-0x696B # <CJK>
0x696D # <CJK>
-0x696E # <CJK>
-0x696F # <CJK>
-0x6973 # <CJK>
-0x6974 # <CJK>
0x6975 # <CJK>
0x6977 # <CJK>
-0x6978 # <CJK>
-0x6979 # <CJK>
0x697C # <CJK>
0x697D # <CJK>
-0x697E # <CJK>
-0x6981 # <CJK>
0x6982 # <CJK>
-0x698A # <CJK>
-0x698E # <CJK>
-0x6991 # <CJK>
-0x6994 # <CJK>
-0x6995 # <CJK>
-0x699B # <CJK>
-0x699C # <CJK>
-0x69A0 # <CJK>
-0x69A7 # <CJK>
-0x69AE # <CJK>
-0x69B1 # <CJK>
-0x69B2 # <CJK>
-0x69B4 # <CJK>
-0x69BB # <CJK>
-0x69BE # <CJK>
-0x69BF # <CJK>
-0x69C1 # <CJK>
-0x69C3 # <CJK>
-0x69C7 # <CJK>
-0x69CA # <CJK>
0x69CB # <CJK>
-0x69CC # <CJK>
-0x69CD # <CJK>
-0x69CE # <CJK>
-0x69D0 # <CJK>
-0x69D3 # <CJK>
0x69D8 # <CJK>
-0x69D9 # <CJK>
-0x69DD # <CJK>
-0x69DE # <CJK>
-0x69E7 # <CJK>
-0x69E8 # <CJK>
-0x69EB # <CJK>
-0x69ED # <CJK>
-0x69F2 # <CJK>
-0x69F9 # <CJK>
-0x69FB # <CJK>
0x69FD # <CJK>
-0x69FF # <CJK>
-0x6A02 # <CJK>
-0x6A05 # <CJK>
-0x6A0A # <CJK>
-0x6A0B # <CJK>
-0x6A0C # <CJK>
-0x6A12 # <CJK>
-0x6A13 # <CJK>
-0x6A14 # <CJK>
-0x6A17 # <CJK>
0x6A19 # <CJK>
-0x6A1B # <CJK>
-0x6A1E # <CJK>
-0x6A1F # <CJK>
0x6A21 # <CJK>
-0x6A22 # <CJK>
-0x6A23 # <CJK>
0x6A29 # <CJK>
0x6A2A # <CJK>
-0x6A2B # <CJK>
-0x6A2E # <CJK>
-0x6A35 # <CJK>
-0x6A36 # <CJK>
-0x6A38 # <CJK>
0x6A39 # <CJK>
-0x6A3A # <CJK>
-0x6A3D # <CJK>
-0x6A44 # <CJK>
-0x6A47 # <CJK>
-0x6A48 # <CJK>
0x6A4B # <CJK>
-0x6A58 # <CJK>
-0x6A59 # <CJK>
0x6A5F # <CJK>
-0x6A61 # <CJK>
-0x6A62 # <CJK>
-0x6A66 # <CJK>
-0x6A72 # <CJK>
-0x6A78 # <CJK>
-0x6A7F # <CJK>
-0x6A80 # <CJK>
-0x6A84 # <CJK>
-0x6A8D # <CJK>
-0x6A8E # <CJK>
-0x6A90 # <CJK>
-0x6A97 # <CJK>
-0x6A9C # <CJK>
-0x6AA0 # <CJK>
-0x6AA2 # <CJK>
-0x6AA3 # <CJK>
-0x6AAA # <CJK>
-0x6AAC # <CJK>
-0x6AAE # <CJK>
-0x6AB3 # <CJK>
-0x6AB8 # <CJK>
-0x6ABB # <CJK>
-0x6AC1 # <CJK>
-0x6AC2 # <CJK>
-0x6AC3 # <CJK>
-0x6AD1 # <CJK>
-0x6AD3 # <CJK>
-0x6ADA # <CJK>
-0x6ADB # <CJK>
-0x6ADE # <CJK>
-0x6ADF # <CJK>
-0x6AE8 # <CJK>
-0x6AEA # <CJK>
-0x6AFA # <CJK>
-0x6AFB # <CJK>
0x6B04 # <CJK>
-0x6B05 # <CJK>
-0x6B0A # <CJK>
-0x6B12 # <CJK>
-0x6B16 # <CJK>
-0x6B1D # <CJK>
-0x6B1F # <CJK>
0x6B20 # <CJK>
0x6B21 # <CJK>
-0x6B23 # <CJK>
0x6B27 # <CJK>
0x6B32 # <CJK>
-0x6B37 # <CJK>
-0x6B38 # <CJK>
-0x6B39 # <CJK>
0x6B3A # <CJK>
-0x6B3D # <CJK>
0x6B3E # <CJK>
-0x6B43 # <CJK>
-0x6B47 # <CJK>
-0x6B49 # <CJK>
0x6B4C # <CJK>
-0x6B4E # <CJK>
-0x6B50 # <CJK>
0x6B53 # <CJK>
-0x6B54 # <CJK>
-0x6B59 # <CJK>
-0x6B5B # <CJK>
-0x6B5F # <CJK>
-0x6B61 # <CJK>
0x6B62 # <CJK>
0x6B63 # <CJK>
-0x6B64 # <CJK>
0x6B66 # <CJK>
0x6B69 # <CJK>
-0x6B6A # <CJK>
0x6B6F # <CJK>
0x6B73 # <CJK>
0x6B74 # <CJK>
-0x6B78 # <CJK>
-0x6B79 # <CJK>
0x6B7B # <CJK>
-0x6B7F # <CJK>
-0x6B80 # <CJK>
-0x6B83 # <CJK>
-0x6B84 # <CJK>
-0x6B86 # <CJK>
0x6B89 # <CJK>
0x6B8A # <CJK>
0x6B8B # <CJK>
-0x6B8D # <CJK>
-0x6B95 # <CJK>
0x6B96 # <CJK>
-0x6B98 # <CJK>
-0x6B9E # <CJK>
-0x6BA4 # <CJK>
-0x6BAA # <CJK>
-0x6BAB # <CJK>
-0x6BAF # <CJK>
-0x6BB1 # <CJK>
-0x6BB2 # <CJK>
-0x6BB3 # <CJK>
0x6BB4 # <CJK>
0x6BB5 # <CJK>
-0x6BB7 # <CJK>
0x6BBA # <CJK>
0x6BBB # <CJK>
-0x6BBC # <CJK>
0x6BBF # <CJK>
0x6BC0 # <CJK>
-0x6BC5 # <CJK>
-0x6BC6 # <CJK>
-0x6BCB # <CJK>
0x6BCD # <CJK>
0x6BCE # <CJK>
0x6BD2 # <CJK>
-0x6BD3 # <CJK>
0x6BD4 # <CJK>
-0x6BD8 # <CJK>
0x6BDB # <CJK>
-0x6BDF # <CJK>
-0x6BEB # <CJK>
-0x6BEC # <CJK>
-0x6BEF # <CJK>
-0x6BF3 # <CJK>
-0x6C08 # <CJK>
0x6C0F # <CJK>
0x6C11 # <CJK>
-0x6C13 # <CJK>
-0x6C14 # <CJK>
0x6C17 # <CJK>
-0x6C1B # <CJK>
-0x6C23 # <CJK>
-0x6C24 # <CJK>
0x6C34 # <CJK>
0x6C37 # <CJK>
0x6C38 # <CJK>
0x6C3E # <CJK>
-0x6C40 # <CJK>
0x6C41 # <CJK>
0x6C42 # <CJK>
0x6C4E # <CJK>
-0x6C50 # <CJK>
-0x6C55 # <CJK>
0x6C57 # <CJK>
0x6C5A # <CJK>
-0x6C5D # <CJK>
-0x6C5E # <CJK>
0x6C5F # <CJK>
0x6C60 # <CJK>
-0x6C62 # <CJK>
-0x6C68 # <CJK>
-0x6C6A # <CJK>
0x6C70 # <CJK>
-0x6C72 # <CJK>
-0x6C73 # <CJK>
0x6C7A # <CJK>
0x6C7D # <CJK>
-0x6C7E # <CJK>
-0x6C81 # <CJK>
-0x6C82 # <CJK>
0x6C83 # <CJK>
0x6C88 # <CJK>
-0x6C8C # <CJK>
-0x6C8D # <CJK>
-0x6C90 # <CJK>
-0x6C92 # <CJK>
-0x6C93 # <CJK>
0x6C96 # <CJK>
0x6C99 # <CJK>
-0x6C9A # <CJK>
-0x6C9B # <CJK>
0x6CA1 # <CJK>
0x6CA2 # <CJK>
-0x6CAB # <CJK>
-0x6CAE # <CJK>
-0x6CB1 # <CJK>
0x6CB3 # <CJK>
0x6CB8 # <CJK>
0x6CB9 # <CJK>
-0x6CBA # <CJK>
0x6CBB # <CJK>
0x6CBC # <CJK>
-0x6CBD # <CJK>
-0x6CBE # <CJK>
0x6CBF # <CJK>
0x6CC1 # <CJK>
-0x6CC4 # <CJK>
-0x6CC5 # <CJK>
0x6CC9 # <CJK>
0x6CCA # <CJK>
0x6CCC # <CJK>
-0x6CD3 # <CJK>
0x6CD5 # <CJK>
-0x6CD7 # <CJK>
-0x6CD9 # <CJK>
-0x6CDB # <CJK>
-0x6CDD # <CJK>
0x6CE1 # <CJK>
0x6CE2 # <CJK>
0x6CE3 # <CJK>
0x6CE5 # <CJK>
0x6CE8 # <CJK>
-0x6CEA # <CJK>
-0x6CEF # <CJK>
0x6CF0 # <CJK>
-0x6CF1 # <CJK>
0x6CF3 # <CJK>
0x6D0B # <CJK>
-0x6D0C # <CJK>
-0x6D12 # <CJK>
0x6D17 # <CJK>
-0x6D19 # <CJK>
-0x6D1B # <CJK>
0x6D1E # <CJK>
-0x6D1F # <CJK>
0x6D25 # <CJK>
-0x6D29 # <CJK>
0x6D2A # <CJK>
-0x6D2B # <CJK>
-0x6D32 # <CJK>
-0x6D33 # <CJK>
-0x6D35 # <CJK>
-0x6D36 # <CJK>
-0x6D38 # <CJK>
0x6D3B # <CJK>
-0x6D3D # <CJK>
0x6D3E # <CJK>
0x6D41 # <CJK>
0x6D44 # <CJK>
0x6D45 # <CJK>
-0x6D59 # <CJK>
-0x6D5A # <CJK>
0x6D5C # <CJK>
-0x6D63 # <CJK>
-0x6D64 # <CJK>
0x6D66 # <CJK>
-0x6D69 # <CJK>
0x6D6A # <CJK>
-0x6D6C # <CJK>
0x6D6E # <CJK>
0x6D74 # <CJK>
0x6D77 # <CJK>
0x6D78 # <CJK>
-0x6D79 # <CJK>
-0x6D85 # <CJK>
0x6D88 # <CJK>
-0x6D8C # <CJK>
-0x6D8E # <CJK>
-0x6D93 # <CJK>
-0x6D95 # <CJK>
0x6D99 # <CJK>
-0x6D9B # <CJK>
-0x6D9C # <CJK>
0x6DAF # <CJK>
0x6DB2 # <CJK>
-0x6DB5 # <CJK>
-0x6DB8 # <CJK>
0x6DBC # <CJK>
-0x6DC0 # <CJK>
-0x6DC5 # <CJK>
-0x6DC6 # <CJK>
-0x6DC7 # <CJK>
-0x6DCB # <CJK>
-0x6DCC # <CJK>
0x6DD1 # <CJK>
-0x6DD2 # <CJK>
-0x6DD5 # <CJK>
-0x6DD8 # <CJK>
-0x6DD9 # <CJK>
-0x6DDE # <CJK>
0x6DE1 # <CJK>
-0x6DE4 # <CJK>
-0x6DE6 # <CJK>
-0x6DE8 # <CJK>
-0x6DEA # <CJK>
0x6DEB # <CJK>
-0x6DEC # <CJK>
-0x6DEE # <CJK>
0x6DF1 # <CJK>
-0x6DF3 # <CJK>
-0x6DF5 # <CJK>
0x6DF7 # <CJK>
-0x6DF9 # <CJK>
-0x6DFA # <CJK>
0x6DFB # <CJK>
0x6E05 # <CJK>
0x6E07 # <CJK>
0x6E08 # <CJK>
0x6E09 # <CJK>
-0x6E0A # <CJK>
0x6E0B # <CJK>
0x6E13 # <CJK>
-0x6E15 # <CJK>
-0x6E19 # <CJK>
-0x6E1A # <CJK>
0x6E1B # <CJK>
-0x6E1D # <CJK>
-0x6E1F # <CJK>
-0x6E20 # <CJK>
0x6E21 # <CJK>
-0x6E23 # <CJK>
-0x6E24 # <CJK>
-0x6E25 # <CJK>
0x6E26 # <CJK>
0x6E29 # <CJK>
-0x6E2B # <CJK>
0x6E2C # <CJK>
-0x6E2D # <CJK>
-0x6E2E # <CJK>
0x6E2F # <CJK>
-0x6E38 # <CJK>
-0x6E3A # <CJK>
-0x6E3E # <CJK>
-0x6E43 # <CJK>
-0x6E4A # <CJK>
-0x6E4D # <CJK>
-0x6E4E # <CJK>
0x6E56 # <CJK>
-0x6E58 # <CJK>
-0x6E5B # <CJK>
-0x6E5F # <CJK>
0x6E67 # <CJK>
-0x6E6B # <CJK>
-0x6E6E # <CJK>
0x6E6F # <CJK>
-0x6E72 # <CJK>
-0x6E76 # <CJK>
0x6E7E # <CJK>
0x6E7F # <CJK>
0x6E80 # <CJK>
-0x6E82 # <CJK>
-0x6E8C # <CJK>
-0x6E8F # <CJK>
0x6E90 # <CJK>
0x6E96 # <CJK>
-0x6E98 # <CJK>
-0x6E9C # <CJK>
0x6E9D # <CJK>
-0x6E9F # <CJK>
-0x6EA2 # <CJK>
-0x6EA5 # <CJK>
-0x6EAA # <CJK>
-0x6EAF # <CJK>
-0x6EB2 # <CJK>
0x6EB6 # <CJK>
-0x6EB7 # <CJK>
0x6EBA # <CJK>
-0x6EBD # <CJK>
-0x6EC2 # <CJK>
-0x6EC4 # <CJK>
0x6EC5 # <CJK>
-0x6EC9 # <CJK>
0x6ECB # <CJK>
-0x6ECC # <CJK>
0x6ED1 # <CJK>
-0x6ED3 # <CJK>
-0x6ED4 # <CJK>
-0x6ED5 # <CJK>
0x6EDD # <CJK>
0x6EDE # <CJK>
-0x6EEC # <CJK>
-0x6EEF # <CJK>
-0x6EF2 # <CJK>
0x6EF4 # <CJK>
-0x6EF7 # <CJK>
-0x6EF8 # <CJK>
-0x6EFE # <CJK>
-0x6EFF # <CJK>
0x6F01 # <CJK>
0x6F02 # <CJK>
0x6F06 # <CJK>
-0x6F09 # <CJK>
0x6F0F # <CJK>
-0x6F11 # <CJK>
-0x6F13 # <CJK>
0x6F14 # <CJK>
-0x6F15 # <CJK>
0x6F20 # <CJK>
0x6F22 # <CJK>
-0x6F23 # <CJK>
0x6F2B # <CJK>
0x6F2C # <CJK>
-0x6F31 # <CJK>
-0x6F32 # <CJK>
0x6F38 # <CJK>
-0x6F3E # <CJK>
-0x6F3F # <CJK>
-0x6F41 # <CJK>
-0x6F45 # <CJK>
0x6F54 # <CJK>
-0x6F58 # <CJK>
-0x6F5B # <CJK>
0x6F5C # <CJK>
0x6F5F # <CJK>
0x6F64 # <CJK>
-0x6F66 # <CJK>
-0x6F6D # <CJK>
0x6F6E # <CJK>
-0x6F6F # <CJK>
0x6F70 # <CJK>
-0x6F74 # <CJK>
-0x6F78 # <CJK>
-0x6F7A # <CJK>
-0x6F7C # <CJK>
-0x6F80 # <CJK>
-0x6F81 # <CJK>
-0x6F82 # <CJK>
0x6F84 # <CJK>
-0x6F86 # <CJK>
-0x6F8E # <CJK>
-0x6F91 # <CJK>
-0x6F97 # <CJK>
-0x6FA1 # <CJK>
-0x6FA3 # <CJK>
-0x6FA4 # <CJK>
-0x6FAA # <CJK>
-0x6FB1 # <CJK>
-0x6FB3 # <CJK>
-0x6FB9 # <CJK>
0x6FC0 # <CJK>
0x6FC1 # <CJK>
-0x6FC2 # <CJK>
0x6FC3 # <CJK>
-0x6FC6 # <CJK>
-0x6FD4 # <CJK>
-0x6FD5 # <CJK>
-0x6FD8 # <CJK>
-0x6FDB # <CJK>
-0x6FDF # <CJK>
-0x6FE0 # <CJK>
-0x6FE1 # <CJK>
-0x6FE4 # <CJK>
0x6FEB # <CJK>
-0x6FEC # <CJK>
-0x6FEE # <CJK>
0x6FEF # <CJK>
-0x6FF1 # <CJK>
-0x6FF3 # <CJK>
-0x6FF6 # <CJK>
-0x6FFA # <CJK>
-0x6FFE # <CJK>
-0x7001 # <CJK>
-0x7009 # <CJK>
-0x700B # <CJK>
-0x700F # <CJK>
-0x7011 # <CJK>
-0x7015 # <CJK>
-0x7018 # <CJK>
-0x701A # <CJK>
-0x701B # <CJK>
-0x701D # <CJK>
-0x701E # <CJK>
-0x701F # <CJK>
-0x7026 # <CJK>
-0x7027 # <CJK>
0x702C # <CJK>
-0x7030 # <CJK>
-0x7032 # <CJK>
-0x703E # <CJK>
-0x704C # <CJK>
-0x7051 # <CJK>
-0x7058 # <CJK>
-0x7063 # <CJK>
0x706B # <CJK>
0x706F # <CJK>
0x7070 # <CJK>
-0x7078 # <CJK>
-0x707C # <CJK>
0x707D # <CJK>
0x7089 # <CJK>
0x708A # <CJK>
0x708E # <CJK>
-0x7092 # <CJK>
-0x7099 # <CJK>
-0x70AC # <CJK>
0x70AD # <CJK>
-0x70AE # <CJK>
-0x70AF # <CJK>
-0x70B3 # <CJK>
-0x70B8 # <CJK>
0x70B9 # <CJK>
0x70BA # <CJK>
0x70C8 # <CJK>
-0x70CB # <CJK>
-0x70CF # <CJK>
-0x70D9 # <CJK>
-0x70DD # <CJK>
-0x70DF # <CJK>
-0x70F1 # <CJK>
-0x70F9 # <CJK>
-0x70FD # <CJK>
-0x7109 # <CJK>
-0x7114 # <CJK>
-0x7119 # <CJK>
-0x711A # <CJK>
-0x711C # <CJK>
0x7121 # <CJK>
0x7126 # <CJK>
0x7136 # <CJK>
0x713C # <CJK>
-0x7149 # <CJK>
-0x714C # <CJK>
0x714E # <CJK>
-0x7155 # <CJK>
-0x7156 # <CJK>
0x7159 # <CJK>
-0x7162 # <CJK>
-0x7164 # <CJK>
-0x7165 # <CJK>
-0x7166 # <CJK>
0x7167 # <CJK>
0x7169 # <CJK>
-0x716C # <CJK>
0x716E # <CJK>
-0x717D # <CJK>
-0x7184 # <CJK>
-0x7188 # <CJK>
0x718A # <CJK>
-0x718F # <CJK>
-0x7194 # <CJK>
-0x7195 # <CJK>
-#0x7199 # <CJK> # not in kochi fonts
0x719F # <CJK>
-0x71A8 # <CJK>
-0x71AC # <CJK>
0x71B1 # <CJK>
-0x71B9 # <CJK>
-0x71BE # <CJK>
0x71C3 # <CJK>
-0x71C8 # <CJK>
-0x71C9 # <CJK>
-0x71CE # <CJK>
-0x71D0 # <CJK>
-0x71D2 # <CJK>
-0x71D4 # <CJK>
-0x71D5 # <CJK>
-0x71D7 # <CJK>
-0x71DF # <CJK>
-0x71E0 # <CJK>
0x71E5 # <CJK>
-0x71E6 # <CJK>
-0x71E7 # <CJK>
-0x71EC # <CJK>
-0x71ED # <CJK>
-0x71EE # <CJK>
-0x71F5 # <CJK>
-0x71F9 # <CJK>
-0x71FB # <CJK>
-0x71FC # <CJK>
-0x71FF # <CJK>
0x7206 # <CJK>
-0x720D # <CJK>
-0x7210 # <CJK>
-0x721B # <CJK>
-0x7228 # <CJK>
0x722A # <CJK>
-0x722C # <CJK>
-0x722D # <CJK>
-0x7230 # <CJK>
-0x7232 # <CJK>
0x7235 # <CJK>
0x7236 # <CJK>
-0x723A # <CJK>
-0x723B # <CJK>
-0x723C # <CJK>
0x723D # <CJK>
-0x723E # <CJK>
-0x723F # <CJK>
-0x7240 # <CJK>
-0x7246 # <CJK>
0x7247 # <CJK>
0x7248 # <CJK>
-0x724B # <CJK>
-0x724C # <CJK>
-0x7252 # <CJK>
-0x7258 # <CJK>
0x7259 # <CJK>
0x725B # <CJK>
-0x725D # <CJK>
-0x725F # <CJK>
-0x7261 # <CJK>
-0x7262 # <CJK>
0x7267 # <CJK>
0x7269 # <CJK>
0x7272 # <CJK>
-0x7274 # <CJK>
0x7279 # <CJK>
-0x727D # <CJK>
-0x727E # <CJK>
-0x7280 # <CJK>
-0x7281 # <CJK>
-0x7282 # <CJK>
-0x7287 # <CJK>
-0x7292 # <CJK>
-0x7296 # <CJK>
0x72A0 # <CJK>
-0x72A2 # <CJK>
-0x72A7 # <CJK>
0x72AC # <CJK>
0x72AF # <CJK>
-0x72B2 # <CJK>
0x72B6 # <CJK>
-0x72B9 # <CJK>
0x72C2 # <CJK>
-0x72C3 # <CJK>
-0x72C4 # <CJK>
-0x72C6 # <CJK>
-0x72CE # <CJK>
-0x72D0 # <CJK>
-0x72D2 # <CJK>
-0x72D7 # <CJK>
0x72D9 # <CJK>
-0x72DB # <CJK>
-0x72E0 # <CJK>
-0x72E1 # <CJK>
-0x72E2 # <CJK>
0x72E9 # <CJK>
0x72EC # <CJK>
0x72ED # <CJK>
-0x72F7 # <CJK>
-0x72F8 # <CJK>
-0x72F9 # <CJK>
-0x72FC # <CJK>
-0x72FD # <CJK>
-0x730A # <CJK>
-0x7316 # <CJK>
-0x7317 # <CJK>
0x731B # <CJK>
-0x731C # <CJK>
-0x731D # <CJK>
0x731F # <CJK>
-0x7325 # <CJK>
-0x7329 # <CJK>
-0x732A # <CJK>
0x732B # <CJK>
0x732E # <CJK>
-0x732F # <CJK>
-0x7334 # <CJK>
0x7336 # <CJK>
-0x7337 # <CJK>
-0x733E # <CJK>
0x733F # <CJK>
0x7344 # <CJK>
-0x7345 # <CJK>
-0x734E # <CJK>
-0x734F # <CJK>
-0x7357 # <CJK>
0x7363 # <CJK>
-0x7368 # <CJK>
-0x736A # <CJK>
-0x7370 # <CJK>
0x7372 # <CJK>
-0x7375 # <CJK>
-0x7378 # <CJK>
-0x737A # <CJK>
-0x737B # <CJK>
0x7384 # <CJK>
0x7387 # <CJK>
0x7389 # <CJK>
0x738B # <CJK>
-0x7396 # <CJK>
0x73A9 # <CJK>
-0x73B2 # <CJK>
-0x73B3 # <CJK>
-0x73BB # <CJK>
-0x73C0 # <CJK>
-0x73C2 # <CJK>
-0x73C8 # <CJK>
-0x73CA # <CJK>
0x73CD # <CJK>
-0x73CE # <CJK>
-0x73DE # <CJK>
0x73E0 # <CJK>
-0x73E5 # <CJK>
-0x73EA # <CJK>
0x73ED # <CJK>
-0x73EE # <CJK>
-0x73F1 # <CJK>
-0x73F8 # <CJK>
0x73FE # <CJK>
0x7403 # <CJK>
-0x7405 # <CJK>
0x7406 # <CJK>
-0x7409 # <CJK>
-0x7422 # <CJK>
-0x7425 # <CJK>
-0x7432 # <CJK>
-0x7433 # <CJK>
0x7434 # <CJK>
-0x7435 # <CJK>
-0x7436 # <CJK>
-0x743A # <CJK>
-0x743F # <CJK>
-0x7441 # <CJK>
-0x7455 # <CJK>
-0x7459 # <CJK>
-0x745A # <CJK>
-0x745B # <CJK>
-0x745C # <CJK>
-0x745E # <CJK>
-0x745F # <CJK>
0x7460 # <CJK>
-0x7463 # <CJK>
-0x7464 # <CJK>
-0x7469 # <CJK>
-0x746A # <CJK>
-0x746F # <CJK>
-0x7470 # <CJK>
-0x7473 # <CJK>
-0x7476 # <CJK>
-0x747E # <CJK>
0x7483 # <CJK>
-0x748B # <CJK>
-0x749E # <CJK>
-0x74A2 # <CJK>
0x74A7 # <CJK>
0x74B0 # <CJK>
0x74BD # <CJK>
-0x74CA # <CJK>
-0x74CF # <CJK>
-0x74D4 # <CJK>
-0x74DC # <CJK>
-0x74E0 # <CJK>
-0x74E2 # <CJK>
-0x74E3 # <CJK>
0x74E6 # <CJK>
-0x74E7 # <CJK>
-0x74E9 # <CJK>
-0x74EE # <CJK>
-0x74F0 # <CJK>
-0x74F1 # <CJK>
-0x74F2 # <CJK>
0x74F6 # <CJK>
-0x74F7 # <CJK>
-0x74F8 # <CJK>
-0x7503 # <CJK>
-0x7504 # <CJK>
-0x7505 # <CJK>
-0x750C # <CJK>
-0x750D # <CJK>
-0x750E # <CJK>
-0x7511 # <CJK>
-0x7513 # <CJK>
-0x7515 # <CJK>
0x7518 # <CJK>
0x751A # <CJK>
-0x751C # <CJK>
-0x751E # <CJK>
0x751F # <CJK>
0x7523 # <CJK>
-0x7525 # <CJK>
-0x7526 # <CJK>
0x7528 # <CJK>
-0x752B # <CJK>
-0x752C # <CJK>
0x7530 # <CJK>
0x7531 # <CJK>
0x7532 # <CJK>
0x7533 # <CJK>
0x7537 # <CJK>
-0x7538 # <CJK>
0x753A # <CJK>
0x753B # <CJK>
-0x753C # <CJK>
-0x7544 # <CJK>
-0x7546 # <CJK>
-0x7549 # <CJK>
-0x754A # <CJK>
-0x754B # <CJK>
0x754C # <CJK>
-0x754D # <CJK>
0x754F # <CJK>
0x7551 # <CJK>
0x7554 # <CJK>
0x7559 # <CJK>
-0x755A # <CJK>
-0x755B # <CJK>
0x755C # <CJK>
0x755D # <CJK>
-0x7560 # <CJK>
-0x7562 # <CJK>
-0x7564 # <CJK>
0x7565 # <CJK>
-0x7566 # <CJK>
-0x7567 # <CJK>
-0x7569 # <CJK>
0x756A # <CJK>
-0x756B # <CJK>
-0x756D # <CJK>
0x7570 # <CJK>
0x7573 # <CJK>
-0x7574 # <CJK>
-0x7576 # <CJK>
-0x7577 # <CJK>
-0x7578 # <CJK>
0x757F # <CJK>
-0x7582 # <CJK>
-0x7586 # <CJK>
-0x7587 # <CJK>
-0x7589 # <CJK>
-0x758A # <CJK>
-0x758B # <CJK>
0x758E # <CJK>
-0x758F # <CJK>
0x7591 # <CJK>
-0x7594 # <CJK>
-0x759A # <CJK>
-0x759D # <CJK>
-0x75A3 # <CJK>
-0x75A5 # <CJK>
0x75AB # <CJK>
-0x75B1 # <CJK>
0x75B2 # <CJK>
-0x75B3 # <CJK>
-0x75B5 # <CJK>
-0x75B8 # <CJK>
-0x75B9 # <CJK>
-0x75BC # <CJK>
-0x75BD # <CJK>
0x75BE # <CJK>
-0x75C2 # <CJK>
-0x75C3 # <CJK>
0x75C5 # <CJK>
0x75C7 # <CJK>
-0x75CA # <CJK>
-0x75CD # <CJK>
-0x75D2 # <CJK>
-0x75D4 # <CJK>
0x75D5 # <CJK>
0x75D8 # <CJK>
-0x75D9 # <CJK>
0x75DB # <CJK>
-0x75DE # <CJK>
0x75E2 # <CJK>
-0x75E3 # <CJK>
0x75E9 # <CJK>
-0x75F0 # <CJK>
-0x75F2 # <CJK>
-0x75F3 # <CJK>
0x75F4 # <CJK>
-0x75FA # <CJK>
-0x75FC # <CJK>
-0x75FE # <CJK>
-0x75FF # <CJK>
-0x7601 # <CJK>
-0x7609 # <CJK>
-0x760B # <CJK>
0x760D # <CJK>
-0x761F # <CJK>
-0x7620 # <CJK>
-0x7621 # <CJK>
-0x7622 # <CJK>
-0x7624 # <CJK>
-0x7627 # <CJK>
-0x7630 # <CJK>
-0x7634 # <CJK>
-0x763B # <CJK>
0x7642 # <CJK>
-0x7646 # <CJK>
-0x7647 # <CJK>
-0x7648 # <CJK>
-0x764C # <CJK>
0x7652 # <CJK>
0x7656 # <CJK>
-0x7658 # <CJK>
-0x765C # <CJK>
-0x7661 # <CJK>
-0x7662 # <CJK>
-0x7667 # <CJK>
-0x7668 # <CJK>
-0x7669 # <CJK>
-0x766A # <CJK>
-0x766C # <CJK>
-0x7670 # <CJK>
-0x7672 # <CJK>
-0x7676 # <CJK>
-0x7678 # <CJK>
0x767A # <CJK>
0x767B # <CJK>
-0x767C # <CJK>
0x767D # <CJK>
0x767E # <CJK>
-0x7680 # <CJK>
-0x7683 # <CJK>
0x7684 # <CJK>
0x7686 # <CJK>
0x7687 # <CJK>
-0x7688 # <CJK>
-0x768B # <CJK>
-0x768E # <CJK>
-0x7690 # <CJK>
-0x7693 # <CJK>
-0x7696 # <CJK>
-0x7699 # <CJK>
-0x769A # <CJK>
0x76AE # <CJK>
-0x76B0 # <CJK>
-0x76B4 # <CJK>
-0x76B7 # <CJK>
-0x76B8 # <CJK>
-0x76B9 # <CJK>
-0x76BA # <CJK>
0x76BF # <CJK>
-0x76C2 # <CJK>
-0x76C3 # <CJK>
0x76C6 # <CJK>
-0x76C8 # <CJK>
0x76CA # <CJK>
-0x76CD # <CJK>
-0x76D2 # <CJK>
-0x76D6 # <CJK>
0x76D7 # <CJK>
0x76DB # <CJK>
-0x76DC # <CJK>
-0x76DE # <CJK>
0x76DF # <CJK>
-0x76E1 # <CJK>
0x76E3 # <CJK>
0x76E4 # <CJK>
-0x76E5 # <CJK>
-0x76E7 # <CJK>
-0x76EA # <CJK>
0x76EE # <CJK>
0x76F2 # <CJK>
0x76F4 # <CJK>
0x76F8 # <CJK>
-0x76FB # <CJK>
0x76FE # <CJK>
0x7701 # <CJK>
-0x7704 # <CJK>
-0x7707 # <CJK>
-0x7708 # <CJK>
0x7709 # <CJK>
0x770B # <CJK>
0x770C # <CJK>
-0x771B # <CJK>
-0x771E # <CJK>
0x771F # <CJK>
0x7720 # <CJK>
-0x7724 # <CJK>
-0x7725 # <CJK>
-0x7726 # <CJK>
-0x7729 # <CJK>
-0x7737 # <CJK>
-0x7738 # <CJK>
0x773A # <CJK>
0x773C # <CJK>
0x7740 # <CJK>
-0x7747 # <CJK>
-0x775A # <CJK>
-0x775B # <CJK>
0x7761 # <CJK>
0x7763 # <CJK>
-0x7765 # <CJK>
0x7766 # <CJK>
-0x7768 # <CJK>
-0x776B # <CJK>
-0x7779 # <CJK>
-0x777E # <CJK>
-0x777F # <CJK>
-0x778B # <CJK>
-0x778E # <CJK>
-0x7791 # <CJK>
-0x779E # <CJK>
-0x77A0 # <CJK>
-0x77A5 # <CJK>
0x77AC # <CJK>
0x77AD # <CJK>
-0x77B0 # <CJK>
0x77B3 # <CJK>
-0x77B6 # <CJK>
-0x77B9 # <CJK>
-0x77BB # <CJK>
-0x77BC # <CJK>
-0x77BD # <CJK>
-0x77BF # <CJK>
-0x77C7 # <CJK>
-0x77CD # <CJK>
-0x77D7 # <CJK>
-0x77DA # <CJK>
0x77DB # <CJK>
-0x77DC # <CJK>
0x77E2 # <CJK>
-0x77E3 # <CJK>
0x77E5 # <CJK>
-0x77E7 # <CJK>
-0x77E9 # <CJK>
0x77ED # <CJK>
-0x77EE # <CJK>
0x77EF # <CJK>
0x77F3 # <CJK>
-0x77FC # <CJK>
0x7802 # <CJK>
-0x780C # <CJK>
-0x7812 # <CJK>
0x7814 # <CJK>
0x7815 # <CJK>
-0x7820 # <CJK>
-0x7825 # <CJK>
-0x7826 # <CJK>
-0x7827 # <CJK>
0x7832 # <CJK>
0x7834 # <CJK>
-0x783A # <CJK>
-0x783F # <CJK>
-0x7845 # <CJK>
0x785D # <CJK>
0x786B # <CJK>
0x786C # <CJK>
-0x786F # <CJK>
-0x7872 # <CJK>
-0x7874 # <CJK>
-0x787C # <CJK>
0x7881 # <CJK>
-0x7886 # <CJK>
-0x7887 # <CJK>
-0x788C # <CJK>
-0x788D # <CJK>
-0x788E # <CJK>
0x7891 # <CJK>
-0x7893 # <CJK>
-0x7895 # <CJK>
-0x7897 # <CJK>
-0x789A # <CJK>
-0x78A3 # <CJK>
-0x78A7 # <CJK>
-0x78A9 # <CJK>
-0x78AA # <CJK>
-0x78AF # <CJK>
-0x78B5 # <CJK>
0x78BA # <CJK>
-0x78BC # <CJK>
-0x78BE # <CJK>
0x78C1 # <CJK>
-0x78C5 # <CJK>
-0x78C6 # <CJK>
-0x78CA # <CJK>
-0x78CB # <CJK>
-0x78D0 # <CJK>
-0x78D1 # <CJK>
-0x78D4 # <CJK>
-0x78DA # <CJK>
-0x78E7 # <CJK>
0x78E8 # <CJK>
-0x78EC # <CJK>
-0x78EF # <CJK>
-0x78F4 # <CJK>
-0x78FD # <CJK>
0x7901 # <CJK>
-0x7907 # <CJK>
0x790E # <CJK>
-0x7911 # <CJK>
-0x7912 # <CJK>
-0x7919 # <CJK>
-0x7926 # <CJK>
-0x792A # <CJK>
-0x792B # <CJK>
-0x792C # <CJK>
0x793A # <CJK>
0x793C # <CJK>
0x793E # <CJK>
-0x7940 # <CJK>
-0x7941 # <CJK>
-0x7947 # <CJK>
0x7948 # <CJK>
0x7949 # <CJK>
-0x7950 # <CJK>
-0x7953 # <CJK>
-0x7955 # <CJK>
0x7956 # <CJK>
-0x7957 # <CJK>
-0x795A # <CJK>
0x795D # <CJK>
0x795E # <CJK>
-0x795F # <CJK>
-0x7960 # <CJK>
-0x7962 # <CJK>
0x7965 # <CJK>
0x7968 # <CJK>
0x796D # <CJK>
-0x7977 # <CJK>
-0x797A # <CJK>
-0x797F # <CJK>
-0x7980 # <CJK>
0x7981 # <CJK>
-0x7984 # <CJK>
0x7985 # <CJK>
-0x798A # <CJK>
0x798D # <CJK>
-0x798E # <CJK>
0x798F # <CJK>
-0x799D # <CJK>
-0x79A6 # <CJK>
-0x79A7 # <CJK>
-0x79AA # <CJK>
-0x79AE # <CJK>
-0x79B0 # <CJK>
-0x79B3 # <CJK>
-0x79B9 # <CJK>
-0x79BA # <CJK>
-0x79BD # <CJK>
-0x79BE # <CJK>
-0x79BF # <CJK>
0x79C0 # <CJK>
0x79C1 # <CJK>
-0x79C9 # <CJK>
0x79CB # <CJK>
0x79D1 # <CJK>
0x79D2 # <CJK>
-0x79D5 # <CJK>
0x79D8 # <CJK>
0x79DF # <CJK>
-0x79E1 # <CJK>
-0x79E3 # <CJK>
-0x79E4 # <CJK>
-0x79E6 # <CJK>
-0x79E7 # <CJK>
0x79E9 # <CJK>
-0x79EC # <CJK>
0x79F0 # <CJK>
0x79FB # <CJK>
-0x7A00 # <CJK>
-0x7A08 # <CJK>
0x7A0B # <CJK>
-0x7A0D # <CJK>
0x7A0E # <CJK>
-0x7A14 # <CJK>
-0x7A17 # <CJK>
-0x7A18 # <CJK>
-0x7A19 # <CJK>
0x7A1A # <CJK>
-0x7A1C # <CJK>
-0x7A1F # <CJK>
-0x7A20 # <CJK>
0x7A2E # <CJK>
-0x7A31 # <CJK>
0x7A32 # <CJK>
-0x7A37 # <CJK>
-0x7A3B # <CJK>
0x7A3C # <CJK>
0x7A3D # <CJK>
-0x7A3E # <CJK>
0x7A3F # <CJK>
0x7A40 # <CJK>
0x7A42 # <CJK>
-0x7A43 # <CJK>
-0x7A46 # <CJK>
-0x7A49 # <CJK>
0x7A4D # <CJK>
-0x7A4E # <CJK>
0x7A4F # <CJK>
-0x7A50 # <CJK>
-0x7A57 # <CJK>
-0x7A61 # <CJK>
-0x7A62 # <CJK>
-0x7A63 # <CJK>
-0x7A69 # <CJK>
0x7A6B # <CJK>
-0x7A70 # <CJK>
0x7A74 # <CJK>
0x7A76 # <CJK>
-0x7A79 # <CJK>
0x7A7A # <CJK>
-0x7A7D # <CJK>
-0x7A7F # <CJK>
0x7A81 # <CJK>
0x7A83 # <CJK>
-0x7A84 # <CJK>
-0x7A88 # <CJK>
0x7A92 # <CJK>
0x7A93 # <CJK>
-0x7A95 # <CJK>
-0x7A96 # <CJK>
-0x7A97 # <CJK>
-0x7A98 # <CJK>
0x7A9F # <CJK>
-0x7AA9 # <CJK>
-0x7AAA # <CJK>
0x7AAE # <CJK>
0x7AAF # <CJK>
-0x7AB0 # <CJK>
-0x7AB6 # <CJK>
-0x7ABA # <CJK>
-0x7ABF # <CJK>
-0x7AC3 # <CJK>
-0x7AC4 # <CJK>
-0x7AC5 # <CJK>
-0x7AC7 # <CJK>
-0x7AC8 # <CJK>
-0x7ACA # <CJK>
0x7ACB # <CJK>
-0x7ACD # <CJK>
-0x7ACF # <CJK>
-0x7AD2 # <CJK>
-0x7AD3 # <CJK>
-0x7AD5 # <CJK>
-0x7AD9 # <CJK>
-0x7ADA # <CJK>
0x7ADC # <CJK>
-0x7ADD # <CJK>
-0x7ADF # <CJK>
0x7AE0 # <CJK>
-0x7AE1 # <CJK>
-0x7AE2 # <CJK>
-0x7AE3 # <CJK>
0x7AE5 # <CJK>
-0x7AE6 # <CJK>
-0x7AEA # <CJK>
-0x7AED # <CJK>
0x7AEF # <CJK>
-0x7AF0 # <CJK>
0x7AF6 # <CJK>
-0x7AF8 # <CJK>
0x7AF9 # <CJK>
-0x7AFA # <CJK>
-0x7AFF # <CJK>
-0x7B02 # <CJK>
-0x7B04 # <CJK>
-0x7B06 # <CJK>
-0x7B08 # <CJK>
-0x7B0A # <CJK>
-0x7B0B # <CJK>
-0x7B0F # <CJK>
0x7B11 # <CJK>
-0x7B18 # <CJK>
-0x7B19 # <CJK>
0x7B1B # <CJK>
-0x7B1E # <CJK>
-0x7B20 # <CJK>
-0x7B25 # <CJK>
0x7B26 # <CJK>
-0x7B28 # <CJK>
0x7B2C # <CJK>
-0x7B33 # <CJK>
-0x7B35 # <CJK>
-0x7B36 # <CJK>
-0x7B39 # <CJK>
-0x7B45 # <CJK>
0x7B46 # <CJK>
-0x7B48 # <CJK>
0x7B49 # <CJK>
0x7B4B # <CJK>
-0x7B4C # <CJK>
-0x7B4D # <CJK>
-0x7B4F # <CJK>
-0x7B50 # <CJK>
-0x7B51 # <CJK>
0x7B52 # <CJK>
0x7B54 # <CJK>
0x7B56 # <CJK>
-0x7B5D # <CJK>
-0x7B65 # <CJK>
-0x7B67 # <CJK>
-0x7B6C # <CJK>
-0x7B6E # <CJK>
-0x7B70 # <CJK>
-0x7B71 # <CJK>
-0x7B74 # <CJK>
-0x7B75 # <CJK>
-0x7B7A # <CJK>
-0x7B86 # <CJK>
0x7B87 # <CJK>
0x7B8B # <CJK>
-0x7B8D # <CJK>
-0x7B8F # <CJK>
-0x7B92 # <CJK>
-0x7B94 # <CJK>
-0x7B95 # <CJK>
0x7B97 # <CJK>
-0x7B98 # <CJK>
-0x7B99 # <CJK>
-0x7B9A # <CJK>
-0x7B9C # <CJK>
-0x7B9D # <CJK>
-0x7B9F # <CJK>
0x7BA1 # <CJK>
-0x7BAA # <CJK>
-0x7BAD # <CJK>
0x7BB1 # <CJK>
-0x7BB4 # <CJK>
0x7BB8 # <CJK>
0x7BC0 # <CJK>
-0x7BC1 # <CJK>
0x7BC4 # <CJK>
-0x7BC6 # <CJK>
-0x7BC7 # <CJK>
0x7BC9 # <CJK>
-0x7BCB # <CJK>
-0x7BCC # <CJK>
-0x7BCF # <CJK>
-0x7BDD # <CJK>
-0x7BE0 # <CJK>
0x7BE4 # <CJK>
-0x7BE5 # <CJK>
-0x7BE6 # <CJK>
-0x7BE9 # <CJK>
-0x7BED # <CJK>
-0x7BF3 # <CJK>
-0x7BF6 # <CJK>
-0x7BF7 # <CJK>
-0x7C00 # <CJK>
-0x7C07 # <CJK>
-0x7C0D # <CJK>
-0x7C11 # <CJK>
-0x7C12 # <CJK>
-0x7C13 # <CJK>
-0x7C14 # <CJK>
-0x7C17 # <CJK>
-0x7C1F # <CJK>
0x7C21 # <CJK>
-0x7C23 # <CJK>
-0x7C27 # <CJK>
-0x7C2A # <CJK>
-0x7C2B # <CJK>
-0x7C37 # <CJK>
-0x7C38 # <CJK>
-0x7C3D # <CJK>
-0x7C3E # <CJK>
0x7C3F # <CJK>
-0x7C40 # <CJK>
-0x7C43 # <CJK>
-0x7C4C # <CJK>
0x7C4D # <CJK>
-0x7C4F # <CJK>
-0x7C50 # <CJK>
-0x7C54 # <CJK>
-0x7C56 # <CJK>
-0x7C58 # <CJK>
-0x7C5F # <CJK>
0x7C60 # <CJK>
-0x7C64 # <CJK>
-0x7C65 # <CJK>
-0x7C6C # <CJK>
0x7C73 # <CJK>
-0x7C75 # <CJK>
-0x7C7E # <CJK>
-0x7C81 # <CJK>
-0x7C82 # <CJK>
-0x7C83 # <CJK>
0x7C89 # <CJK>
0x7C8B # <CJK>
-0x7C8D # <CJK>
-0x7C90 # <CJK>
0x7C92 # <CJK>
-0x7C95 # <CJK>
0x7C97 # <CJK>
0x7C98 # <CJK>
0x7C9B # <CJK>
-0x7C9F # <CJK>
-0x7CA1 # <CJK>
-0x7CA2 # <CJK>
-0x7CA4 # <CJK>
-0x7CA5 # <CJK>
0x7CA7 # <CJK>
-0x7CA8 # <CJK>
-0x7CAB # <CJK>
-0x7CAD # <CJK>
-0x7CAE # <CJK>
-0x7CB1 # <CJK>
-0x7CB2 # <CJK>
-0x7CB3 # <CJK>
-0x7CB9 # <CJK>
-0x7CBD # <CJK>
0x7CBE # <CJK>
-0x7CC0 # <CJK>
-0x7CC2 # <CJK>
-0x7CC5 # <CJK>
-0x7CCA # <CJK>
-0x7CCE # <CJK>
-0x7CD2 # <CJK>
0x7CD6 # <CJK>
-0x7CD8 # <CJK>
-0x7CDC # <CJK>
-0x7CDE # <CJK>
-0x7CDF # <CJK>
-0x7CE0 # <CJK>
-0x7CE2 # <CJK>
0x7CE7 # <CJK>
-0x7CEF # <CJK>
-0x7CF2 # <CJK>
-0x7CF4 # <CJK>
-0x7CF6 # <CJK>
0x7CF8 # <CJK>
-0x7CFA # <CJK>
0x7CFB # <CJK>
0x7CFE # <CJK>
0x7D00 # <CJK>
-0x7D02 # <CJK>
0x7D04 # <CJK>
0x7D05 # <CJK>
-0x7D06 # <CJK>
-0x7D0A # <CJK>
0x7D0B # <CJK>
0x7D0D # <CJK>
-0x7D10 # <CJK>
0x7D14 # <CJK>
-0x7D15 # <CJK>
-0x7D17 # <CJK>
-0x7D18 # <CJK>
0x7D19 # <CJK>
0x7D1A # <CJK>
0x7D1B # <CJK>
-0x7D1C # <CJK>
0x7D20 # <CJK>
0x7D21 # <CJK>
0x7D22 # <CJK>
0x7D2B # <CJK>
-0x7D2C # <CJK>
-0x7D2E # <CJK>
0x7D2F # <CJK>
0x7D30 # <CJK>
-0x7D32 # <CJK>
0x7D33 # <CJK>
-0x7D35 # <CJK>
0x7D39 # <CJK>
0x7D3A # <CJK>
-0x7D3F # <CJK>
0x7D42 # <CJK>
-0x7D43 # <CJK>
0x7D44 # <CJK>
-0x7D45 # <CJK>
-0x7D46 # <CJK>
-0x7D4B # <CJK>
0x7D4C # <CJK>
-0x7D4E # <CJK>
-0x7D4F # <CJK>
0x7D50 # <CJK>
-0x7D56 # <CJK>
-0x7D5B # <CJK>
0x7D5E # <CJK>
0x7D61 # <CJK>
-0x7D62 # <CJK>
-0x7D63 # <CJK>
0x7D66 # <CJK>
-0x7D68 # <CJK>
-0x7D6E # <CJK>
0x7D71 # <CJK>
-0x7D72 # <CJK>
-0x7D73 # <CJK>
0x7D75 # <CJK>
0x7D76 # <CJK>
0x7D79 # <CJK>
-0x7D7D # <CJK>
-0x7D89 # <CJK>
-0x7D8F # <CJK>
-0x7D93 # <CJK>
0x7D99 # <CJK>
0x7D9A # <CJK>
-0x7D9B # <CJK>
-0x7D9C # <CJK>
-0x7D9F # <CJK>
-0x7DA2 # <CJK>
-0x7DA3 # <CJK>
-0x7DAB # <CJK>
-0x7DAC # <CJK>
0x7DAD # <CJK>
-0x7DAE # <CJK>
-0x7DAF # <CJK>
-0x7DB0 # <CJK>
0x7DB1 # <CJK>
0x7DB2 # <CJK>
-0x7DB4 # <CJK>
-0x7DB5 # <CJK>
-0x7DB8 # <CJK>
-0x7DBA # <CJK>
0x7DBB # <CJK>
-0x7DBD # <CJK>
-0x7DBE # <CJK>
0x7DBF # <CJK>
-0x7DC7 # <CJK>
0x7DCA # <CJK>
-0x7DCB # <CJK>
0x7DCF # <CJK>
0x7DD1 # <CJK>
0x7DD2 # <CJK>
-0x7DD5 # <CJK>
-0x7DD8 # <CJK>
0x7DDA # <CJK>
-0x7DDC # <CJK>
-0x7DDD # <CJK>
-0x7DDE # <CJK>
0x7DE0 # <CJK>
-0x7DE1 # <CJK>
-0x7DE4 # <CJK>
0x7DE8 # <CJK>
0x7DE9 # <CJK>
-0x7DEC # <CJK>
0x7DEF # <CJK>
-0x7DF2 # <CJK>
0x7DF4 # <CJK>
0x7DFB # <CJK>
0x7E01 # <CJK>
0x7E04 # <CJK>
-0x7E05 # <CJK>
-0x7E09 # <CJK>
-0x7E0A # <CJK>
-0x7E0B # <CJK>
-0x7E12 # <CJK>
0x7E1B # <CJK>
-0x7E1E # <CJK>
-0x7E1F # <CJK>
-0x7E21 # <CJK>
-0x7E22 # <CJK>
-0x7E23 # <CJK>
0x7E26 # <CJK>
0x7E2B # <CJK>
0x7E2E # <CJK>
-0x7E31 # <CJK>
-0x7E32 # <CJK>
-0x7E35 # <CJK>
-0x7E37 # <CJK>
-0x7E39 # <CJK>
-0x7E3A # <CJK>
-0x7E3B # <CJK>
-0x7E3D # <CJK>
0x7E3E # <CJK>
0x7E41 # <CJK>
-0x7E43 # <CJK>
-0x7E46 # <CJK>
0x7E4A # <CJK>
-0x7E4B # <CJK>
-0x7E4D # <CJK>
0x7E54 # <CJK>
0x7E55 # <CJK>
-0x7E56 # <CJK>
-0x7E59 # <CJK>
-0x7E5A # <CJK>
-0x7E5D # <CJK>
-0x7E5E # <CJK>
-0x7E66 # <CJK>
-0x7E67 # <CJK>
-0x7E69 # <CJK>
-0x7E6A # <CJK>
0x7E6D # <CJK>
0x7E70 # <CJK>
-0x7E79 # <CJK>
-0x7E7B # <CJK>
-0x7E7C # <CJK>
-0x7E7D # <CJK>
-0x7E7F # <CJK>
-0x7E82 # <CJK>
-0x7E83 # <CJK>
-0x7E88 # <CJK>
-0x7E89 # <CJK>
-0x7E8C # <CJK>
-0x7E8E # <CJK>
-0x7E8F # <CJK>
-0x7E90 # <CJK>
-0x7E92 # <CJK>
-0x7E93 # <CJK>
-0x7E94 # <CJK>
-0x7E96 # <CJK>
-0x7E9B # <CJK>
-0x7E9C # <CJK>
0x7F36 # <CJK>
-0x7F38 # <CJK>
-0x7F3A # <CJK>
-0x7F45 # <CJK>
-0x7F4C # <CJK>
-0x7F4D # <CJK>
-0x7F4E # <CJK>
-0x7F50 # <CJK>
-0x7F51 # <CJK>
-0x7F54 # <CJK>
-0x7F55 # <CJK>
-0x7F58 # <CJK>
-0x7F5F # <CJK>
-0x7F60 # <CJK>
-0x7F67 # <CJK>
-0x7F68 # <CJK>
-0x7F69 # <CJK>
0x7F6A # <CJK>
-0x7F6B # <CJK>
0x7F6E # <CJK>
0x7F70 # <CJK>
0x7F72 # <CJK>
0x7F75 # <CJK>
0x7F77 # <CJK>
-0x7F78 # <CJK>
-0x7F79 # <CJK>
-0x7F82 # <CJK>
-0x7F83 # <CJK>
0x7F85 # <CJK>
-0x7F86 # <CJK>
-0x7F87 # <CJK>
-0x7F88 # <CJK>
0x7F8A # <CJK>
-0x7F8C # <CJK>
0x7F8E # <CJK>
-0x7F94 # <CJK>
-0x7F9A # <CJK>
-0x7F9D # <CJK>
0x7F9E # <CJK>
-0x7FA3 # <CJK>
0x7FA4 # <CJK>
0x7FA8 # <CJK>
0x7FA9 # <CJK>
-0x7FAE # <CJK>
-0x7FAF # <CJK>
-0x7FB2 # <CJK>
-0x7FB6 # <CJK>
-0x7FB8 # <CJK>
-0x7FB9 # <CJK>
0x7FBD # <CJK>
0x7FC1 # <CJK>
-0x7FC5 # <CJK>
-0x7FC6 # <CJK>
-0x7FCA # <CJK>
0x7FCC # <CJK>
0x7FD2 # <CJK>
-0x7FD4 # <CJK>
-0x7FD5 # <CJK>
-0x7FE0 # <CJK>
-0x7FE1 # <CJK>
-0x7FE6 # <CJK>
-0x7FE9 # <CJK>
-0x7FEB # <CJK>
-0x7FF0 # <CJK>
-0x7FF3 # <CJK>
-0x7FF9 # <CJK>
0x7FFB # <CJK>
0x7FFC # <CJK>
-0x8000 # <CJK>
0x8001 # <CJK>
0x8003 # <CJK>
-0x8004 # <CJK>
0x8005 # <CJK>
-0x8006 # <CJK>
-0x800B # <CJK>
-0x800C # <CJK>
0x8010 # <CJK>
-0x8012 # <CJK>
0x8015 # <CJK>
0x8017 # <CJK>
-0x8018 # <CJK>
-0x8019 # <CJK>
-0x801C # <CJK>
-0x8021 # <CJK>
-0x8028 # <CJK>
0x8033 # <CJK>
-0x8036 # <CJK>
-0x803B # <CJK>
-0x803D # <CJK>
-0x803F # <CJK>
-0x8046 # <CJK>
-0x804A # <CJK>
-0x8052 # <CJK>
0x8056 # <CJK>
-0x8058 # <CJK>
-0x805A # <CJK>
0x805E # <CJK>
-0x805F # <CJK>
-0x8061 # <CJK>
-0x8062 # <CJK>
-0x8068 # <CJK>
-0x806F # <CJK>
-0x8070 # <CJK>
-0x8072 # <CJK>
-0x8073 # <CJK>
0x8074 # <CJK>
-0x8076 # <CJK>
0x8077 # <CJK>
-0x8079 # <CJK>
-0x807D # <CJK>
-0x807E # <CJK>
-0x807F # <CJK>
-0x8084 # <CJK>
-0x8085 # <CJK>
-0x8086 # <CJK>
-0x8087 # <CJK>
0x8089 # <CJK>
-0x808B # <CJK>
0x808C # <CJK>
-0x8093 # <CJK>
0x8096 # <CJK>
0x8098 # <CJK>
-0x809A # <CJK>
-0x809B # <CJK>
0x809D # <CJK>
0x80A1 # <CJK>
0x80A2 # <CJK>
0x80A5 # <CJK>
0x80A9 # <CJK>
0x80AA # <CJK>
-0x80AC # <CJK>
-0x80AD # <CJK>
0x80AF # <CJK>
-0x80B1 # <CJK>
0x80B2 # <CJK>
-0x80B4 # <CJK>
0x80BA # <CJK>
0x80C3 # <CJK>
-0x80C4 # <CJK>
0x80C6 # <CJK>
0x80CC # <CJK>
0x80CE # <CJK>
-0x80D6 # <CJK>
-0x80D9 # <CJK>
-0x80DA # <CJK>
-0x80DB # <CJK>
-0x80DD # <CJK>
0x80DE # <CJK>
-0x80E1 # <CJK>
-0x80E4 # <CJK>
-0x80E5 # <CJK>
-0x80EF # <CJK>
-0x80F1 # <CJK>
0x80F4 # <CJK>
0x80F8 # <CJK>
-0x80FC # <CJK>
0x80FD # <CJK>
0x8102 # <CJK>
0x8105 # <CJK>
-0x8106 # <CJK>
0x8107 # <CJK>
0x8108 # <CJK>
-0x8109 # <CJK>
0x810A # <CJK>
0x811A # <CJK>
-0x811B # <CJK>
-0x8123 # <CJK>
-0x8129 # <CJK>
-0x812F # <CJK>
0x8131 # <CJK>
0x8133 # <CJK>
-0x8139 # <CJK>
-0x813E # <CJK>
-0x8146 # <CJK>
-0x814B # <CJK>
0x814E # <CJK>
0x8150 # <CJK>
-0x8151 # <CJK>
-0x8153 # <CJK>
-0x8154 # <CJK>
0x8155 # <CJK>
-0x815F # <CJK>
-0x8165 # <CJK>
-0x8166 # <CJK>
0x816B # <CJK>
-0x816E # <CJK>
0x8170 # <CJK>
-0x8171 # <CJK>
-0x8174 # <CJK>
0x8178 # <CJK>
0x8179 # <CJK>
0x817A # <CJK>
-0x817F # <CJK>
-0x8180 # <CJK>
-0x8182 # <CJK>
-0x8183 # <CJK>
-0x8188 # <CJK>
-0x818A # <CJK>
-0x818F # <CJK>
-0x8193 # <CJK>
-0x8195 # <CJK>
0x819A # <CJK>
0x819C # <CJK>
0x819D # <CJK>
-0x81A0 # <CJK>
-0x81A3 # <CJK>
-0x81A4 # <CJK>
0x81A8 # <CJK>
-0x81A9 # <CJK>
-0x81B0 # <CJK>
0x81B3 # <CJK>
-0x81B5 # <CJK>
-0x81B8 # <CJK>
-0x81BA # <CJK>
-0x81BD # <CJK>
-0x81BE # <CJK>
-0x81BF # <CJK>
-0x81C0 # <CJK>
-0x81C2 # <CJK>
0x81C6 # <CJK>
-0x81C8 # <CJK>
-0x81C9 # <CJK>
-0x81CD # <CJK>
-0x81D1 # <CJK>
0x81D3 # <CJK>
-0x81D8 # <CJK>
-0x81D9 # <CJK>
-0x81DA # <CJK>
-0x81DF # <CJK>
-0x81E0 # <CJK>
0x81E3 # <CJK>
-0x81E5 # <CJK>
-0x81E7 # <CJK>
0x81E8 # <CJK>
0x81EA # <CJK>
0x81ED # <CJK>
0x81F3 # <CJK>
0x81F4 # <CJK>
-0x81FA # <CJK>
-0x81FB # <CJK>
0x81FC # <CJK>
-0x81FE # <CJK>
-0x8201 # <CJK>
-0x8202 # <CJK>
-0x8205 # <CJK>
-0x8207 # <CJK>
0x8208 # <CJK>
-0x8209 # <CJK>
-0x820A # <CJK>
0x820C # <CJK>
-0x820D # <CJK>
0x820E # <CJK>
-0x8210 # <CJK>
-0x8212 # <CJK>
-0x8216 # <CJK>
0x8217 # <CJK>
-0x8218 # <CJK>
-0x821B # <CJK>
-0x821C # <CJK>
0x821E # <CJK>
0x821F # <CJK>
-0x8229 # <CJK>
0x822A # <CJK>
-0x822B # <CJK>
0x822C # <CJK>
-0x822E # <CJK>
-0x8233 # <CJK>
-0x8235 # <CJK>
0x8236 # <CJK>
0x8237 # <CJK>
-0x8238 # <CJK>
0x8239 # <CJK>
-0x8240 # <CJK>
0x8247 # <CJK>
-0x8258 # <CJK>
-0x8259 # <CJK>
-0x825A # <CJK>
-0x825D # <CJK>
-0x825F # <CJK>
-0x8262 # <CJK>
-0x8264 # <CJK>
0x8266 # <CJK>
-0x8268 # <CJK>
-0x826A # <CJK>
-0x826B # <CJK>
-0x826E # <CJK>
0x826F # <CJK>
-0x8271 # <CJK>
0x8272 # <CJK>
0x8276 # <CJK>
-0x8277 # <CJK>
-0x8278 # <CJK>
-0x827E # <CJK>
0x828B # <CJK>
-0x828D # <CJK>
-0x8292 # <CJK>
-0x8299 # <CJK>
0x829D # <CJK>
-0x829F # <CJK>
-0x82A5 # <CJK>
-0x82A6 # <CJK>
-0x82AB # <CJK>
-0x82AC # <CJK>
-0x82AD # <CJK>
0x82AF # <CJK>
0x82B1 # <CJK>
0x82B3 # <CJK>
0x82B8 # <CJK>
-0x82B9 # <CJK>
-0x82BB # <CJK>
0x82BD # <CJK>
-0x82C5 # <CJK>
-0x82D1 # <CJK>
-0x82D2 # <CJK>
-0x82D3 # <CJK>
-0x82D4 # <CJK>
0x82D7 # <CJK>
-0x82D9 # <CJK>
0x82DB # <CJK>
-0x82DC # <CJK>
-0x82DE # <CJK>
-0x82DF # <CJK>
-0x82E1 # <CJK>
-0x82E3 # <CJK>
0x82E5 # <CJK>
0x82E6 # <CJK>
-0x82E7 # <CJK>
-0x82EB # <CJK>
0x82F1 # <CJK>
-0x82F3 # <CJK>
-0x82F4 # <CJK>
-0x82F9 # <CJK>
-0x82FA # <CJK>
-0x82FB # <CJK>
0x8302 # <CJK>
-0x8303 # <CJK>
-0x8304 # <CJK>
-0x8305 # <CJK>
-0x8306 # <CJK>
-0x8309 # <CJK>
0x830E # <CJK>
-0x8316 # <CJK>
-0x8317 # <CJK>
-0x8318 # <CJK>
-0x831C # <CJK>
-0x8323 # <CJK>
0x8328 # <CJK>
-0x832B # <CJK>
-0x832F # <CJK>
-0x8331 # <CJK>
-0x8332 # <CJK>
-0x8334 # <CJK>
-0x8335 # <CJK>
0x8336 # <CJK>
-0x8338 # <CJK>
-0x8339 # <CJK>
-0x8340 # <CJK>
-0x8345 # <CJK>
0x8349 # <CJK>
-0x834A # <CJK>
-0x834F # <CJK>
-0x8350 # <CJK>
0x8352 # <CJK>
0x8358 # <CJK>
-0x8373 # <CJK>
-0x8375 # <CJK>
0x8377 # <CJK>
-0x837B # <CJK>
-0x837C # <CJK>
-0x8385 # <CJK>
-0x8387 # <CJK>
-0x8389 # <CJK>
-0x838A # <CJK>
-0x838E # <CJK>
-0x8393 # <CJK>
-0x8396 # <CJK>
-0x839A # <CJK>
-0x839E # <CJK>
-0x839F # <CJK>
-0x83A0 # <CJK>
-0x83A2 # <CJK>
-0x83A8 # <CJK>
-0x83AA # <CJK>
-0x83AB # <CJK>
-0x83B1 # <CJK>
-0x83B5 # <CJK>
-0x83BD # <CJK>
-0x83C1 # <CJK>
-0x83C5 # <CJK>
0x83CA # <CJK>
0x83CC # <CJK>
-0x83CE # <CJK>
0x83D3 # <CJK>
-0x83D6 # <CJK>
-0x83D8 # <CJK>
0x83DC # <CJK>
-0x83DF # <CJK>
-0x83E0 # <CJK>
-0x83E9 # <CJK>
-0x83EB # <CJK>
0x83EF # <CJK>
-0x83F0 # <CJK>
-0x83F1 # <CJK>
-0x83F2 # <CJK>
-0x83F4 # <CJK>
-0x83F7 # <CJK>
-0x83FB # <CJK>
-0x83FD # <CJK>
-0x8403 # <CJK>
-0x8404 # <CJK>
-0x8407 # <CJK>
-0x840B # <CJK>
-0x840C # <CJK>
-0x840D # <CJK>
0x840E # <CJK>
-0x8413 # <CJK>
-0x8420 # <CJK>
-0x8422 # <CJK>
-0x8429 # <CJK>
-0x842A # <CJK>
-0x842C # <CJK>
-0x8431 # <CJK>
-0x8435 # <CJK>
-0x8438 # <CJK>
-0x843C # <CJK>
0x843D # <CJK>
-0x8446 # <CJK>
0x8449 # <CJK>
-0x844E # <CJK>
0x8457 # <CJK>
0x845B # <CJK>
-0x8461 # <CJK>
-0x8462 # <CJK>
-0x8463 # <CJK>
-0x8466 # <CJK>
-0x8469 # <CJK>
-0x846B # <CJK>
0x846C # <CJK>
-0x846D # <CJK>
-0x846E # <CJK>
-0x846F # <CJK>
-0x8471 # <CJK>
-0x8475 # <CJK>
-0x8477 # <CJK>
-0x8479 # <CJK>
-0x847A # <CJK>
-0x8482 # <CJK>
-0x8484 # <CJK>
-0x848B # <CJK>
-0x8490 # <CJK>
-0x8494 # <CJK>
-0x8499 # <CJK>
-0x849C # <CJK>
-0x849F # <CJK>
-0x84A1 # <CJK>
-0x84AD # <CJK>
-0x84B2 # <CJK>
0x84B8 # <CJK>
-0x84B9 # <CJK>
-0x84BB # <CJK>
-0x84BC # <CJK>
-0x84BF # <CJK>
-0x84C1 # <CJK>
0x84C4 # <CJK>
-0x84C6 # <CJK>
-0x84C9 # <CJK>
-0x84CA # <CJK>
0x84CB # <CJK>
-0x84CD # <CJK>
-0x84D0 # <CJK>
-0x84D1 # <CJK>
-0x84D6 # <CJK>
-0x84D9 # <CJK>
-0x84DA # <CJK>
-0x84EC # <CJK>
-0x84EE # <CJK>
-0x84F4 # <CJK>
-0x84FC # <CJK>
-0x84FF # <CJK>
-0x8500 # <CJK>
-0x8506 # <CJK>
0x8511 # <CJK>
-0x8513 # <CJK>
-0x8514 # <CJK>
-0x8515 # <CJK>
-0x8517 # <CJK>
-0x8518 # <CJK>
-0x851A # <CJK>
-0x851F # <CJK>
-0x8521 # <CJK>
-0x8526 # <CJK>
-0x852C # <CJK>
-0x852D # <CJK>
0x8535 # <CJK>
0x853D # <CJK>
-0x8540 # <CJK>
-0x8541 # <CJK>
-0x8543 # <CJK>
-0x8548 # <CJK>
-0x8549 # <CJK>
-0x854A # <CJK>
-0x854B # <CJK>
-0x854E # <CJK>
-0x8555 # <CJK>
-0x8557 # <CJK>
-0x8558 # <CJK>
-0x855A # <CJK>
-0x8563 # <CJK>
-0x8568 # <CJK>
-0x8569 # <CJK>
-0x856A # <CJK>
-0x856D # <CJK>
-0x8577 # <CJK>
-0x857E # <CJK>
-0x8580 # <CJK>
0x8584 # <CJK>
-0x8587 # <CJK>
-0x8588 # <CJK>
-0x858A # <CJK>
-0x8590 # <CJK>
-0x8591 # <CJK>
-0x8594 # <CJK>
-0x8597 # <CJK>
-0x8599 # <CJK>
-0x859B # <CJK>
-0x859C # <CJK>
-0x85A4 # <CJK>
0x85A6 # <CJK>
-0x85A8 # <CJK>
-0x85A9 # <CJK>
0x85AA # <CJK>
0x85AB # <CJK>
0x85AC # <CJK>
-0x85AE # <CJK>
-0x85AF # <CJK>
-0x85B9 # <CJK>
-0x85BA # <CJK>
-0x85C1 # <CJK>
-0x85C9 # <CJK>
0x85CD # <CJK>
-0x85CF # <CJK>
-0x85D0 # <CJK>
-0x85D5 # <CJK>
-0x85DC # <CJK>
-0x85DD # <CJK>
0x85E4 # <CJK>
-0x85E5 # <CJK>
0x85E9 # <CJK>
-0x85EA # <CJK>
-0x85F7 # <CJK>
-0x85F9 # <CJK>
-0x85FA # <CJK>
0x85FB # <CJK>
-0x85FE # <CJK>
-0x8602 # <CJK>
-0x8606 # <CJK>
-0x8607 # <CJK>
-0x860A # <CJK>
-0x860B # <CJK>
-0x8613 # <CJK>
-0x8616 # <CJK>
-0x8617 # <CJK>
-0x861A # <CJK>
-0x8622 # <CJK>
-0x862D # <CJK>
-0x862F # <CJK>
-0x8630 # <CJK>
-0x863F # <CJK>
-0x864D # <CJK>
0x864E # <CJK>
0x8650 # <CJK>
-0x8654 # <CJK>
-0x8655 # <CJK>
0x865A # <CJK>
0x865C # <CJK>
0x865E # <CJK>
-0x865F # <CJK>
-0x8667 # <CJK>
0x866B # <CJK>
-0x8671 # <CJK>
0x8679 # <CJK>
-0x867B # <CJK>
0x868A # <CJK>
-0x868B # <CJK>
-0x868C # <CJK>
-0x8693 # <CJK>
0x8695 # <CJK>
-0x86A3 # <CJK>
-0x86A4 # <CJK>
-0x86A9 # <CJK>
-0x86AA # <CJK>
-0x86AB # <CJK>
-0x86AF # <CJK>
-0x86B0 # <CJK>
-0x86B6 # <CJK>
-0x86C4 # <CJK>
-0x86C6 # <CJK>
0x86C7 # <CJK>
-0x86C9 # <CJK>
-0x86CB # <CJK>
0x86CD # <CJK>
-0x86CE # <CJK>
-0x86D4 # <CJK>
-0x86D9 # <CJK>
-0x86DB # <CJK>
-0x86DE # <CJK>
-0x86DF # <CJK>
-0x86E4 # <CJK>
-0x86E9 # <CJK>
-0x86EC # <CJK>
-0x86ED # <CJK>
0x86EE # <CJK>
-0x86EF # <CJK>
-0x86F8 # <CJK>
-0x86F9 # <CJK>
-0x86FB # <CJK>
-0x86FE # <CJK>
-0x8700 # <CJK>
0x8702 # <CJK>
-0x8703 # <CJK>
-0x8706 # <CJK>
-0x8708 # <CJK>
-0x8709 # <CJK>
-0x870A # <CJK>
-0x870D # <CJK>
-0x8711 # <CJK>
-0x8712 # <CJK>
-0x8718 # <CJK>
-0x871A # <CJK>
0x871C # <CJK>
-0x8725 # <CJK>
-0x8729 # <CJK>
-0x8734 # <CJK>
-0x8737 # <CJK>
-0x873B # <CJK>
-0x873F # <CJK>
-0x8749 # <CJK>
-0x874B # <CJK>
-0x874C # <CJK>
-0x874E # <CJK>
-0x8753 # <CJK>
-0x8755 # <CJK>
-0x8757 # <CJK>
-0x8759 # <CJK>
-0x875F # <CJK>
-0x8760 # <CJK>
-0x8763 # <CJK>
-0x8766 # <CJK>
-0x8768 # <CJK>
-0x876A # <CJK>
-0x876E # <CJK>
-0x8774 # <CJK>
-0x8776 # <CJK>
-0x8778 # <CJK>
-0x877F # <CJK>
-0x8782 # <CJK>
0x878D # <CJK>
-0x879F # <CJK>
-0x87A2 # <CJK>
-0x87AB # <CJK>
-0x87AF # <CJK>
-0x87B3 # <CJK>
-0x87BA # <CJK>
-0x87BB # <CJK>
-0x87BD # <CJK>
-0x87C0 # <CJK>
-0x87C4 # <CJK>
-0x87C6 # <CJK>
-0x87C7 # <CJK>
-0x87CB # <CJK>
-0x87D0 # <CJK>
-0x87D2 # <CJK>
-0x87E0 # <CJK>
-0x87EF # <CJK>
-0x87F2 # <CJK>
-0x87F6 # <CJK>
-0x87F7 # <CJK>
-0x87F9 # <CJK>
-0x87FB # <CJK>
-0x87FE # <CJK>
-0x8805 # <CJK>
-0x880D # <CJK>
-0x880E # <CJK>
-0x880F # <CJK>
-0x8811 # <CJK>
-0x8815 # <CJK>
-0x8816 # <CJK>
-0x8821 # <CJK>
-0x8822 # <CJK>
-0x8823 # <CJK>
-0x8827 # <CJK>
-0x8831 # <CJK>
-0x8836 # <CJK>
-0x8839 # <CJK>
-0x883B # <CJK>
0x8840 # <CJK>
-0x8842 # <CJK>
-0x8844 # <CJK>
0x8846 # <CJK>
0x884C # <CJK>
-0x884D # <CJK>
-0x8852 # <CJK>
0x8853 # <CJK>
0x8857 # <CJK>
-0x8859 # <CJK>
0x885B # <CJK>
0x885D # <CJK>
-0x885E # <CJK>
0x8861 # <CJK>
-0x8862 # <CJK>
0x8863 # <CJK>
0x8868 # <CJK>
-0x886B # <CJK>
0x8870 # <CJK>
-0x8872 # <CJK>
-0x8875 # <CJK>
0x8877 # <CJK>
-0x887D # <CJK>
-0x887E # <CJK>
-0x887F # <CJK>
-0x8881 # <CJK>
-0x8882 # <CJK>
-0x8888 # <CJK>
0x888B # <CJK>
-0x888D # <CJK>
-0x8892 # <CJK>
0x8896 # <CJK>
-0x8897 # <CJK>
-0x8899 # <CJK>
-0x889E # <CJK>
-0x88A2 # <CJK>
-0x88A4 # <CJK>
0x88AB # <CJK>
-0x88AE # <CJK>
-0x88B0 # <CJK>
-0x88B1 # <CJK>
-0x88B4 # <CJK>
-0x88B5 # <CJK>
-0x88B7 # <CJK>
-0x88BF # <CJK>
0x88C1 # <CJK>
0x88C2 # <CJK>
-0x88C3 # <CJK>
-0x88C4 # <CJK>
0x88C5 # <CJK>
0x88CF # <CJK>
-0x88D4 # <CJK>
0x88D5 # <CJK>
-0x88D8 # <CJK>
-0x88D9 # <CJK>
0x88DC # <CJK>
-0x88DD # <CJK>
-0x88DF # <CJK>
-0x88E1 # <CJK>
-0x88E8 # <CJK>
-0x88F2 # <CJK>
-0x88F3 # <CJK>
-0x88F4 # <CJK>
0x88F8 # <CJK>
-0x88F9 # <CJK>
-0x88FC # <CJK>
0x88FD # <CJK>
0x88FE # <CJK>
-0x8902 # <CJK>
-0x8904 # <CJK>
0x8907 # <CJK>
-0x890A # <CJK>
-0x890C # <CJK>
0x8910 # <CJK>
0x8912 # <CJK>
-0x8913 # <CJK>
-0x891D # <CJK>
-0x891E # <CJK>
-0x8925 # <CJK>
-0x892A # <CJK>
-0x892B # <CJK>
-0x8936 # <CJK>
-0x8938 # <CJK>
-0x893B # <CJK>
-0x8941 # <CJK>
-0x8943 # <CJK>
-0x8944 # <CJK>
-0x894C # <CJK>
-0x894D # <CJK>
-0x8956 # <CJK>
-0x895E # <CJK>
0x895F # <CJK>
-0x8960 # <CJK>
-0x8964 # <CJK>
-0x8966 # <CJK>
-0x896A # <CJK>
-0x896D # <CJK>
-0x896F # <CJK>
0x8972 # <CJK>
-0x8974 # <CJK>
-0x8977 # <CJK>
-0x897E # <CJK>
0x897F # <CJK>
0x8981 # <CJK>
-0x8983 # <CJK>
0x8986 # <CJK>
0x8987 # <CJK>
-0x8988 # <CJK>
-0x898A # <CJK>
0x898B # <CJK>
0x898F # <CJK>
-0x8993 # <CJK>
0x8996 # <CJK>
-0x8997 # <CJK>
-0x8998 # <CJK>
0x899A # <CJK>
-0x89A1 # <CJK>
-0x89A6 # <CJK>
0x89A7 # <CJK>
-0x89A9 # <CJK>
0x89AA # <CJK>
-0x89AC # <CJK>
-0x89AF # <CJK>
-0x89B2 # <CJK>
0x89B3 # <CJK>
-0x89BA # <CJK>
-0x89BD # <CJK>
-0x89BF # <CJK>
-0x89C0 # <CJK>
0x89D2 # <CJK>
-0x89DA # <CJK>
-0x89DC # <CJK>
-0x89DD # <CJK>
0x89E3 # <CJK>
0x89E6 # <CJK>
-0x89E7 # <CJK>
-0x89F4 # <CJK>
-0x89F8 # <CJK>
0x8A00 # <CJK>
0x8A02 # <CJK>
0x8A03 # <CJK>
0x8A08 # <CJK>
-0x8A0A # <CJK>
-0x8A0C # <CJK>
0x8A0E # <CJK>
-0x8A10 # <CJK>
0x8A13 # <CJK>
-0x8A16 # <CJK>
0x8A17 # <CJK>
0x8A18 # <CJK>
-0x8A1B # <CJK>
-0x8A1D # <CJK>
0x8A1F # <CJK>
-0x8A23 # <CJK>
-0x8A25 # <CJK>
0x8A2A # <CJK>
0x8A2D # <CJK>
0x8A31 # <CJK>
0x8A33 # <CJK>
0x8A34 # <CJK>
-0x8A36 # <CJK>
0x8A3A # <CJK>
-0x8A3B # <CJK>
0x8A3C # <CJK>
-0x8A41 # <CJK>
-0x8A46 # <CJK>
-0x8A48 # <CJK>
0x8A50 # <CJK>
-0x8A51 # <CJK>
-0x8A52 # <CJK>
0x8A54 # <CJK>
0x8A55 # <CJK>
-0x8A5B # <CJK>
0x8A5E # <CJK>
0x8A60 # <CJK>
-0x8A62 # <CJK>
0x8A63 # <CJK>
0x8A66 # <CJK>
0x8A69 # <CJK>
-0x8A6B # <CJK>
-0x8A6C # <CJK>
-0x8A6D # <CJK>
0x8A6E # <CJK>
0x8A70 # <CJK>
0x8A71 # <CJK>
0x8A72 # <CJK>
0x8A73 # <CJK>
-0x8A7C # <CJK>
-0x8A82 # <CJK>
-0x8A84 # <CJK>
-0x8A85 # <CJK>
0x8A87 # <CJK>
0x8A89 # <CJK>
0x8A8C # <CJK>
0x8A8D # <CJK>
-0x8A91 # <CJK>
0x8A93 # <CJK>
0x8A95 # <CJK>
0x8A98 # <CJK>
-0x8A9A # <CJK>
0x8A9E # <CJK>
0x8AA0 # <CJK>
-0x8AA1 # <CJK>
-0x8AA3 # <CJK>
0x8AA4 # <CJK>
-0x8AA5 # <CJK>
-0x8AA6 # <CJK>
-0x8AA8 # <CJK>
0x8AAC # <CJK>
0x8AAD # <CJK>
0x8AB0 # <CJK>
0x8AB2 # <CJK>
-0x8AB9 # <CJK>
-0x8ABC # <CJK>
0x8ABF # <CJK>
-0x8AC2 # <CJK>
-0x8AC4 # <CJK>
0x8AC7 # <CJK>
0x8ACB # <CJK>
-0x8ACC # <CJK>
-0x8ACD # <CJK>
-0x8ACF # <CJK>
-0x8AD2 # <CJK>
0x8AD6 # <CJK>
-0x8ADA # <CJK>
-0x8ADB # <CJK>
-0x8ADC # <CJK>
-0x8ADE # <CJK>
-0x8AE0 # <CJK>
-0x8AE1 # <CJK>
-0x8AE2 # <CJK>
-0x8AE4 # <CJK>
0x8AE6 # <CJK>
0x8AE7 # <CJK>
-0x8AEB # <CJK>
0x8AED # <CJK>
0x8AEE # <CJK>
-0x8AF1 # <CJK>
-0x8AF3 # <CJK>
-0x8AF7 # <CJK>
0x8AF8 # <CJK>
-0x8AFA # <CJK>
0x8AFE # <CJK>
0x8B00 # <CJK>
0x8B01 # <CJK>
-0x8B02 # <CJK>
0x8B04 # <CJK>
-0x8B07 # <CJK>
-0x8B0C # <CJK>
0x8B0E # <CJK>
-0x8B10 # <CJK>
-0x8B14 # <CJK>
-0x8B16 # <CJK>
-0x8B17 # <CJK>
0x8B19 # <CJK>
-0x8B1A # <CJK>
0x8B1B # <CJK>
0x8B1D # <CJK>
-0x8B20 # <CJK>
0x8B21 # <CJK>
-0x8B26 # <CJK>
-0x8B28 # <CJK>
-0x8B2B # <CJK>
-0x8B2C # <CJK>
-0x8B33 # <CJK>
0x8B39 # <CJK>
-0x8B3E # <CJK>
-0x8B41 # <CJK>
-0x8B49 # <CJK>
-0x8B4C # <CJK>
-0x8B4E # <CJK>
-0x8B4F # <CJK>
-0x8B56 # <CJK>
0x8B58 # <CJK>
-0x8B5A # <CJK>
-0x8B5B # <CJK>
0x8B5C # <CJK>
-0x8B5F # <CJK>
0x8B66 # <CJK>
-0x8B6B # <CJK>
-0x8B6C # <CJK>
-0x8B6F # <CJK>
0x8B70 # <CJK>
-0x8B71 # <CJK>
0x8B72 # <CJK>
-0x8B74 # <CJK>
0x8B77 # <CJK>
-0x8B7D # <CJK>
-0x8B80 # <CJK>
-0x8B83 # <CJK>
-0x8B8A # <CJK>
-0x8B8C # <CJK>
-0x8B8E # <CJK>
-0x8B90 # <CJK>
-0x8B92 # <CJK>
-0x8B93 # <CJK>
-0x8B96 # <CJK>
-0x8B99 # <CJK>
-0x8B9A # <CJK>
0x8C37 # <CJK>
-0x8C3A # <CJK>
-0x8C3F # <CJK>
-0x8C41 # <CJK>
0x8C46 # <CJK>
-0x8C48 # <CJK>
0x8C4A # <CJK>
-0x8C4C # <CJK>
-0x8C4E # <CJK>
-0x8C50 # <CJK>
-0x8C55 # <CJK>
0x8C5A # <CJK>
0x8C61 # <CJK>
-0x8C62 # <CJK>
0x8C6A # <CJK>
-0x8C6B # <CJK>
-0x8C6C # <CJK>
-0x8C78 # <CJK>
-0x8C79 # <CJK>
-0x8C7A # <CJK>
-0x8C7C # <CJK>
-0x8C82 # <CJK>
-0x8C85 # <CJK>
-0x8C89 # <CJK>
-0x8C8A # <CJK>
0x8C8C # <CJK>
-0x8C8D # <CJK>
-0x8C8E # <CJK>
-0x8C94 # <CJK>
-0x8C98 # <CJK>
0x8C9D # <CJK>
0x8C9E # <CJK>
0x8CA0 # <CJK>
@@ -5348,1218 +2008,338 @@
0x8CAA # <CJK>
0x8CAB # <CJK>
0x8CAC # <CJK>
-0x8CAD # <CJK>
-0x8CAE # <CJK>
0x8CAF # <CJK>
-0x8CB0 # <CJK>
-0x8CB2 # <CJK>
-0x8CB3 # <CJK>
0x8CB4 # <CJK>
-0x8CB6 # <CJK>
0x8CB7 # <CJK>
0x8CB8 # <CJK>
0x8CBB # <CJK>
0x8CBC # <CJK>
-0x8CBD # <CJK>
0x8CBF # <CJK>
0x8CC0 # <CJK>
-0x8CC1 # <CJK>
0x8CC2 # <CJK>
0x8CC3 # <CJK>
0x8CC4 # <CJK>
0x8CC7 # <CJK>
-0x8CC8 # <CJK>
0x8CCA # <CJK>
-0x8CCD # <CJK>
-0x8CCE # <CJK>
-0x8CD1 # <CJK>
0x8CD3 # <CJK>
-0x8CDA # <CJK>
0x8CDB # <CJK>
0x8CDC # <CJK>
0x8CDE # <CJK>
0x8CE0 # <CJK>
0x8CE2 # <CJK>
-0x8CE3 # <CJK>
-0x8CE4 # <CJK>
0x8CE6 # <CJK>
0x8CEA # <CJK>
0x8CED # <CJK>
-0x8CFA # <CJK>
-0x8CFB # <CJK>
0x8CFC # <CJK>
-0x8CFD # <CJK>
-0x8D04 # <CJK>
-0x8D05 # <CJK>
-0x8D07 # <CJK>
0x8D08 # <CJK>
-0x8D0A # <CJK>
-0x8D0B # <CJK>
-0x8D0D # <CJK>
-0x8D0F # <CJK>
-0x8D10 # <CJK>
-0x8D13 # <CJK>
-0x8D14 # <CJK>
-0x8D16 # <CJK>
0x8D64 # <CJK>
0x8D66 # <CJK>
-0x8D67 # <CJK>
-0x8D6B # <CJK>
-0x8D6D # <CJK>
0x8D70 # <CJK>
-0x8D71 # <CJK>
-0x8D73 # <CJK>
0x8D74 # <CJK>
0x8D77 # <CJK>
-0x8D81 # <CJK>
0x8D85 # <CJK>
0x8D8A # <CJK>
-0x8D99 # <CJK>
0x8DA3 # <CJK>
-0x8DA8 # <CJK>
0x8DB3 # <CJK>
-0x8DBA # <CJK>
-0x8DBE # <CJK>
-0x8DC2 # <CJK>
-0x8DCB # <CJK>
-0x8DCC # <CJK>
-0x8DCF # <CJK>
-0x8DD6 # <CJK>
-0x8DDA # <CJK>
-0x8DDB # <CJK>
0x8DDD # <CJK>
-0x8DDF # <CJK>
0x8DE1 # <CJK>
-0x8DE3 # <CJK>
-0x8DE8 # <CJK>
-0x8DEA # <CJK>
-0x8DEB # <CJK>
0x8DEF # <CJK>
0x8DF3 # <CJK>
0x8DF5 # <CJK>
-0x8DFC # <CJK>
-0x8DFF # <CJK>
-0x8E08 # <CJK>
-0x8E09 # <CJK>
0x8E0A # <CJK>
0x8E0F # <CJK>
-0x8E10 # <CJK>
-0x8E1D # <CJK>
-0x8E1E # <CJK>
-0x8E1F # <CJK>
0x8E2A # <CJK>
-0x8E30 # <CJK>
-0x8E34 # <CJK>
-0x8E35 # <CJK>
-0x8E42 # <CJK>
-0x8E44 # <CJK>
-0x8E47 # <CJK>
-0x8E48 # <CJK>
-0x8E49 # <CJK>
-0x8E4A # <CJK>
-0x8E4C # <CJK>
-0x8E50 # <CJK>
-0x8E55 # <CJK>
-0x8E59 # <CJK>
-0x8E5F # <CJK>
-0x8E60 # <CJK>
-0x8E63 # <CJK>
-0x8E64 # <CJK>
-0x8E72 # <CJK>
0x8E74 # <CJK>
-0x8E76 # <CJK>
-0x8E7C # <CJK>
-0x8E81 # <CJK>
-0x8E84 # <CJK>
-0x8E85 # <CJK>
-0x8E87 # <CJK>
-0x8E8A # <CJK>
-0x8E8B # <CJK>
0x8E8D # <CJK>
-0x8E91 # <CJK>
-0x8E93 # <CJK>
-0x8E94 # <CJK>
-0x8E99 # <CJK>
-0x8EA1 # <CJK>
-0x8EAA # <CJK>
0x8EAB # <CJK>
-0x8EAC # <CJK>
-0x8EAF # <CJK>
-0x8EB0 # <CJK>
-0x8EB1 # <CJK>
-0x8EBE # <CJK>
-0x8EC5 # <CJK>
-0x8EC6 # <CJK>
-0x8EC8 # <CJK>
0x8ECA # <CJK>
-0x8ECB # <CJK>
0x8ECC # <CJK>
0x8ECD # <CJK>
0x8ED2 # <CJK>
-0x8EDB # <CJK>
0x8EDF # <CJK>
0x8EE2 # <CJK>
-0x8EE3 # <CJK>
-0x8EEB # <CJK>
0x8EF8 # <CJK>
-0x8EFB # <CJK>
-0x8EFC # <CJK>
0x8EFD # <CJK>
-0x8EFE # <CJK>
0x8F03 # <CJK>
-0x8F05 # <CJK>
0x8F09 # <CJK>
-0x8F0A # <CJK>
-0x8F0C # <CJK>
-0x8F12 # <CJK>
-0x8F13 # <CJK>
-0x8F14 # <CJK>
-0x8F15 # <CJK>
-0x8F19 # <CJK>
-0x8F1B # <CJK>
-0x8F1C # <CJK>
0x8F1D # <CJK>
-0x8F1F # <CJK>
-0x8F26 # <CJK>
0x8F29 # <CJK>
0x8F2A # <CJK>
-0x8F2F # <CJK>
-0x8F33 # <CJK>
0x8F38 # <CJK>
-0x8F39 # <CJK>
-0x8F3B # <CJK>
-0x8F3E # <CJK>
-0x8F3F # <CJK>
-0x8F42 # <CJK>
0x8F44 # <CJK>
-0x8F45 # <CJK>
-0x8F46 # <CJK>
-0x8F49 # <CJK>
-0x8F4C # <CJK>
-0x8F4D # <CJK>
-0x8F4E # <CJK>
-0x8F57 # <CJK>
-0x8F5C # <CJK>
-0x8F5F # <CJK>
-0x8F61 # <CJK>
-0x8F62 # <CJK>
-0x8F63 # <CJK>
-0x8F64 # <CJK>
0x8F9B # <CJK>
-0x8F9C # <CJK>
0x8F9E # <CJK>
-0x8F9F # <CJK>
0x8FA3 # <CJK>
-0x8FA7 # <CJK>
-0x8FA8 # <CJK>
-0x8FAD # <CJK>
-0x8FAE # <CJK>
-0x8FAF # <CJK>
-0x8FB0 # <CJK>
0x8FB1 # <CJK>
0x8FB2 # <CJK>
-0x8FB7 # <CJK>
0x8FBA # <CJK>
-0x8FBB # <CJK>
0x8FBC # <CJK>
-0x8FBF # <CJK>
-0x8FC2 # <CJK>
-0x8FC4 # <CJK>
0x8FC5 # <CJK>
0x8FCE # <CJK>
0x8FD1 # <CJK>
0x8FD4 # <CJK>
-0x8FDA # <CJK>
-0x8FE2 # <CJK>
-0x8FE5 # <CJK>
-0x8FE6 # <CJK>
-0x8FE9 # <CJK>
-0x8FEA # <CJK>
0x8FEB # <CJK>
0x8FED # <CJK>
-0x8FEF # <CJK>
0x8FF0 # <CJK>
-0x8FF4 # <CJK>
0x8FF7 # <CJK>
-0x8FF8 # <CJK>
-0x8FF9 # <CJK>
-0x8FFA # <CJK>
0x8FFD # <CJK>
0x9000 # <CJK>
0x9001 # <CJK>
0x9003 # <CJK>
-0x9005 # <CJK>
0x9006 # <CJK>
-0x900B # <CJK>
-0x900D # <CJK>
-0x900E # <CJK>
0x900F # <CJK>
0x9010 # <CJK>
-0x9011 # <CJK>
0x9013 # <CJK>
0x9014 # <CJK>
-0x9015 # <CJK>
-0x9016 # <CJK>
-0x9017 # <CJK>
-0x9019 # <CJK>
0x901A # <CJK>
0x901D # <CJK>
-0x901E # <CJK>
0x901F # <CJK>
0x9020 # <CJK>
-0x9021 # <CJK>
-0x9022 # <CJK>
0x9023 # <CJK>
-0x9027 # <CJK>
0x902E # <CJK>
0x9031 # <CJK>
0x9032 # <CJK>
-0x9035 # <CJK>
-0x9036 # <CJK>
0x9038 # <CJK>
-0x9039 # <CJK>
-0x903C # <CJK>
-0x903E # <CJK>
-0x9041 # <CJK>
0x9042 # <CJK>
0x9045 # <CJK>
0x9047 # <CJK>
-0x9049 # <CJK>
0x904A # <CJK>
0x904B # <CJK>
0x904D # <CJK>
0x904E # <CJK>
-0x904F # <CJK>
-0x9050 # <CJK>
-0x9051 # <CJK>
-0x9052 # <CJK>
0x9053 # <CJK>
0x9054 # <CJK>
0x9055 # <CJK>
-0x9056 # <CJK>
-0x9058 # <CJK>
-0x9059 # <CJK>
0x905C # <CJK>
-0x905E # <CJK>
0x9060 # <CJK>
0x9061 # <CJK>
0x9063 # <CJK>
-0x9065 # <CJK>
-0x9068 # <CJK>
0x9069 # <CJK>
0x906D # <CJK>
0x906E # <CJK>
-0x906F # <CJK>
-0x9072 # <CJK>
0x9075 # <CJK>
-0x9076 # <CJK>
0x9077 # <CJK>
0x9078 # <CJK>
0x907A # <CJK>
-0x907C # <CJK>
-0x907D # <CJK>
0x907F # <CJK>
-0x9080 # <CJK>
-0x9081 # <CJK>
-0x9082 # <CJK>
-0x9083 # <CJK>
0x9084 # <CJK>
-0x9087 # <CJK>
-0x9089 # <CJK>
-0x908A # <CJK>
-0x908F # <CJK>
-0x9091 # <CJK>
0x90A3 # <CJK>
0x90A6 # <CJK>
-0x90A8 # <CJK>
0x90AA # <CJK>
-0x90AF # <CJK>
-0x90B1 # <CJK>
-0x90B5 # <CJK>
0x90B8 # <CJK>
-0x90C1 # <CJK>
0x90CA # <CJK>
0x90CE # <CJK>
-0x90DB # <CJK>
0x90E1 # <CJK>
-0x90E2 # <CJK>
-0x90E4 # <CJK>
0x90E8 # <CJK>
0x90ED # <CJK>
0x90F5 # <CJK>
0x90F7 # <CJK>
0x90FD # <CJK>
-0x9102 # <CJK>
-0x9112 # <CJK>
-0x9119 # <CJK>
-0x912D # <CJK>
-0x9130 # <CJK>
-0x9132 # <CJK>
-0x9149 # <CJK>
-0x914A # <CJK>
-0x914B # <CJK>
0x914C # <CJK>
0x914D # <CJK>
0x914E # <CJK>
0x9152 # <CJK>
0x9154 # <CJK>
-0x9156 # <CJK>
-0x9158 # <CJK>
0x9162 # <CJK>
-0x9163 # <CJK>
-0x9165 # <CJK>
-0x9169 # <CJK>
0x916A # <CJK>
0x916C # <CJK>
-0x9172 # <CJK>
-0x9173 # <CJK>
0x9175 # <CJK>
0x9177 # <CJK>
0x9178 # <CJK>
-0x9182 # <CJK>
-0x9187 # <CJK>
-0x9189 # <CJK>
-0x918B # <CJK>
-0x918D # <CJK>
-0x9190 # <CJK>
0x9192 # <CJK>
-0x9197 # <CJK>
0x919C # <CJK>
-0x91A2 # <CJK>
-0x91A4 # <CJK>
-0x91AA # <CJK>
-0x91AB # <CJK>
-0x91AF # <CJK>
-0x91B4 # <CJK>
-0x91B5 # <CJK>
0x91B8 # <CJK>
-0x91BA # <CJK>
-0x91C0 # <CJK>
-0x91C1 # <CJK>
-0x91C6 # <CJK>
0x91C7 # <CJK>
0x91C8 # <CJK>
-0x91C9 # <CJK>
-0x91CB # <CJK>
0x91CC # <CJK>
0x91CD # <CJK>
0x91CE # <CJK>
0x91CF # <CJK>
-0x91D0 # <CJK>
0x91D1 # <CJK>
-0x91D6 # <CJK>
-0x91D8 # <CJK>
-0x91DB # <CJK>
0x91DC # <CJK>
0x91DD # <CJK>
-0x91DF # <CJK>
-0x91E1 # <CJK>
0x91E3 # <CJK>
-0x91E6 # <CJK>
-0x91E7 # <CJK>
-0x91F5 # <CJK>
-0x91F6 # <CJK>
-0x91FC # <CJK>
-0x91FF # <CJK>
0x920D # <CJK>
-0x920E # <CJK>
-0x9211 # <CJK>
-0x9214 # <CJK>
-0x9215 # <CJK>
-0x921E # <CJK>
-0x9229 # <CJK>
-0x922C # <CJK>
0x9234 # <CJK>
-0x9237 # <CJK>
-0x923F # <CJK>
0x9244 # <CJK>
-0x9245 # <CJK>
-0x9248 # <CJK>
-0x9249 # <CJK>
-0x924B # <CJK>
-0x9250 # <CJK>
-0x9257 # <CJK>
-0x925A # <CJK>
0x925B # <CJK>
-0x925E # <CJK>
0x9262 # <CJK>
-0x9264 # <CJK>
-0x9266 # <CJK>
0x9271 # <CJK>
-0x927E # <CJK>
0x9280 # <CJK>
0x9283 # <CJK>
0x9285 # <CJK>
-0x9291 # <CJK>
-0x9293 # <CJK>
-0x9295 # <CJK>
-0x9296 # <CJK>
0x9298 # <CJK>
-0x929A # <CJK>
-0x929B # <CJK>
-0x929C # <CJK>
0x92AD # <CJK>
-0x92B7 # <CJK>
-0x92B9 # <CJK>
-0x92CF # <CJK>
-0x92D2 # <CJK>
-0x92E4 # <CJK>
-0x92E9 # <CJK>
-0x92EA # <CJK>
0x92ED # <CJK>
-0x92F2 # <CJK>
0x92F3 # <CJK>
-0x92F8 # <CJK>
-0x92FA # <CJK>
0x92FC # <CJK>
-0x9306 # <CJK>
-0x930F # <CJK>
-0x9310 # <CJK>
-0x9318 # <CJK>
-0x9319 # <CJK>
-0x931A # <CJK>
0x9320 # <CJK>
-0x9322 # <CJK>
-0x9323 # <CJK>
0x9326 # <CJK>
-0x9328 # <CJK>
-0x932B # <CJK>
0x932C # <CJK>
0x932E # <CJK>
0x932F # <CJK>
0x9332 # <CJK>
-0x9335 # <CJK>
-0x933A # <CJK>
-0x933B # <CJK>
-0x9344 # <CJK>
0x934B # <CJK>
-0x934D # <CJK>
-0x9354 # <CJK>
-0x9356 # <CJK>
0x935B # <CJK>
-0x935C # <CJK>
-0x9360 # <CJK>
-0x936C # <CJK>
-0x936E # <CJK>
0x9375 # <CJK>
-0x937C # <CJK>
-0x937E # <CJK>
0x938C # <CJK>
-0x9394 # <CJK>
0x9396 # <CJK>
-0x9397 # <CJK>
-0x939A # <CJK>
-0x93A7 # <CJK>
-0x93AC # <CJK>
-0x93AD # <CJK>
0x93AE # <CJK>
-0x93B0 # <CJK>
-0x93B9 # <CJK>
-0x93C3 # <CJK>
-0x93C8 # <CJK>
-0x93D0 # <CJK>
-0x93D1 # <CJK>
-0x93D6 # <CJK>
-0x93D7 # <CJK>
-0x93D8 # <CJK>
-0x93DD # <CJK>
0x93E1 # <CJK>
-0x93E4 # <CJK>
-0x93E5 # <CJK>
-0x93E8 # <CJK>
-0x9403 # <CJK>
-0x9407 # <CJK>
-0x9410 # <CJK>
-0x9413 # <CJK>
-0x9414 # <CJK>
0x9418 # <CJK>
-0x9419 # <CJK>
-0x941A # <CJK>
-0x9421 # <CJK>
-0x942B # <CJK>
-0x9435 # <CJK>
-0x9436 # <CJK>
-0x9438 # <CJK>
-0x943A # <CJK>
-0x9441 # <CJK>
-0x9444 # <CJK>
0x9451 # <CJK>
-0x9452 # <CJK>
-0x9453 # <CJK>
-0x945A # <CJK>
-0x945B # <CJK>
-0x945E # <CJK>
-0x9460 # <CJK>
-0x9462 # <CJK>
-0x946A # <CJK>
-0x9470 # <CJK>
-0x9475 # <CJK>
-0x9477 # <CJK>
-0x947C # <CJK>
-0x947D # <CJK>
-0x947E # <CJK>
-0x947F # <CJK>
-0x9481 # <CJK>
0x9577 # <CJK>
0x9580 # <CJK>
-0x9582 # <CJK>
-0x9583 # <CJK>
-0x9587 # <CJK>
0x9589 # <CJK>
-0x958A # <CJK>
0x958B # <CJK>
-0x958F # <CJK>
0x9591 # <CJK>
0x9593 # <CJK>
-0x9594 # <CJK>
-0x9596 # <CJK>
-0x9598 # <CJK>
-0x9599 # <CJK>
-0x95A0 # <CJK>
0x95A2 # <CJK>
0x95A3 # <CJK>
-0x95A4 # <CJK>
0x95A5 # <CJK>
-0x95A7 # <CJK>
-0x95A8 # <CJK>
-0x95AD # <CJK>
0x95B2 # <CJK>
-0x95B9 # <CJK>
-0x95BB # <CJK>
-0x95BC # <CJK>
-0x95BE # <CJK>
-0x95C3 # <CJK>
0x95C7 # <CJK>
-0x95CA # <CJK>
-0x95CC # <CJK>
-0x95CD # <CJK>
-0x95D4 # <CJK>
-0x95D5 # <CJK>
-0x95D6 # <CJK>
0x95D8 # <CJK>
-0x95DC # <CJK>
-0x95E1 # <CJK>
-0x95E2 # <CJK>
-0x95E5 # <CJK>
0x961C # <CJK>
-0x9621 # <CJK>
-0x9628 # <CJK>
0x962A # <CJK>
-0x962E # <CJK>
-0x962F # <CJK>
0x9632 # <CJK>
0x963B # <CJK>
-0x963F # <CJK>
-0x9640 # <CJK>
-0x9642 # <CJK>
0x9644 # <CJK>
-0x964B # <CJK>
-0x964C # <CJK>
0x964D # <CJK>
-0x964F # <CJK>
0x9650 # <CJK>
0x965B # <CJK>
-0x965C # <CJK>
-0x965D # <CJK>
-0x965E # <CJK>
-0x965F # <CJK>
0x9662 # <CJK>
0x9663 # <CJK>
0x9664 # <CJK>
0x9665 # <CJK>
-0x9666 # <CJK>
0x966A # <CJK>
-0x966C # <CJK>
0x9670 # <CJK>
-0x9672 # <CJK>
0x9673 # <CJK>
0x9675 # <CJK>
0x9676 # <CJK>
-0x9677 # <CJK>
0x9678 # <CJK>
0x967A # <CJK>
0x967D # <CJK>
0x9685 # <CJK>
0x9686 # <CJK>
-0x9688 # <CJK>
0x968A # <CJK>
-0x968B # <CJK>
-0x968D # <CJK>
0x968E # <CJK>
0x968F # <CJK>
0x9694 # <CJK>
-0x9695 # <CJK>
-0x9697 # <CJK>
-0x9698 # <CJK>
0x9699 # <CJK>
0x969B # <CJK>
0x969C # <CJK>
0x96A0 # <CJK>
0x96A3 # <CJK>
-0x96A7 # <CJK>
-0x96A8 # <CJK>
-0x96AA # <CJK>
-0x96B0 # <CJK>
-0x96B1 # <CJK>
-0x96B2 # <CJK>
-0x96B4 # <CJK>
-0x96B6 # <CJK>
0x96B7 # <CJK>
-0x96B8 # <CJK>
-0x96B9 # <CJK>
0x96BB # <CJK>
-0x96BC # <CJK>
-0x96C0 # <CJK>
-0x96C1 # <CJK>
0x96C4 # <CJK>
0x96C5 # <CJK>
0x96C6 # <CJK>
0x96C7 # <CJK>
-0x96C9 # <CJK>
-0x96CB # <CJK>
0x96CC # <CJK>
-0x96CD # <CJK>
-0x96CE # <CJK>
0x96D1 # <CJK>
-0x96D5 # <CJK>
-0x96D6 # <CJK>
-0x96D9 # <CJK>
-0x96DB # <CJK>
-0x96DC # <CJK>
0x96E2 # <CJK>
0x96E3 # <CJK>
0x96E8 # <CJK>
0x96EA # <CJK>
-0x96EB # <CJK>
0x96F0 # <CJK>
0x96F2 # <CJK>
0x96F6 # <CJK>
0x96F7 # <CJK>
-0x96F9 # <CJK>
0x96FB # <CJK>
0x9700 # <CJK>
-0x9704 # <CJK>
-0x9706 # <CJK>
0x9707 # <CJK>
-0x9708 # <CJK>
0x970A # <CJK>
-0x970D # <CJK>
-0x970E # <CJK>
-0x970F # <CJK>
-0x9711 # <CJK>
-0x9713 # <CJK>
-0x9716 # <CJK>
-0x9719 # <CJK>
0x971C # <CJK>
-0x971E # <CJK>
-0x9724 # <CJK>
0x9727 # <CJK>
-0x972A # <CJK>
-0x9730 # <CJK>
0x9732 # <CJK>
-0x9738 # <CJK>
-0x9739 # <CJK>
-0x973D # <CJK>
-0x973E # <CJK>
-0x9742 # <CJK>
-0x9744 # <CJK>
-0x9746 # <CJK>
-0x9748 # <CJK>
-0x9749 # <CJK>
0x9752 # <CJK>
-0x9756 # <CJK>
0x9759 # <CJK>
-0x975C # <CJK>
0x975E # <CJK>
-0x9760 # <CJK>
-0x9761 # <CJK>
0x9762 # <CJK>
-0x9764 # <CJK>
-0x9766 # <CJK>
-0x9768 # <CJK>
0x9769 # <CJK>
-0x976B # <CJK>
-0x976D # <CJK>
-0x9771 # <CJK>
0x9774 # <CJK>
-0x9779 # <CJK>
-0x977A # <CJK>
-0x977C # <CJK>
-0x9781 # <CJK>
-0x9784 # <CJK>
-0x9785 # <CJK>
-0x9786 # <CJK>
-0x978B # <CJK>
-0x978D # <CJK>
-0x978F # <CJK>
-0x9790 # <CJK>
-0x9798 # <CJK>
-0x979C # <CJK>
-0x97A0 # <CJK>
-0x97A3 # <CJK>
-0x97A6 # <CJK>
-0x97A8 # <CJK>
-0x97AB # <CJK>
-0x97AD # <CJK>
-0x97B3 # <CJK>
-0x97B4 # <CJK>
-0x97C3 # <CJK>
-0x97C6 # <CJK>
-0x97C8 # <CJK>
-0x97CB # <CJK>
0x97D3 # <CJK>
-0x97DC # <CJK>
-0x97ED # <CJK>
-0x97EE # <CJK>
-0x97F2 # <CJK>
0x97F3 # <CJK>
-0x97F5 # <CJK>
-0x97F6 # <CJK>
0x97FB # <CJK>
0x97FF # <CJK>
-0x9801 # <CJK>
0x9802 # <CJK>
0x9803 # <CJK>
0x9805 # <CJK>
0x9806 # <CJK>
0x9808 # <CJK>
-0x980C # <CJK>
-0x980F # <CJK>
0x9810 # <CJK>
0x9811 # <CJK>
0x9812 # <CJK>
0x9813 # <CJK>
-0x9817 # <CJK>
0x9818 # <CJK>
-0x981A # <CJK>
-0x9821 # <CJK>
-0x9824 # <CJK>
-0x982C # <CJK>
0x982D # <CJK>
-0x9834 # <CJK>
-0x9837 # <CJK>
-0x9838 # <CJK>
+#0x9830 # <CJK> # not in DroidSansJapanese
0x983B # <CJK>
0x983C # <CJK>
-0x983D # <CJK>
-0x9846 # <CJK>
-0x984B # <CJK>
0x984C # <CJK>
0x984D # <CJK>
0x984E # <CJK>
-0x984F # <CJK>
0x9854 # <CJK>
0x9855 # <CJK>
0x9858 # <CJK>
-0x985B # <CJK>
0x985E # <CJK>
0x9867 # <CJK>
-0x986B # <CJK>
-0x986F # <CJK>
-0x9870 # <CJK>
-0x9871 # <CJK>
-0x9873 # <CJK>
-0x9874 # <CJK>
0x98A8 # <CJK>
-0x98AA # <CJK>
-0x98AF # <CJK>
-0x98B1 # <CJK>
-0x98B6 # <CJK>
-0x98C3 # <CJK>
-0x98C4 # <CJK>
-0x98C6 # <CJK>
0x98DB # <CJK>
-0x98DC # <CJK>
0x98DF # <CJK>
0x98E2 # <CJK>
-0x98E9 # <CJK>
-0x98EB # <CJK>
-0x98ED # <CJK>
-0x98EE # <CJK>
0x98EF # <CJK>
0x98F2 # <CJK>
-0x98F4 # <CJK>
0x98FC # <CJK>
0x98FD # <CJK>
0x98FE # <CJK>
-0x9903 # <CJK>
0x9905 # <CJK>
-0x9909 # <CJK>
0x990A # <CJK>
0x990C # <CJK>
-0x9910 # <CJK>
-0x9912 # <CJK>
0x9913 # <CJK>
-0x9914 # <CJK>
-0x9918 # <CJK>
-0x991D # <CJK>
-0x991E # <CJK>
-0x9920 # <CJK>
-0x9921 # <CJK>
-0x9924 # <CJK>
0x9928 # <CJK>
-0x992C # <CJK>
-0x992E # <CJK>
-0x993D # <CJK>
-0x993E # <CJK>
-0x9942 # <CJK>
-0x9945 # <CJK>
-0x9949 # <CJK>
-0x994B # <CJK>
-0x994C # <CJK>
-0x9950 # <CJK>
-0x9951 # <CJK>
-0x9952 # <CJK>
-0x9955 # <CJK>
-0x9957 # <CJK>
0x9996 # <CJK>
-0x9997 # <CJK>
-0x9998 # <CJK>
0x9999 # <CJK>
-0x99A5 # <CJK>
-0x99A8 # <CJK>
0x99AC # <CJK>
-0x99AD # <CJK>
-0x99AE # <CJK>
-0x99B3 # <CJK>
-0x99B4 # <CJK>
-0x99BC # <CJK>
-0x99C1 # <CJK>
0x99C4 # <CJK>
0x99C5 # <CJK>
0x99C6 # <CJK>
-0x99C8 # <CJK>
0x99D0 # <CJK>
-0x99D1 # <CJK>
0x99D2 # <CJK>
-0x99D5 # <CJK>
-0x99D8 # <CJK>
-0x99DB # <CJK>
-0x99DD # <CJK>
-0x99DF # <CJK>
-0x99E2 # <CJK>
-0x99ED # <CJK>
-0x99EE # <CJK>
-0x99F1 # <CJK>
-0x99F2 # <CJK>
-0x99F8 # <CJK>
-0x99FB # <CJK>
-0x99FF # <CJK>
-0x9A01 # <CJK>
-0x9A05 # <CJK>
0x9A0E # <CJK>
-0x9A0F # <CJK>
0x9A12 # <CJK>
0x9A13 # <CJK>
-0x9A19 # <CJK>
-0x9A28 # <CJK>
-0x9A2B # <CJK>
0x9A30 # <CJK>
-0x9A37 # <CJK>
-0x9A3E # <CJK>
-0x9A40 # <CJK>
-0x9A42 # <CJK>
-0x9A43 # <CJK>
-0x9A45 # <CJK>
-0x9A4D # <CJK>
-0x9A55 # <CJK>
-0x9A57 # <CJK>
0x9A5A # <CJK>
-0x9A5B # <CJK>
-0x9A5F # <CJK>
-0x9A62 # <CJK>
-0x9A64 # <CJK>
-0x9A65 # <CJK>
-0x9A69 # <CJK>
-0x9A6A # <CJK>
-0x9A6B # <CJK>
0x9AA8 # <CJK>
-0x9AAD # <CJK>
-0x9AB0 # <CJK>
0x9AB8 # <CJK>
-0x9ABC # <CJK>
-0x9AC0 # <CJK>
0x9AC4 # <CJK>
-0x9ACF # <CJK>
-0x9AD1 # <CJK>
-0x9AD3 # <CJK>
-0x9AD4 # <CJK>
0x9AD8 # <CJK>
-0x9ADE # <CJK>
-0x9ADF # <CJK>
-0x9AE2 # <CJK>
-0x9AE3 # <CJK>
-0x9AE6 # <CJK>
0x9AEA # <CJK>
-0x9AEB # <CJK>
-0x9AED # <CJK>
-0x9AEE # <CJK>
-0x9AEF # <CJK>
-0x9AF1 # <CJK>
-0x9AF4 # <CJK>
-0x9AF7 # <CJK>
-0x9AFB # <CJK>
-0x9B06 # <CJK>
-0x9B18 # <CJK>
-0x9B1A # <CJK>
-0x9B1F # <CJK>
-0x9B22 # <CJK>
-0x9B23 # <CJK>
-0x9B25 # <CJK>
-0x9B27 # <CJK>
-0x9B28 # <CJK>
-0x9B29 # <CJK>
-0x9B2A # <CJK>
-0x9B2E # <CJK>
-0x9B2F # <CJK>
0x9B31 # <CJK>
-0x9B32 # <CJK>
-0x9B3B # <CJK>
0x9B3C # <CJK>
-0x9B41 # <CJK>
0x9B42 # <CJK>
-0x9B43 # <CJK>
-0x9B44 # <CJK>
0x9B45 # <CJK>
-0x9B4D # <CJK>
-0x9B4E # <CJK>
-0x9B4F # <CJK>
-0x9B51 # <CJK>
0x9B54 # <CJK>
-0x9B58 # <CJK>
0x9B5A # <CJK>
-0x9B6F # <CJK>
-0x9B74 # <CJK>
-0x9B83 # <CJK>
-0x9B8E # <CJK>
-0x9B91 # <CJK>
-0x9B92 # <CJK>
-0x9B93 # <CJK>
-0x9B96 # <CJK>
-0x9B97 # <CJK>
-0x9B9F # <CJK>
-0x9BA0 # <CJK>
-0x9BA8 # <CJK>
-0x9BAA # <CJK>
-0x9BAB # <CJK>
-0x9BAD # <CJK>
0x9BAE # <CJK>
-0x9BB4 # <CJK>
-0x9BB9 # <CJK>
-0x9BC0 # <CJK>
-0x9BC6 # <CJK>
-0x9BC9 # <CJK>
-0x9BCA # <CJK>
-0x9BCF # <CJK>
-0x9BD1 # <CJK>
-0x9BD2 # <CJK>
-0x9BD4 # <CJK>
-0x9BD6 # <CJK>
-0x9BDB # <CJK>
-0x9BE1 # <CJK>
-0x9BE2 # <CJK>
-0x9BE3 # <CJK>
-0x9BE4 # <CJK>
0x9BE8 # <CJK>
-0x9BF0 # <CJK>
-0x9BF1 # <CJK>
-0x9BF2 # <CJK>
-0x9BF5 # <CJK>
-0x9C04 # <CJK>
-0x9C06 # <CJK>
-0x9C08 # <CJK>
-0x9C09 # <CJK>
-0x9C0A # <CJK>
-0x9C0C # <CJK>
-0x9C0D # <CJK>
-0x9C10 # <CJK>
-0x9C12 # <CJK>
-0x9C13 # <CJK>
-0x9C14 # <CJK>
-0x9C15 # <CJK>
-0x9C1B # <CJK>
-0x9C21 # <CJK>
-0x9C24 # <CJK>
-0x9C25 # <CJK>
-0x9C2D # <CJK>
-0x9C2E # <CJK>
-0x9C2F # <CJK>
-0x9C30 # <CJK>
-0x9C32 # <CJK>
-0x9C39 # <CJK>
-0x9C3A # <CJK>
-0x9C3B # <CJK>
-0x9C3E # <CJK>
-0x9C46 # <CJK>
-0x9C47 # <CJK>
-0x9C48 # <CJK>
-0x9C52 # <CJK>
-0x9C57 # <CJK>
-0x9C5A # <CJK>
-0x9C60 # <CJK>
-0x9C67 # <CJK>
-0x9C76 # <CJK>
-0x9C78 # <CJK>
0x9CE5 # <CJK>
-0x9CE7 # <CJK>
-0x9CE9 # <CJK>
-0x9CEB # <CJK>
-0x9CEC # <CJK>
-0x9CF0 # <CJK>
-0x9CF3 # <CJK>
0x9CF4 # <CJK>
-0x9CF6 # <CJK>
-0x9D03 # <CJK>
-0x9D06 # <CJK>
-0x9D07 # <CJK>
-0x9D08 # <CJK>
-0x9D09 # <CJK>
-0x9D0E # <CJK>
-0x9D12 # <CJK>
-0x9D15 # <CJK>
-0x9D1B # <CJK>
-0x9D1F # <CJK>
-0x9D23 # <CJK>
-0x9D26 # <CJK>
-0x9D28 # <CJK>
-0x9D2A # <CJK>
-0x9D2B # <CJK>
-0x9D2C # <CJK>
-0x9D3B # <CJK>
-0x9D3E # <CJK>
-0x9D3F # <CJK>
-0x9D41 # <CJK>
-0x9D44 # <CJK>
-0x9D46 # <CJK>
-0x9D48 # <CJK>
-0x9D50 # <CJK>
-0x9D51 # <CJK>
-0x9D59 # <CJK>
-0x9D5C # <CJK>
-0x9D5D # <CJK>
-0x9D5E # <CJK>
-0x9D60 # <CJK>
-0x9D61 # <CJK>
-0x9D64 # <CJK>
-0x9D6C # <CJK>
-0x9D6F # <CJK>
-0x9D72 # <CJK>
-0x9D7A # <CJK>
-0x9D87 # <CJK>
-0x9D89 # <CJK>
0x9D8F # <CJK>
-0x9D9A # <CJK>
-0x9DA4 # <CJK>
-0x9DA9 # <CJK>
-0x9DAB # <CJK>
-0x9DAF # <CJK>
-0x9DB2 # <CJK>
0x9DB4 # <CJK>
-0x9DB8 # <CJK>
-0x9DBA # <CJK>
-0x9DBB # <CJK>
-0x9DC1 # <CJK>
-0x9DC2 # <CJK>
-0x9DC4 # <CJK>
-0x9DC6 # <CJK>
-0x9DCF # <CJK>
-0x9DD3 # <CJK>
-0x9DD9 # <CJK>
-0x9DE6 # <CJK>
-0x9DED # <CJK>
-0x9DEF # <CJK>
-0x9DF2 # <CJK>
-0x9DF8 # <CJK>
-0x9DF9 # <CJK>
-0x9DFA # <CJK>
-0x9DFD # <CJK>
-0x9E1A # <CJK>
-0x9E1B # <CJK>
-0x9E1E # <CJK>
-0x9E75 # <CJK>
-0x9E78 # <CJK>
-0x9E79 # <CJK>
-0x9E7D # <CJK>
0x9E7F # <CJK>
-0x9E81 # <CJK>
-0x9E88 # <CJK>
-0x9E8B # <CJK>
-0x9E8C # <CJK>
-0x9E91 # <CJK>
-0x9E92 # <CJK>
0x9E93 # <CJK>
-0x9E95 # <CJK>
0x9E97 # <CJK>
-0x9E9D # <CJK>
-0x9E9F # <CJK>
-0x9EA5 # <CJK>
0x9EA6 # <CJK>
-0x9EA9 # <CJK>
-0x9EAA # <CJK>
-0x9EAD # <CJK>
-0x9EB8 # <CJK>
-0x9EB9 # <CJK>
0x9EBA # <CJK>
0x9EBB # <CJK>
-0x9EBC # <CJK>
-0x9EBE # <CJK>
-0x9EBF # <CJK>
0x9EC4 # <CJK>
-0x9ECC # <CJK>
-0x9ECD # <CJK>
-0x9ECE # <CJK>
-0x9ECF # <CJK>
-0x9ED0 # <CJK>
0x9ED2 # <CJK>
-0x9ED4 # <CJK>
-0x9ED8 # <CJK>
0x9ED9 # <CJK>
-0x9EDB # <CJK>
-0x9EDC # <CJK>
-0x9EDD # <CJK>
-0x9EDE # <CJK>
-0x9EE0 # <CJK>
-0x9EE5 # <CJK>
-0x9EE8 # <CJK>
-0x9EEF # <CJK>
-0x9EF4 # <CJK>
-0x9EF6 # <CJK>
-0x9EF7 # <CJK>
-0x9EF9 # <CJK>
-0x9EFB # <CJK>
-0x9EFC # <CJK>
-0x9EFD # <CJK>
-0x9F07 # <CJK>
-0x9F08 # <CJK>
-0x9F0E # <CJK>
0x9F13 # <CJK>
-0x9F15 # <CJK>
-0x9F20 # <CJK>
-0x9F21 # <CJK>
-0x9F2C # <CJK>
0x9F3B # <CJK>
-0x9F3E # <CJK>
-0x9F4A # <CJK>
-0x9F4B # <CJK>
-0x9F4E # <CJK>
-0x9F4F # <CJK>
-0x9F52 # <CJK>
-0x9F54 # <CJK>
-0x9F5F # <CJK>
-0x9F60 # <CJK>
-0x9F61 # <CJK>
0x9F62 # <CJK>
-0x9F63 # <CJK>
-0x9F66 # <CJK>
-0x9F67 # <CJK>
-0x9F6A # <CJK>
-0x9F6C # <CJK>
-0x9F72 # <CJK>
-0x9F76 # <CJK>
-0x9F77 # <CJK>
-0x9F8D # <CJK>
-0x9F95 # <CJK>
-0x9F9C # <CJK>
-0x9F9D # <CJK>
-0x9FA0 # <CJK>
-#0xFFE5 # FULLWIDTH YEN SIGN
+#0x20B9F # <CJK>
diff --git a/chromium/third_party/fontconfig/src/fc-lang/ko.orth b/chromium/third_party/fontconfig/src/fc-lang/ko.orth
index 39114a5af1f..4bb52c6f487 100644
--- a/chromium/third_party/fontconfig/src/fc-lang/ko.orth
+++ b/chromium/third_party/fontconfig/src/fc-lang/ko.orth
@@ -86,7 +86,6 @@
0x3161 # HANGUL LETTER EU
0x3162 # HANGUL LETTER YI
0x3163 # HANGUL LETTER I
-0x3164 # HANGUL FILLER
0x3165 # HANGUL LETTER SSANGNIEUN
0x3166 # HANGUL LETTER NIEUN-TIKEUT
0x3167 # HANGUL LETTER NIEUN-SIOS
diff --git a/chromium/third_party/fontconfig/src/fc-lang/zh_hk.orth b/chromium/third_party/fontconfig/src/fc-lang/zh_hk.orth
index 5d5ef052696..8701cbcbc95 100644
--- a/chromium/third_party/fontconfig/src/fc-lang/zh_hk.orth
+++ b/chromium/third_party/fontconfig/src/fc-lang/zh_hk.orth
@@ -2,6 +2,7 @@
# fontconfig/fc-lang/zh_hk.orth
#
# Copyright © 2002 Keith Packard
+# Copyright © 2014 Abel Cheung
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
@@ -23,546 +24,610 @@
#
# Chinese Hong Kong Supplementary Character Set (ZH-HK)
#
-# Taken from the HKSCS-2001, including only the non-PUA BMP glyphs
-# as encoded in ISO/IEC 10646-1:2000
+# This list is a concatenation of:
+# (1) Most frequently used HKSCS characters accounting for ~99.75% usage in:
+# i. Around 11000 crawled UTF-8 Hong Kong web pages in
+# http://html5.org/temp/hk-data.tar.gz
+# ii. Database dump of main content in Cantonese Wikipedia dated 20131228:
+# http://dumps.wikimedia.org/zh_yuewiki/
+# (2) Word recommendation list from a local linguist:
+# http://founder.acgvlyric.org/iu/doku.php/%E9%80%A0%E5%AD%97:%E5%B8%B8%E7%94%A8%E9%A6%99%E6%B8%AF%E5%A4%96%E5%AD%97%E8%A1%A8
+# Level 1-5 characters are taken, excluding non-HKSCS chars.
+#
+3007
+344C
+3464
+3473
+347A
+347D
+347E
+3493
+3496
+34A5
+34BC
+34C1
+34C8
+34DF
+34E4
+34FB
+3506
+353E
+3551
+3561
+356D
+3570
+3572
+3577
+3578
+3584
+3597
+35A1
+35A5
+35AD
+35BF
+35C1
+35C5
+35C7
+35CA
+35CE
+35D2
+35D6
+35DB
+35F1
+35F2
+35F3
+35FB
+35FE
+3609
+361A
+3623
+362D
+3635
+3639
+3647
+3648
+3649
+364E
+365F
+367A
+3681
+36A5
+36AA
+36AC
+36B0
+36B1
+36B5
+36B9
+36BC
+36C1
+36C3
+36C4
+36C5
+36D3
+36D4
+36D6
+36DD
+36E5
+36E6
+36F5
+3703
+3708
+370A
+370D
+371C
+3723
+3725
+3730
+3732
+3733
+373A
+3740
+3743
+3762
+376F
+3797
+37A0
+37B9
+37BE
+37F2
+37F8
+37FB
+380F
+3819
+3820
+382D
+3836
+3838
+3863
+38A0
+38C3
+38CC
+38D1
+38FA
+3908
+3914
+3927
+3932
+393F
+394D
+3963
+3980
+3989
+398A
+3992
+399B
+39A1
+39A4
+39B8
+39DC
+39E2
+39E5
+39EC
+39F8
+39FB
+39FE
+3A01
+3A03
+3A06
+3A17
+3A18
+3A29
+3A2A
+3A34
+3A4B
+3A52
+3A57
+3A5C
+3A5E
+3A66
+3A67
+3A97
+3AAB
+3ABD
+3ADE
+3AF0
+3AF2
+3AFB
+3B0E
+3B19
+3B22
+3B2B
+3B39
+3B42
+3B58
+3B60
+3B71
+3B72
+3B7B
+3B7C
+3B80
+3B96
+3B99
+3BA1
+3BBE
+3BC2
+3BC4
+3BD7
+3BDD
+3BEC
+3BF2
+3BF3
+3C0D
+3C11
+3C15
+3C54
+3CCB
+3CCD
+3CD1
+3CD6
+3CDC
+3CEB
+3D13
+3D1D
+3D32
+3D46
+3D4C
+3D4E
+3D51
+3D5F
+3D62
+3D69
+3D6A
+3D6F
+3D75
+3D7D
+3D85
+3D8F
+3D91
+3DA5
+3DAD
+3DB4
+3DBF
+3DC6
+3DC7
+3DCD
+3DD3
+3DDB
+3DEB
+3DF3
+3DF7
+3DFC
+3E40
+3E43
+3E48
+3E55
+3E74
+3EA8
+3EA9
+3EAA
+3EAD
+3EB1
+3EB8
+3EBF
+3EC2
+3ECA
+3ECC
+3ED1
+3ED6
+3ED7
+3EDE
+3EE1
+3EE7
+3EEB
+3EF0
+3EFA
+3EFF
+3F04
+3F0E
+3F58
+3F59
+3F63
+3F93
+3FC0
+3FD7
+3FDC
+3FE5
+3FED
+3FF9
+3FFA
+4004
+4039
+4045
+4053
+4057
+4062
+4065
+406A
+406F
+40BB
+40BF
+40C8
+40D8
+40DF
+40FA
+4103
+4104
+4109
+410E
+4132
+4167
+416C
+416E
+417F
+4190
+41B2
+41CF
+41DB
+41EF
+41F9
+4211
+4240
+4260
+426A
+427A
+4294
+42A2
+42B5
+42B9
+42BC
+42F4
+42FB
+42FC
+432B
+436E
+4397
+43BA
+43C1
+43D9
+43DF
+43ED
+43F2
+4401
+4402
+4413
+447A
+448F
+449F
+44A0
+44B0
+44B7
+44DD
+44DF
+44E4
+44EA
+44F4
+4503
+4504
+4509
+4516
+4527
+452E
+4533
+453B
+453F
+4543
+4551
+4552
+4555
+4562
+456A
+4577
+4585
+45E9
+4603
+4606
+460F
+4615
+4617
+465B
+467A
+46CF
+46D0
+46F5
+4718
+477C
+47D5
+47ED
+47F4
+4800
+480B
+4871
+489B
+48AD
+48D0
+48DD
+48ED
+48FA
+4906
+491E
+492A
+492D
+4935
+493C
+493E
+4945
+4951
+4953
+4965
+496A
+4972
+4989
+49A7
+49DF
+49E5
+4A0F
+4A1D
+4A24
+4A35
+4A96
+4AB4
+4AB8
+4AD1
+4AE4
+4AFF
+4B19
+4B2C
+4B37
+4B6F
+4B70
+4B72
+4B7B
+4B7E
+4B8E
+4B90
+4B93
+4B96
+4B97
+4B9D
+4BBD
+4BBE
+4BC0
+4C04
+4C07
+4C0E
+4C3B
+4C3E
+4C5B
+4C6D
+4C77
+4C7B
+4C7D
+4C81
+4CAE
+4CB0
+4CCD
+4CE1
+4CED
+4D09
+4D10
+4D34
+4D77
+4D91
+4D9C
4E04
-4E1A
-4E1C
4E21
-4E24
-4E28
4E2A
-4E2C
-4E2F
-4E36
-4E37
-4E3D
-4E3F
-4E49
4E5A
4E5B
4E6A
4E78
4E80
-4E81
4E85
-4E87
-4E89
4E98
-4E9A
-4EA0
-4EA3
-4EB7
-4EBB
-4EBC
-4EBF
4ECE
-4EEA
-4EEB
4EEE
-4EF8
-4F03
-4F17
-4F1A
-4F28
-4F29
-4F32
4F37
-4F39
-4F42
-4F45
-4F4B
-4F72
-4F8A
-4FA2
-4FA8
-4FAB
-4FB0
-4FBD
-4FC8
-4FCC
-4FE4
4FE5
-4FF0
-4FF2
4FF9
-4FFD
-5003
5008
-502E
-5034
503B
-5056
-5058
-5066
-506C
-5081
-5088
-5090
-50A6
-50BC
50CD
-50D0
-50D9
-50DF
-50E1
-50F4
-50FC
-5101
510D
510E
-512B
-5156
-5160
516A
-5174
-5179
-5182
5186
-5188
-5196
519A
-519C
51A7
51A8
-51AB
-51AE
51B2
51B3
51B4
51B5
-51B8
-51C3
-51C7
51C9
-51CF
-51D1
-51D2
-51D3
-51DB
-51DF
-51E2
-51E4
51ED
51F4
-51FC
-51FE
-5202
-5205
520B
-521F
-5220
5226
5227
5234
523C
5257
-5259
-5260
-5268
-5273
-5279
528F
-5290
-5294
-529A
-52A1
-52A4
-52A8
52B5
52B9
52C5
-52CC
-52D0
52D1
-52E0
-52E1
-52F9
-5301
-5324
-5327
-532C
-5332
-5333
5338
-533B
-5342
-534E
-535D
-535F
-5364
-5367
-5369
-536D
5374
537D
-537E
5393
53A0
-53A2
53A6
53A8
-53A9
-53AA
-53AB
-53AE
-53B0
-53B6
53C1
-53C2
-53C5
53CC
-53D0
-53D1
-53D2
-53D8
53D9
-53DA
53E0
53F6
-53F7
53FE
5413
5414
5416
-541A
5421
-5423
-542F
-5432
-5434
-544B
+544C
544D
-5469
546A
546D
-5485
548F
5493
5494
5497
-549C
-549E
-54A3
54A4
54B2
-54B4
-54B9
54CB
-54CC
54CD
-54D0
-54DA
54E3
-54EF
5502
-550D
5513
-5518
551E
-5523
5525
-5528
-552B
-553F
-5547
-5549
5553
555D
5569
556B
5571
5572
-5573
5579
5586
5590
55A9
55B0
-55B4
-55B9
55BA
55BC
-55C1
55D7
-55D8
55DE
-55EA
55EC
55F0
55F1
-55F5
55FB
5605
5611
561E
-5620
-5621
5622
5623
5625
562D
-5637
5643
564D
564F
-5650
5652
5654
565D
-5661
-567A
-567B
-567C
5689
-568A
-568B
5692
-569E
569F
56A1
56A4
-56AF
56B1
56B9
56BF
56D6
-56E2
-56ED
-56EF
-56F1
56FD
-5700
-5715
-571D
-5732
-573D
-573F
5742
-5743
-5746
-5754
-5757
-575B
-575F
-5767
577A
-577E
-577F
-5788
-578A
-578D
-5790
-579C
-57A1
-57A7
-57AA
-57B4
-57BB
-57BE
-57C4
57C8
57D7
-57DD
57DE
-57E6
-57EF
-57FE
5803
-5812
-5822
5826
583A
5840
-5844
-5847
-585C
-585F
5869
-586C
5872
5873
-5892
-5899
-589A
-58A7
58AA
-58B0
-58B5
-58B6
58BB
-58CB
-58D0
-58DC
58E0
-58F0
58F2
58F3
58FB
-5902
-5904
-5905
-5907
590A
-5911
-591F
-5932
-5934
-5965
5975
-5989
-5994
-599A
599F
59AC
-59B0
-59B7
-59B8
-59C4
59C9
-59D9
59EB
-59EF
-59F0
59F8
-59F9
-5A02
-5A0B
-5A0D
-5A12
-5A1A
-5A21
-5A24
-5A27
-5A2A
5A2B
-5A2C
-5A3D
-5A45
-5A54
-5A59
-5A61
-5A63
-5A68
-5A6B
-5A6E
-5A71
-5A79
5A7E
-5A81
-5A82
-5A86
-5A88
-5A91
-5A96
-5A99
-5AA0
-5AA1
-5AAB
-5AC3
-5ACE
-5ACF
-5AD3
-5AE4
-5AF0
5AF2
5AFA
-5AFE
-5B0D
-5B11
-5B15
-5B1F
-5B2B
-5B41
-5B44
5B46
-5B4A
-5B4F
-5B66
-5B68
5B6D
-5B74
-5B76
-5B7C
-5B80
-5B82
-5B90
-5B96
5B9D
-5B9E
5B9F
-5BAA
5BC3
-5BD5
-5BD7
+5BDB
5BF3
-5BFF
5C05
-5C13
-5C14
-5C1C
-5C1E
-5C20
-5C23
-5C49
5C4A
-5C53
5C5E
-5C85
-5C99
-5C9A
-5C9C
-5C9E
-5CBA
-5CC1
-5CC2
-5CD1
-5CE5
-5CE9
5CEF
-5CF5
-5D10
-5D15
-5D18
-5D2C
-5D2F
-5D3E
-5D46
-5D48
-5D56
-5D57
-5D5B
-5D70
-5D74
-5D7B
-5D85
5D8B
-5D8E
-5DA4
-5DAB
-5DB6
-5DB9
-5DC1
-5DD7
-5DDB
5DF5
-5E09
-5E0B
-5E12
-5E2E
-5E42
-5E48
-5E5E
5E7A
-5E7F
5E83
-5E86
-5E92
-5E99
-5EBD
-5ECD
5ED0
-5EF4
5EF8
5EF9
5EFB
@@ -570,1671 +635,485 @@
5F0C
5F0D
5F0E
-5F25
-5F3A
-5F4D
-5F50
-5F51
5F5C
-5F61
-5F63
-5F72
-5F7B
-5F83
-5FA4
5FA7
-5FB1
-5FBA
-5FC2
-5FC4
-5FDB
5FDF
-6023
6031
-603B
-604A
-6052
6075
-6077
-607E
609E
60A4
-60A7
-60B3
60D7
-60DE
60E3
-60E7
-60E8
-60E9
-60FD
-6107
-610C
-6119
-6122
-6130
-613D
-6142
-6150
6159
-615C
-6160
6164
-616F
617D
-6181
6187
-6195
-6198
-6199
-619C
-61B7
-61B9
-61C0
-61CF
61D0
-61D3
-61DA
-61E2
-622C
-6237
6239
-624C
-6268
-6282
-6285
-6290
629D
-62A4
62A6
62C3
62C5
62D5
-62DF
-62E5
-6318
-632E
6331
-6335
-6337
-6364
-636C
6379
-637F
-638B
63B9
-63C1
63D1
63DE
-63E2
63E6
63F8
-63FB
63FC
63FE
6407
6432
-6438
643A
-643B
-645A
-6471
647C
648D
6491
-64AF
64B4
-64B6
-64C0
-64D3
64DD
64E1
-64E5
64E7
-64EA
-650A
-6511
651E
-651F
6530
-6534
-6535
654D
-655F
-656B
-656D
-6585
6586
-6588
6589
-658B
-65B5
-65BE
-65D1
-65D4
-65E0
65E3
-65FF
-6618
-661E
-6623
6630
6644
-6648
664B
-6653
-6657
-6663
6667
666B
6673
-667D
-6685
668E
-6692
-669A
-66A4
-66AD
-66B3
-66B6
-66BF
-66CD
-66CE
66F1
-6702
-670C
-670E
-6716
-6719
-671E
6725
6736
-6744
6761
-6762
6767
-676B
-678F
67A0
-67A4
-67AC
67B1
-67BF
-67D6
-67D7
-67F9
-67FE
-6800
-6801
-6802
6803
6804
-680D
-6810
-681B
681E
6822
-6836
-6837
-683E
-6847
-684A
-6855
-6856
-685D
-6865
-6884
-6888
6898
-68A6
68B6
-68B9
-68BD
-68C3
-68C5
-68CA
6900
-6901
-6902
-6903
-6909
-6918
-6919
-691A
-691B
-692C
6936
-693E
-6943
-6946
-6955
6961
-6964
-6967
-6972
6973
-6980
-6985
698A
-6998
-699F
-69A2
69B2
-69C0
-69D1
-69D5
-69D6
-69E1
-69E9
-69F9
-69FA
-6A03
6A0B
-6A0C
-6A1A
-6A1C
6A2B
-6A2C
-6A2D
-6A33
-6A43
-6A45
-6A4C
-6A52
-6A53
-6A57
-6A63
-6A65
-6A71
-6A74
-6A7A
-6A82
-6A8A
-6A8F
-6A99
-6A9D
-6AA7
-6AAB
-6AB1
-6AB2
-6AB5
-6ABE
6AC8
-6AC9
-6ACA
-6AD4
-6AD8
-6AF6
-6B05
-6B1D
6B35
-6B52
-6B57
6B6F
6B74
6B7A
-6B81
-6BC1
-6BDC
6BE1
-6BEA
-6BFA
-6C1C
-6C31
-6C35
6C37
6C39
-6C3A
-6C3D
-6C49
-6C58
6C5A
-6C6E
-6C75
-6C79
-6C7F
-6C9F
6CA2
-6CAA
-6CAF
-6CB2
-6CCB
-6CCE
-6CDF
6CEA
-6CFF
-6D02
-6D05
-6D06
-6D24
-6D26
-6D4E
-6D57
-6D5B
6D5C
-6D71
6D72
-6D81
-6D8F
6D96
-6DA4
-6DA5
-6DB1
-6DB9
-6DFE
-6E02
-6E04
-6E0A
-6E0F
6E15
-6E18
6E29
-6E2A
-6E4F
-6E50
-6E59
-6E76
6E7C
-6E86
-6E8B
-6E9A
-6EB5
-6EB8
-6EBB
6ED9
-6EDA
6EDB
6EDD
-6EE2
-6EE8
-6EE9
-6EFA
-6F04
-6F0B
-6F0C
6F16
-6F17
-6F24
-6F34
-6F3D
-6F44
6F56
-6F5C
-6F74
-6F79
6F81
-6F8A
-6F9D
-6F9F
-6FB5
-6FBB
6FBE
-6FD3
-6FD9
-6FDA
6FF6
-6FF8
-7003
701E
702C
-704B
-704D
-7050
-7054
-705C
-7067
-706C
-706F
-7075
-7077
-7079
-707E
-707F
7081
7089
-708B
-708F
-70A0
-70A3
-70A5
-70A6
-70A7
70B9
-70BB
-70BC
-70BD
-70C0
-70C4
-70CC
-70D0
-70D5
-70D6
70DF
70F1
-70F5
-70FE
7105
-711D
-7129
712B
-712C
-7133
-7134
-7135
-713B
-713E
7140
7145
714A
-714F
7151
-716B
7171
-7173
-7175
-7176
-7177
-717A
-717C
-717E
-7188
-718C
-718E
-7191
-7196
-7198
-71A2
-71A3
-71AD
-71B4
-71B7
-71BA
-71D1
-71DD
-71EB
-71F5
71F6
-7200
-7209
-720E
-720F
7215
-7216
-7217
-7224
-722B
-722E
7240
-7250
-7255
-7257
-725C
-7266
7282
7287
-728F
-7294
-729F
-72AD
-72B2
-72CD
-72E2
-7302
-7304
-7310
-7328
732A
-732B
-732C
732E
-7338
-7339
7341
-7348
-734F
-7371
7374
-738C
-738F
-7398
-739C
-739E
-73A7
-73AA
-73BA
73C9
-73CE
73CF
-73D0
-73D5
-73E1
-73E2
-73E4
-73E6
-73EF
-73F3
-73F7
-73F9
-73FB
-7402
-7411
-7412
-7414
-7415
-7417
-7419
-741C
-741E
-741F
-7437
-7438
7439
743C
-7443
-7445
-7447
7448
-7449
-7453
-7456
-745D
7460
-7465
-7468
-746B
-746C
-7474
-7476
-747A
-7482
-748C
-748D
-7499
-749B
-74A4
-74B4
-74B9
-74C8
-74CC
-74D0
-74D3
-74E7
-74F0
-74F1
-74F2
-74F8
7505
-750E
-7519
-751E
7534
-7535
753B
-7542
-7546
754A
-754D
7551
7553
-7555
7560
7567
-756D
-756E
-7572
-757A
-7583
758D
758E
-7592
-759E
75B1
75B4
-75C3
-75C8
-75DC
7602
-7607
-762C
763B
-7640
-764D
764E
-764F
-7651
-7654
7666
7667
-766F
-7673
-7674
7676
767A
-7690
-76A1
-76A5
-76B7
-76CC
-76D6
-76D9
770C
-770E
-770F
771E
-7724
-7726
-772B
7740
-7743
7758
-7772
-7777
7778
777A
-777B
7793
-7798
-77AF
77B9
-77BE
-77C3
-77C5
77CB
-77DD
-77E6
-77F4
-77FE
7808
-7818
-781C
-781E
-7839
-783C
-783D
-7842
-7844
-7847
-784B
-7851
-7853
-7854
-7866
-787A
7881
-7888
788D
-78AF
78B1
-78B6
78B8
-78B9
-78C7
-78D2
-78D3
78D7
-78D8
-78E4
-78EE
-78F0
-78F1
-78F5
7906
792E
-7932
-7933
-7934
-7936
-793B
-793C
7958
-7959
7962
-7971
-797E
-7980
-7983
-7986
-7987
7991
-7999
-799D
-799F
-79A5
-79A9
79C4
-79C6
-79CC
-79D4
-79E2
-79F1
-79F4
-7A06
-7A2A
-7A2D
-7A3A
-7A3E
-7A43
-7A45
-7A49
-7A65
-7A7D
-7A83
-7A91
7A93
7AB0
-7ABB
-7ABC
-7AC2
-7AC3
7AC8
7AC9
-7ACF
-7AD3
-7ADA
-7ADB
7ADC
7ADD
-7AE2
-7AE7
-7AE9
7AEA
-7AFE
7B0B
-7B0C
-7B14
-7B1F
-7B27
-7B29
7B39
-7B42
-7B43
-7B55
-7B62
-7B6C
7B6F
-7B7B
-7B92
-7BA2
-7BA3
-7BB2
-7BCF
-7BD0
-7BEC
-7BFA
-7BFC
-7C12
7C15
-7C1B
-7C35
-7C42
-7C44
-7C51
-7C56
-7C5D
-7C6D
-7C70
-7C74
-7C7B
-7C7C
-7C7E
-7C83
-7C86
-7C8E
-7C9C
7CA6
7CA7
-7CAC
7CAE
-7CB8
-7CC2
-7CC3
-7CC7
7CC9
7CCD
-7CD3
-7CDA
-7CE6
7CED
-7CF3
-7CF5
7CF9
7CFC
7D25
-7D4D
-7D5A
7D5D
7D89
-7D8B
-7D97
-7DA4
-7DA8
7DAB
7DB3
7DCD
7DCF
-7DD0
-7DD3
-7DD4
7DDC
-7DE4
-7DE5
-7DF5
-7DFD
-7DFE
-7E07
-7E27
-7E5B
-7E65
-7E67
-7E6C
7E6E
-7E7F
-7E8E
-7E92
-7E9F
-7EA4
-7EAC
-7EBA
-7EC7
-7ECF
-7EDF
-7F06
-7F37
-7F40
-7F41
7F47
7F49
7F4E
-7F52
-7F53
-7F71
7F78
-7F8F
-7F93
7F97
7FA3
-7FAE
-7FB4
-7FDD
-7FE7
-7FFA
-8002
-8008
-801D
-8020
-8025
-802E
-802F
-8031
-803B
-803C
-8054
-805B
8061
-8062
-8063
-8066
-8080
-809F
-80A7
80B6
-80B7
-80BC
80BD
80C6
-80E9
-80EC
-80F6
-8103
8107
-8109
-810C
-810E
-8112
-8114
8117
-811A
-812A
-8132
-8134
8137
-8142
-8148
-8156
-8159
-815A
-816D
-817C
-8184
-8193
81A5
-81AA
81B6
-81C1
-81C8
-81E4
81EF
-81F6
8218
-821A
8226
-8229
-822D
-823E
-8254
-8262
-8265
8276
-8279
-827A
-827B
-8287
82A6
82AA
-82BF
-82C4
-82CA
-82CF
-82D0
-82D8
-82E2
-82EE
82F7
-82F8
-82FC
-82FD
-82FF
-830B
8318
-831A
-831D
-833D
-8357
-8362
-8363
-8366
-836F
-8385
-8391
-839C
-83AC
-83B9
-83BE
-83CD
83D3
-83ED
-8405
-8414
-8416
8418
-841C
8420
-8421
-8424
-8426
-842E
-843E
-8448
-844A
-8453
-8455
-8458
-845C
-8462
-8464
8471
-8472
-847F
-8480
-8488
-8492
-8493
-8496
-84A3
84AD
84BD
-84BE
-84DA
-84DE
-84E1
84E2
-84E4
-84E5
-84F8
8503
-8505
-8510
-8533
8534
-8538
-8542
-854B
-854C
-8552
-855A
-855F
-856F
8570
-8573
-8597
-85C1
-85D6
-85E0
-85EE
-85FC
8602
-860D
-860F
-8610
-8614
-8616
-8628
862F
-8642
-8645
-866C
-8672
-867E
-8692
-86A0
-86AD
-86B2
86EF
-8770
-8771
-877D
8786
-878B
-878C
-87A5
-87A9
-87B1
-87C1
87CE
-87D6
-87DA
-87EE
-87F5
8804
-880F
-8818
-8827
882D
-8842
-8845
8846
-884F
885E
-8860
-8864
-8865
-886E
-8884
-8887
-888F
-8890
889C
-88A0
-88AE
-88B4
-88B5
-88BF
-88C5
88C7
88CF
-88E6
-88F5
-88FF
-8900
-8924
-8943
8947
-894D
-8954
-8965
-8977
-8980
8987
-8989
-898A
-8991
8994
89A5
89A7
-89A9
-89BC
-89C1
-89C6
-89E7
-8A1C
-8A29
-8A2B
-8A38
-8A3D
-8A49
-8A67
-8A7E
-8A90
8A94
-8A9C
-8AA9
-8AAF
-8AB4
-8ADA
-8AEA
-8B0C
-8B1F
-8B2D
-8B3F
-8B43
8B4C
-8B4D
-8B5E
-8B62
-8B69
8B81
8B83
8B90
-8B9B
-8BA0
-8BBE
-8BE2
-8C51
-8C9B
-8C9F
-8CAD
8CCD
-8CD4
-8CD6
8CDB
-8CE9
-8CEB
-8CF2
-8CF7
8D03
8D0B
-8D0C
-8D11
-8D12
-8D18
-8D1C
-8D1D
-8D7A
-8D82
-8DA6
-8DA9
-8DC0
-8DC3
-8DD4
-8E01
8E0E
-8E28
8E2A
8E2D
-8E3A
-8E46
8E4F
-8E68
-8E71
-8E75
-8E77
8E7E
8E80
-8EA7
8EAD
-8EB0
-8EB6
-8EB9
-8EBC
-8EC3
-8ECE
8EDA
8EE2
-8EE4
-8EED
8EF2
-8F19
8F2D
-8F30
-8F41
-8F4A
-8F5C
-8F66
-8F67
-8F6E
-8F93
-8FA0
-8FA5
-8FA7
-8FB3
8FB5
-8FB6
-8FB7
-8FB8
-8FB9
8FBA
8FBB
8FBC
-8FBE
-8FC1
-8FCA
-8FCC
-8FCF
-8FD0
-8FDA
8FF9
-9008
-9012
9033
-9037
-904C
9056
9061
-9064
-906C
90A8
-90AE
-90BB
-90C4
-9151
-9159
-915C
-915E
-9167
-9170
9176
-917C
-918C
-918E
-91A9
-91B6
-91BB
-91C4
-91D6
-91DF
-91E5
-91F6
-91FA
-91FE
9208
920E
-9213
-9221
-9228
922A
-922B
-9235
-923C
-9241
9244
9255
-9258
925D
-925F
9262
-926B
926E
-9277
-9281
-9284
-9289
-928F
-92AE
-92B1
92B9
-92BA
92BE
-92BF
-92D4
-92DB
-92E3
-92E5
-92EB
-92EC
-92F2
-92F3
-92F4
-92F6
-92FD
-9303
9307
-932C
-9330
-9331
9340
-9341
-9342
-9343
-9344
9345
9348
-935F
-9362
-9366
-9368
9369
-936B
-936E
-9373
-9374
-9378
-937D
-9381
9384
9385
-9386
9387
-9390
-939C
-93A0
93AD
-93B8
-93BB
-93BD
93BF
-93C6
-93CB
-93D3
-93DB
-93E0
93F0
-93F1
-93F3
-93F4
-9401
9404
-9408
-9417
-941B
-941D
-9424
-9425
9426
9427
-942D
-943E
-9442
-9443
-944D
9454
-9458
945B
9465
-9467
-946C
-9479
-947B
-9485
-949F
-94A2
-94C1
-94C3
-94DC
-94F6
-952D
-9547
-9578
-957F
-9585
-9596
-9597
9599
-95A0
95A2
-95A6
-95A7
95AA
-95E8
-95F4
-961D
-9633
-9638
-9641
-9645
-9656
-9669
-967B
-9681
-968F
9696
96A3
-96A5
-96B6
-96BD
-96F4
-9703
-971B
9721
-9731
-9736
-9740
-9741
9751
-9755
-9757
-975D
-975F
976D
-9771
-9787
-9789
-979B
-979F
-97B1
-97B2
-97B4
-97B8
-97BA
-97BD
-97BE
-97C0
-97C2
-97C8
-97D2
-97E0
-97E6
97EE
-97F2
97F5
-9814
-9815
-981F
-9823
-982E
-9833
9834
-9847
-984B
-9866
-9868
-986C
-9875
-98B4
98B7
-98B9
-98C3
-98C7
98C8
-98CA
-98CE
-98DC
-98DE
98E0
-98E1
-98E6
-98EC
-98F1
-98F5
-990E
-9919
991C
-9937
9938
-9939
-993B
-9940
-9942
994A
994D
-995D
9962
-9963
-999B
-99A4
-99AA
-99B8
-99BC
-99C4
99C5
-99DA
-99E0
99E1
-99E6
-99F5
-9A0C
9A10
-9A1F
-9A21
-9A26
-9A2F
-9A3B
-9A3C
-9A58
-9A5C
-9A63
-9A6C
-9A8F
-9AB2
-9AB6
-9ABA
-9ABD
-9AD7
-9AE0
-9AE2
-9AF4
-9AFF
-9B02
-9B09
-9B0F
-9B14
9B2A
9B2D
-9B34
-9B39
-9B40
-9B50
-9B69
-9B7F
9B81
-9B83
9B8B
-9B8D
9B8E
-9B8F
-9B97
-9B9D
-9B9F
-9BB0
-9BCF
-9BDD
-9BE9
9BED
9BF1
-9BF4
9BFF
9C02
-9C0A
9C0C
-9C10
-9C15
-9C1B
-9C1F
-9C20
-9C26
9C2F
9C35
9C3A
9C45
-9C4F
-9C53
9C5D
9C72
-9C7B
-9C7C
-9D02
-9D0C
-9D16
-9D21
9D34
-9D39
-9D44
-9D49
-9D4E
9D50
9D5E
-9D6D
-9D6E
-9D7C
-9D7E
-9D83
9D93
-9DA5
-9DAB
-9DBD
9DC0
9DC4
9DC9
9DD4
-9DFC
9E0A
9E0C
-9E0E
-9E18
-9E1C
-9E1F
-9E7B
-9E81
-9E84
-9E85
9E90
9E95
9E96
-9E98
-9E9E
-9EA2
-9EA6
-9EA8
9EAA
9EAB
-9EAC
9EAF
-9EB1
-9EBD
9EBF
-9EC1
-9EC4
-9EC6
-9EC7
-9EE2
-9EF1
-9EF8
-9EFE
-9F02
9F08
-9F17
9F26
-9F27
-9F39
-9F44
-9F45
-9F50
-9F53
-9F5A
9F62
-9F69
-9F7F
9F8E
-9F99
-9F9F
-9FA5
-20547
+200CA
+201A4
+201A9
+20325
+20341
+2070E
+20779
+20C41
+20C53
+20C65
+20C78
+20C96
+20CB5
+20CCF
+20D31
+20D71
+20D7E
+20D7F
+20D9C
+20DA7
+20E04
+20E09
+20E4C
+20E73
+20E76
+20E7A
+20E9D
+20EA2
+20ED7
+20EF9
+20F2D
+20F2E
+20F3B
+20F4C
+20FB4
+20FEA
+21014
+2105C
+2106F
+21075
+21076
+2107B
+210C1
+210D3
+2113D
+21145
+2114F
+2197C
+21A34
+21C2A
+21DF9
+220C7
+221A1
+22ACF
+22B43
+22BCA
+22C51
+22C55
+22C62
+22CB2
+22CC2
+22D4C
+22D67
+22D8D
+22DEE
+22F74
+23231
+23595
+236BA
+23CB7
+23E89
+23F80
+244D3
+24DB8
+24DEA
+24EA7
+2512B
+25148
+2517E
+25535
+25E49
+26258
+266DA
+267CC
+2688A
+269F2
+269FA
+27285
+27574
+27657
+27735
+2775E
+2789D
+2797A
+279A0
+27A3E
+27A59
+27D73
+28024
+280BD
+2815D
+28207
+282E2
+2836D
+289C0
+289DC
+28A0F
+28B46
+28B4E
+28CCA
+28CCD
+28CD2
+28D99
+28EE7
+294E5
+29720
+298D1
+29A4D
+29D98
+2A632
+2A65B
diff --git a/chromium/third_party/fontconfig/src/fc-query/fc-query.c b/chromium/third_party/fontconfig/src/fc-query/fc-query.c
index 2983e0f199b..9bd398059ac 100644
--- a/chromium/third_party/fontconfig/src/fc-query/fc-query.c
+++ b/chromium/third_party/fontconfig/src/fc-query/fc-query.c
@@ -52,6 +52,7 @@
#define _GNU_SOURCE
#include <getopt.h>
static const struct option longopts[] = {
+ {"ignore-blanks", 0, 0, 'b'},
{"index", 1, 0, 'i'},
{"format", 1, 0, 'f'},
{"version", 0, 0, 'V'},
@@ -70,24 +71,26 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-Vh] [-i index] [-f FORMAT] [--index index] [--format FORMAT] [--version] [--help] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-i index] [-f FORMAT] [--ignore-blanks] [--index index] [--format FORMAT] [--version] [--help] font-file...\n",
program);
#else
- fprintf (file, "usage: %s [-Vh] [-i index] [-f FORMAT] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-i index] [-f FORMAT] font-file...\n",
program);
#endif
fprintf (file, "Query font files and print resulting pattern(s)\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
+ fprintf (file, " -b, --ignore-blanks ignore blanks to compute langauges\n");
fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\n");
fprintf (file, " -f, --format=FORMAT use the given output format\n");
fprintf (file, " -V, --version display font config version and exit\n");
fprintf (file, " -h, --help display this help and exit\n");
#else
- fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n");
- fprintf (file, " -f FORMAT (format) use the given output format\n");
- fprintf (file, " -V (version) display font config version and exit\n");
- fprintf (file, " -h (help) display this help and exit\n");
+ fprintf (file, " -b (ignore-blanks) ignore blanks to compute languages\n");
+ fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n");
+ fprintf (file, " -f FORMAT (format) use the given output format\n");
+ fprintf (file, " -V (version) display font config version and exit\n");
+ fprintf (file, " -h (help) display this help and exit\n");
#endif
exit (error);
}
@@ -97,19 +100,24 @@ main (int argc, char **argv)
{
int index_set = 0;
int set_index = 0;
+ int ignore_blanks = 0;
FcChar8 *format = NULL;
+ FcBlanks *blanks = NULL;
int err = 0;
int i;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "i:f:Vh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "bi:f:Vh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "i:f:Vh")) != -1)
+ while ((c = getopt (argc, argv, "bi:f:Vh")) != -1)
#endif
{
switch (c) {
+ case 'b':
+ ignore_blanks = 1;
+ break;
case 'i':
index_set = 1;
set_index = atoi (optarg);
@@ -135,6 +143,8 @@ main (int argc, char **argv)
if (i == argc)
usage (argv[0], 1);
+ if (!ignore_blanks)
+ blanks = FcConfigGetBlanks (NULL);
for (; i < argc; i++)
{
int index;
@@ -145,7 +155,7 @@ main (int argc, char **argv)
do {
FcPattern *pat;
- pat = FcFreeTypeQuery ((FcChar8 *) argv[i], index, NULL, &count);
+ pat = FcFreeTypeQuery ((FcChar8 *) argv[i], index, blanks, &count);
if (pat)
{
if (format)
diff --git a/chromium/third_party/fontconfig/src/fc-query/fc-query.sgml b/chromium/third_party/fontconfig/src/fc-query/fc-query.sgml
index 5351d1e4d70..fd51d217157 100644
--- a/chromium/third_party/fontconfig/src/fc-query/fc-query.sgml
+++ b/chromium/third_party/fontconfig/src/fc-query/fc-query.sgml
@@ -65,6 +65,10 @@ manpage.1: manpage.sgml
<arg><option>-Vh</option></arg>
<sbr>
<group>
+ <arg><option>-b</option></arg>
+ <arg><option>--ignore-blanks</option></arg>
+ </group>
+ <group>
<arg><option>-i</option> <option><replaceable>index</replaceable></option></arg>
<arg><option>--index</option> <option><replaceable>index</replaceable></option></arg>
</group>
@@ -97,6 +101,14 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
+ <term><option>-b</option>
+ <option>--ignore-blanks</option>
+ </term>
+ <listitem>
+ <para>Ignore blanks to compute languages</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-i</option>
<option>--index</option>
<option><replaceable>index</replaceable></option>
diff --git a/chromium/third_party/fontconfig/src/fc-scan/fc-scan.c b/chromium/third_party/fontconfig/src/fc-scan/fc-scan.c
index 5638b51cf43..4d0b1db44fb 100644
--- a/chromium/third_party/fontconfig/src/fc-scan/fc-scan.c
+++ b/chromium/third_party/fontconfig/src/fc-scan/fc-scan.c
@@ -52,6 +52,7 @@
#define _GNU_SOURCE
#include <getopt.h>
static const struct option longopts[] = {
+ {"ignore-blanks", 0, 0, 'b'},
{"format", 1, 0, 'f'},
{"version", 0, 0, 'V'},
{"help", 0, 0, 'h'},
@@ -69,22 +70,24 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-Vh] [-f FORMAT] [--format FORMAT] [--version] [--help] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-f FORMAT] [--ignore-blanks] [--format FORMAT] [--version] [--help] font-file...\n",
program);
#else
- fprintf (file, "usage: %s [-Vh] [-f FORMAT] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-f FORMAT] font-file...\n",
program);
#endif
fprintf (file, "Scan font files and directories, and print resulting pattern(s)\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
+ fprintf (file, " -b, --ignore-blanks ignore blanks to compute languages\n");
fprintf (file, " -f, --format=FORMAT use the given output format\n");
fprintf (file, " -V, --version display font config version and exit\n");
fprintf (file, " -h, --help display this help and exit\n");
#else
- fprintf (file, " -f FORMAT (format) use the given output format\n");
- fprintf (file, " -V (version) display font config version and exit\n");
- fprintf (file, " -h (help) display this help and exit\n");
+ fprintf (file, " -b (ignore-blanks) ignore blanks to compute languages\n");
+ fprintf (file, " -f FORMAT (format) use the given output format\n");
+ fprintf (file, " -V (version) display font config version and exit\n");
+ fprintf (file, " -h (help) display this help and exit\n");
#endif
exit (error);
}
@@ -94,17 +97,22 @@ main (int argc, char **argv)
{
FcChar8 *format = NULL;
int i;
+ int ignore_blanks = 0;
FcFontSet *fs;
+ FcBlanks *blanks = NULL;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "f:Vh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "bf:Vh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "f:Vh")) != -1)
+ while ((c = getopt (argc, argv, "bf:Vh")) != -1)
#endif
{
switch (c) {
+ case 'b':
+ ignore_blanks = 1;
+ break;
case 'f':
format = (FcChar8 *) strdup (optarg);
break;
@@ -127,20 +135,22 @@ main (int argc, char **argv)
usage (argv[0], 1);
fs = FcFontSetCreate ();
+ if (!ignore_blanks)
+ blanks = FcConfigGetBlanks (NULL);
for (; i < argc; i++)
{
const FcChar8 *file = (FcChar8*) argv[i];
if (!FcFileIsDir (file))
- FcFileScan (fs, NULL, NULL, NULL, file, FcTrue);
+ FcFileScan (fs, NULL, NULL, blanks, file, FcTrue);
else
{
FcStrSet *dirs = FcStrSetCreate ();
FcStrList *strlist = FcStrListCreate (dirs);
do
{
- FcDirScan (fs, dirs, NULL, NULL, file, FcTrue);
+ FcDirScan (fs, dirs, NULL, blanks, file, FcTrue);
}
while ((file = FcStrListNext (strlist)));
FcStrListDone (strlist);
diff --git a/chromium/third_party/fontconfig/src/fc-scan/fc-scan.sgml b/chromium/third_party/fontconfig/src/fc-scan/fc-scan.sgml
index 9af403c1fde..65a66c4f364 100644
--- a/chromium/third_party/fontconfig/src/fc-scan/fc-scan.sgml
+++ b/chromium/third_party/fontconfig/src/fc-scan/fc-scan.sgml
@@ -62,9 +62,13 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
- <arg><option>-Vh</option></arg>
+ <arg><option>-Vbh</option></arg>
<sbr>
<group>
+ <arg><option>-b</option></arg>
+ <arg><option>--ignore-blanks</option></arg>
+ </group>
+ <group>
<arg><option>-f</option> <option><replaceable>format</replaceable></option></arg>
<arg><option>--format</option> <option><replaceable>format</replaceable></option></arg>
</group>
@@ -91,6 +95,14 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
+ <term><option>-b</option>
+ <option>--ignore-blanks</option>
+ </term>
+ <listitem>
+ <para>Ignore blanks to compute languages</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-f</option>
<option>--format</option>
<option><replaceable>format</replaceable></option>
diff --git a/chromium/third_party/fontconfig/src/fontconfig.pc.in b/chromium/third_party/fontconfig/src/fontconfig.pc.in
index 6e112bb496e..fa00a72d7fd 100644
--- a/chromium/third_party/fontconfig/src/fontconfig.pc.in
+++ b/chromium/third_party/fontconfig/src/fontconfig.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
PACKAGE=@PACKAGE@
-confdir=@baseconfigdir@
+confdir=@BASECONFIGDIR@
cachedir=@fc_cachedir@
Name: Fontconfig
diff --git a/chromium/third_party/fontconfig/src/fontconfig/fcprivate.h b/chromium/third_party/fontconfig/src/fontconfig/fcprivate.h
index 210c1d8a371..a6ee5c23499 100644
--- a/chromium/third_party/fontconfig/src/fontconfig/fcprivate.h
+++ b/chromium/third_party/fontconfig/src/fontconfig/fcprivate.h
@@ -77,6 +77,9 @@
case FcTypeLangSet: \
__v__.u.l = va_arg (va, const FcLangSet *); \
break; \
+ case FcTypeRange: \
+ __v__.u.r = va_arg (va, const FcRange *); \
+ break; \
} \
if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \
goto _FcPatternVapBuild_bail1; \
diff --git a/chromium/third_party/fontconfig/src/fontconfig/fontconfig.h b/chromium/third_party/fontconfig/src/fontconfig/fontconfig.h
index dfc48f9e337..5c72b227279 100644
--- a/chromium/third_party/fontconfig/src/fontconfig/fontconfig.h
+++ b/chromium/third_party/fontconfig/src/fontconfig/fontconfig.h
@@ -51,8 +51,8 @@ typedef int FcBool;
*/
#define FC_MAJOR 2
-#define FC_MINOR 11
-#define FC_REVISION 0
+#define FC_MINOR 12
+#define FC_REVISION 1
#define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
@@ -66,7 +66,10 @@ typedef int FcBool;
* it means multiple copies of the font information.
*/
-#define FC_CACHE_VERSION "4"
+#define FC_CACHE_VERSION_NUMBER 7
+#define _FC_STRINGIFY_(s) #s
+#define _FC_STRINGIFY(s) _FC_STRINGIFY_(s)
+#define FC_CACHE_VERSION _FC_STRINGIFY(FC_CACHE_VERSION_NUMBER)
#define FcTrue 1
#define FcFalse 0
@@ -75,7 +78,7 @@ typedef int FcBool;
#define FC_STYLE "style" /* String */
#define FC_SLANT "slant" /* Int */
#define FC_WEIGHT "weight" /* Int */
-#define FC_SIZE "size" /* Double */
+#define FC_SIZE "size" /* Range (double) */
#define FC_ASPECT "aspect" /* Double */
#define FC_PIXEL_SIZE "pixelsize" /* Double */
#define FC_SPACING "spacing" /* Int */
@@ -94,7 +97,9 @@ typedef int FcBool;
#define FC_RASTERIZER "rasterizer" /* String (deprecated) */
#define FC_OUTLINE "outline" /* Bool */
#define FC_SCALABLE "scalable" /* Bool */
-#define FC_SCALE "scale" /* double */
+#define FC_COLOR "color" /* Bool */
+#define FC_SCALE "scale" /* double (deprecated) */
+#define FC_SYMBOL "symbol" /* Bool */
#define FC_DPI "dpi" /* double */
#define FC_RGBA "rgba" /* Int */
#define FC_MINSPACE "minspace" /* Bool use minimum line spacing */
@@ -115,7 +120,7 @@ typedef int FcBool;
#define FC_FONT_FEATURES "fontfeatures" /* String */
#define FC_NAMELANG "namelang" /* String RFC 3866 langs */
#define FC_PRGNAME "prgname" /* String */
-#define FC_HASH "hash" /* String */
+#define FC_HASH "hash" /* String (deprecated) */
#define FC_POSTSCRIPT_NAME "postscriptname" /* String */
#define FC_CACHE_SUFFIX ".cache-" FC_CACHE_VERSION
@@ -131,6 +136,8 @@ typedef int FcBool;
#define FC_WEIGHT_EXTRALIGHT 40
#define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
#define FC_WEIGHT_LIGHT 50
+#define FC_WEIGHT_DEMILIGHT 55
+#define FC_WEIGHT_SEMILIGHT FC_WEIGHT_DEMILIGHT
#define FC_WEIGHT_BOOK 75
#define FC_WEIGHT_REGULAR 80
#define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
@@ -194,7 +201,8 @@ typedef enum _FcType {
FcTypeMatrix,
FcTypeCharSet,
FcTypeFTFace,
- FcTypeLangSet
+ FcTypeLangSet,
+ FcTypeRange
} FcType;
typedef struct _FcMatrix {
@@ -212,7 +220,7 @@ typedef struct _FcMatrix {
typedef struct _FcCharSet FcCharSet;
typedef struct _FcObjectType {
- const char *object;
+ char *object;
FcType type;
} FcObjectType;
@@ -231,6 +239,8 @@ typedef struct _FcPattern FcPattern;
typedef struct _FcLangSet FcLangSet;
+typedef struct _FcRange FcRange;
+
typedef struct _FcValue {
FcType type;
union {
@@ -242,6 +252,7 @@ typedef struct _FcValue {
const FcCharSet *c;
void *f;
const FcLangSet *l;
+ const FcRange *r;
} u;
} FcValue;
@@ -541,6 +552,9 @@ FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
FcPublic FcCache *
FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file);
+
+FcPublic FcCache *
+FcDirCacheRescan (const FcChar8 *dir, FcConfig *config);
FcPublic FcCache *
FcDirCacheRead (const FcChar8 *dir, FcBool force, FcConfig *config);
@@ -850,6 +864,9 @@ FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
FcPublic FcBool
FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls);
+FcPublic FcBool
+FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r);
+
FcPublic FcResult
FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i);
@@ -871,6 +888,9 @@ FcPatternGetBool (const FcPattern *p, const char *object, int n, FcBool *b);
FcPublic FcResult
FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls);
+FcPublic FcResult
+FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r);
+
FcPublic FcPattern *
FcPatternVaBuild (FcPattern *p, va_list va);
@@ -880,6 +900,30 @@ FcPatternBuild (FcPattern *p, ...) FC_ATTRIBUTE_SENTINEL(0);
FcPublic FcChar8 *
FcPatternFormat (FcPattern *pat, const FcChar8 *format);
+/* fcrange.c */
+FcPublic FcRange *
+FcRangeCreateDouble (double begin, double end);
+
+FcPublic FcRange *
+FcRangeCreateInteger (FcChar32 begin, FcChar32 end);
+
+FcPublic void
+FcRangeDestroy (FcRange *range);
+
+FcPublic FcRange *
+FcRangeCopy (const FcRange *r);
+
+FcPublic FcBool
+FcRangeGetDouble(const FcRange *range, double *begin, double *end);
+
+/* fcweight.c */
+
+FcPublic int
+FcWeightFromOpenType (int ot_weight);
+
+FcPublic int
+FcWeightToOpenType (int fc_weight);
+
/* fcstr.c */
FcPublic FcChar8 *
diff --git a/chromium/third_party/fontconfig/src/fonts.conf.in b/chromium/third_party/fontconfig/src/fonts.conf.in
index 6a8753d01b3..7c16a70747d 100644
--- a/chromium/third_party/fontconfig/src/fonts.conf.in
+++ b/chromium/third_party/fontconfig/src/fonts.conf.in
@@ -79,72 +79,6 @@
<config>
<!--
- These are the default Unicode chars that are expected to be blank
- in fonts. All other blank chars are assumed to be broken and
- won't appear in the resulting charsets
- -->
- <blank>
- <int>0x0020</int> <!-- SPACE -->
- <int>0x00A0</int> <!-- NO-BREAK SPACE -->
- <int>0x00AD</int> <!-- SOFT HYPHEN -->
- <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER -->
- <int>0x0600</int> <!-- ARABIC NUMBER SIGN -->
- <int>0x0601</int> <!-- ARABIC SIGN SANAH -->
- <int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER -->
- <int>0x0603</int> <!-- ARABIC SIGN SAFHA -->
- <int>0x06DD</int> <!-- ARABIC END OF AYAH -->
- <int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK -->
- <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER -->
- <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
- <int>0x1680</int> <!-- OGHAM SPACE MARK -->
- <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ -->
- <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA -->
- <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR -->
- <int>0x2000</int> <!-- EN QUAD -->
- <int>0x2001</int> <!-- EM QUAD -->
- <int>0x2002</int> <!-- EN SPACE -->
- <int>0x2003</int> <!-- EM SPACE -->
- <int>0x2004</int> <!-- THREE-PER-EM SPACE -->
- <int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
- <int>0x2006</int> <!-- SIX-PER-EM SPACE -->
- <int>0x2007</int> <!-- FIGURE SPACE -->
- <int>0x2008</int> <!-- PUNCTUATION SPACE -->
- <int>0x2009</int> <!-- THIN SPACE -->
- <int>0x200A</int> <!-- HAIR SPACE -->
- <int>0x200B</int> <!-- ZERO WIDTH SPACE -->
- <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER -->
- <int>0x200D</int> <!-- ZERO WIDTH JOINER -->
- <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK -->
- <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK -->
- <int>0x2028</int> <!-- LINE SEPARATOR -->
- <int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
- <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
- <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
- <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING -->
- <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
- <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
- <int>0x202F</int> <!-- NARROW NO-BREAK SPACE -->
- <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE -->
- <int>0x2060</int> <!-- WORD JOINER -->
- <int>0x2061</int> <!-- FUNCTION APPLICATION -->
- <int>0x2062</int> <!-- INVISIBLE TIMES -->
- <int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
- <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
- <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
- <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
- <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
- <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
- <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
- <int>0x2800</int> <!-- BRAILLE PATTERN BLANK -->
- <int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
- <int>0x3164</int> <!-- HANGUL FILLER -->
- <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
- <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER -->
- <int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
- <int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
- <int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
- </blank>
-<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
diff --git a/chromium/third_party/fontconfig/src/fonts.dtd b/chromium/third_party/fontconfig/src/fonts.dtd
index 4c38e77f08f..479f2c0fb84 100644
--- a/chromium/third_party/fontconfig/src/fonts.dtd
+++ b/chromium/third_party/fontconfig/src/fonts.dtd
@@ -140,7 +140,7 @@
if 'target' is 'font', execute the match on the result of a font
selection.
-->
-<!ELEMENT match (test*, edit*)+>
+<!ELEMENT match (test|edit)+>
<!ATTLIST match
target (pattern|font|scan) "pattern">
diff --git a/chromium/third_party/fontconfig/src/m4/ac_check_symbol.m4 b/chromium/third_party/fontconfig/src/m4/ac_check_symbol.m4
new file mode 100644
index 00000000000..41c15286a6f
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/m4/ac_check_symbol.m4
@@ -0,0 +1,48 @@
+dnl @synopsis AC_CHECK_SYMBOL(SYMBOL, HEADER... [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
+dnl
+dnl a wrapper around AC_EGREP_HEADER the shellvar $ac_found will hold
+dnl the HEADER-name that had been containing the symbol. This value is
+dnl shown to the user.
+dnl
+dnl @category C
+dnl @author Guido U. Draheim <guidod@gmx.de>
+dnl @version 2006-10-13
+dnl @license GPLWithACException
+
+AC_DEFUN([AC_CHECK_SYMBOL],
+[AC_MSG_CHECKING([for $1 in $2])
+AC_CACHE_VAL(ac_cv_func_$1,
+[AC_REQUIRE_CPP()dnl
+changequote(, )dnl
+symbol="[^a-zA-Z_0-9]$1[^a-zA-Z_0-9]"
+changequote([, ])dnl
+ac_found=no
+for ac_header in $2 ; do
+ ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%' `
+ if test $ac_found != "yes" ; then
+ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ AC_EGREP_HEADER( $symbol, $ac_header, [ac_found="$ac_header"] )
+ fi
+ fi
+done
+if test "$ac_found" != "no" ; then
+ AC_MSG_RESULT($ac_found)
+ ifelse([$3], , :, [$3])
+else
+ AC_MSG_RESULT(no)
+ ifelse([$4], , , [$4
+])dnl
+fi
+])])
+
+dnl AC_CHECK_SYMBOLS( symbol..., header... [, action-if-found [, action-if-not-found]])
+AC_DEFUN([AC_CHECK_SYMBOLS],
+[for ac_func in $1
+do
+P4_CHECK_SYMBOL($ac_func, $2,
+[changequote(, )dnl
+ ac_tr_func=HAVE_`echo $ac_func | sed -e 'y:abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:' -e 's:[[^A-Z0-9]]:_:'`
+changequote([, ])dnl
+ AC_DEFINE_UNQUOTED($ac_tr_func) $2], $3)dnl
+done
+])
diff --git a/chromium/third_party/fontconfig/src/m4/ax_pthread.m4 b/chromium/third_party/fontconfig/src/m4/ax_pthread.m4
index d90de34d14b..e77541cea90 100644
--- a/chromium/third_party/fontconfig/src/m4/ax_pthread.m4
+++ b/chromium/third_party/fontconfig/src/m4/ax_pthread.m4
@@ -82,7 +82,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 18
+#serial 21
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
@@ -103,8 +103,8 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
- AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
- AC_MSG_RESULT($ax_pthread_ok)
+ AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
+ AC_MSG_RESULT([$ax_pthread_ok])
if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
@@ -162,8 +162,27 @@ case ${host_os} in
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;;
+ netbsd*)
+ # use libc stubs, don't link against libpthread, to allow
+ # dynamic loading
+ ax_pthread_flags=""
+ ;;
esac
+# Clang doesn't consider unrecognized options an error unless we specify
+# -Werror. We throw in some extra Clang-specific options to ensure that
+# this doesn't happen for GCC, which also accepts -Werror.
+
+AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
+save_CFLAGS="$CFLAGS"
+ax_pthread_extra_flags="-Werror"
+CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
+ [AC_MSG_RESULT([yes])],
+ [ax_pthread_extra_flags=
+ AC_MSG_RESULT([no])])
+CFLAGS="$save_CFLAGS"
+
if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do
@@ -178,7 +197,7 @@ for flag in $ax_pthread_flags; do
;;
pthread-config)
- AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
+ AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
if test x"$ax_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
@@ -193,7 +212,7 @@ for flag in $ax_pthread_flags; do
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
@@ -219,7 +238,7 @@ for flag in $ax_pthread_flags; do
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
- AC_MSG_RESULT($ax_pthread_ok)
+ AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = xyes; then
break;
fi
@@ -245,9 +264,9 @@ if test "x$ax_pthread_ok" = xyes; then
[attr_name=$attr; break],
[])
done
- AC_MSG_RESULT($attr_name)
+ AC_MSG_RESULT([$attr_name])
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
- AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+ AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
@@ -261,45 +280,54 @@ if test "x$ax_pthread_ok" = xyes; then
if test "$GCC" = "yes"; then
flag="-D_REENTRANT"
else
+ # TODO: What about Clang on Solaris?
flag="-mt -D_REENTRANT"
fi
;;
esac
- AC_MSG_RESULT(${flag})
+ AC_MSG_RESULT([$flag])
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
- ax_cv_PTHREAD_PRIO_INHERIT, [
- AC_LINK_IFELSE([
- AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
+ [ax_cv_PTHREAD_PRIO_INHERIT], [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
+ [[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
- AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
+ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
- # More AIX lossage: must compile with xlc_r or cc_r
- if test x"$GCC" != xyes; then
- AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
- else
- PTHREAD_CC=$CC
+ # More AIX lossage: compile with *_r variant
+ if test "x$GCC" != xyes; then
+ case $host_os in
+ aix*)
+ AS_CASE(["x/$CC"],
+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+ [#handle absolute path differently from PATH based program lookup
+ AS_CASE(["x$CC"],
+ [x/*],
+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+ ;;
+ esac
fi
-else
- PTHREAD_CC="$CC"
fi
-AC_SUBST(PTHREAD_LIBS)
-AC_SUBST(PTHREAD_CFLAGS)
-AC_SUBST(PTHREAD_CC)
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
+AC_SUBST([PTHREAD_LIBS])
+AC_SUBST([PTHREAD_CFLAGS])
+AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_pthread_ok" = xyes; then
- ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+ ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
diff --git a/chromium/third_party/fontconfig/src/m4/pkg.m4 b/chromium/third_party/fontconfig/src/m4/pkg.m4
new file mode 100644
index 00000000000..c5b26b52e6c
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/m4/pkg.m4
@@ -0,0 +1,214 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+#
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_default([$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes ],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ AC_MSG_RESULT([no])
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+ ])
+elif test $pkg_failed = untried; then
+ AC_MSG_RESULT([no])
+ m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+ ])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ $3
+fi[]dnl
+])# PKG_CHECK_MODULES
+
+
+# PKG_INSTALLDIR(DIRECTORY)
+# -------------------------
+# Substitutes the variable pkgconfigdir as the location where a module
+# should install pkg-config .pc files. By default the directory is
+# $libdir/pkgconfig, but the default can be changed by passing
+# DIRECTORY. The user can override through the --with-pkgconfigdir
+# parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+ [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+ [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+ [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+]) dnl PKG_INSTALLDIR
+
+
+# PKG_NOARCH_INSTALLDIR(DIRECTORY)
+# -------------------------
+# Substitutes the variable noarch_pkgconfigdir as the location where a
+# module should install arch-independent pkg-config .pc files. By
+# default the directory is $datadir/pkgconfig, but the default can be
+# changed by passing DIRECTORY. The user can override through the
+# --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+ [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+ [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+ [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+]) dnl PKG_NOARCH_INSTALLDIR
+
+
+# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------
+# Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])# PKG_CHECK_VAR
diff --git a/chromium/third_party/fontconfig/src/new-version.sh b/chromium/third_party/fontconfig/src/new-version.sh
index 36e46f59350..eecfd81a028 100644
--- a/chromium/third_party/fontconfig/src/new-version.sh
+++ b/chromium/third_party/fontconfig/src/new-version.sh
@@ -1,4 +1,25 @@
#!/bin/sh
+# fontconfig/new-version.sh
+#
+# Copyright © 2000 Keith Packard
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of the author(s) not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. The authors make no
+# representations about the suitability of this software for any purpose. It
+# is provided "as is" without express or implied warranty.
+#
+# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
if [ "x`git status -s -uno`" != "x" ]; then
echo 'Uncommited changes in repository' 1>&2
diff --git a/chromium/third_party/fontconfig/src/src/Makefile.am b/chromium/third_party/fontconfig/src/src/Makefile.am
index 066cc03e718..3757cf8f3e5 100644
--- a/chromium/third_party/fontconfig/src/src/Makefile.am
+++ b/chromium/third_party/fontconfig/src/src/Makefile.am
@@ -139,7 +139,6 @@ libfontconfig_la_SOURCES = \
fcformat.c \
fcfreetype.c \
fcfs.c \
- fchash.c \
fcinit.c \
fclang.c \
fclist.c \
@@ -151,9 +150,11 @@ libfontconfig_la_SOURCES = \
fcobjs.h \
fcobjshash.h \
fcpat.c \
+ fcrange.c \
fcserialize.c \
fcstat.c \
fcstr.c \
+ fcweight.c \
fcwindows.h \
fcxml.c \
ftglue.h \
diff --git a/chromium/third_party/fontconfig/src/src/fcarch.c b/chromium/third_party/fontconfig/src/src/fcarch.c
index 398f4bbfcd5..6ca15a991f7 100644
--- a/chromium/third_party/fontconfig/src/src/fcarch.c
+++ b/chromium/third_party/fontconfig/src/src/fcarch.c
@@ -21,10 +21,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-#include <stdio.h>
-
#include "fcint.h"
#include "fcarch.h"
+#include <stdio.h>
FC_ASSERT_STATIC (1 == sizeof (char));
FC_ASSERT_STATIC (2 == sizeof (FcChar16));
@@ -49,7 +48,7 @@ FC_ASSERT_STATIC (0x08 + 1*FC_MAX(SIZEOF_VOID_P,ALIGNOF_DOUBLE) == sizeof (FcVal
FC_ASSERT_STATIC (0x00 + 2*SIZEOF_VOID_P == sizeof (FcPatternElt));
FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcPattern));
FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcCharSet));
-FC_ASSERT_STATIC (0x08 + 6*SIZEOF_VOID_P == sizeof (FcCache));
+FC_ASSERT_STATIC (0x10 + 6*SIZEOF_VOID_P == sizeof (FcCache));
int
diff --git a/chromium/third_party/fontconfig/src/src/fcatomic.c b/chromium/third_party/fontconfig/src/src/fcatomic.c
index c1daed938e5..d12d32408d8 100644
--- a/chromium/third_party/fontconfig/src/src/fcatomic.c
+++ b/chromium/third_party/fontconfig/src/src/fcatomic.c
@@ -131,7 +131,7 @@ FcAtomicLock (FcAtomic *atomic)
return FcFalse;
}
ret = link ((char *) atomic->tmp, (char *) atomic->lck);
- if (ret < 0 && errno == EPERM)
+ if (ret < 0 && (errno == EPERM || errno == ENOTSUP || errno == EACCES))
{
/* the filesystem where atomic->lck points to may not supports
* the hard link. so better try to fallback
diff --git a/chromium/third_party/fontconfig/src/src/fcatomic.h b/chromium/third_party/fontconfig/src/src/fcatomic.h
index 362e52164b7..cc28a883c13 100644
--- a/chromium/third_party/fontconfig/src/src/fcatomic.h
+++ b/chromium/third_party/fontconfig/src/src/fcatomic.h
@@ -48,22 +48,22 @@
#include "fcwindows.h"
-/* mingw32 does not have MemoryBarrier.
- * MemoryBarrier may be defined as a macro or a function.
- * Just make a failsafe version for ourselves. */
-#ifdef MemoryBarrier
-#define HBMemoryBarrier MemoryBarrier
-#else
-static inline void HBMemoryBarrier (void) {
+/* MinGW has a convoluted history of supporting MemoryBarrier
+ * properly. As such, define a function to wrap the whole
+ * thing. */
+static inline void _FCMemoryBarrier (void) {
+#if !defined(MemoryBarrier)
long dummy = 0;
InterlockedExchange (&dummy, 1);
-}
+#else
+ MemoryBarrier ();
#endif
+}
typedef LONG fc_atomic_int_t;
#define fc_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
-#define fc_atomic_ptr_get(P) (HBMemoryBarrier (), (void *) *(P))
+#define fc_atomic_ptr_get(P) (_FCMemoryBarrier (), (void *) *(P))
#define fc_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
diff --git a/chromium/third_party/fontconfig/src/src/fcblanks.c b/chromium/third_party/fontconfig/src/src/fcblanks.c
index 46698bcdac3..5132a510f98 100644
--- a/chromium/third_party/fontconfig/src/src/fcblanks.c
+++ b/chromium/third_party/fontconfig/src/src/fcblanks.c
@@ -41,6 +41,8 @@ FcBlanksCreate (void)
void
FcBlanksDestroy (FcBlanks *b)
{
+ if (b->sblank == -1)
+ return;
if (b->blanks)
free (b->blanks);
free (b);
@@ -56,6 +58,11 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
if (b->blanks[sblank] == ucs4)
return FcTrue;
+ if (b->sblank == -1)
+ {
+ fprintf (stderr, "Unable to update the static FcBlanks: 0x%04x\n", ucs4);
+ return FcTrue;
+ }
if (b->nblank == b->sblank)
{
sblank = b->sblank + 32;
@@ -75,11 +82,25 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
FcBool
FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
{
- int i;
+ int lower = 0, higher = b->nblank, middle;
- for (i = 0; i < b->nblank; i++)
- if (b->blanks[i] == ucs4)
+ if (b->nblank == 0 ||
+ b->blanks[0] > ucs4 ||
+ b->blanks[b->nblank - 1] < ucs4)
+ return FcFalse;
+ while (1)
+ {
+ middle = (lower + higher) / 2;
+ if (b->blanks[middle] == ucs4)
return FcTrue;
+ if (lower >= higher)
+ break;
+ if (b->blanks[middle] < ucs4)
+ lower = middle + 1;
+ else
+ higher = middle - 1;
+ }
+
return FcFalse;
}
#define __fcblanks__
diff --git a/chromium/third_party/fontconfig/src/src/fccache.c b/chromium/third_party/fontconfig/src/src/fccache.c
index 3568595eda5..6f3c68a2f16 100644
--- a/chromium/third_party/fontconfig/src/src/fccache.c
+++ b/chromium/third_party/fontconfig/src/src/fccache.c
@@ -27,12 +27,17 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <assert.h>
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
# include <unistd.h>
# include <sys/mman.h>
#endif
+#if defined(_WIN32)
+#include <sys/locking.h>
+#endif
#ifndef O_BINARY
#define O_BINARY 0
@@ -176,19 +181,28 @@ FcDirCacheOpenFile (const FcChar8 *cache_file, struct stat *file_stat)
*/
static FcBool
FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
- FcBool (*callback) (int fd, struct stat *fd_stat,
+ FcBool (*callback) (FcConfig *config, int fd, struct stat *fd_stat,
struct stat *dir_stat, void *closure),
void *closure, FcChar8 **cache_file_ret)
{
int fd = -1;
FcChar8 cache_base[CACHEBASE_LEN];
FcStrList *list;
- FcChar8 *cache_dir;
+ FcChar8 *cache_dir, *d;
struct stat file_stat, dir_stat;
FcBool ret = FcFalse;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
- if (FcStatChecksum (dir, &dir_stat) < 0)
+ if (sysroot)
+ d = FcStrBuildFilename (sysroot, dir, NULL);
+ else
+ d = FcStrdup (dir);
+ if (FcStatChecksum (d, &dir_stat) < 0)
+ {
+ FcStrFree (d);
return FcFalse;
+ }
+ FcStrFree (d);
FcDirCacheBasename (dir, cache_base);
@@ -198,7 +212,6 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
while ((cache_dir = FcStrListNext (list)))
{
- const FcChar8 *sysroot = FcConfigGetSysRoot (config);
FcChar8 *cache_hashed;
if (sysroot)
@@ -209,7 +222,7 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
break;
fd = FcDirCacheOpenFile (cache_hashed, &file_stat);
if (fd >= 0) {
- ret = (*callback) (fd, &file_stat, &dir_stat, closure);
+ ret = (*callback) (config, fd, &file_stat, &dir_stat, closure);
close (fd);
if (ret)
{
@@ -244,6 +257,7 @@ struct _FcCacheSkip {
dev_t cache_dev;
ino_t cache_ino;
time_t cache_mtime;
+ long cache_mtime_nano;
FcCacheSkip *next[1];
};
@@ -371,12 +385,18 @@ FcCacheInsert (FcCache *cache, struct stat *cache_stat)
s->cache_dev = cache_stat->st_dev;
s->cache_ino = cache_stat->st_ino;
s->cache_mtime = cache_stat->st_mtime;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ s->cache_mtime_nano = cache_stat->st_mtim.tv_nsec;
+#else
+ s->cache_mtime_nano = 0;
+#endif
}
else
{
s->cache_dev = 0;
s->cache_ino = 0;
s->cache_mtime = 0;
+ s->cache_mtime_nano = 0;
}
/*
@@ -464,6 +484,10 @@ FcCacheFindByStat (struct stat *cache_stat)
s->cache_ino == cache_stat->st_ino &&
s->cache_mtime == cache_stat->st_mtime)
{
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ if (s->cache_mtime != cache_stat->st_mtim.tv_nsec)
+ continue;
+#endif
FcRefInc (&s->ref);
unlock_cache ();
return s->cache;
@@ -528,37 +552,141 @@ FcCacheFini (void)
}
static FcBool
-FcCacheTimeValid (FcCache *cache, struct stat *dir_stat)
+FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
{
struct stat dir_static;
+ FcBool fnano = FcTrue;
if (!dir_stat)
{
- if (FcStatChecksum (FcCacheDir (cache), &dir_static) < 0)
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ FcChar8 *d;
+
+ if (sysroot)
+ d = FcStrBuildFilename (sysroot, FcCacheDir (cache), NULL);
+ else
+ d = FcStrdup (FcCacheDir (cache));
+ if (FcStatChecksum (d, &dir_static) < 0)
+ {
+ FcStrFree (d);
return FcFalse;
+ }
+ FcStrFree (d);
dir_stat = &dir_static;
}
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ fnano = (cache->checksum_nano == dir_stat->st_mtim.tv_nsec);
+ if (FcDebug () & FC_DBG_CACHE)
+ printf ("FcCacheTimeValid dir \"%s\" cache checksum %d.%ld dir checksum %d.%ld\n",
+ FcCacheDir (cache), cache->checksum, (long)cache->checksum_nano, (int) dir_stat->st_mtime, dir_stat->st_mtim.tv_nsec);
+#else
if (FcDebug () & FC_DBG_CACHE)
printf ("FcCacheTimeValid dir \"%s\" cache checksum %d dir checksum %d\n",
FcCacheDir (cache), cache->checksum, (int) dir_stat->st_mtime);
- return cache->checksum == (int) dir_stat->st_mtime;
+#endif
+
+ return cache->checksum == (int) dir_stat->st_mtime && fnano;
+}
+
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+ char *last_offset;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = 0; j < font->num; j++)
+ {
+ last_offset = (char *) font + font->elts_offset;
+ for (l = FcPatternEltValues(&e[j]); l; l = FcValueListNext(l))
+ {
+ if ((char *) l < last_offset || (char *) l > end - sizeof (*l) ||
+ (l->next != NULL && !FcIsEncodedOffset(l->next)))
+ return FcFalse;
+ last_offset = (char *) l + 1;
+ }
+ }
+ }
+ }
+
+ return FcTrue;
}
/*
* Map a cache file into memory
*/
static FcCache *
-FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
+FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat)
{
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
{
- if (FcCacheTimeValid (cache, dir_stat))
+ if (FcCacheTimeValid (config, cache, dir_stat))
return cache;
FcDirCacheUnload (cache);
cache = NULL;
@@ -572,7 +700,7 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
{
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
cache = mmap (0, fd_stat->st_size, PROT_READ, MAP_SHARED, fd, 0);
-#ifdef HAVE_POSIX_FADVISE
+#if (HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
posix_fadvise (fd, 0, fd_stat->st_size, POSIX_FADV_WILLNEED);
#endif
if (cache == MAP_FAILED)
@@ -607,9 +735,10 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
allocated = FcTrue;
}
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
- cache->version < FC_CACHE_CONTENT_VERSION ||
+ cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
- !FcCacheTimeValid (cache, dir_stat) ||
+ !FcCacheOffsetsValid (cache) ||
+ !FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
if (allocated)
@@ -648,9 +777,9 @@ FcDirCacheUnload (FcCache *cache)
}
static FcBool
-FcDirCacheMapHelper (int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure)
+FcDirCacheMapHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure)
{
- FcCache *cache = FcDirCacheMapFd (fd, fd_stat, dir_stat);
+ FcCache *cache = FcDirCacheMapFd (config, fd, fd_stat, dir_stat);
if (!cache)
return FcFalse;
@@ -667,6 +796,7 @@ FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file)
FcDirCacheMapHelper,
&cache, cache_file))
return NULL;
+
return cache;
}
@@ -682,7 +812,7 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
fd = FcDirCacheOpenFile (cache_file, file_stat);
if (fd < 0)
return NULL;
- cache = FcDirCacheMapFd (fd, file_stat, NULL);
+ cache = FcDirCacheMapFd (FcConfigGetCurrent (), fd, file_stat, NULL);
close (fd);
return cache;
}
@@ -692,7 +822,7 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
* the magic number and the size field
*/
static FcBool
-FcDirCacheValidateHelper (int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure FC_UNUSED)
+FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure FC_UNUSED)
{
FcBool ret = FcTrue;
FcCache c;
@@ -701,12 +831,16 @@ FcDirCacheValidateHelper (int fd, struct stat *fd_stat, struct stat *dir_stat, v
ret = FcFalse;
else if (c.magic != FC_CACHE_MAGIC_MMAP)
ret = FcFalse;
- else if (c.version < FC_CACHE_CONTENT_VERSION)
+ else if (c.version < FC_CACHE_VERSION_NUMBER)
ret = FcFalse;
else if (fd_stat->st_size != c.size)
ret = FcFalse;
else if (c.checksum != (int) dir_stat->st_mtime)
ret = FcFalse;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ else if (c.checksum_nano != dir_stat->st_mtim.tv_nsec)
+ ret = FcFalse;
+#endif
return ret;
}
@@ -778,9 +912,12 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcSt
serialize->linear = cache;
cache->magic = FC_CACHE_MAGIC_ALLOC;
- cache->version = FC_CACHE_CONTENT_VERSION;
+ cache->version = FC_CACHE_VERSION_NUMBER;
cache->size = serialize->size;
cache->checksum = (int) dir_stat->st_mtime;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ cache->checksum_nano = dir_stat->st_mtim.tv_nsec;
+#endif
/*
* Serialize directory name
@@ -827,6 +964,19 @@ bail1:
return NULL;
}
+FcCache *
+FcDirCacheRebuild (FcCache *cache, struct stat *dir_stat, FcStrSet *dirs)
+{
+ FcCache *new;
+ FcFontSet *set = FcFontSetDeserialize (FcCacheSet (cache));
+ const FcChar8 *dir = FcCacheDir (cache);
+
+ new = FcDirCacheBuild (set, dir, dir_stat, dirs);
+ FcFontSetDestroy (set);
+
+ return new;
+}
+
/* write serialized state to the cache file */
FcBool
FcDirCacheWrite (FcCache *cache, FcConfig *config)
@@ -955,6 +1105,11 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
skip->cache_dev = cache_stat.st_dev;
skip->cache_ino = cache_stat.st_ino;
skip->cache_mtime = cache_stat.st_mtime;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ skip->cache_mtime_nano = cache_stat.st_mtim.tv_nsec;
+#else
+ skip->cache_mtime_nano = 0;
+#endif
}
unlock_cache ();
}
@@ -1044,15 +1199,22 @@ FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
}
else
{
+ FcChar8 *s;
+
target_dir = FcCacheDir (cache);
- if (stat ((char *) target_dir, &target_stat) < 0)
+ if (sysroot)
+ s = FcStrBuildFilename (sysroot, target_dir, NULL);
+ else
+ s = FcStrdup (target_dir);
+ if (stat ((char *) s, &target_stat) < 0)
{
if (verbose || FcDebug () & FC_DBG_CACHE)
printf ("%s: %s: missing directory: %s \n",
- dir, ent->d_name, target_dir);
+ dir, ent->d_name, s);
remove = FcTrue;
}
FcDirCacheUnload (cache);
+ FcStrFree (s);
}
if (remove)
{
@@ -1072,6 +1234,82 @@ FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
return ret;
}
+int
+FcDirCacheLock (const FcChar8 *dir,
+ FcConfig *config)
+{
+ FcChar8 *cache_hashed = NULL;
+ FcChar8 cache_base[CACHEBASE_LEN];
+ FcStrList *list;
+ FcChar8 *cache_dir;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ int fd = -1;
+
+ FcDirCacheBasename (dir, cache_base);
+ list = FcStrListCreate (config->cacheDirs);
+ if (!list)
+ return -1;
+
+ while ((cache_dir = FcStrListNext (list)))
+ {
+ if (sysroot)
+ cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL);
+ else
+ cache_hashed = FcStrBuildFilename (cache_dir, cache_base, NULL);
+ if (!cache_hashed)
+ break;
+ fd = FcOpen ((const char *)cache_hashed, O_RDWR);
+ FcStrFree (cache_hashed);
+ /* No caches in that directory. simply retry with another one */
+ if (fd != -1)
+ {
+#if defined(_WIN32)
+ if (_locking (fd, _LK_LOCK, 1) == -1)
+ goto bail;
+#else
+ struct flock fl;
+
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = getpid ();
+ if (fcntl (fd, F_SETLKW, &fl) == -1)
+ goto bail;
+#endif
+ break;
+ }
+ }
+ FcStrListDone (list);
+ return fd;
+bail:
+ FcStrListDone (list);
+ if (fd != -1)
+ close (fd);
+ return -1;
+}
+
+void
+FcDirCacheUnlock (int fd)
+{
+ if (fd != -1)
+ {
+#if defined(_WIN32)
+ _locking (fd, _LK_UNLCK, 1);
+#else
+ struct flock fl;
+
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = getpid ();
+ fcntl (fd, F_SETLK, &fl);
+#endif
+ close (fd);
+ }
+}
+
/*
* Hokey little macro trick to permit the definitions of C functions
* with the same name as CPP macros
diff --git a/chromium/third_party/fontconfig/src/src/fccfg.c b/chromium/third_party/fontconfig/src/src/fccfg.c
index 6377fd7c6b1..9f8ee7c7e6f 100644
--- a/chromium/third_party/fontconfig/src/src/fccfg.c
+++ b/chromium/third_party/fontconfig/src/src/fccfg.c
@@ -27,6 +27,7 @@
#include "fcint.h"
#include <dirent.h>
#include <sys/types.h>
+#include "../fc-blanks/fcblanks.h"
#if defined (_WIN32) && !defined (R_OK)
#define R_OK 4
@@ -109,7 +110,7 @@ FcConfigCreate (void)
if (!config->cacheDirs)
goto bail8;
- config->blanks = 0;
+ config->blanks = &fcBlanks;
config->substPattern = 0;
config->substFont = 0;
@@ -375,7 +376,7 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
while ((dir = FcStrListNext (dirlist)))
{
if (FcDebug () & FC_DBG_FONTSET)
- printf ("adding fonts from%s\n", dir);
+ printf ("adding fonts from %s\n", dir);
cache = FcDirCacheRead (dir, FcFalse, config);
if (!cache)
continue;
@@ -434,6 +435,7 @@ retry:
if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config))
goto retry;
+ FcConfigReference (config);
if (cfg)
FcConfigDestroy (cfg);
@@ -722,6 +724,21 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
v.u.l = FcLangSetPromote (v.u.s, buf);
v.type = FcTypeLangSet;
}
+ else if (v.type == FcTypeVoid && u.type == FcTypeLangSet)
+ {
+ v.u.l = FcLangSetPromote (NULL, buf);
+ v.type = FcTypeLangSet;
+ }
+ else if (v.type == FcTypeVoid && u.type == FcTypeCharSet)
+ {
+ v.u.c = FcCharSetPromote (buf);
+ v.type = FcTypeCharSet;
+ }
+ if (buf && v.type == FcTypeDouble && u.type == FcTypeRange)
+ {
+ v.u.r = FcRangePromote (v.u.d, buf);
+ v.type = FcTypeRange;
+ }
return v;
}
@@ -894,6 +911,9 @@ FcConfigCompareValue (const FcValue *left_o,
break;
}
break;
+ case FcTypeRange:
+ ret = FcRangeCompare (op, left.u.r, right.u.r);
+ break;
}
}
else
@@ -915,10 +935,11 @@ FcConfigCompareValue (const FcValue *left_o,
static FcValue
FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
{
- FcValue v, vl, vr;
+ FcValue v, vl, vr, vle, vre;
FcMatrix *m;
FcChar8 *str;
FcOp op = FC_OP_GET_OP (e->op);
+ FcValuePromotionBuffer buf1, buf2;
switch ((int) op) {
case FcOpInteger:
@@ -967,6 +988,11 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
v.u.l = e->u.lval;
v = FcValueSave (v);
break;
+ case FcOpRange:
+ v.type = FcTypeRange;
+ v.u.r = e->u.rval;
+ v = FcValueSave (v);
+ break;
case FcOpBool:
v.type = FcTypeBool;
v.u.b = e->u.bval;
@@ -1033,28 +1059,28 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
case FcOpDivide:
vl = FcConfigEvaluate (p, p_pat, kind, e->u.tree.left);
vr = FcConfigEvaluate (p, p_pat, kind, e->u.tree.right);
- vl = FcConfigPromote (vl, vr, NULL);
- vr = FcConfigPromote (vr, vl, NULL);
- if (vl.type == vr.type)
+ vle = FcConfigPromote (vl, vr, &buf1);
+ vre = FcConfigPromote (vr, vle, &buf2);
+ if (vle.type == vre.type)
{
- switch ((int) vl.type) {
+ switch ((int) vle.type) {
case FcTypeDouble:
switch ((int) op) {
case FcOpPlus:
v.type = FcTypeDouble;
- v.u.d = vl.u.d + vr.u.d;
+ v.u.d = vle.u.d + vre.u.d;
break;
case FcOpMinus:
v.type = FcTypeDouble;
- v.u.d = vl.u.d - vr.u.d;
+ v.u.d = vle.u.d - vre.u.d;
break;
case FcOpTimes:
v.type = FcTypeDouble;
- v.u.d = vl.u.d * vr.u.d;
+ v.u.d = vle.u.d * vre.u.d;
break;
case FcOpDivide:
v.type = FcTypeDouble;
- v.u.d = vl.u.d / vr.u.d;
+ v.u.d = vle.u.d / vre.u.d;
break;
default:
v.type = FcTypeVoid;
@@ -1071,11 +1097,11 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
switch ((int) op) {
case FcOpOr:
v.type = FcTypeBool;
- v.u.b = vl.u.b || vr.u.b;
+ v.u.b = vle.u.b || vre.u.b;
break;
case FcOpAnd:
v.type = FcTypeBool;
- v.u.b = vl.u.b && vr.u.b;
+ v.u.b = vle.u.b && vre.u.b;
break;
default:
v.type = FcTypeVoid;
@@ -1086,7 +1112,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
switch ((int) op) {
case FcOpPlus:
v.type = FcTypeString;
- str = FcStrPlus (vl.u.s, vr.u.s);
+ str = FcStrPlus (vle.u.s, vre.u.s);
v.u.s = FcStrdup (str);
FcStrFree (str);
@@ -1105,7 +1131,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
m = malloc (sizeof (FcMatrix));
if (m)
{
- FcMatrixMultiply (m, vl.u.m, vr.u.m);
+ FcMatrixMultiply (m, vle.u.m, vre.u.m);
v.u.m = m;
}
else
@@ -1122,13 +1148,13 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
switch ((int) op) {
case FcOpPlus:
v.type = FcTypeCharSet;
- v.u.c = FcCharSetUnion (vl.u.c, vr.u.c);
+ v.u.c = FcCharSetUnion (vle.u.c, vre.u.c);
if (!v.u.c)
v.type = FcTypeVoid;
break;
case FcOpMinus:
v.type = FcTypeCharSet;
- v.u.c = FcCharSetSubtract (vl.u.c, vr.u.c);
+ v.u.c = FcCharSetSubtract (vle.u.c, vre.u.c);
if (!v.u.c)
v.type = FcTypeVoid;
break;
@@ -1141,13 +1167,13 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
switch ((int) op) {
case FcOpPlus:
v.type = FcTypeLangSet;
- v.u.l = FcLangSetUnion (vl.u.l, vr.u.l);
+ v.u.l = FcLangSetUnion (vle.u.l, vre.u.l);
if (!v.u.l)
v.type = FcTypeVoid;
break;
case FcOpMinus:
v.type = FcTypeLangSet;
- v.u.l = FcLangSetSubtract (vl.u.l, vr.u.l);
+ v.u.l = FcLangSetSubtract (vle.u.l, vre.u.l);
if (!v.u.l)
v.type = FcTypeVoid;
break;
@@ -1518,15 +1544,52 @@ FcConfigSubstituteWithPat (FcConfig *config,
FcStrList *l = FcStrListCreate (strs);
FcChar8 *lang;
FcValue v;
+ FcLangSet *lsund = FcLangSetCreate ();
+ FcLangSetAdd (lsund, (const FcChar8 *)"und");
FcStrSetDestroy (strs);
while (l && (lang = FcStrListNext (l)))
{
+ FcPatternElt *e = FcPatternObjectFindElt (p, FC_LANG_OBJECT);
+
+ if (e)
+ {
+ FcValueListPtr ll;
+
+ for (ll = FcPatternEltValues (e); ll; ll = FcValueListNext (ll))
+ {
+ FcValue vv = FcValueCanonicalize (&ll->value);
+
+ if (vv.type == FcTypeLangSet)
+ {
+ FcLangSet *ls = FcLangSetCreate ();
+ FcBool b;
+
+ FcLangSetAdd (ls, lang);
+ b = FcLangSetContains (vv.u.l, ls);
+ FcLangSetDestroy (ls);
+ if (b)
+ goto bail_lang;
+ if (FcLangSetContains (vv.u.l, lsund))
+ goto bail_lang;
+ }
+ else
+ {
+ if (FcStrCmpIgnoreCase (vv.u.s, lang) == 0)
+ goto bail_lang;
+ if (FcStrCmpIgnoreCase (vv.u.s, (const FcChar8 *)"und") == 0)
+ goto bail_lang;
+ }
+ }
+ }
v.type = FcTypeString;
v.u.s = lang;
+
FcPatternObjectAddWithBinding (p, FC_LANG_OBJECT, v, FcValueBindingWeak, FcTrue);
}
+ bail_lang:
FcStrListDone (l);
+ FcLangSetDestroy (lsund);
}
if (FcPatternObjectGet (p, FC_PRGNAME_OBJECT, 0, &v) == FcResultNoMatch)
{
@@ -1778,6 +1841,7 @@ FcConfigSubstitute (FcConfig *config,
#if defined (_WIN32)
static FcChar8 fontconfig_path[1000] = ""; /* MT-dontcare */
+FcChar8 fontconfig_instprefix[1000] = ""; /* MT-dontcare */
# if (defined (PIC) || defined (DLL_EXPORT))
@@ -1812,6 +1876,7 @@ DllMain (HINSTANCE hinstDLL,
if (p && (FcStrCmpIgnoreCase (p + 1, (const FcChar8 *) "bin") == 0 ||
FcStrCmpIgnoreCase (p + 1, (const FcChar8 *) "lib") == 0))
*p = '\0';
+ strcat ((char *) fontconfig_instprefix, (char *) fontconfig_path);
strcat ((char *) fontconfig_path, "\\etc\\fonts");
}
else
@@ -1985,6 +2050,8 @@ FcConfigXdgCacheHome (void)
const char *env = getenv ("XDG_CACHE_HOME");
FcChar8 *ret = NULL;
+ if (!_FcConfigHomeEnabled)
+ return NULL;
if (env)
ret = FcStrCopy ((const FcChar8 *)env);
else
@@ -2010,6 +2077,8 @@ FcConfigXdgConfigHome (void)
const char *env = getenv ("XDG_CONFIG_HOME");
FcChar8 *ret = NULL;
+ if (!_FcConfigHomeEnabled)
+ return NULL;
if (env)
ret = FcStrCopy ((const FcChar8 *)env);
else
@@ -2035,6 +2104,8 @@ FcConfigXdgDataHome (void)
const char *env = getenv ("XDG_DATA_HOME");
FcChar8 *ret = NULL;
+ if (!_FcConfigHomeEnabled)
+ return NULL;
if (env)
ret = FcStrCopy ((const FcChar8 *)env);
else
@@ -2134,7 +2205,7 @@ FcConfigAppFontAddFile (FcConfig *config,
return FcFalse;
}
- subdirs = FcStrSetCreate ();
+ subdirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
if (!subdirs)
return FcFalse;
@@ -2181,7 +2252,7 @@ FcConfigAppFontAddDir (FcConfig *config,
return FcFalse;
}
- dirs = FcStrSetCreate ();
+ dirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
if (!dirs)
return FcFalse;
@@ -2312,7 +2383,7 @@ void
FcConfigSetSysRoot (FcConfig *config,
const FcChar8 *sysroot)
{
- FcChar8 *s;
+ FcChar8 *s = NULL;
FcBool init = FcFalse;
if (!config)
@@ -2332,9 +2403,12 @@ FcConfigSetSysRoot (FcConfig *config,
}
}
- s = FcStrCopyFilename (sysroot);
- if (!s)
- return;
+ if (sysroot)
+ {
+ s = FcStrCopyFilename (sysroot);
+ if (!s)
+ return;
+ }
if (config->sysRoot)
FcStrFree (config->sysRoot);
@@ -2344,6 +2418,10 @@ FcConfigSetSysRoot (FcConfig *config,
{
config = FcInitLoadOwnConfigAndFonts (config);
FcConfigSetCurrent (config);
+ /* FcConfigSetCurrent() increases the refcount.
+ * decrease it here to avoid the memory leak.
+ */
+ FcConfigDestroy (config);
}
}
diff --git a/chromium/third_party/fontconfig/src/src/fccharset.c b/chromium/third_party/fontconfig/src/src/fccharset.c
index c9f928cd480..3f1789230e6 100644
--- a/chromium/third_party/fontconfig/src/src/fccharset.c
+++ b/chromium/third_party/fontconfig/src/src/fccharset.c
@@ -43,6 +43,21 @@ FcCharSetCreate (void)
}
FcCharSet *
+FcCharSetPromote (FcValuePromotionBuffer *vbuf)
+{
+ FcCharSet *fcs = (FcCharSet *) vbuf;
+
+ FC_ASSERT_STATIC (sizeof (FcCharSet) <= sizeof (FcValuePromotionBuffer));
+
+ FcRefSetConst (&fcs->ref);
+ fcs->num = 0;
+ fcs->leaves_offset = 0;
+ fcs->numbers_offset = 0;
+
+ return fcs;
+}
+
+FcCharSet *
FcCharSetNew (void)
{
return FcCharSetCreate ();
@@ -149,6 +164,14 @@ FcCharSetPutLeaf (FcCharSet *fcs,
unsigned int alloced = 8;
leaves = malloc (alloced * sizeof (*leaves));
numbers = malloc (alloced * sizeof (*numbers));
+ if (!leaves || !numbers)
+ {
+ if (leaves)
+ free (leaves);
+ if (numbers)
+ free (numbers);
+ return FcFalse;
+ }
}
else
{
@@ -157,8 +180,19 @@ FcCharSetPutLeaf (FcCharSet *fcs,
alloced *= 2;
new_leaves = realloc (leaves, alloced * sizeof (*leaves));
+ if (!new_leaves)
+ return FcFalse;
numbers = realloc (numbers, alloced * sizeof (*numbers));
-
+ if (!numbers)
+ {
+ /* Revert the reallocation of leaves */
+ leaves = realloc (new_leaves, (alloced / 2) * sizeof (*new_leaves));
+ /* unlikely to fail though */
+ if (!leaves)
+ return FcFalse;
+ fcs->leaves_offset = FcPtrToOffset (fcs, leaves);
+ return FcFalse;
+ }
distance = (intptr_t) new_leaves - (intptr_t) leaves;
if (new_leaves && distance)
{
@@ -169,9 +203,6 @@ FcCharSetPutLeaf (FcCharSet *fcs,
leaves = new_leaves;
}
- if (!leaves || !numbers)
- return FcFalse;
-
fcs->leaves_offset = FcPtrToOffset (fcs, leaves);
fcs->numbers_offset = FcPtrToOffset (fcs, numbers);
}
@@ -800,188 +831,123 @@ FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result)
return page;
}
-/*
- * ASCII representation of charsets.
- *
- * Each leaf is represented as 9 32-bit values, the code of the first character followed
- * by 8 32 bit values for the leaf itself. Each value is encoded as 5 ASCII characters,
- * only 85 different values are used to avoid control characters as well as the other
- * characters used to encode font names. 85**5 > 2^32 so things work out, but
- * it's not exactly human readable output. As a special case, 0 is encoded as a space
- */
-
-static const unsigned char charToValue[256] = {
- /* "" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\b" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\020" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\030" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* " " */ 0xff, 0x00, 0xff, 0x01, 0x02, 0x03, 0x04, 0xff,
- /* "(" */ 0x05, 0x06, 0x07, 0x08, 0xff, 0xff, 0x09, 0x0a,
- /* "0" */ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
- /* "8" */ 0x13, 0x14, 0xff, 0x15, 0x16, 0xff, 0x17, 0x18,
- /* "@" */ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- /* "H" */ 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- /* "P" */ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- /* "X" */ 0x31, 0x32, 0x33, 0x34, 0xff, 0x35, 0x36, 0xff,
- /* "`" */ 0xff, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d,
- /* "h" */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
- /* "p" */ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
- /* "x" */ 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0xff,
- /* "\200" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\210" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\220" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\230" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\240" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\250" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\260" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\270" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\300" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\310" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\320" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\330" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\340" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\350" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\360" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- /* "\370" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-};
-
-static const FcChar8 valueToChar[0x55] = {
- /* 0x00 */ '!', '#', '$', '%', '&', '(', ')', '*',
- /* 0x08 */ '+', '.', '/', '0', '1', '2', '3', '4',
- /* 0x10 */ '5', '6', '7', '8', '9', ';', '<', '>',
- /* 0x18 */ '?', '@', 'A', 'B', 'C', 'D', 'E', 'F',
- /* 0x20 */ 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
- /* 0x28 */ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
- /* 0x30 */ 'W', 'X', 'Y', 'Z', '[', ']', '^', 'a',
- /* 0x38 */ 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
- /* 0x40 */ 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
- /* 0x48 */ 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
- /* 0x50 */ 'z', '{', '|', '}', '~',
-};
-
-static FcChar8 *
-FcCharSetParseValue (FcChar8 *string, FcChar32 *value)
-{
- int i;
- FcChar32 v;
- FcChar32 c;
-
- if (*string == ' ')
- {
- v = 0;
- string++;
- }
- else
- {
- v = 0;
- for (i = 0; i < 5; i++)
- {
- if (!(c = (FcChar32) (unsigned char) *string++))
- return 0;
- c = charToValue[c];
- if (c == 0xff)
- return 0;
- v = v * 85 + c;
- }
- }
- *value = v;
- return string;
-}
-
static FcBool
-FcCharSetUnparseValue (FcStrBuf *buf, FcChar32 value)
+FcNameParseRange (FcChar8 **string, FcChar32 *pfirst, FcChar32 *plast)
{
- int i;
- if (value == 0)
- {
- return FcStrBufChar (buf, ' ');
- }
- else
- {
- FcChar8 string[6];
- FcChar8 *s = string + 5;
- string[5] = '\0';
- for (i = 0; i < 5; i++)
+ char *s = (char *) *string;
+ char *t;
+ long first, last;
+
+ while (isspace(*s))
+ s++;
+ t = s;
+ errno = 0;
+ first = last = strtol (s, &s, 16);
+ if (errno)
+ return FcFalse;
+ while (isspace(*s))
+ s++;
+ if (*s == '-')
{
- *--s = valueToChar[value % 85];
- value /= 85;
- }
- for (i = 0; i < 5; i++)
- if (!FcStrBufChar (buf, *s++))
+ s++;
+ errno = 0;
+ last = strtol (s, &s, 16);
+ if (errno)
return FcFalse;
- }
- return FcTrue;
+ }
+
+ if (s == t || first < 0 || last < 0 || last < first || last > 0x10ffff)
+ return FcFalse;
+
+ *string = (FcChar8 *) s;
+ *pfirst = first;
+ *plast = last;
+ return FcTrue;
}
FcCharSet *
FcNameParseCharSet (FcChar8 *string)
{
FcCharSet *c;
- FcChar32 ucs4;
- FcCharLeaf *leaf;
- FcCharLeaf temp;
- FcChar32 bits;
- int i;
+ FcChar32 first, last;
c = FcCharSetCreate ();
if (!c)
goto bail0;
while (*string)
{
- string = FcCharSetParseValue (string, &ucs4);
- if (!string)
- goto bail1;
- bits = 0;
- for (i = 0; i < 256/32; i++)
- {
- string = FcCharSetParseValue (string, &temp.map[i]);
- if (!string)
- goto bail1;
- bits |= temp.map[i];
- }
- if (bits)
- {
- leaf = malloc (sizeof (FcCharLeaf));
- if (!leaf)
- goto bail1;
- *leaf = temp;
- if (!FcCharSetInsertLeaf (c, ucs4, leaf))
+ FcChar32 u;
+
+ if (!FcNameParseRange (&string, &first, &last))
goto bail1;
- }
+
+ for (u = first; u < last + 1; u++)
+ FcCharSetAddChar (c, u);
}
return c;
bail1:
- if (c->num)
- {
- free (FcCharSetLeaves (c));
- }
- if (c->num)
- {
- free (FcCharSetNumbers (c));
- }
- free (c);
+ FcCharSetDestroy (c);
bail0:
return NULL;
}
+static void
+FcNameUnparseUnicode (FcStrBuf *buf, FcChar32 u)
+{
+ FcChar8 buf_static[64];
+ snprintf ((char *) buf_static, sizeof (buf_static), "%x", u);
+ FcStrBufString (buf, buf_static);
+}
+
FcBool
FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c)
{
FcCharSetIter ci;
+ FcChar32 first, last;
int i;
#ifdef CHECK
int len = buf->len;
#endif
+ first = last = 0x7FFFFFFF;
+
for (FcCharSetIterStart (c, &ci);
ci.leaf;
FcCharSetIterNext (c, &ci))
{
- if (!FcCharSetUnparseValue (buf, ci.ucs4))
- return FcFalse;
for (i = 0; i < 256/32; i++)
- if (!FcCharSetUnparseValue (buf, ci.leaf->map[i]))
- return FcFalse;
+ {
+ FcChar32 bits = ci.leaf->map[i];
+ FcChar32 u = ci.ucs4 + i * 32;
+
+ while (bits)
+ {
+ if (bits & 1)
+ {
+ if (u != last + 1)
+ {
+ if (last != first)
+ {
+ FcStrBufChar (buf, '-');
+ FcNameUnparseUnicode (buf, last);
+ }
+ if (last != 0x7FFFFFFF)
+ FcStrBufChar (buf, ' ');
+ /* Start new range. */
+ first = u;
+ FcNameUnparseUnicode (buf, u);
+ }
+ last = u;
+ }
+ bits >>= 1;
+ u++;
+ }
+ }
+ }
+ if (last != first)
+ {
+ FcStrBufChar (buf, '-');
+ FcNameUnparseUnicode (buf, last);
}
#ifdef CHECK
{
diff --git a/chromium/third_party/fontconfig/src/src/fccompat.c b/chromium/third_party/fontconfig/src/src/fccompat.c
index 1c2ba8bedde..31d80bef162 100644
--- a/chromium/third_party/fontconfig/src/src/fccompat.c
+++ b/chromium/third_party/fontconfig/src/src/fccompat.c
@@ -170,14 +170,27 @@ FcRandom(void)
static struct random_data fcrandbuf;
static char statebuf[256];
static FcBool initialized = FcFalse;
+#ifdef _AIX
+ static char *retval;
+ long res;
+#endif
if (initialized != FcTrue)
{
- initstate_r(time(NULL), statebuf, 256, &fcrandbuf);
+#ifdef _AIX
+ initstate_r (time (NULL), statebuf, 256, &retval, &fcrandbuf);
+#else
+ initstate_r (time (NULL), statebuf, 256, &fcrandbuf);
+#endif
initialized = FcTrue;
}
- random_r(&fcrandbuf, &result);
+#ifdef _AIX
+ random_r (&res, &fcrandbuf);
+ result = (int32_t)res;
+#else
+ random_r (&fcrandbuf, &result);
+#endif
#elif HAVE_RANDOM
static char statebuf[256];
char *state;
@@ -185,30 +198,30 @@ FcRandom(void)
if (initialized != FcTrue)
{
- state = initstate(time(NULL), statebuf, 256);
+ state = initstate (time (NULL), statebuf, 256);
initialized = FcTrue;
}
else
- state = setstate(statebuf);
+ state = setstate (statebuf);
- result = random();
+ result = random ();
- setstate(state);
+ setstate (state);
#elif HAVE_LRAND48
- result = lrand48();
+ result = lrand48 ();
#elif HAVE_RAND_R
- static unsigned int seed = time(NULL);
+ static unsigned int seed = time (NULL);
- result = rand_r(&seed);
+ result = rand_r (&seed);
#elif HAVE_RAND
static FcBool initialized = FcFalse;
if (initialized != FcTrue)
{
- srand(time(NULL));
+ srand (time (NULL));
initialized = FcTrue;
}
- result = rand();
+ result = rand ();
#else
# error no random number generator function available.
#endif
@@ -242,3 +255,7 @@ FcMakeDirectory (const FcChar8 *dir)
FcStrFree (parent);
return ret;
}
+
+#define __fccompat__
+#include "fcaliastail.h"
+#undef __fccompat__
diff --git a/chromium/third_party/fontconfig/src/src/fcdbg.c b/chromium/third_party/fontconfig/src/src/fcdbg.c
index d74bc276940..c2853fff376 100644
--- a/chromium/third_party/fontconfig/src/src/fcdbg.c
+++ b/chromium/third_party/fontconfig/src/src/fcdbg.c
@@ -61,6 +61,9 @@ _FcValuePrintFile (FILE *f, const FcValue v)
case FcTypeFTFace:
fprintf (f, "face");
break;
+ case FcTypeRange:
+ fprintf (f, "[%g %g)", v.u.r->begin, v.u.r->end);
+ break;
}
}
@@ -208,6 +211,84 @@ FcPatternPrint (const FcPattern *p)
}
void
+FcPatternPrint2 (FcPattern *pp1,
+ FcPattern *pp2,
+ const FcObjectSet *os)
+{
+ int i, j, k, pos;
+ FcPatternElt *e1, *e2;
+ FcPattern *p1, *p2;
+
+ if (os)
+ {
+ p1 = FcPatternFilter (pp1, os);
+ p2 = FcPatternFilter (pp2, os);
+ }
+ else
+ {
+ p1 = pp1;
+ p2 = pp2;
+ }
+ printf ("Pattern has %d elts (size %d), %d elts (size %d)\n",
+ p1->num, p1->size, p2->num, p2->size);
+ for (i = 0, j = 0; i < p1->num; i++)
+ {
+ e1 = &FcPatternElts(p1)[i];
+ e2 = &FcPatternElts(p2)[j];
+ if (!e2 || e1->object != e2->object)
+ {
+ pos = FcPatternPosition (p2, FcObjectName (e1->object));
+ if (pos >= 0)
+ {
+ for (k = j; k < pos; k++)
+ {
+ e2 = &FcPatternElts(p2)[k];
+ printf ("\t%s: (None) -> ", FcObjectName (e2->object));
+ FcValueListPrint (FcPatternEltValues (e2));
+ printf ("\n");
+ }
+ j = pos;
+ goto cont;
+ }
+ else
+ {
+ printf ("\t%s:", FcObjectName (e1->object));
+ FcValueListPrint (FcPatternEltValues (e1));
+ printf (" -> (None)\n");
+ }
+ }
+ else
+ {
+ cont:
+ printf ("\t%s:", FcObjectName (e1->object));
+ FcValueListPrint (FcPatternEltValues (e1));
+ printf (" -> ");
+ e2 = &FcPatternElts(p2)[j];
+ FcValueListPrint (FcPatternEltValues (e2));
+ printf ("\n");
+ j++;
+ }
+ }
+ if (j < p2->num)
+ {
+ for (k = j; k < p2->num; k++)
+ {
+ e2 = &FcPatternElts(p2)[k];
+ if (FcObjectName (e2->object))
+ {
+ printf ("\t%s: (None) -> ", FcObjectName (e2->object));
+ FcValueListPrint (FcPatternEltValues (e2));
+ printf ("\n");
+ }
+ }
+ }
+ if (p1 != pp1)
+ FcPatternDestroy (p1);
+ if (p2 != pp2)
+ FcPatternDestroy (p2);
+}
+
+void
FcOpPrint (FcOp op_)
{
FcOp op = FC_OP_GET_OP (op_);
@@ -277,7 +358,9 @@ FcExprPrint (const FcExpr *expr)
FcExprPrint (expr->u.mexpr->yy);
printf ("]");
break;
- case FcOpRange: break;
+ case FcOpRange:
+ printf ("(%g, %g)", expr->u.rval->begin, expr->u.rval->end);
+ break;
case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
case FcOpCharSet: printf ("charset\n"); break;
case FcOpLangSet:
diff --git a/chromium/third_party/fontconfig/src/src/fcdefault.c b/chromium/third_party/fontconfig/src/src/fcdefault.c
index d1b917fd9de..6647a8fe81c 100644
--- a/chromium/third_party/fontconfig/src/src/fcdefault.c
+++ b/chromium/third_party/fontconfig/src/src/fcdefault.c
@@ -38,6 +38,7 @@ static const struct {
{ FC_GLOBAL_ADVANCE_OBJECT, FcTrue }, /* !FC_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
{ FC_EMBEDDED_BITMAP_OBJECT, FcTrue }, /* !FC_LOAD_NO_BITMAP */
{ FC_DECORATIVE_OBJECT, FcFalse },
+ { FC_SYMBOL_OBJECT, FcFalse },
};
#define NUM_FC_BOOL_DEFAULTS (int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
@@ -94,7 +95,6 @@ retry:
{
FcStrSet *langs = FcGetDefaultLangs ();
lang = FcStrdup (langs->strs[0]);
- FcStrSetDestroy (langs);
if (!fc_atomic_ptr_cmpexch (&default_lang, NULL, lang)) {
free (lang);
@@ -149,7 +149,7 @@ retry:
#else
# if defined (HAVE_GETEXECNAME)
const char *p = getexecname ();
-# else
+# elif defined (HAVE_READLINK)
char buf[PATH_MAX + 1];
int len;
char *p = NULL;
@@ -160,6 +160,8 @@ retry:
buf[len] = '\0';
p = buf;
}
+# else
+ char *p = NULL;
# endif
if (p)
{
@@ -217,9 +219,10 @@ FcDefaultSubstitute (FcPattern *pattern)
{
FcValue v, namelang, v2;
int i;
+ double dpi, size, scale, pixelsize;
if (FcPatternObjectGet (pattern, FC_WEIGHT_OBJECT, 0, &v) == FcResultNoMatch )
- FcPatternObjectAddInteger (pattern, FC_WEIGHT_OBJECT, FC_WEIGHT_MEDIUM);
+ FcPatternObjectAddInteger (pattern, FC_WEIGHT_OBJECT, FC_WEIGHT_NORMAL);
if (FcPatternObjectGet (pattern, FC_SLANT_OBJECT, 0, &v) == FcResultNoMatch)
FcPatternObjectAddInteger (pattern, FC_SLANT_OBJECT, FC_SLANT_ROMAN);
@@ -231,32 +234,30 @@ FcDefaultSubstitute (FcPattern *pattern)
if (FcPatternObjectGet (pattern, FcBoolDefaults[i].field, 0, &v) == FcResultNoMatch)
FcPatternObjectAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value);
- if (FcPatternObjectGet (pattern, FC_PIXEL_SIZE_OBJECT, 0, &v) == FcResultNoMatch)
- {
- double dpi, size, scale;
+ if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch)
+ size = 12.0L;
+ if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch)
+ scale = 1.0;
+ if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch)
+ dpi = 75.0;
- if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch)
- {
- size = 12.0;
- (void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT);
- FcPatternObjectAddDouble (pattern, FC_SIZE_OBJECT, size);
- }
- if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch)
- {
- scale = 1.0;
- (void) FcPatternObjectDel (pattern, FC_SCALE_OBJECT);
- FcPatternObjectAddDouble (pattern, FC_SCALE_OBJECT, scale);
- }
- size *= scale;
- if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch)
- {
- dpi = 75.0;
- (void) FcPatternObjectDel (pattern, FC_DPI_OBJECT);
- FcPatternObjectAddDouble (pattern, FC_DPI_OBJECT, dpi);
- }
- size *= dpi / 72.0;
- FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, size);
+ if (FcPatternObjectGet (pattern, FC_PIXEL_SIZE_OBJECT, 0, &v) != FcResultMatch)
+ {
+ (void) FcPatternObjectDel (pattern, FC_SCALE_OBJECT);
+ FcPatternObjectAddDouble (pattern, FC_SCALE_OBJECT, scale);
+ pixelsize = size * scale;
+ (void) FcPatternObjectDel (pattern, FC_DPI_OBJECT);
+ FcPatternObjectAddDouble (pattern, FC_DPI_OBJECT, dpi);
+ pixelsize *= dpi / 72.0;
+ FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, pixelsize);
+ }
+ else
+ {
+ size = v.u.d;
+ size = size / dpi * 72.0 / scale;
}
+ (void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT);
+ FcPatternObjectAddDouble (pattern, FC_SIZE_OBJECT, size);
if (FcPatternObjectGet (pattern, FC_FONTVERSION_OBJECT, 0, &v) == FcResultNoMatch)
{
diff --git a/chromium/third_party/fontconfig/src/src/fcdir.c b/chromium/third_party/fontconfig/src/src/fcdir.c
index b040a285ad6..fd62a342f81 100644
--- a/chromium/third_party/fontconfig/src/src/fcdir.c
+++ b/chromium/third_party/fontconfig/src/src/fcdir.c
@@ -23,6 +23,9 @@
*/
#include "fcint.h"
+#include "fcftint.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
#include <dirent.h>
FcBool
@@ -65,12 +68,20 @@ FcFileScanFontConfig (FcFontSet *set,
const FcChar8 *file,
FcConfig *config)
{
+ FT_Library ftLibrary;
+ FT_Face face;
FcPattern *font;
FcBool ret = FcTrue;
+ int num_faces = 0;
+ int num_instances = 0;
+ int face_num = 0;
+ int instance_num = 0;
int id;
- int count = 0;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+
+ if (FT_Init_FreeType (&ftLibrary))
+ return FcFalse;
- id = 0;
do
{
font = 0;
@@ -82,9 +93,39 @@ FcFileScanFontConfig (FcFontSet *set,
printf ("\tScanning file %s...", file);
fflush (stdout);
}
- font = FcFreeTypeQuery (file, id, blanks, &count);
+
+ id = ((instance_num << 16) + face_num);
+ if (FT_New_Face (ftLibrary, (char *) file, id, &face))
+ return FcFalse;
+ num_faces = face->num_faces;
+ num_instances = face->style_flags >> 16;
+ font = FcFreeTypeQueryFace (face, file, id, blanks);
+ FT_Done_Face (face);
+
if (FcDebug () & FC_DBG_SCAN)
printf ("done\n");
+ /*
+ * Get rid of sysroot here so that targeting scan rule may contains FC_FILE pattern
+ * and they should usually expect without sysroot.
+ */
+ if (font && sysroot)
+ {
+ size_t len = strlen ((const char *)sysroot);
+ FcChar8 *f = NULL;
+
+ if (FcPatternObjectGetString (font, FC_FILE_OBJECT, 0, &f) == FcResultMatch &&
+ strncmp ((const char *)f, (const char *)sysroot, len) == 0)
+ {
+ FcChar8 *s = FcStrdup (f);
+ FcPatternObjectDel (font, FC_FILE_OBJECT);
+ if (s[len] != '/')
+ len--;
+ else if (s[len+1] == '/')
+ len++;
+ FcPatternObjectAddString (font, FC_FILE_OBJECT, &s[len]);
+ FcStrFree (s);
+ }
+ }
/*
* Edit pattern with user-defined rules
@@ -113,10 +154,20 @@ FcFileScanFontConfig (FcFontSet *set,
ret = FcFalse;
}
}
- else if (font)
- FcPatternDestroy (font);
- id++;
- } while (font && ret && id < count);
+ else
+ ret = FcFalse;
+
+ if (instance_num < num_instances)
+ instance_num++;
+ else
+ {
+ face_num++;
+ instance_num = 0;
+ }
+ } while (font && ret && face_num < num_faces);
+
+ FT_Done_FreeType (ftLibrary);
+
return ret;
}
@@ -128,9 +179,32 @@ FcFileScanConfig (FcFontSet *set,
FcConfig *config)
{
if (FcFileIsDir (file))
- return FcStrSetAdd (dirs, file);
+ {
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ const FcChar8 *d = file;
+ size_t len;
+
+ if (sysroot)
+ {
+ len = strlen ((const char *)sysroot);
+ if (strncmp ((const char *)file, (const char *)sysroot, len) == 0)
+ {
+ if (file[len] != '/')
+ len--;
+ else if (file[len+1] == '/')
+ len++;
+ d = &file[len];
+ }
+ }
+ return FcStrSetAdd (dirs, d);
+ }
else
- return FcFileScanFontConfig (set, blanks, file, config);
+ {
+ if (set)
+ return FcFileScanFontConfig (set, blanks, file, config);
+ else
+ return FcTrue;
+ }
}
FcBool
@@ -201,7 +275,7 @@ FcDirScanConfig (FcFontSet *set,
goto bail;
}
- files = FcStrSetCreate ();
+ files = FcStrSetCreateEx (FCSS_ALLOW_DUPLICATES | FCSS_GROW_BY_64);
if (!files)
{
ret = FcFalse;
@@ -265,25 +339,34 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
FcFontSet *set;
FcCache *cache = NULL;
struct stat dir_stat;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ FcChar8 *d;
+ int fd = -1;
+
+ if (sysroot)
+ d = FcStrBuildFilename (sysroot, dir, NULL);
+ else
+ d = FcStrdup (dir);
if (FcDebug () & FC_DBG_FONTSET)
- printf ("cache scan dir %s\n", dir);
+ printf ("cache scan dir %s\n", d);
- if (FcStatChecksum (dir, &dir_stat) < 0)
+ if (FcStatChecksum (d, &dir_stat) < 0)
goto bail;
set = FcFontSetCreate();
if (!set)
goto bail;
- dirs = FcStrSetCreate ();
+ dirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
if (!dirs)
goto bail1;
+ fd = FcDirCacheLock (dir, config);
/*
* Scan the dir
*/
- if (!FcDirScanConfig (set, dirs, NULL, dir, FcTrue, config))
+ if (!FcDirScanConfig (set, dirs, NULL, d, FcTrue, config))
goto bail2;
/*
@@ -299,13 +382,69 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
FcDirCacheWrite (cache, config);
bail2:
+ FcDirCacheUnlock (fd);
FcStrSetDestroy (dirs);
bail1:
FcFontSetDestroy (set);
bail:
+ FcStrFree (d);
+
return cache;
}
+FcCache *
+FcDirCacheRescan (const FcChar8 *dir, FcConfig *config)
+{
+ FcCache *cache;
+ FcCache *new = NULL;
+ struct stat dir_stat;
+ FcStrSet *dirs;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ FcChar8 *d = NULL;
+ int fd = -1;
+
+ cache = FcDirCacheLoad (dir, config, NULL);
+ if (!cache)
+ goto bail;
+
+ if (sysroot)
+ d = FcStrBuildFilename (sysroot, dir, NULL);
+ else
+ d = FcStrdup (dir);
+ if (FcStatChecksum (d, &dir_stat) < 0)
+ goto bail;
+ dirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
+ if (!dirs)
+ goto bail;
+
+ fd = FcDirCacheLock (dir, config);
+ /*
+ * Scan the dir
+ */
+ if (!FcDirScanConfig (NULL, dirs, NULL, d, FcTrue, config))
+ goto bail1;
+ /*
+ * Rebuild the cache object
+ */
+ new = FcDirCacheRebuild (cache, &dir_stat, dirs);
+ if (!new)
+ goto bail1;
+ FcDirCacheUnload (cache);
+ /*
+ * Write out the cache file, ignoring any troubles
+ */
+ FcDirCacheWrite (new, config);
+
+bail1:
+ FcDirCacheUnlock (fd);
+ FcStrSetDestroy (dirs);
+bail:
+ if (d)
+ FcStrFree (d);
+
+ return new;
+}
+
/*
* Read (or construct) the cache for a directory
*/
diff --git a/chromium/third_party/fontconfig/src/src/fcfreetype.c b/chromium/third_party/fontconfig/src/src/fcfreetype.c
index e39430762c7..b4d926d4667 100644
--- a/chromium/third_party/fontconfig/src/src/fcfreetype.c
+++ b/chromium/third_party/fontconfig/src/src/fcfreetype.c
@@ -62,6 +62,7 @@
#include FT_BDF_H
#include FT_MODULE_H
#endif
+#include FT_MULTIPLE_MASTERS_H
#include "ftglue.h"
@@ -558,6 +559,139 @@ FcFontCapabilities(FT_Face face);
#define NUM_FC_MAC_ROMAN_FAKE (int) (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0]))
+
+/* From http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT */
+static const FcChar16 fcMacRomanNonASCIIToUnicode[128] = {
+ /*0x80*/ 0x00C4, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
+ /*0x81*/ 0x00C5, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
+ /*0x82*/ 0x00C7, /* LATIN CAPITAL LETTER C WITH CEDILLA */
+ /*0x83*/ 0x00C9, /* LATIN CAPITAL LETTER E WITH ACUTE */
+ /*0x84*/ 0x00D1, /* LATIN CAPITAL LETTER N WITH TILDE */
+ /*0x85*/ 0x00D6, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
+ /*0x86*/ 0x00DC, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+ /*0x87*/ 0x00E1, /* LATIN SMALL LETTER A WITH ACUTE */
+ /*0x88*/ 0x00E0, /* LATIN SMALL LETTER A WITH GRAVE */
+ /*0x89*/ 0x00E2, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
+ /*0x8A*/ 0x00E4, /* LATIN SMALL LETTER A WITH DIAERESIS */
+ /*0x8B*/ 0x00E3, /* LATIN SMALL LETTER A WITH TILDE */
+ /*0x8C*/ 0x00E5, /* LATIN SMALL LETTER A WITH RING ABOVE */
+ /*0x8D*/ 0x00E7, /* LATIN SMALL LETTER C WITH CEDILLA */
+ /*0x8E*/ 0x00E9, /* LATIN SMALL LETTER E WITH ACUTE */
+ /*0x8F*/ 0x00E8, /* LATIN SMALL LETTER E WITH GRAVE */
+ /*0x90*/ 0x00EA, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
+ /*0x91*/ 0x00EB, /* LATIN SMALL LETTER E WITH DIAERESIS */
+ /*0x92*/ 0x00ED, /* LATIN SMALL LETTER I WITH ACUTE */
+ /*0x93*/ 0x00EC, /* LATIN SMALL LETTER I WITH GRAVE */
+ /*0x94*/ 0x00EE, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
+ /*0x95*/ 0x00EF, /* LATIN SMALL LETTER I WITH DIAERESIS */
+ /*0x96*/ 0x00F1, /* LATIN SMALL LETTER N WITH TILDE */
+ /*0x97*/ 0x00F3, /* LATIN SMALL LETTER O WITH ACUTE */
+ /*0x98*/ 0x00F2, /* LATIN SMALL LETTER O WITH GRAVE */
+ /*0x99*/ 0x00F4, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
+ /*0x9A*/ 0x00F6, /* LATIN SMALL LETTER O WITH DIAERESIS */
+ /*0x9B*/ 0x00F5, /* LATIN SMALL LETTER O WITH TILDE */
+ /*0x9C*/ 0x00FA, /* LATIN SMALL LETTER U WITH ACUTE */
+ /*0x9D*/ 0x00F9, /* LATIN SMALL LETTER U WITH GRAVE */
+ /*0x9E*/ 0x00FB, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
+ /*0x9F*/ 0x00FC, /* LATIN SMALL LETTER U WITH DIAERESIS */
+ /*0xA0*/ 0x2020, /* DAGGER */
+ /*0xA1*/ 0x00B0, /* DEGREE SIGN */
+ /*0xA2*/ 0x00A2, /* CENT SIGN */
+ /*0xA3*/ 0x00A3, /* POUND SIGN */
+ /*0xA4*/ 0x00A7, /* SECTION SIGN */
+ /*0xA5*/ 0x2022, /* BULLET */
+ /*0xA6*/ 0x00B6, /* PILCROW SIGN */
+ /*0xA7*/ 0x00DF, /* LATIN SMALL LETTER SHARP S */
+ /*0xA8*/ 0x00AE, /* REGISTERED SIGN */
+ /*0xA9*/ 0x00A9, /* COPYRIGHT SIGN */
+ /*0xAA*/ 0x2122, /* TRADE MARK SIGN */
+ /*0xAB*/ 0x00B4, /* ACUTE ACCENT */
+ /*0xAC*/ 0x00A8, /* DIAERESIS */
+ /*0xAD*/ 0x2260, /* NOT EQUAL TO */
+ /*0xAE*/ 0x00C6, /* LATIN CAPITAL LETTER AE */
+ /*0xAF*/ 0x00D8, /* LATIN CAPITAL LETTER O WITH STROKE */
+ /*0xB0*/ 0x221E, /* INFINITY */
+ /*0xB1*/ 0x00B1, /* PLUS-MINUS SIGN */
+ /*0xB2*/ 0x2264, /* LESS-THAN OR EQUAL TO */
+ /*0xB3*/ 0x2265, /* GREATER-THAN OR EQUAL TO */
+ /*0xB4*/ 0x00A5, /* YEN SIGN */
+ /*0xB5*/ 0x00B5, /* MICRO SIGN */
+ /*0xB6*/ 0x2202, /* PARTIAL DIFFERENTIAL */
+ /*0xB7*/ 0x2211, /* N-ARY SUMMATION */
+ /*0xB8*/ 0x220F, /* N-ARY PRODUCT */
+ /*0xB9*/ 0x03C0, /* GREEK SMALL LETTER PI */
+ /*0xBA*/ 0x222B, /* INTEGRAL */
+ /*0xBB*/ 0x00AA, /* FEMININE ORDINAL INDICATOR */
+ /*0xBC*/ 0x00BA, /* MASCULINE ORDINAL INDICATOR */
+ /*0xBD*/ 0x03A9, /* GREEK CAPITAL LETTER OMEGA */
+ /*0xBE*/ 0x00E6, /* LATIN SMALL LETTER AE */
+ /*0xBF*/ 0x00F8, /* LATIN SMALL LETTER O WITH STROKE */
+ /*0xC0*/ 0x00BF, /* INVERTED QUESTION MARK */
+ /*0xC1*/ 0x00A1, /* INVERTED EXCLAMATION MARK */
+ /*0xC2*/ 0x00AC, /* NOT SIGN */
+ /*0xC3*/ 0x221A, /* SQUARE ROOT */
+ /*0xC4*/ 0x0192, /* LATIN SMALL LETTER F WITH HOOK */
+ /*0xC5*/ 0x2248, /* ALMOST EQUAL TO */
+ /*0xC6*/ 0x2206, /* INCREMENT */
+ /*0xC7*/ 0x00AB, /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
+ /*0xC8*/ 0x00BB, /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
+ /*0xC9*/ 0x2026, /* HORIZONTAL ELLIPSIS */
+ /*0xCA*/ 0x00A0, /* NO-BREAK SPACE */
+ /*0xCB*/ 0x00C0, /* LATIN CAPITAL LETTER A WITH GRAVE */
+ /*0xCC*/ 0x00C3, /* LATIN CAPITAL LETTER A WITH TILDE */
+ /*0xCD*/ 0x00D5, /* LATIN CAPITAL LETTER O WITH TILDE */
+ /*0xCE*/ 0x0152, /* LATIN CAPITAL LIGATURE OE */
+ /*0xCF*/ 0x0153, /* LATIN SMALL LIGATURE OE */
+ /*0xD0*/ 0x2013, /* EN DASH */
+ /*0xD1*/ 0x2014, /* EM DASH */
+ /*0xD2*/ 0x201C, /* LEFT DOUBLE QUOTATION MARK */
+ /*0xD3*/ 0x201D, /* RIGHT DOUBLE QUOTATION MARK */
+ /*0xD4*/ 0x2018, /* LEFT SINGLE QUOTATION MARK */
+ /*0xD5*/ 0x2019, /* RIGHT SINGLE QUOTATION MARK */
+ /*0xD6*/ 0x00F7, /* DIVISION SIGN */
+ /*0xD7*/ 0x25CA, /* LOZENGE */
+ /*0xD8*/ 0x00FF, /* LATIN SMALL LETTER Y WITH DIAERESIS */
+ /*0xD9*/ 0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
+ /*0xDA*/ 0x2044, /* FRACTION SLASH */
+ /*0xDB*/ 0x20AC, /* EURO SIGN */
+ /*0xDC*/ 0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
+ /*0xDD*/ 0x203A, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
+ /*0xDE*/ 0xFB01, /* LATIN SMALL LIGATURE FI */
+ /*0xDF*/ 0xFB02, /* LATIN SMALL LIGATURE FL */
+ /*0xE0*/ 0x2021, /* DOUBLE DAGGER */
+ /*0xE1*/ 0x00B7, /* MIDDLE DOT */
+ /*0xE2*/ 0x201A, /* SINGLE LOW-9 QUOTATION MARK */
+ /*0xE3*/ 0x201E, /* DOUBLE LOW-9 QUOTATION MARK */
+ /*0xE4*/ 0x2030, /* PER MILLE SIGN */
+ /*0xE5*/ 0x00C2, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+ /*0xE6*/ 0x00CA, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+ /*0xE7*/ 0x00C1, /* LATIN CAPITAL LETTER A WITH ACUTE */
+ /*0xE8*/ 0x00CB, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
+ /*0xE9*/ 0x00C8, /* LATIN CAPITAL LETTER E WITH GRAVE */
+ /*0xEA*/ 0x00CD, /* LATIN CAPITAL LETTER I WITH ACUTE */
+ /*0xEB*/ 0x00CE, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
+ /*0xEC*/ 0x00CF, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
+ /*0xED*/ 0x00CC, /* LATIN CAPITAL LETTER I WITH GRAVE */
+ /*0xEE*/ 0x00D3, /* LATIN CAPITAL LETTER O WITH ACUTE */
+ /*0xEF*/ 0x00D4, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+ /*0xF0*/ 0xF8FF, /* Apple logo */
+ /*0xF1*/ 0x00D2, /* LATIN CAPITAL LETTER O WITH GRAVE */
+ /*0xF2*/ 0x00DA, /* LATIN CAPITAL LETTER U WITH ACUTE */
+ /*0xF3*/ 0x00DB, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
+ /*0xF4*/ 0x00D9, /* LATIN CAPITAL LETTER U WITH GRAVE */
+ /*0xF5*/ 0x0131, /* LATIN SMALL LETTER DOTLESS I */
+ /*0xF6*/ 0x02C6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+ /*0xF7*/ 0x02DC, /* SMALL TILDE */
+ /*0xF8*/ 0x00AF, /* MACRON */
+ /*0xF9*/ 0x02D8, /* BREVE */
+ /*0xFA*/ 0x02D9, /* DOT ABOVE */
+ /*0xFB*/ 0x02DA, /* RING ABOVE */
+ /*0xFC*/ 0x00B8, /* CEDILLA */
+ /*0xFD*/ 0x02DD, /* DOUBLE ACUTE ACCENT */
+ /*0xFE*/ 0x02DB, /* OGONEK */
+ /*0xFF*/ 0x02C7, /* CARON */
+};
+
#if USE_ICONV
#include <iconv.h>
#endif
@@ -696,6 +830,35 @@ FcSfntNameTranscode (FT_SfntName *sname)
*u8 = '\0';
goto done;
}
+ if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN))
+ {
+ FcChar8 *src = sname->string;
+ int src_len = sname->string_len;
+ int olen;
+ FcChar8 *u8;
+ FcChar32 ucs4;
+
+ /*
+ * Convert Latin1 to Utf8. Freed below
+ */
+ utf8 = malloc (src_len * 3 + 1);
+ if (!utf8)
+ return 0;
+
+ u8 = utf8;
+ while (src_len > 0)
+ {
+ ucs4 = *src++;
+ if (ucs4 >= 128)
+ ucs4 = fcMacRomanNonASCIIToUnicode[ucs4 - 128];
+ src_len--;
+ olen = FcUcs4ToUtf8 (ucs4, u8);
+ u8 += olen;
+ }
+ *u8 = '\0';
+ goto done;
+ }
+
#if USE_ICONV
cd = iconv_open ("UTF-8", fromcode);
if (cd && cd != (iconv_t) (-1))
@@ -816,76 +979,6 @@ FcNoticeFoundry(const FT_String *notice)
return 0;
}
-static FcBool
-FcVendorMatch(const FT_Char vendor[4], const FT_Char *vendor_string)
-{
- /* vendor is not necessarily NUL-terminated. */
- int i, len;
-
- len = strlen((char *) vendor_string);
- if (memcmp(vendor, vendor_string, len) != 0)
- return FcFalse;
- for (i = len; i < 4; i++)
- if (vendor[i] != ' ' && vendor[i] != '\0')
- return FcFalse;
- return FcTrue;
-}
-
-/* This table is partly taken from ttmkfdir by Joerg Pommnitz. */
-
-/* It should not contain useless entries (such as UNKN) nor duplicate
- entries for padding both with spaces and NULs. */
-
-static const struct {
- const FT_Char vendor[5];
- const FcChar8 foundry[13];
-} FcVendorFoundries[] = {
- { "ADBE", "adobe"},
- { "AGFA", "agfa"},
- { "ALTS", "altsys"},
- { "APPL", "apple"},
- { "ARPH", "arphic"},
- { "ATEC", "alltype"},
- { "B&H", "b&h"},
- { "BITS", "bitstream"},
- { "CANO", "cannon"},
- { "CLM", "culmus"},
- { "DYNA", "dynalab"},
- { "EPSN", "epson"},
- { "FJ", "fujitsu"},
- { "IBM", "ibm"},
- { "ITC", "itc"},
- { "IMPR", "impress"},
- { "LARA", "larabiefonts"},
- { "LEAF", "interleaf"},
- { "LETR", "letraset"},
- { "LINO", "linotype"},
- { "MACR", "macromedia"},
- { "MONO", "monotype"},
- { "MS", "microsoft"},
- { "MT", "monotype"},
- { "NEC", "nec"},
- { "PARA", "paratype"},
- { "QMSI", "qms"},
- { "RICO", "ricoh"},
- { "URW", "urw"},
- { "Y&Y", "y&y"}
-};
-
-#define NUM_VENDOR_FOUNDRIES (int) (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0]))
-
-static const FcChar8 *
-FcVendorFoundry(const FT_Char vendor[4])
-{
- int i;
-
- if (vendor)
- for(i = 0; i < NUM_VENDOR_FOUNDRIES; i++)
- if (FcVendorMatch (vendor, FcVendorFoundries[i].vendor))
- return FcVendorFoundries[i].foundry;
- return 0;
-}
-
typedef struct _FcStringConst {
const FcChar8 *name;
int value;
@@ -933,6 +1026,8 @@ static const FcStringConst weightConsts[] = {
{ (FC8) "thin", FC_WEIGHT_THIN },
{ (FC8) "extralight", FC_WEIGHT_EXTRALIGHT },
{ (FC8) "ultralight", FC_WEIGHT_ULTRALIGHT },
+ { (FC8) "demilight", FC_WEIGHT_DEMILIGHT },
+ { (FC8) "semilight", FC_WEIGHT_SEMILIGHT },
{ (FC8) "light", FC_WEIGHT_LIGHT },
{ (FC8) "book", FC_WEIGHT_BOOK },
{ (FC8) "regular", FC_WEIGHT_REGULAR },
@@ -1075,9 +1170,16 @@ FcFreeTypeQueryFace (const FT_Face face,
#if 0
FcChar8 *family = 0;
#endif
- FcChar8 *complex_;
+ FcChar8 *complex_, *foundry_ = NULL;
const FcChar8 *foundry = 0;
int spacing;
+
+ /* Support for glyph-variation named-instances. */
+ FT_MM_Var *master = NULL;
+ FT_Var_Named_Style *instance = NULL;
+ double weight_mult = 1.0;
+ double width_mult = 1.0;
+
TT_OS2 *os2;
#if HAVE_FT_GET_PS_FONT_INFO
PS_FontInfoRec psfontinfo;
@@ -1104,22 +1206,70 @@ FcFreeTypeQueryFace (const FT_Face face,
char psname[256];
const char *tmp;
- FcChar8 *hashstr = NULL;
- FT_Error err;
- FT_ULong len = 0, alen;
+ FcRange *r = NULL;
+
+ FcBool symbol = FcFalse;
+
+ FcInitDebug (); /* We might be called with no initizalization whatsoever. */
pat = FcPatternCreate ();
if (!pat)
goto bail0;
- if (!FcPatternAddBool (pat, FC_OUTLINE,
- (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
- goto bail1;
+ {
+ int has_outline = !!(face->face_flags & FT_FACE_FLAG_SCALABLE);
+ int has_color = 0;
- if (!FcPatternAddBool (pat, FC_SCALABLE,
- (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
- goto bail1;
+#ifdef FT_FACE_FLAG_COLOR
+ has_color = !!(face->face_flags & FT_FACE_FLAG_COLOR);
+#endif
+
+ if (!FcPatternAddBool (pat, FC_OUTLINE, has_outline))
+ goto bail1;
+
+#ifdef FT_FACE_FLAG_COLOR
+ if (!FcPatternAddBool (pat, FC_COLOR, has_color))
+ goto bail1;
+#endif
+
+ /* All color fonts are designed to be scaled, even if they only have
+ * bitmap strikes. Client is responsible to scale the bitmaps. This
+ * is in constrast to non-color strikes... */
+ if (!FcPatternAddBool (pat, FC_SCALABLE, has_outline || has_color))
+ goto bail1;
+ }
+
+ if (id >> 16)
+ {
+ if (!FT_Get_MM_Var (face, &master))
+ instance = &master->namedstyle[(id >> 16) - 1];
+
+ if (instance)
+ {
+ /* Pull out weight and width from named-instance. */
+ unsigned int i;
+
+ for (i = 0; i < master->num_axis; i++)
+ {
+ double value = instance->coords[i] / (double) (1 << 16);
+ double default_value = master->axis[i].def / (double) (1 << 16);
+ double mult = value / default_value;
+ //printf ("named-instance, axis %d tag %lx value %g\n", i, master->axis[i].tag, value);
+ switch (master->axis[i].tag)
+ {
+ case FT_MAKE_TAG ('w','g','h','t'):
+ weight_mult = mult;
+ break;
+
+ case FT_MAKE_TAG ('w','d','t','h'):
+ width_mult = mult;
+ break;
+ /* TODO optical size! */
+ }
+ }
+ }
+ }
/*
* Get the OS/2 table
@@ -1135,7 +1285,15 @@ FcFreeTypeQueryFace (const FT_Face face,
*/
if (os2 && os2->version >= 0x0001 && os2->version != 0xffff)
- foundry = FcVendorFoundry(os2->achVendID);
+ {
+ if (os2->achVendID && os2->achVendID[0] != 0)
+ {
+ foundry_ = (FcChar8 *) malloc (sizeof (os2->achVendID) + 1);
+ memcpy ((void *)foundry_, os2->achVendID, sizeof (os2->achVendID));
+ foundry_[sizeof (os2->achVendID)] = 0;
+ foundry = foundry_;
+ }
+ }
if (FcDebug () & FC_DBG_SCANV)
printf ("\n");
@@ -1170,6 +1328,19 @@ FcFreeTypeQueryFace (const FT_Face face,
if (FT_Get_Sfnt_Name (face, snamei, &sname) != 0)
continue;
+
+ if (instance)
+ {
+ /* For named-instances, we regular style nameIDs,
+ * and map the instance's strid to FONT_SUBFAMILY. */
+ if (sname.name_id == TT_NAME_ID_WWS_SUBFAMILY ||
+ sname.name_id == TT_NAME_ID_PREFERRED_SUBFAMILY ||
+ sname.name_id == TT_NAME_ID_FONT_SUBFAMILY)
+ continue;
+ if (sname.name_id == instance->strid)
+ sname.name_id = TT_NAME_ID_FONT_SUBFAMILY;
+ }
+
if (sname.name_id != nameid)
continue;
@@ -1283,10 +1454,10 @@ FcFreeTypeQueryFace (const FT_Face face,
free (utf8);
if (lang)
{
- /* pad lang list with 'xx' to line up with elt */
+ /* pad lang list with 'und' to line up with elt */
while (*nlangp < *np)
{
- if (!FcPatternAddString (pat, eltlang, (FcChar8 *) "xx"))
+ if (!FcPatternAddString (pat, eltlang, (FcChar8 *) "und"))
goto bail1;
++*nlangp;
}
@@ -1309,6 +1480,8 @@ FcFreeTypeQueryFace (const FT_Face face,
printf ("using FreeType family \"%s\"\n", face->family_name);
if (!FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) face->family_name))
goto bail1;
+ if (!FcPatternAddString (pat, FC_STYLELANG, (FcChar8 *) "en"))
+ goto bail1;
++nfamily;
}
@@ -1319,10 +1492,12 @@ FcFreeTypeQueryFace (const FT_Face face,
printf ("using FreeType style \"%s\"\n", face->style_name);
if (!FcPatternAddString (pat, FC_STYLE, (FcChar8 *) face->style_name))
goto bail1;
+ if (!FcPatternAddString (pat, FC_STYLELANG, (FcChar8 *) "en"))
+ goto bail1;
++nstyle;
}
- if (!nfamily)
+ if (!nfamily && file && *file)
{
FcChar8 *start, *end;
FcChar8 *family;
@@ -1391,12 +1566,13 @@ FcFreeTypeQueryFace (const FT_Face face,
}
else
{
- strcpy (psname, tmp);
+ strncpy (psname, tmp, 255);
+ psname[255] = 0;
}
if (!FcPatternAddString (pat, FC_POSTSCRIPT_NAME, (const FcChar8 *)psname))
goto bail1;
- if (!FcPatternAddString (pat, FC_FILE, file))
+ if (file && *file && !FcPatternAddString (pat, FC_FILE, file))
goto bail1;
if (!FcPatternAddInteger (pat, FC_INDEX, id))
@@ -1463,33 +1639,22 @@ FcFreeTypeQueryFace (const FT_Face face,
if (os2 && os2->version != 0xffff)
{
- if (os2->usWeightClass == 0)
- ;
- else if (os2->usWeightClass < 150)
- weight = FC_WEIGHT_THIN;
- else if (os2->usWeightClass < 250)
- weight = FC_WEIGHT_EXTRALIGHT;
- else if (os2->usWeightClass < 350)
- weight = FC_WEIGHT_LIGHT;
- else if (os2->usWeightClass < 450)
- weight = FC_WEIGHT_REGULAR;
- else if (os2->usWeightClass < 550)
- weight = FC_WEIGHT_MEDIUM;
- else if (os2->usWeightClass < 650)
- weight = FC_WEIGHT_SEMIBOLD;
- else if (os2->usWeightClass < 750)
- weight = FC_WEIGHT_BOLD;
- else if (os2->usWeightClass < 850)
- weight = FC_WEIGHT_EXTRABOLD;
- else if (os2->usWeightClass < 925)
- weight = FC_WEIGHT_BLACK;
- else if (os2->usWeightClass < 1000)
- weight = FC_WEIGHT_EXTRABLACK;
+ weight = os2->usWeightClass;
+ if (weight < 10 && weight_mult != 1.0)
+ {
+ /* Work around bad values by cleaning them up before
+ * multiplying by weight_mult. */
+ weight = FcWeightToOpenType (FcWeightFromOpenType (weight));
+ }
+ weight = FcWeightFromOpenType ((int) (weight * weight_mult + .5));
if ((FcDebug() & FC_DBG_SCANV) && weight != -1)
- printf ("\tos2 weight class %d maps to weight %d\n",
- os2->usWeightClass, weight);
+ printf ("\tos2 weight class %d multiplier %g maps to weight %d\n",
+ os2->usWeightClass, weight_mult, weight);
- switch (os2->usWidthClass) {
+ /* TODO:
+ * Add FcWidthFromOpenType and FcWidthToOpenType,
+ * and apply width_mult post-conversion? */
+ switch ((int) (os2->usWidthClass * width_mult + .5)) {
case 1: width = FC_WIDTH_ULTRACONDENSED; break;
case 2: width = FC_WIDTH_EXTRACONDENSED; break;
case 3: width = FC_WIDTH_CONDENSED; break;
@@ -1501,8 +1666,8 @@ FcFreeTypeQueryFace (const FT_Face face,
case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
}
if ((FcDebug() & FC_DBG_SCANV) && width != -1)
- printf ("\tos2 width class %d maps to width %d\n",
- os2->usWidthClass, width);
+ printf ("\tos2 width class %d multiplier %g maps to width %d\n",
+ os2->usWidthClass, width_mult, width);
}
if (os2 && (complex_ = FcFontCapabilities(face)))
{
@@ -1514,6 +1679,25 @@ FcFreeTypeQueryFace (const FT_Face face,
free (complex_);
}
+#if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE)
+ if (os2 && os2->version >= 0x0005 && os2->version != 0xffff)
+ {
+ double lower_size, upper_size;
+
+ /* usLowerPointSize and usUpperPointSize is actually twips */
+ lower_size = os2->usLowerOpticalPointSize / 20.0L;
+ upper_size = os2->usUpperOpticalPointSize / 20.0L;
+
+ r = FcRangeCreateDouble (lower_size, upper_size);
+ if (!FcPatternAddRange (pat, FC_SIZE, r))
+ {
+ FcRangeDestroy (r);
+ goto bail1;
+ }
+ FcRangeDestroy (r);
+ }
+#endif
+
/*
* Type 1: Check for FontInfo dictionary information
* Code from g2@magestudios.net (Gerard Escalante)
@@ -1586,7 +1770,7 @@ FcFreeTypeQueryFace (const FT_Face face,
}
if (width == -1 &&
FT_Get_BDF_Property (face, "SETWIDTH_NAME", &prop) == 0 &&
- prop.type == BDF_PROPERTY_TYPE_ATOM)
+ prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom != NULL)
{
width = FcIsWidth ((FcChar8 *) prop.u.atom);
if (FcDebug () & FC_DBG_SCANV)
@@ -1664,46 +1848,6 @@ FcFreeTypeQueryFace (const FT_Face face,
if (!FcPatternAddBool (pat, FC_DECORATIVE, decorative))
goto bail1;
- err = FT_Load_Sfnt_Table (face, 0, 0, NULL, &len);
- if (err == FT_Err_Ok)
- {
- char *fontdata;
-
- alen = (len + 63) & ~63;
- fontdata = malloc (alen);
- if (!fontdata)
- goto bail3;
- err = FT_Load_Sfnt_Table (face, 0, 0, (FT_Byte *)fontdata, &len);
- if (err != FT_Err_Ok)
- {
- free (fontdata);
- goto bail3;
- }
- memset (&fontdata[len], 0, alen - len);
- hashstr = FcHashGetSHA256DigestFromMemory (fontdata, len);
- free (fontdata);
- }
- else if (err == FT_Err_Invalid_Face_Handle)
- {
- /* font may not support SFNT. falling back to
- * read the font data from file directly
- */
- hashstr = FcHashGetSHA256DigestFromFile (file);
- }
- else
- {
- goto bail3;
- }
- if (hashstr)
- {
- if (!FcPatternAddString (pat, FC_HASH, hashstr))
- {
- free (hashstr);
- goto bail1;
- }
- free (hashstr);
- }
-bail3:
/*
* Compute the unicode coverage for the font
@@ -1712,11 +1856,16 @@ bail3:
if (!cs)
goto bail1;
+ /* The FcFreeTypeCharSetAndSpacing() chose the encoding; test it for symbol. */
+ symbol = face->charmap && face->charmap->encoding == FT_ENCODING_MS_SYMBOL;
+ if (!FcPatternAddBool (pat, FC_SYMBOL, symbol))
+ goto bail1;
+
#if HAVE_FT_GET_BDF_PROPERTY
/* For PCF fonts, override the computed spacing with the one from
the property */
if(FT_Get_BDF_Property(face, "SPACING", &prop) == 0 &&
- prop.type == BDF_PROPERTY_TYPE_ATOM) {
+ prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom != NULL) {
if(!strcmp(prop.u.atom, "c") || !strcmp(prop.u.atom, "C"))
spacing = FC_CHARCELL;
else if(!strcmp(prop.u.atom, "m") || !strcmp(prop.u.atom, "M"))
@@ -1744,9 +1893,18 @@ bail3:
if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
goto bail2;
- ls = FcFreeTypeLangSet (cs, exclusiveLang);
- if (!ls)
- goto bail2;
+ if (!symbol)
+ {
+ ls = FcFreeTypeLangSet (cs, exclusiveLang);
+ if (!ls)
+ goto bail2;
+ }
+ else
+ {
+ /* Symbol fonts don't cover any language, even though they
+ * claim to support Latin1 range. */
+ ls = FcLangSetCreate ();
+ }
if (!FcPatternAddLangSet (pat, FC_LANG, ls))
{
@@ -1786,6 +1944,13 @@ bail3:
* Drop our reference to the charset
*/
FcCharSetDestroy (cs);
+ if (foundry_)
+ free (foundry_);
+
+ if (master)
+ {
+ /* TODO: How to free master?! */
+ }
return pat;
@@ -1793,6 +1958,8 @@ bail2:
FcCharSetDestroy (cs);
bail1:
FcPatternDestroy (pat);
+ if (foundry_)
+ free (foundry_);
bail0:
return NULL;
}
@@ -1833,282 +2000,12 @@ bail:
#warning "No FT_Get_Next_Char: Please install freetype version 2.1.0 or newer"
#endif
-typedef struct _FcCharEnt {
- FcChar16 bmp;
- unsigned char encode;
-} FcCharEnt;
-
-struct _FcCharMap {
- const FcCharEnt *ent;
- int nent;
-};
-
-typedef struct _FcFontDecode {
- FT_Encoding encoding;
- const FcCharMap *map;
- FcChar32 max;
-} FcFontDecode;
-
-static const FcCharEnt AdobeSymbolEnt[] = {
- { 0x0020, 0x20 }, /* SPACE # space */
- { 0x0021, 0x21 }, /* EXCLAMATION MARK # exclam */
- { 0x0023, 0x23 }, /* NUMBER SIGN # numbersign */
- { 0x0025, 0x25 }, /* PERCENT SIGN # percent */
- { 0x0026, 0x26 }, /* AMPERSAND # ampersand */
- { 0x0028, 0x28 }, /* LEFT PARENTHESIS # parenleft */
- { 0x0029, 0x29 }, /* RIGHT PARENTHESIS # parenright */
- { 0x002B, 0x2B }, /* PLUS SIGN # plus */
- { 0x002C, 0x2C }, /* COMMA # comma */
- { 0x002E, 0x2E }, /* FULL STOP # period */
- { 0x002F, 0x2F }, /* SOLIDUS # slash */
- { 0x0030, 0x30 }, /* DIGIT ZERO # zero */
- { 0x0031, 0x31 }, /* DIGIT ONE # one */
- { 0x0032, 0x32 }, /* DIGIT TWO # two */
- { 0x0033, 0x33 }, /* DIGIT THREE # three */
- { 0x0034, 0x34 }, /* DIGIT FOUR # four */
- { 0x0035, 0x35 }, /* DIGIT FIVE # five */
- { 0x0036, 0x36 }, /* DIGIT SIX # six */
- { 0x0037, 0x37 }, /* DIGIT SEVEN # seven */
- { 0x0038, 0x38 }, /* DIGIT EIGHT # eight */
- { 0x0039, 0x39 }, /* DIGIT NINE # nine */
- { 0x003A, 0x3A }, /* COLON # colon */
- { 0x003B, 0x3B }, /* SEMICOLON # semicolon */
- { 0x003C, 0x3C }, /* LESS-THAN SIGN # less */
- { 0x003D, 0x3D }, /* EQUALS SIGN # equal */
- { 0x003E, 0x3E }, /* GREATER-THAN SIGN # greater */
- { 0x003F, 0x3F }, /* QUESTION MARK # question */
- { 0x005B, 0x5B }, /* LEFT SQUARE BRACKET # bracketleft */
- { 0x005D, 0x5D }, /* RIGHT SQUARE BRACKET # bracketright */
- { 0x005F, 0x5F }, /* LOW LINE # underscore */
- { 0x007B, 0x7B }, /* LEFT CURLY BRACKET # braceleft */
- { 0x007C, 0x7C }, /* VERTICAL LINE # bar */
- { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET # braceright */
- { 0x00A0, 0x20 }, /* NO-BREAK SPACE # space */
- { 0x00AC, 0xD8 }, /* NOT SIGN # logicalnot */
- { 0x00B0, 0xB0 }, /* DEGREE SIGN # degree */
- { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN # plusminus */
- { 0x00B5, 0x6D }, /* MICRO SIGN # mu */
- { 0x00D7, 0xB4 }, /* MULTIPLICATION SIGN # multiply */
- { 0x00F7, 0xB8 }, /* DIVISION SIGN # divide */
- { 0x0192, 0xA6 }, /* LATIN SMALL LETTER F WITH HOOK # florin */
- { 0x0391, 0x41 }, /* GREEK CAPITAL LETTER ALPHA # Alpha */
- { 0x0392, 0x42 }, /* GREEK CAPITAL LETTER BETA # Beta */
- { 0x0393, 0x47 }, /* GREEK CAPITAL LETTER GAMMA # Gamma */
- { 0x0394, 0x44 }, /* GREEK CAPITAL LETTER DELTA # Delta */
- { 0x0395, 0x45 }, /* GREEK CAPITAL LETTER EPSILON # Epsilon */
- { 0x0396, 0x5A }, /* GREEK CAPITAL LETTER ZETA # Zeta */
- { 0x0397, 0x48 }, /* GREEK CAPITAL LETTER ETA # Eta */
- { 0x0398, 0x51 }, /* GREEK CAPITAL LETTER THETA # Theta */
- { 0x0399, 0x49 }, /* GREEK CAPITAL LETTER IOTA # Iota */
- { 0x039A, 0x4B }, /* GREEK CAPITAL LETTER KAPPA # Kappa */
- { 0x039B, 0x4C }, /* GREEK CAPITAL LETTER LAMDA # Lambda */
- { 0x039C, 0x4D }, /* GREEK CAPITAL LETTER MU # Mu */
- { 0x039D, 0x4E }, /* GREEK CAPITAL LETTER NU # Nu */
- { 0x039E, 0x58 }, /* GREEK CAPITAL LETTER XI # Xi */
- { 0x039F, 0x4F }, /* GREEK CAPITAL LETTER OMICRON # Omicron */
- { 0x03A0, 0x50 }, /* GREEK CAPITAL LETTER PI # Pi */
- { 0x03A1, 0x52 }, /* GREEK CAPITAL LETTER RHO # Rho */
- { 0x03A3, 0x53 }, /* GREEK CAPITAL LETTER SIGMA # Sigma */
- { 0x03A4, 0x54 }, /* GREEK CAPITAL LETTER TAU # Tau */
- { 0x03A5, 0x55 }, /* GREEK CAPITAL LETTER UPSILON # Upsilon */
- { 0x03A6, 0x46 }, /* GREEK CAPITAL LETTER PHI # Phi */
- { 0x03A7, 0x43 }, /* GREEK CAPITAL LETTER CHI # Chi */
- { 0x03A8, 0x59 }, /* GREEK CAPITAL LETTER PSI # Psi */
- { 0x03A9, 0x57 }, /* GREEK CAPITAL LETTER OMEGA # Omega */
- { 0x03B1, 0x61 }, /* GREEK SMALL LETTER ALPHA # alpha */
- { 0x03B2, 0x62 }, /* GREEK SMALL LETTER BETA # beta */
- { 0x03B3, 0x67 }, /* GREEK SMALL LETTER GAMMA # gamma */
- { 0x03B4, 0x64 }, /* GREEK SMALL LETTER DELTA # delta */
- { 0x03B5, 0x65 }, /* GREEK SMALL LETTER EPSILON # epsilon */
- { 0x03B6, 0x7A }, /* GREEK SMALL LETTER ZETA # zeta */
- { 0x03B7, 0x68 }, /* GREEK SMALL LETTER ETA # eta */
- { 0x03B8, 0x71 }, /* GREEK SMALL LETTER THETA # theta */
- { 0x03B9, 0x69 }, /* GREEK SMALL LETTER IOTA # iota */
- { 0x03BA, 0x6B }, /* GREEK SMALL LETTER KAPPA # kappa */
- { 0x03BB, 0x6C }, /* GREEK SMALL LETTER LAMDA # lambda */
- { 0x03BC, 0x6D }, /* GREEK SMALL LETTER MU # mu */
- { 0x03BD, 0x6E }, /* GREEK SMALL LETTER NU # nu */
- { 0x03BE, 0x78 }, /* GREEK SMALL LETTER XI # xi */
- { 0x03BF, 0x6F }, /* GREEK SMALL LETTER OMICRON # omicron */
- { 0x03C0, 0x70 }, /* GREEK SMALL LETTER PI # pi */
- { 0x03C1, 0x72 }, /* GREEK SMALL LETTER RHO # rho */
- { 0x03C2, 0x56 }, /* GREEK SMALL LETTER FINAL SIGMA # sigma1 */
- { 0x03C3, 0x73 }, /* GREEK SMALL LETTER SIGMA # sigma */
- { 0x03C4, 0x74 }, /* GREEK SMALL LETTER TAU # tau */
- { 0x03C5, 0x75 }, /* GREEK SMALL LETTER UPSILON # upsilon */
- { 0x03C6, 0x66 }, /* GREEK SMALL LETTER PHI # phi */
- { 0x03C7, 0x63 }, /* GREEK SMALL LETTER CHI # chi */
- { 0x03C8, 0x79 }, /* GREEK SMALL LETTER PSI # psi */
- { 0x03C9, 0x77 }, /* GREEK SMALL LETTER OMEGA # omega */
- { 0x03D1, 0x4A }, /* GREEK THETA SYMBOL # theta1 */
- { 0x03D2, 0xA1 }, /* GREEK UPSILON WITH HOOK SYMBOL # Upsilon1 */
- { 0x03D5, 0x6A }, /* GREEK PHI SYMBOL # phi1 */
- { 0x03D6, 0x76 }, /* GREEK PI SYMBOL # omega1 */
- { 0x2022, 0xB7 }, /* BULLET # bullet */
- { 0x2026, 0xBC }, /* HORIZONTAL ELLIPSIS # ellipsis */
- { 0x2032, 0xA2 }, /* PRIME # minute */
- { 0x2033, 0xB2 }, /* DOUBLE PRIME # second */
- { 0x2044, 0xA4 }, /* FRACTION SLASH # fraction */
- { 0x20AC, 0xA0 }, /* EURO SIGN # Euro */
- { 0x2111, 0xC1 }, /* BLACK-LETTER CAPITAL I # Ifraktur */
- { 0x2118, 0xC3 }, /* SCRIPT CAPITAL P # weierstrass */
- { 0x211C, 0xC2 }, /* BLACK-LETTER CAPITAL R # Rfraktur */
- { 0x2126, 0x57 }, /* OHM SIGN # Omega */
- { 0x2135, 0xC0 }, /* ALEF SYMBOL # aleph */
- { 0x2190, 0xAC }, /* LEFTWARDS ARROW # arrowleft */
- { 0x2191, 0xAD }, /* UPWARDS ARROW # arrowup */
- { 0x2192, 0xAE }, /* RIGHTWARDS ARROW # arrowright */
- { 0x2193, 0xAF }, /* DOWNWARDS ARROW # arrowdown */
- { 0x2194, 0xAB }, /* LEFT RIGHT ARROW # arrowboth */
- { 0x21B5, 0xBF }, /* DOWNWARDS ARROW WITH CORNER LEFTWARDS # carriagereturn */
- { 0x21D0, 0xDC }, /* LEFTWARDS DOUBLE ARROW # arrowdblleft */
- { 0x21D1, 0xDD }, /* UPWARDS DOUBLE ARROW # arrowdblup */
- { 0x21D2, 0xDE }, /* RIGHTWARDS DOUBLE ARROW # arrowdblright */
- { 0x21D3, 0xDF }, /* DOWNWARDS DOUBLE ARROW # arrowdbldown */
- { 0x21D4, 0xDB }, /* LEFT RIGHT DOUBLE ARROW # arrowdblboth */
- { 0x2200, 0x22 }, /* FOR ALL # universal */
- { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL # partialdiff */
- { 0x2203, 0x24 }, /* THERE EXISTS # existential */
- { 0x2205, 0xC6 }, /* EMPTY SET # emptyset */
- { 0x2206, 0x44 }, /* INCREMENT # Delta */
- { 0x2207, 0xD1 }, /* NABLA # gradient */
- { 0x2208, 0xCE }, /* ELEMENT OF # element */
- { 0x2209, 0xCF }, /* NOT AN ELEMENT OF # notelement */
- { 0x220B, 0x27 }, /* CONTAINS AS MEMBER # suchthat */
- { 0x220F, 0xD5 }, /* N-ARY PRODUCT # product */
- { 0x2211, 0xE5 }, /* N-ARY SUMMATION # summation */
- { 0x2212, 0x2D }, /* MINUS SIGN # minus */
- { 0x2215, 0xA4 }, /* DIVISION SLASH # fraction */
- { 0x2217, 0x2A }, /* ASTERISK OPERATOR # asteriskmath */
- { 0x221A, 0xD6 }, /* SQUARE ROOT # radical */
- { 0x221D, 0xB5 }, /* PROPORTIONAL TO # proportional */
- { 0x221E, 0xA5 }, /* INFINITY # infinity */
- { 0x2220, 0xD0 }, /* ANGLE # angle */
- { 0x2227, 0xD9 }, /* LOGICAL AND # logicaland */
- { 0x2228, 0xDA }, /* LOGICAL OR # logicalor */
- { 0x2229, 0xC7 }, /* INTERSECTION # intersection */
- { 0x222A, 0xC8 }, /* UNION # union */
- { 0x222B, 0xF2 }, /* INTEGRAL # integral */
- { 0x2234, 0x5C }, /* THEREFORE # therefore */
- { 0x223C, 0x7E }, /* TILDE OPERATOR # similar */
- { 0x2245, 0x40 }, /* APPROXIMATELY EQUAL TO # congruent */
- { 0x2248, 0xBB }, /* ALMOST EQUAL TO # approxequal */
- { 0x2260, 0xB9 }, /* NOT EQUAL TO # notequal */
- { 0x2261, 0xBA }, /* IDENTICAL TO # equivalence */
- { 0x2264, 0xA3 }, /* LESS-THAN OR EQUAL TO # lessequal */
- { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO # greaterequal */
- { 0x2282, 0xCC }, /* SUBSET OF # propersubset */
- { 0x2283, 0xC9 }, /* SUPERSET OF # propersuperset */
- { 0x2284, 0xCB }, /* NOT A SUBSET OF # notsubset */
- { 0x2286, 0xCD }, /* SUBSET OF OR EQUAL TO # reflexsubset */
- { 0x2287, 0xCA }, /* SUPERSET OF OR EQUAL TO # reflexsuperset */
- { 0x2295, 0xC5 }, /* CIRCLED PLUS # circleplus */
- { 0x2297, 0xC4 }, /* CIRCLED TIMES # circlemultiply */
- { 0x22A5, 0x5E }, /* UP TACK # perpendicular */
- { 0x22C5, 0xD7 }, /* DOT OPERATOR # dotmath */
- { 0x2320, 0xF3 }, /* TOP HALF INTEGRAL # integraltp */
- { 0x2321, 0xF5 }, /* BOTTOM HALF INTEGRAL # integralbt */
- { 0x2329, 0xE1 }, /* LEFT-POINTING ANGLE BRACKET # angleleft */
- { 0x232A, 0xF1 }, /* RIGHT-POINTING ANGLE BRACKET # angleright */
- { 0x25CA, 0xE0 }, /* LOZENGE # lozenge */
- { 0x2660, 0xAA }, /* BLACK SPADE SUIT # spade */
- { 0x2663, 0xA7 }, /* BLACK CLUB SUIT # club */
- { 0x2665, 0xA9 }, /* BLACK HEART SUIT # heart */
- { 0x2666, 0xA8 }, /* BLACK DIAMOND SUIT # diamond */
- { 0xF6D9, 0xD3 }, /* COPYRIGHT SIGN SERIF # copyrightserif (CUS) */
- { 0xF6DA, 0xD2 }, /* REGISTERED SIGN SERIF # registerserif (CUS) */
- { 0xF6DB, 0xD4 }, /* TRADE MARK SIGN SERIF # trademarkserif (CUS) */
- { 0xF8E5, 0x60 }, /* RADICAL EXTENDER # radicalex (CUS) */
- { 0xF8E6, 0xBD }, /* VERTICAL ARROW EXTENDER # arrowvertex (CUS) */
- { 0xF8E7, 0xBE }, /* HORIZONTAL ARROW EXTENDER # arrowhorizex (CUS) */
- { 0xF8E8, 0xE2 }, /* REGISTERED SIGN SANS SERIF # registersans (CUS) */
- { 0xF8E9, 0xE3 }, /* COPYRIGHT SIGN SANS SERIF # copyrightsans (CUS) */
- { 0xF8EA, 0xE4 }, /* TRADE MARK SIGN SANS SERIF # trademarksans (CUS) */
- { 0xF8EB, 0xE6 }, /* LEFT PAREN TOP # parenlefttp (CUS) */
- { 0xF8EC, 0xE7 }, /* LEFT PAREN EXTENDER # parenleftex (CUS) */
- { 0xF8ED, 0xE8 }, /* LEFT PAREN BOTTOM # parenleftbt (CUS) */
- { 0xF8EE, 0xE9 }, /* LEFT SQUARE BRACKET TOP # bracketlefttp (CUS) */
- { 0xF8EF, 0xEA }, /* LEFT SQUARE BRACKET EXTENDER # bracketleftex (CUS) */
- { 0xF8F0, 0xEB }, /* LEFT SQUARE BRACKET BOTTOM # bracketleftbt (CUS) */
- { 0xF8F1, 0xEC }, /* LEFT CURLY BRACKET TOP # bracelefttp (CUS) */
- { 0xF8F2, 0xED }, /* LEFT CURLY BRACKET MID # braceleftmid (CUS) */
- { 0xF8F3, 0xEE }, /* LEFT CURLY BRACKET BOTTOM # braceleftbt (CUS) */
- { 0xF8F4, 0xEF }, /* CURLY BRACKET EXTENDER # braceex (CUS) */
- { 0xF8F5, 0xF4 }, /* INTEGRAL EXTENDER # integralex (CUS) */
- { 0xF8F6, 0xF6 }, /* RIGHT PAREN TOP # parenrighttp (CUS) */
- { 0xF8F7, 0xF7 }, /* RIGHT PAREN EXTENDER # parenrightex (CUS) */
- { 0xF8F8, 0xF8 }, /* RIGHT PAREN BOTTOM # parenrightbt (CUS) */
- { 0xF8F9, 0xF9 }, /* RIGHT SQUARE BRACKET TOP # bracketrighttp (CUS) */
- { 0xF8FA, 0xFA }, /* RIGHT SQUARE BRACKET EXTENDER # bracketrightex (CUS) */
- { 0xF8FB, 0xFB }, /* RIGHT SQUARE BRACKET BOTTOM # bracketrightbt (CUS) */
- { 0xF8FC, 0xFC }, /* RIGHT CURLY BRACKET TOP # bracerighttp (CUS) */
- { 0xF8FD, 0xFD }, /* RIGHT CURLY BRACKET MID # bracerightmid (CUS) */
- { 0xF8FE, 0xFE }, /* RIGHT CURLY BRACKET BOTTOM # bracerightbt (CUS) */
+static const FT_Encoding fcFontEncodings[] = {
+ FT_ENCODING_UNICODE,
+ FT_ENCODING_MS_SYMBOL
};
-static const FcCharMap AdobeSymbol = {
- AdobeSymbolEnt,
- sizeof (AdobeSymbolEnt) / sizeof (AdobeSymbolEnt[0]),
-};
-
-static const FcFontDecode fcFontDecoders[] = {
- { ft_encoding_unicode, 0, (1 << 21) - 1 },
- { ft_encoding_symbol, &AdobeSymbol, (1 << 16) - 1 },
-};
-
-#define NUM_DECODE (int) (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0]))
-
-static const FcChar32 prefer_unicode[] = {
- 0x20ac, /* EURO SIGN */
-};
-
-#define NUM_PREFER_UNICODE (int) (sizeof (prefer_unicode) / sizeof (prefer_unicode[0]))
-
-FcChar32
-FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map)
-{
- int low, high, mid;
- FcChar16 bmp;
-
- low = 0;
- high = map->nent - 1;
- if (ucs4 < map->ent[low].bmp || map->ent[high].bmp < ucs4)
- return ~0;
- while (low <= high)
- {
- mid = (high + low) >> 1;
- bmp = map->ent[mid].bmp;
- if (ucs4 == bmp)
- return (FT_ULong) map->ent[mid].encode;
- if (ucs4 < bmp)
- high = mid - 1;
- else
- low = mid + 1;
- }
- return ~0;
-}
-
-FcChar32
-FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map)
-{
- int i;
-
- for (i = 0; i < map->nent; i++)
- if (map->ent[i].encode == private)
- return (FcChar32) map->ent[i].bmp;
- return ~0;
-}
-
-const FcCharMap *
-FcFreeTypeGetPrivateMap (FT_Encoding encoding)
-{
- int i;
-
- for (i = 0; i < NUM_DECODE; i++)
- if (fcFontDecoders[i].encoding == encoding)
- return fcFontDecoders[i].map;
- return 0;
-}
+#define NUM_DECODE (int) (sizeof (fcFontEncodings) / sizeof (fcFontEncodings[0]))
#include "../fc-glyphname/fcglyphname.h"
@@ -2237,8 +2134,6 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
{
int initial, offset, decode;
FT_UInt glyphindex;
- FcChar32 charcode;
- int p;
initial = 0;
@@ -2251,37 +2146,39 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
if (face->charmap)
{
for (; initial < NUM_DECODE; initial++)
- if (fcFontDecoders[initial].encoding == face->charmap->encoding)
+ if (fcFontEncodings[initial] == face->charmap->encoding)
break;
if (initial == NUM_DECODE)
initial = 0;
}
- for (p = 0; p < NUM_PREFER_UNICODE; p++)
- if (ucs4 == prefer_unicode[p])
- {
- initial = 0;
- break;
- }
/*
* Check each encoding for the glyph, starting with the current one
*/
for (offset = 0; offset < NUM_DECODE; offset++)
{
decode = (initial + offset) % NUM_DECODE;
- if (!face->charmap || face->charmap->encoding != fcFontDecoders[decode].encoding)
- if (FT_Select_Charmap (face, fcFontDecoders[decode].encoding) != 0)
+ if (!face->charmap || face->charmap->encoding != fcFontEncodings[decode])
+ if (FT_Select_Charmap (face, fcFontEncodings[decode]) != 0)
continue;
- if (fcFontDecoders[decode].map)
- {
- charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map);
- if (charcode == ~0U)
- continue;
- }
- else
- charcode = ucs4;
- glyphindex = FT_Get_Char_Index (face, (FT_ULong) charcode);
+ glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4);
if (glyphindex)
return glyphindex;
+ if (ucs4 < 0x100 && face->charmap &&
+ face->charmap->encoding == FT_ENCODING_MS_SYMBOL)
+ {
+ /* For symbol-encoded OpenType fonts, we duplicate the
+ * U+F000..F0FF range at U+0000..U+00FF. That's what
+ * Windows seems to do, and that's hinted about at:
+ * http://www.microsoft.com/typography/otspec/recom.htm
+ * under "Non-Standard (Symbol) Fonts".
+ *
+ * See thread with subject "Webdings and other MS symbol
+ * fonts don't display" on mailing list from May 2015.
+ */
+ glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4 + 0xF000);
+ if (glyphindex)
+ return glyphindex;
+ }
}
#if HAVE_FT_HAS_PS_GLYPH_NAMES
/*
@@ -2372,9 +2269,7 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
#endif
FcCharSet *fcs;
FcCharLeaf *leaf;
- const FcCharMap *map;
int o;
- int i;
FT_UInt glyph;
FT_Pos advance, advance_one = 0, advance_two = 0;
FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
@@ -2397,62 +2292,9 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
#endif
for (o = 0; o < NUM_DECODE; o++)
{
- if (FT_Select_Charmap (face, fcFontDecoders[o].encoding) != 0)
+ if (FT_Select_Charmap (face, fcFontEncodings[o]) != 0)
continue;
- map = fcFontDecoders[o].map;
- if (map)
- {
- /*
- * Non-Unicode tables are easy; there's a list of all possible
- * characters
- */
- for (i = 0; i < map->nent; i++)
- {
- ucs4 = map->ent[i].bmp;
- glyph = FT_Get_Char_Index (face, map->ent[i].encode);
- if (glyph &&
- FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance, using_strike))
- {
- /*
- * ignore glyphs with zero advance. They’re
- * combining characters, and while their behaviour
- * isn’t well defined for monospaced applications in
- * Unicode, there are many fonts which include
- * zero-width combining characters in otherwise
- * monospaced fonts.
- */
- if (advance)
- {
- if (!has_advance)
- {
- has_advance = FcTrue;
- advance_one = advance;
- }
- else if (!APPROXIMATELY_EQUAL (advance, advance_one))
- {
- if (fixed_advance)
- {
- dual_advance = FcTrue;
- fixed_advance = FcFalse;
- advance_two = advance;
- }
- else if (!APPROXIMATELY_EQUAL (advance, advance_two))
- dual_advance = FcFalse;
- }
- }
- leaf = FcCharSetFindLeafCreate (fcs, ucs4);
- if (!leaf)
- goto bail1;
- leaf->map[(ucs4 & 0xff) >> 5] |= (1 << (ucs4 & 0x1f));
-#ifdef CHECK
- if (ucs4 > font_max)
- font_max = ucs4;
-#endif
- }
- }
- }
- else
{
page = ~0;
leaf = NULL;
@@ -2497,6 +2339,23 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
}
ucs4 = FT_Get_Next_Char (face, ucs4, &glyph);
}
+ if (fcFontEncodings[o] == FT_ENCODING_MS_SYMBOL)
+ {
+ /* For symbol-encoded OpenType fonts, we duplicate the
+ * U+F000..F0FF range at U+0000..U+00FF. That's what
+ * Windows seems to do, and that's hinted about at:
+ * http://www.microsoft.com/typography/otspec/recom.htm
+ * under "Non-Standard (Symbol) Fonts".
+ *
+ * See thread with subject "Webdings and other MS symbol
+ * fonts don't display" on mailing list from May 2015.
+ */
+ for (ucs4 = 0xF000; ucs4 < 0xF100; ucs4++)
+ {
+ if (FcCharSetHasChar (fcs, ucs4))
+ FcCharSetAddChar (fcs, ucs4 - 0xF000);
+ }
+ }
#ifdef CHECK
for (ucs4 = 0; ucs4 < 0x10000; ucs4++)
{
@@ -2511,6 +2370,8 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
}
#endif
}
+
+ break;
}
#if HAVE_FT_HAS_PS_GLYPH_NAMES
/*
diff --git a/chromium/third_party/fontconfig/src/src/fcfs.c b/chromium/third_party/fontconfig/src/src/fcfs.c
index 941abba8f40..21c6c7cbb0e 100644
--- a/chromium/third_party/fontconfig/src/src/fcfs.c
+++ b/chromium/third_party/fontconfig/src/src/fcfs.c
@@ -122,6 +122,28 @@ FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s)
return s_serialize;
}
+
+FcFontSet *
+FcFontSetDeserialize (const FcFontSet *set)
+{
+ int i;
+ FcFontSet *new = FcFontSetCreate ();
+
+ if (!new)
+ return NULL;
+ for (i = 0; i < set->nfont; i++)
+ {
+ if (!FcFontSetAdd (new, FcPatternDuplicate (FcFontSetFont (set, i))))
+ goto bail;
+ }
+
+ return new;
+bail:
+ FcFontSetDestroy (new);
+
+ return NULL;
+}
+
#define __fcfs__
#include "fcaliastail.h"
#undef __fcfs__
diff --git a/chromium/third_party/fontconfig/src/src/fchash.c b/chromium/third_party/fontconfig/src/src/fchash.c
deleted file mode 100644
index 38300028c8e..00000000000
--- a/chromium/third_party/fontconfig/src/src/fchash.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * fontconfig/src/fchash.c
- *
- * Copyright © 2003 Keith Packard
- * Copyright © 2013 Red Hat, Inc.
- * Red Hat Author(s): Akira TAGOH
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the author(s) not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. The authors make no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-#include "fcint.h"
-#include <stdio.h>
-#include <string.h>
-
-#define ROTRN(w, v, n) ((((FcChar32)v) >> n) | (((FcChar32)v) << (w - n)))
-#define ROTR32(v, n) ROTRN(32, v, n)
-#define SHR(v, n) (v >> n)
-#define Ch(x, y, z) ((x & y) ^ (~x & z))
-#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
-#define SS0(x) (ROTR32(x, 2) ^ ROTR32(x, 13) ^ ROTR32(x, 22))
-#define SS1(x) (ROTR32(x, 6) ^ ROTR32(x, 11) ^ ROTR32(x, 25))
-#define ss0(x) (ROTR32(x, 7) ^ ROTR32(x, 18) ^ SHR(x, 3))
-#define ss1(x) (ROTR32(x, 17) ^ ROTR32(x, 19) ^ SHR(x, 10))
-
-
-static FcChar32 *
-FcHashInitSHA256Digest (void)
-{
- int i;
- static const FcChar32 h[] = {
- 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL,
- 0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL
- };
- FcChar32 *ret = malloc (sizeof (FcChar32) * 8);
-
- if (!ret)
- return NULL;
-
- for (i = 0; i < 8; i++)
- ret[i] = h[i];
-
- return ret;
-}
-
-static void
-FcHashComputeSHA256Digest (FcChar32 *hash,
- const char *block)
-{
- static const FcChar32 k[] = {
- 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
- 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
- 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
- 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
- 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
- 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
- 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
- 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
- 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
- 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
- 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
- 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
- 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
- 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
- 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
- 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
- };
- FcChar32 w[64], i, j, t1, t2;
- FcChar32 a, b, c, d, e, f, g, h;
-
-#define H(n) (hash[n])
-
- a = H(0);
- b = H(1);
- c = H(2);
- d = H(3);
- e = H(4);
- f = H(5);
- g = H(6);
- h = H(7);
-
- for (i = 0; i < 16; i++)
- {
- j = (block[(i * 4) + 0] & 0xff) << (8 * 3);
- j |= (block[(i * 4) + 1] & 0xff) << (8 * 2);
- j |= (block[(i * 4) + 2] & 0xff) << (8 * 1);
- j |= (block[(i * 4) + 3] & 0xff);
- w[i] = j;
- }
- for (i = 16; i < 64; i++)
- w[i] = ss1(w[i - 2]) + w[i - 7] + ss0(w[i - 15]) + w[i - 16];
-
- for (i = 0; i < 64; i++)
- {
- t1 = h + SS1(e) + Ch(e, f, g) + k[i] + w[i];
- t2 = SS0(a) + Maj(a, b, c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
-
- H(0) += a;
- H(1) += b;
- H(2) += c;
- H(3) += d;
- H(4) += e;
- H(5) += f;
- H(6) += g;
- H(7) += h;
-
-#undef H
-}
-
-static FcChar8 *
-FcHashSHA256ToString (FcChar32 *hash)
-{
- FcChar8 *ret = NULL;
- static const char hex[] = "0123456789abcdef";
- int i, j;
-
- if (hash)
- {
- ret = malloc (sizeof (FcChar8) * (8 * 8 + 7 + 1));
- if (!ret)
- return NULL;
- memcpy (ret, "sha256:", 7);
-#define H(n) hash[n]
- for (i = 0; i < 8; i++)
- {
- FcChar32 v = H(i);
-
- for (j = 0; j < 8; j++)
- ret[7 + (i * 8) + j] = hex[(v >> (28 - j * 4)) & 0xf];
- }
- ret[7 + i * 8] = 0;
-#undef H
- free (hash);
- }
-
- return ret;
-}
-
-FcChar8 *
-FcHashGetSHA256Digest (const FcChar8 *input_strings,
- size_t len)
-{
- size_t i, round_len = len / 64;
- char block[64];
- FcChar32 *ret = FcHashInitSHA256Digest ();
-
- if (!ret)
- return NULL;
-
- for (i = 0; i < round_len; i++)
- {
- FcHashComputeSHA256Digest (ret, (const char *)&input_strings[i * 64]);
- }
- /* padding */
- if ((len % 64) != 0)
- memcpy (block, &input_strings[len / 64], len % 64);
- memset (&block[len % 64], 0, 64 - (len % 64));
- block[len % 64] = 0x80;
- if ((64 - (len % 64)) < 9)
- {
- /* process a block once */
- FcHashComputeSHA256Digest (ret, block);
- memset (block, 0, 64);
- }
- /* set input size at the end */
- len *= 8;
- block[63 - 0] = (uint64_t)len & 0xff;
- block[63 - 1] = ((uint64_t)len >> 8) & 0xff;
- block[63 - 2] = ((uint64_t)len >> 16) & 0xff;
- block[63 - 3] = ((uint64_t)len >> 24) & 0xff;
- block[63 - 4] = ((uint64_t)len >> 32) & 0xff;
- block[63 - 5] = ((uint64_t)len >> 40) & 0xff;
- block[63 - 6] = ((uint64_t)len >> 48) & 0xff;
- block[63 - 7] = ((uint64_t)len >> 56) & 0xff;
- FcHashComputeSHA256Digest (ret, block);
-
- return FcHashSHA256ToString (ret);
-}
-
-FcChar8 *
-FcHashGetSHA256DigestFromFile (const FcChar8 *filename)
-{
- FILE *fp = fopen ((const char *)filename, "rb");
- char ibuf[64];
- FcChar32 *ret;
- size_t len;
- struct stat st;
-
- if (!fp)
- return NULL;
-
- if (FcStat (filename, &st))
- goto bail0;
-
- ret = FcHashInitSHA256Digest ();
- if (!ret)
- goto bail0;
-
- while (!feof (fp))
- {
- if ((len = fread (ibuf, sizeof (char), 64, fp)) < 64)
- {
- uint64_t v;
-
- /* add a padding */
- memset (&ibuf[len], 0, 64 - len);
- ibuf[len] = 0x80;
- if ((64 - len) < 9)
- {
- /* process a block once */
- FcHashComputeSHA256Digest (ret, ibuf);
- memset (ibuf, 0, 64);
- }
- /* set input size at the end */
- v = (long)st.st_size * 8;
- ibuf[63 - 0] = v & 0xff;
- ibuf[63 - 1] = (v >> 8) & 0xff;
- ibuf[63 - 2] = (v >> 16) & 0xff;
- ibuf[63 - 3] = (v >> 24) & 0xff;
- ibuf[63 - 4] = (v >> 32) & 0xff;
- ibuf[63 - 5] = (v >> 40) & 0xff;
- ibuf[63 - 6] = (v >> 48) & 0xff;
- ibuf[63 - 7] = (v >> 56) & 0xff;
- FcHashComputeSHA256Digest (ret, ibuf);
- break;
- }
- else
- {
- FcHashComputeSHA256Digest (ret, ibuf);
- }
- }
- fclose (fp);
-
- return FcHashSHA256ToString (ret);
-
-bail0:
- fclose (fp);
-
- return NULL;
-}
-
-FcChar8 *
-FcHashGetSHA256DigestFromMemory (const char *fontdata,
- size_t length)
-{
- char ibuf[64];
- FcChar32 *ret;
- size_t i = 0;
-
- ret = FcHashInitSHA256Digest ();
- if (!ret)
- return NULL;
-
- while (i <= length)
- {
- if ((length - i) < 64)
- {
- uint64_t v;
- size_t n;
-
- /* add a padding */
- n = length - i;
- if (n > 0)
- memcpy (ibuf, &fontdata[i], n);
- memset (&ibuf[n], 0, 64 - n);
- ibuf[n] = 0x80;
- if ((64 - n) < 9)
- {
- /* process a block once */
- FcHashComputeSHA256Digest (ret, ibuf);
- memset (ibuf, 0, 64);
- }
- /* set input size at the end */
- v = length * 8;
- ibuf[63 - 0] = v & 0xff;
- ibuf[63 - 1] = (v >> 8) & 0xff;
- ibuf[63 - 2] = (v >> 16) & 0xff;
- ibuf[63 - 3] = (v >> 24) & 0xff;
- ibuf[63 - 4] = (v >> 32) & 0xff;
- ibuf[63 - 5] = (v >> 40) & 0xff;
- ibuf[63 - 6] = (v >> 48) & 0xff;
- ibuf[63 - 7] = (v >> 56) & 0xff;
- FcHashComputeSHA256Digest (ret, ibuf);
- break;
- }
- else
- {
- FcHashComputeSHA256Digest (ret, &fontdata[i]);
- }
- i += 64;
- }
-
- return FcHashSHA256ToString (ret);
-}
diff --git a/chromium/third_party/fontconfig/src/src/fcinit.c b/chromium/third_party/fontconfig/src/src/fcinit.c
index b8d5d060c71..5e7c2f15662 100644
--- a/chromium/third_party/fontconfig/src/src/fcinit.c
+++ b/chromium/third_party/fontconfig/src/src/fcinit.c
@@ -36,13 +36,14 @@
#endif
static FcConfig *
-FcInitFallbackConfig (void)
+FcInitFallbackConfig (const FcChar8 *sysroot)
{
FcConfig *config;
config = FcConfigCreate ();
if (!config)
goto bail0;
+ FcConfigSetSysRoot (config, sysroot);
if (!FcConfigAddDir (config, (FcChar8 *) FC_DEFAULT_FONTS))
goto bail1;
if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR))
@@ -78,20 +79,35 @@ FcInitLoadOwnConfig (FcConfig *config)
if (!FcConfigParseAndLoad (config, 0, FcTrue))
{
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ FcConfig *fallback = FcInitFallbackConfig (sysroot);
+
FcConfigDestroy (config);
- return FcInitFallbackConfig ();
+
+ return fallback;
}
if (config->cacheDirs && config->cacheDirs->num == 0)
{
FcChar8 *prefix, *p;
size_t plen;
+ FcBool have_own = FcFalse;
+ char *env_file, *env_path;
- fprintf (stderr,
- "Fontconfig warning: no <cachedir> elements found. Check configuration.\n");
- fprintf (stderr,
- "Fontconfig warning: adding <cachedir>%s</cachedir>\n",
- FC_CACHEDIR);
+ env_file = getenv ("FONTCONFIG_FILE");
+ env_path = getenv ("FONTCONFIG_PATH");
+ if ((env_file != NULL && env_file[0] != 0) ||
+ (env_path != NULL && env_path[0] != 0))
+ have_own = FcTrue;
+
+ if (!have_own)
+ {
+ fprintf (stderr,
+ "Fontconfig warning: no <cachedir> elements found. Check configuration.\n");
+ fprintf (stderr,
+ "Fontconfig warning: adding <cachedir>%s</cachedir>\n",
+ FC_CACHEDIR);
+ }
prefix = FcConfigXdgCacheHome ();
if (!prefix)
goto bail;
@@ -102,19 +118,26 @@ FcInitLoadOwnConfig (FcConfig *config)
prefix = p;
memcpy (&prefix[plen], FC_DIR_SEPARATOR_S "fontconfig", 11);
prefix[plen + 11] = 0;
- fprintf (stderr,
- "Fontconfig warning: adding <cachedir prefix=\"xdg\">fontconfig</cachedir>\n");
+ if (!have_own)
+ fprintf (stderr,
+ "Fontconfig warning: adding <cachedir prefix=\"xdg\">fontconfig</cachedir>\n");
if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR) ||
!FcConfigAddCacheDir (config, (FcChar8 *) prefix))
{
+ FcConfig *fallback;
+ const FcChar8 *sysroot;
+
bail:
+ sysroot = FcConfigGetSysRoot (config);
fprintf (stderr,
"Fontconfig error: out of memory");
if (prefix)
FcStrFree (prefix);
+ fallback = FcInitFallbackConfig (sysroot);
FcConfigDestroy (config);
- return FcInitFallbackConfig ();
+
+ return fallback;
}
FcStrFree (prefix);
}
@@ -169,6 +192,8 @@ FcFini (void)
FcConfigFini ();
FcCacheFini ();
FcDefaultFini ();
+ FcObjectFini ();
+ FcConfigPathFini ();
}
/*
@@ -178,11 +203,18 @@ FcBool
FcInitReinitialize (void)
{
FcConfig *config;
+ FcBool ret;
config = FcInitLoadConfigAndFonts ();
if (!config)
return FcFalse;
- return FcConfigSetCurrent (config);
+ ret = FcConfigSetCurrent (config);
+ /* FcConfigSetCurrent() increases the refcount.
+ * decrease it here to avoid the memory leak.
+ */
+ FcConfigDestroy (config);
+
+ return ret;
}
FcBool
@@ -191,6 +223,8 @@ FcInitBringUptoDate (void)
FcConfig *config = FcConfigGetCurrent ();
time_t now;
+ if (!config)
+ return FcFalse;
/*
* rescanInterval == 0 disables automatic up to date
*/
diff --git a/chromium/third_party/fontconfig/src/src/fcint.h b/chromium/third_party/fontconfig/src/src/fcint.h
index 362ea6f99ad..ac911ad4076 100644
--- a/chromium/third_party/fontconfig/src/src/fcint.h
+++ b/chromium/third_party/fontconfig/src/src/fcint.h
@@ -38,6 +38,8 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
+#include <float.h>
+#include <math.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/types.h>
@@ -85,6 +87,7 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
#define FC_DBG_SCANV 256
#define FC_DBG_CONFIG 1024
#define FC_DBG_LANGSET 2048
+#define FC_DBG_MATCH2 4096
#define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] FC_UNUSED
#define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
@@ -161,6 +164,7 @@ typedef enum _FcValueBinding {
#define FcValueString(v) FcPointerMember(v,u.s,FcChar8)
#define FcValueCharSet(v) FcPointerMember(v,u.c,const FcCharSet)
#define FcValueLangSet(v) FcPointerMember(v,u.l,const FcLangSet)
+#define FcValueRange(v) FcPointerMember(v,u.r,const FcRange)
typedef struct _FcValueList *FcValueListPtr;
@@ -244,20 +248,26 @@ typedef struct _FcExprName {
FcMatchKind kind;
} FcExprName;
+struct _FcRange {
+ double begin;
+ double end;
+};
+
typedef struct _FcExpr {
FcOp op;
union {
- int ival;
- double dval;
- const FcChar8 *sval;
- FcExprMatrix *mexpr;
- FcBool bval;
- FcCharSet *cval;
- FcLangSet *lval;
-
- FcExprName name;
- const FcChar8 *constant;
+ int ival;
+ double dval;
+ const FcChar8 *sval;
+ FcExprMatrix *mexpr;
+ FcBool bval;
+ FcCharSet *cval;
+ FcLangSet *lval;
+ FcRange *rval;
+
+ FcExprName name;
+ const FcChar8 *constant;
struct {
struct _FcExpr *left, *right;
} tree;
@@ -329,11 +339,19 @@ struct _FcCharSet {
FcCharLeaf))
#define FcCharSetNumbers(c) FcOffsetMember(c,numbers_offset,FcChar16)
+#define FCSS_DEFAULT 0 /* default behavior */
+#define FCSS_ALLOW_DUPLICATES 1 /* allows for duplicate strings in the set */
+#define FCSS_GROW_BY_64 2 /* grows buffer by 64 elements instead of 1 */
+
+#define FcStrSetHasControlBit(s,c) (s->control & c)
+#define FcStrSetHasControlBits(s,c) ( (c) == (s->control & (c)) )
+
struct _FcStrSet {
FcRef ref; /* reference count */
int num;
int size;
FcChar8 **strs;
+ unsigned int control; /* control bits for set behavior */
};
struct _FcStrList {
@@ -352,13 +370,14 @@ typedef struct _FcStrBuf {
struct _FcCache {
unsigned int magic; /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
- int version; /* FC_CACHE_CONTENT_VERSION */
+ int version; /* FC_CACHE_VERSION_NUMBER */
intptr_t size; /* size of file */
intptr_t dir; /* offset to dir name */
intptr_t dirs; /* offset to subdirs */
int dirs_count; /* number of subdir strings */
intptr_t set; /* offset to font set */
int checksum; /* checksum of directory state */
+ int64_t checksum_nano; /* checksum of directory state */
};
#undef FcCacheDir
@@ -444,7 +463,6 @@ typedef struct _FcCaseFold {
#define FC_CACHE_MAGIC_MMAP 0xFC02FC04
#define FC_CACHE_MAGIC_ALLOC 0xFC02FC05
-#define FC_CACHE_CONTENT_VERSION 4
struct _FcAtomic {
FcChar8 *file; /* original file name */
@@ -532,13 +550,6 @@ typedef struct _FcFileTime {
typedef struct _FcCharMap FcCharMap;
-typedef struct _FcRange FcRange;
-
-struct _FcRange {
- FcChar32 begin;
- FcChar32 end;
-};
-
typedef struct _FcStatFS FcStatFS;
struct _FcStatFS {
@@ -567,6 +578,9 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config);
FcPrivate FcCache *
FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcStrSet *dirs);
+FcPrivate FcCache *
+FcDirCacheRebuild (FcCache *cache, struct stat *dir_stat, FcStrSet *dirs);
+
FcPrivate FcBool
FcDirCacheWrite (FcCache *cache, FcConfig *config);
@@ -585,6 +599,13 @@ FcCacheFini (void);
FcPrivate void
FcDirCacheReference (FcCache *cache, int nref);
+FcPrivate int
+FcDirCacheLock (const FcChar8 *dir,
+ FcConfig *config);
+
+FcPrivate void
+FcDirCacheUnlock (int fd);
+
/* fccfg.c */
FcPrivate FcBool
@@ -698,6 +719,9 @@ FcPrivate FcLangSet *
FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
/* fccharset.c */
+FcPrivate FcCharSet *
+FcCharSetPromote (FcValuePromotionBuffer *vbuf);
+
FcPrivate void
FcLangCharSetPopulate (void);
@@ -786,6 +810,9 @@ FcSubstPrint (const FcSubst *subst);
FcPrivate void
FcCharSetPrint (const FcCharSet *c);
+FcPrivate void
+FcPatternPrint2 (FcPattern *p1, FcPattern *p2, const FcObjectSet *os);
+
extern FcPrivate int FcDebugVal;
#define FcDebug() (FcDebugVal)
@@ -838,17 +865,8 @@ FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s);
FcPrivate FcFontSet *
FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s);
-/* fchash.c */
-FcPrivate FcChar8 *
-FcHashGetSHA256Digest (const FcChar8 *input_strings,
- size_t len);
-
-FcPrivate FcChar8 *
-FcHashGetSHA256DigestFromFile (const FcChar8 *filename);
-
-FcPrivate FcChar8 *
-FcHashGetSHA256DigestFromMemory (const char *fontdata,
- size_t length);
+FcPrivate FcFontSet *
+FcFontSetDeserialize (const FcFontSet *set);
/* fcinit.c */
FcPrivate FcConfig *
@@ -859,6 +877,9 @@ FcInitLoadOwnConfigAndFonts (FcConfig *config);
/* fcxml.c */
FcPrivate void
+FcConfigPathFini (void);
+
+FcPrivate void
FcTestDestroy (FcTest *test);
FcPrivate void
@@ -1002,6 +1023,9 @@ FcPatternObjectAddBool (FcPattern *p, FcObject object, FcBool b);
FcPrivate FcBool
FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls);
+FcPrivate FcBool
+FcPatternObjectAddRange (FcPattern *p, FcObject object, const FcRange *r);
+
FcPrivate FcResult
FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i);
@@ -1023,9 +1047,15 @@ FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b);
FcPrivate FcResult
FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
+FcPrivate FcResult
+FcPatternObjectGetRange (const FcPattern *p, FcObject object, int id, FcRange **r);
+
FcPrivate FcBool
FcPatternAppend (FcPattern *p, FcPattern *s);
+FcPrivate int
+FcPatternPosition (const FcPattern *p, const char *object);
+
FcPrivate FcChar32
FcStringHash (const FcChar8 *s);
@@ -1050,6 +1080,26 @@ extern FcPrivate const FcMatrix FcIdentityMatrix;
FcPrivate void
FcMatrixFree (FcMatrix *mat);
+/* fcrange.c */
+
+FcPrivate FcRange *
+FcRangePromote (double v, FcValuePromotionBuffer *vbuf);
+
+FcPrivate FcBool
+FcRangeIsInRange (const FcRange *a, const FcRange *b);
+
+FcPrivate FcBool
+FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b);
+
+FcPrivate FcChar32
+FcRangeHash (const FcRange *r);
+
+FcPrivate FcBool
+FcRangeSerializeAlloc (FcSerialize *serialize, const FcRange *r);
+
+FcPrivate FcRange *
+FcRangeSerialize (FcSerialize *serialize, const FcRange *r);
+
/* fcstat.c */
FcPrivate int
@@ -1065,6 +1115,9 @@ FcPrivate FcBool
FcIsFsMtimeBroken (const FcChar8 *dir);
/* fcstr.c */
+FcPrivate FcStrSet *
+FcStrSetCreateEx (unsigned int control);
+
FcPrivate FcBool
FcStrSetAddLangs (FcStrSet *strs, const char *languages);
@@ -1098,12 +1151,6 @@ FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
FcPrivate int
FcStrCmpIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims);
-FcPrivate FcBool
-FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex);
-
-FcPrivate FcBool
-FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex);
-
FcPrivate const FcChar8 *
FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
@@ -1144,6 +1191,9 @@ FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
/* fcobjs.c */
+FcPrivate void
+FcObjectFini (void);
+
FcPrivate FcObject
FcObjectLookupIdByName (const char *str);
diff --git a/chromium/third_party/fontconfig/src/src/fclang.c b/chromium/third_party/fontconfig/src/src/fclang.c
index 9f685f6fdff..b1fd1bcae67 100644
--- a/chromium/third_party/fontconfig/src/src/fclang.c
+++ b/chromium/third_party/fontconfig/src/src/fclang.c
@@ -720,19 +720,22 @@ FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *vbuf)
memset (buf->ls.map, '\0', sizeof (buf->ls.map));
buf->ls.map_size = NUM_LANG_SET_MAP;
buf->ls.extra = 0;
- id = FcLangSetIndex (lang);
- if (id > 0)
+ if (lang)
{
- FcLangSetBitSet (&buf->ls, id);
- }
- else
- {
- buf->ls.extra = &buf->strs;
- buf->strs.num = 1;
- buf->strs.size = 1;
- buf->strs.strs = &buf->str;
- FcRefInit (&buf->strs.ref, 1);
- buf->str = (FcChar8 *) lang;
+ id = FcLangSetIndex (lang);
+ if (id > 0)
+ {
+ FcLangSetBitSet (&buf->ls, id);
+ }
+ else
+ {
+ buf->ls.extra = &buf->strs;
+ buf->strs.num = 1;
+ buf->strs.size = 1;
+ buf->strs.strs = &buf->str;
+ FcRefInit (&buf->strs.ref, 1);
+ buf->str = (FcChar8 *) lang;
+ }
}
return &buf->ls;
}
diff --git a/chromium/third_party/fontconfig/src/src/fclist.c b/chromium/third_party/fontconfig/src/src/fclist.c
index a365098a4d7..d7e8fc09106 100644
--- a/chromium/third_party/fontconfig/src/src/fclist.c
+++ b/chromium/third_party/fontconfig/src/src/fclist.c
@@ -270,9 +270,11 @@ FcListValueHash (FcValue *value)
case FcTypeCharSet:
return FcCharSetCount (v.u.c);
case FcTypeFTFace:
- return (long) v.u.f;
+ return (intptr_t) v.u.f;
case FcTypeLangSet:
return FcLangSetHash (v.u.l);
+ case FcTypeRange:
+ return FcRangeHash (v.u.r);
}
return 0;
}
diff --git a/chromium/third_party/fontconfig/src/src/fcmatch.c b/chromium/third_party/fontconfig/src/src/fcmatch.c
index 627aa1a1696..40efbd3f67b 100644
--- a/chromium/third_party/fontconfig/src/src/fcmatch.c
+++ b/chromium/third_party/fontconfig/src/src/fcmatch.c
@@ -189,6 +189,49 @@ FcCompareSize (FcValue *value1, FcValue *value2)
}
static double
+FcCompareSizeRange (FcValue *v1, FcValue *v2)
+{
+ FcValue value1 = FcValueCanonicalize (v1);
+ FcValue value2 = FcValueCanonicalize (v2);
+ FcRange *r1 = NULL, *r2 = NULL;
+ double ret = -1.0;
+
+ switch ((int) value1.type) {
+ case FcTypeDouble:
+ r1 = FcRangeCreateDouble (value1.u.d, value1.u.d);
+ break;
+ case FcTypeRange:
+ r1 = FcRangeCopy (value1.u.r);
+ break;
+ default:
+ goto bail;
+ }
+ switch ((int) value2.type) {
+ case FcTypeDouble:
+ r2 = FcRangeCreateDouble (value2.u.d, value2.u.d);
+ break;
+ case FcTypeRange:
+ r2 = FcRangeCopy (value2.u.r);
+ break;
+ default:
+ goto bail;
+ }
+
+ if (FcRangeIsInRange (r1, r2))
+ ret = 0.0;
+ else
+ ret = FC_MIN (fabs (r1->end - r2->begin), fabs (r1->begin - r2->end));
+
+bail:
+ if (r1)
+ FcRangeDestroy (r1);
+ if (r2)
+ FcRangeDestroy (r2);
+
+ return ret;
+}
+
+static double
FcCompareFilename (FcValue *v1, FcValue *v2)
{
const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
@@ -202,16 +245,8 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
return 3.0;
}
-static double
-FcCompareHash (FcValue *v1, FcValue *v2)
-{
- const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
- /* Do not match an empty string */
- if (!s1 || !s2 || !s1[0] || !s2[0])
- return 1.0;
- return FcCompareString (v1, v2);
-}
+/* Define priorities to -1 for objects that don't have a compare function. */
#define PRI_NULL(n) \
PRI_ ## n ## _STRONG = -1, \
@@ -226,7 +261,7 @@ FcCompareHash (FcValue *v1, FcValue *v2)
#define PRI_FcCompareCharSet(n) PRI1(n)
#define PRI_FcCompareLang(n) PRI1(n)
#define PRI_FcComparePostScript(n) PRI1(n)
-#define PRI_FcCompareHash(n) PRI1(n)
+#define PRI_FcCompareSizeRange(n) PRI1(n)
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
@@ -236,6 +271,9 @@ typedef enum _FcMatcherPriorityDummy {
#undef FC_OBJECT
+
+/* Canonical match priority order. */
+
#undef PRI1
#define PRI1(n) \
PRI_ ## n, \
@@ -243,10 +281,10 @@ typedef enum _FcMatcherPriorityDummy {
PRI_ ## n ## _WEAK = PRI_ ## n
typedef enum _FcMatcherPriority {
- PRI1(HASH),
PRI1(FILE),
PRI1(FONTFORMAT),
PRI1(SCALABLE),
+ PRI1(COLOR),
PRI1(FOUNDRY),
PRI1(CHARSET),
PRI_FAMILY_STRONG,
@@ -254,7 +292,9 @@ typedef enum _FcMatcherPriority {
PRI1(LANG),
PRI_FAMILY_WEAK,
PRI_POSTSCRIPT_NAME_WEAK,
+ PRI1(SYMBOL),
PRI1(SPACING),
+ PRI1(SIZE),
PRI1(PIXEL_SIZE),
PRI1(STYLE),
PRI1(SLANT),
@@ -337,7 +377,7 @@ FcCompareValueList (FcObject object,
best = 1e99;
bestStrong = 1e99;
bestWeak = 1e99;
- j = 1;
+ j = 0;
for (v1 = v1orig; v1; v1 = FcValueListNext(v1))
{
for (v2 = v2orig, k = 0; v2; v2 = FcValueListNext(v2), k++)
@@ -445,7 +485,7 @@ FcFontRenderPrepare (FcConfig *config,
{
FcPattern *new;
int i;
- FcPatternElt *fe, *pe, *fel, *pel;
+ FcPatternElt *fe, *pe;
FcValue v;
FcResult result;
@@ -470,36 +510,25 @@ FcFontRenderPrepare (FcConfig *config,
fe->object == FC_STYLE_OBJECT ||
fe->object == FC_FULLNAME_OBJECT)
{
+ FcPatternElt *fel, *pel;
+
FC_ASSERT_STATIC ((FC_FAMILY_OBJECT + 1) == FC_FAMILYLANG_OBJECT);
FC_ASSERT_STATIC ((FC_STYLE_OBJECT + 1) == FC_STYLELANG_OBJECT);
FC_ASSERT_STATIC ((FC_FULLNAME_OBJECT + 1) == FC_FULLNAMELANG_OBJECT);
fel = FcPatternObjectFindElt (font, fe->object + 1);
pel = FcPatternObjectFindElt (pat, fe->object + 1);
- }
- else
- {
- fel = NULL;
- pel = NULL;
- }
- pe = FcPatternObjectFindElt (pat, fe->object);
- if (pe)
- {
- const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse);
- if (!FcCompareValueList (pe->object, match,
- FcPatternEltValues(pe),
- FcPatternEltValues(fe), &v, NULL, NULL, &result))
- {
- FcPatternDestroy (new);
- return NULL;
- }
if (fel && pel)
{
+ /* The font has name languages, and pattern asks for specific language(s).
+ * Match on language and and prefer that result.
+ * Note: Currently the code only give priority to first matching language.
+ */
int n = 1, j;
FcValueListPtr l1, l2, ln = NULL, ll = NULL;
+ const FcMatcher *match = FcObjectToMatcher (pel->object, FcTrue);
- match = FcObjectToMatcher (pel->object, FcTrue);
if (!FcCompareValueList (pel->object, match,
FcPatternEltValues (pel),
FcPatternEltValues (fel), NULL, NULL, &n, &result))
@@ -542,9 +571,10 @@ FcFontRenderPrepare (FcConfig *config,
}
else if (fel)
{
+ /* Pattern doesn't ask for specific language. Copy all for name and
+ * lang. */
FcValueListPtr l1, l2;
- copy_lang:
l1 = FcValueListDuplicate (FcPatternEltValues (fe));
l2 = FcValueListDuplicate (FcPatternEltValues (fel));
FcPatternObjectListAdd (new, fe->object, l1, FcFalse);
@@ -552,12 +582,23 @@ FcFontRenderPrepare (FcConfig *config,
continue;
}
+ }
+
+ pe = FcPatternObjectFindElt (pat, fe->object);
+ if (pe)
+ {
+ const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse);
+ if (!FcCompareValueList (pe->object, match,
+ FcPatternEltValues(pe),
+ FcPatternEltValues(fe), &v, NULL, NULL, &result))
+ {
+ FcPatternDestroy (new);
+ return NULL;
+ }
FcPatternObjectAdd (new, fe->object, v, FcFalse);
}
else
{
- if (fel)
- goto copy_lang;
FcPatternObjectListAdd (new, fe->object,
FcValueListDuplicate (FcPatternEltValues (fe)),
FcTrue);
@@ -648,6 +689,47 @@ FcFontSetMatchInternal (FcFontSet **sets,
printf ("\n");
FcPatternPrint (best);
}
+ if (FcDebug () & FC_DBG_MATCH2)
+ {
+ char *env = getenv ("FC_DBG_MATCH_FILTER");
+ FcObjectSet *os = NULL;
+
+ if (env)
+ {
+ char *ss, *s;
+ char *p;
+ FcBool f = FcTrue;
+
+ ss = s = strdup (env);
+ os = FcObjectSetCreate ();
+ while (f)
+ {
+ size_t len;
+ char *x;
+
+ if (!(p = strchr (s, ',')))
+ {
+ f = FcFalse;
+ len = strlen (s) + 1;
+ }
+ else
+ {
+ len = (p - s) + 1;
+ }
+ x = malloc (sizeof (char) * len);
+ strncpy (x, s, len - 1);
+ x[len - 1] = 0;
+ if (FcObjectFromName (x) > 0)
+ FcObjectSetAdd (os, x);
+ s = p + 1;
+ free (x);
+ }
+ free (ss);
+ }
+ FcPatternPrint2 (p, best, os);
+ if (os)
+ FcObjectSetDestroy (os);
+ }
/* assuming that 'result' is initialized with FcResultNoMatch
* outside this function */
if (best)
@@ -743,6 +825,7 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **csp, FcBool tr
{
FcBool ret = FcFalse;
FcCharSet *cs;
+ int i;
cs = 0;
if (trim || csp)
@@ -752,7 +835,7 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **csp, FcBool tr
goto bail;
}
- while (nnode--)
+ for (i = 0; i < nnode; i++)
{
FcSortNode *node = *n++;
FcBool adds_chars = FcFalse;
@@ -776,7 +859,7 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **csp, FcBool tr
* If this font isn't a subset of the previous fonts,
* add it to the list
*/
- if (!trim || adds_chars)
+ if (!i || !trim || adds_chars)
{
FcPatternReference (node->pattern);
if (FcDebug () & FC_DBG_MATCHV)
diff --git a/chromium/third_party/fontconfig/src/src/fcname.c b/chromium/third_party/fontconfig/src/src/fcname.c
index 712b2fad36c..8be36c70c1c 100644
--- a/chromium/third_party/fontconfig/src/src/fcname.c
+++ b/chromium/third_party/fontconfig/src/src/fcname.c
@@ -87,6 +87,12 @@ FcObjectValidType (FcObject object, FcType type)
if (type == FcTypeLangSet || type == FcTypeString)
return FcTrue;
break;
+ case FcTypeRange:
+ if (type == FcTypeRange ||
+ type == FcTypeDouble ||
+ type == FcTypeInteger)
+ return FcTrue;
+ break;
default:
if (type == t->type)
return FcTrue;
@@ -132,6 +138,8 @@ static const FcConstant _FcBaseConstants[] = {
{ (FcChar8 *) "thin", "weight", FC_WEIGHT_THIN, },
{ (FcChar8 *) "extralight", "weight", FC_WEIGHT_EXTRALIGHT, },
{ (FcChar8 *) "ultralight", "weight", FC_WEIGHT_EXTRALIGHT, },
+ { (FcChar8 *) "demilight", "weight", FC_WEIGHT_DEMILIGHT, },
+ { (FcChar8 *) "semilight", "weight", FC_WEIGHT_DEMILIGHT, },
{ (FcChar8 *) "light", "weight", FC_WEIGHT_LIGHT, },
{ (FcChar8 *) "book", "weight", FC_WEIGHT_BOOK, },
{ (FcChar8 *) "regular", "weight", FC_WEIGHT_REGULAR, },
@@ -273,6 +281,8 @@ FcNameConvert (FcType type, FcChar8 *string)
{
FcValue v;
FcMatrix m;
+ double b, e;
+ char *p;
v.type = type;
switch ((int) v.type) {
@@ -307,6 +317,20 @@ FcNameConvert (FcType type, FcChar8 *string)
if (!v.u.l)
v.type = FcTypeVoid;
break;
+ case FcTypeRange:
+ if (sscanf ((char *) string, "[%lg %lg)", &b, &e) != 2)
+ {
+ v.u.d = strtod ((char *) string, &p);
+ if (p != NULL && p[0] != 0)
+ {
+ v.type = FcTypeVoid;
+ break;
+ }
+ v.type = FcTypeDouble;
+ }
+ else
+ v.u.r = FcRangeCreateDouble (b, e);
+ break;
default:
break;
}
@@ -420,6 +444,8 @@ FcNameParse (const FcChar8 *name)
if ((c = FcNameGetConstant (save)))
{
t = FcNameGetObjectType ((char *) c->object);
+ if (t == NULL)
+ goto bail2;
switch ((int) t->type) {
case FcTypeInteger:
case FcTypeDouble:
@@ -499,6 +525,9 @@ FcNameUnparseValue (FcStrBuf *buf,
return FcNameUnparseLangSet (buf, v.u.l);
case FcTypeFTFace:
return FcTrue;
+ case FcTypeRange:
+ sprintf ((char *) temp, "[%g %g)", v.u.r->begin, v.u.r->end);
+ return FcNameUnparseString (buf, temp, 0);
}
return FcFalse;
}
@@ -531,12 +560,13 @@ FcNameUnparse (FcPattern *pat)
FcChar8 *
FcNameUnparseEscaped (FcPattern *pat, FcBool escape)
{
- FcStrBuf buf;
- FcChar8 buf_static[8192];
+ FcStrBuf buf, buf2;
+ FcChar8 buf_static[8192], buf2_static[256];
int i;
FcPatternElt *e;
FcStrBufInit (&buf, buf_static, sizeof (buf_static));
+ FcStrBufInit (&buf2, buf2_static, sizeof (buf2_static));
e = FcPatternObjectFindElt (pat, FC_FAMILY_OBJECT);
if (e)
{
@@ -546,10 +576,17 @@ FcNameUnparseEscaped (FcPattern *pat, FcBool escape)
e = FcPatternObjectFindElt (pat, FC_SIZE_OBJECT);
if (e)
{
- if (!FcNameUnparseString (&buf, (FcChar8 *) "-", 0))
+ FcChar8 *p;
+
+ if (!FcNameUnparseString (&buf2, (FcChar8 *) "-", 0))
goto bail0;
- if (!FcNameUnparseValueList (&buf, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_FIXED : 0))
+ if (!FcNameUnparseValueList (&buf2, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_FIXED : 0))
goto bail0;
+ p = FcStrBufDoneStatic (&buf2);
+ FcStrBufDestroy (&buf2);
+ if (strlen ((const char *)p) > 1)
+ if (!FcStrBufString (&buf, p))
+ goto bail0;
}
for (i = 0; i < NUM_OBJECT_TYPES; i++)
{
diff --git a/chromium/third_party/fontconfig/src/src/fcobjs.c b/chromium/third_party/fontconfig/src/src/fcobjs.c
index bad9824d461..16ff31c4789 100644
--- a/chromium/third_party/fontconfig/src/src/fcobjs.c
+++ b/chromium/third_party/fontconfig/src/src/fcobjs.c
@@ -44,6 +44,28 @@ struct FcObjectOtherTypeInfo {
FcObject id;
} *other_types;
+void
+FcObjectFini (void)
+{
+ struct FcObjectOtherTypeInfo *ots, *ot;
+
+retry:
+ ots = fc_atomic_ptr_get (&other_types);
+ if (!ots)
+ return;
+ if (!fc_atomic_ptr_cmpexch (&other_types, ots, NULL))
+ goto retry;
+
+ while (ots)
+ {
+ ot = ots->next;
+ if (ots->object.object)
+ free (ots->object.object);
+ free (ots);
+ ots = ot;
+ }
+}
+
static FcObjectType *
_FcObjectLookupOtherTypeByName (const char *str, FcObject *id)
{
@@ -62,12 +84,19 @@ retry:
if (!ot)
return NULL;
- ot->object.object = (const char *) FcStrdup (str);
+ ot->object.object = (char *) FcStrdup (str);
ot->object.type = FcTypeUnknown;
ot->id = fc_atomic_int_add (next_id, +1);
+ if (ot->id < (FC_MAX_BASE_OBJECT + FC_EXT_OBJ_INDEX))
+ {
+ fprintf (stderr, "Fontconfig error: No object ID to assign\n");
+ abort ();
+ }
ot->next = ots;
if (!fc_atomic_ptr_cmpexch (&other_types, ots, ot)) {
+ if (ot->object.object)
+ free (ot->object.object);
free (ot);
goto retry;
}
diff --git a/chromium/third_party/fontconfig/src/src/fcobjs.h b/chromium/third_party/fontconfig/src/src/fcobjs.h
index 87c7319e39a..1fc4f656b8e 100644
--- a/chromium/third_party/fontconfig/src/src/fcobjs.h
+++ b/chromium/third_party/fontconfig/src/src/fcobjs.h
@@ -1,3 +1,26 @@
+/*
+ * fontconfig/src/fcobjs.h
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
/* DON'T REORDER! The order is part of the cache signature. */
FC_OBJECT (FAMILY, FcTypeString, FcCompareFamily)
FC_OBJECT (FAMILYLANG, FcTypeString, NULL)
@@ -8,7 +31,7 @@ FC_OBJECT (FULLNAMELANG, FcTypeString, NULL)
FC_OBJECT (SLANT, FcTypeInteger, FcCompareNumber)
FC_OBJECT (WEIGHT, FcTypeInteger, FcCompareNumber)
FC_OBJECT (WIDTH, FcTypeInteger, FcCompareNumber)
-FC_OBJECT (SIZE, FcTypeDouble, NULL)
+FC_OBJECT (SIZE, FcTypeRange, FcCompareSizeRange)
FC_OBJECT (ASPECT, FcTypeDouble, NULL)
FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareSize)
FC_OBJECT (SPACING, FcTypeInteger, FcCompareNumber)
@@ -21,7 +44,7 @@ FC_OBJECT (AUTOHINT, FcTypeBool, NULL)
FC_OBJECT (GLOBAL_ADVANCE, FcTypeBool, NULL) /* deprecated */
FC_OBJECT (FILE, FcTypeString, FcCompareFilename)
FC_OBJECT (INDEX, FcTypeInteger, NULL)
-FC_OBJECT (RASTERIZER, FcTypeString, FcCompareString)
+FC_OBJECT (RASTERIZER, FcTypeString, FcCompareString) /* deprecated */
FC_OBJECT (OUTLINE, FcTypeBool, FcCompareBool)
FC_OBJECT (SCALABLE, FcTypeBool, FcCompareBool)
FC_OBJECT (DPI, FcTypeDouble, NULL)
@@ -43,6 +66,8 @@ FC_OBJECT (LCD_FILTER, FcTypeInteger, NULL)
FC_OBJECT (NAMELANG, FcTypeString, NULL)
FC_OBJECT (FONT_FEATURES, FcTypeString, NULL)
FC_OBJECT (PRGNAME, FcTypeString, NULL)
-FC_OBJECT (HASH, FcTypeString, FcCompareHash)
+FC_OBJECT (HASH, FcTypeString, NULL) /* deprecated */
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
+FC_OBJECT (COLOR, FcTypeBool, FcCompareBool)
+FC_OBJECT (SYMBOL, FcTypeBool, FcCompareBool)
/* ^-------------- Add new objects here. */
diff --git a/chromium/third_party/fontconfig/src/src/fcobjshash.gperf.h b/chromium/third_party/fontconfig/src/src/fcobjshash.gperf.h
index ca23c026116..1765c949d9a 100644
--- a/chromium/third_party/fontconfig/src/src/fcobjshash.gperf.h
+++ b/chromium/third_party/fontconfig/src/src/fcobjshash.gperf.h
@@ -1,3 +1,26 @@
+/*
+ * fontconfig/src/fcobjshash.gperf.h
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
%{
CUT_OUT_BEGIN
#include <fontconfig/fontconfig.h>
diff --git a/chromium/third_party/fontconfig/src/src/fcpat.c b/chromium/third_party/fontconfig/src/src/fcpat.c
index 0614ac2c239..3ef1ed21205 100644
--- a/chromium/third_party/fontconfig/src/src/fcpat.c
+++ b/chromium/third_party/fontconfig/src/src/fcpat.c
@@ -33,6 +33,7 @@ FcPatternCreate (void)
p = (FcPattern *) malloc (sizeof (FcPattern));
if (!p)
return 0;
+ memset (p, 0, sizeof (FcPattern));
p->num = 0;
p->size = 0;
p->elts_offset = FcPtrToOffset (p, NULL);
@@ -56,6 +57,9 @@ FcValueDestroy (FcValue v)
case FcTypeLangSet:
FcLangSetDestroy ((FcLangSet *) v.u.l);
break;
+ case FcTypeRange:
+ FcRangeDestroy ((FcRange *) v.u.r);
+ break;
default:
break;
}
@@ -80,6 +84,10 @@ FcValueCanonicalize (const FcValue *v)
new.u.l = FcValueLangSet(v);
new.type = FcTypeLangSet;
break;
+ case FcTypeRange:
+ new.u.r = FcValueRange(v);
+ new.type = FcTypeRange;
+ break;
default:
new = *v;
break;
@@ -111,6 +119,11 @@ FcValueSave (FcValue v)
if (!v.u.l)
v.type = FcTypeVoid;
break;
+ case FcTypeRange:
+ v.u.r = FcRangeCopy (v.u.r);
+ if (!v.u.r)
+ v.type = FcTypeVoid;
+ break;
default:
break;
}
@@ -144,6 +157,9 @@ FcValueListDestroy (FcValueListPtr l)
FcLangSetDestroy
((FcLangSet *) (l->value.u.l));
break;
+ case FcTypeRange:
+ FcRangeDestroy ((FcRange *) (l->value.u.r));
+ break;
default:
break;
}
@@ -266,6 +282,8 @@ FcValueEqual (FcValue va, FcValue vb)
return va.u.f == vb.u.f;
case FcTypeLangSet:
return FcLangSetEqual (va.u.l, vb.u.l);
+ case FcTypeRange:
+ return FcRangeIsInRange (va.u.r, vb.u.r);
}
return FcFalse;
}
@@ -319,6 +337,8 @@ FcValueHash (const FcValue *v)
FcStringHash ((const FcChar8 *) ((FT_Face) v->u.f)->style_name);
case FcTypeLangSet:
return FcLangSetHash (FcValueLangSet(v));
+ case FcTypeRange:
+ return FcRangeHash (v->u.r);
}
return 0;
}
@@ -405,6 +425,12 @@ FcPatternObjectPosition (const FcPattern *p, FcObject object)
return -(mid + 1);
}
+int
+FcPatternPosition (const FcPattern *p, const char *object)
+{
+ return FcPatternObjectPosition (p, FcObjectFromName (object));
+}
+
FcPatternElt *
FcPatternObjectFindElt (const FcPattern *p, FcObject object)
{
@@ -840,6 +866,22 @@ FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls)
return FcPatternAdd (p, object, v, FcTrue);
}
+FcBool
+FcPatternObjectAddRange (FcPattern *p, FcObject object, const FcRange *r)
+{
+ FcValue v;
+
+ v.type = FcTypeRange;
+ v.u.r = (FcRange *)r;
+ return FcPatternObjectAdd (p, object, v, FcTrue);
+}
+
+FcBool
+FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r)
+{
+ return FcPatternObjectAddRange (p, FcObjectFromName (object), r);
+}
+
FcResult
FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
{
@@ -1024,6 +1066,31 @@ FcPatternGetLangSet(const FcPattern *p, const char *object, int id, FcLangSet **
return FcResultMatch;
}
+FcResult
+FcPatternObjectGetRange (const FcPattern *p, FcObject object, int id, FcRange **r)
+{
+ FcValue v;
+ FcResult res;
+
+ res = FcPatternObjectGet (p, object, id, &v);
+ if (res != FcResultMatch)
+ return res;
+ switch ((int)v.type) {
+ case FcTypeRange:
+ *r = (FcRange *)v.u.r;
+ break;
+ default:
+ return FcResultTypeMismatch;
+ }
+ return FcResultMatch;
+}
+
+FcResult
+FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r)
+{
+ return FcPatternObjectGetRange (p, FcObjectFromName (object), id, r);
+}
+
FcPattern *
FcPatternDuplicate (const FcPattern *orig)
{
@@ -1229,6 +1296,10 @@ FcValueListSerializeAlloc (FcSerialize *serialize, const FcValueList *vl)
if (!FcLangSetSerializeAlloc (serialize, vl->value.u.l))
return FcFalse;
break;
+ case FcTypeRange:
+ if (!FcRangeSerializeAlloc (serialize, vl->value.u.r))
+ return FcFalse;
+ break;
default:
break;
}
@@ -1244,6 +1315,7 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
FcChar8 *s_serialized;
FcCharSet *c_serialized;
FcLangSet *l_serialized;
+ FcRange *r_serialized;
FcValueList *head_serialized = NULL;
FcValueList *prev_serialized = NULL;
@@ -1302,6 +1374,14 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
l_serialized,
FcLangSet);
break;
+ case FcTypeRange:
+ r_serialized = FcRangeSerialize (serialize, vl->value.u.r);
+ if (!r_serialized)
+ return NULL;
+ vl_serialized->value.u.r = FcPtrToEncodedOffset (&vl_serialized->value,
+ r_serialized,
+ FcRange);
+ break;
default:
break;
}
@@ -1310,6 +1390,7 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
}
return head_serialized;
}
+
#define __fcpat__
#include "fcaliastail.h"
#include "fcftaliastail.h"
diff --git a/chromium/third_party/fontconfig/src/src/fcrange.c b/chromium/third_party/fontconfig/src/src/fcrange.c
new file mode 100644
index 00000000000..f70226c5521
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/src/fcrange.c
@@ -0,0 +1,161 @@
+/*
+ * fontconfig/src/fcrange.c
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "fcint.h"
+
+
+FcRange *
+FcRangeCreateDouble (double begin, double end)
+{
+ FcRange *ret = malloc (sizeof (FcRange));
+
+ if (ret)
+ {
+ ret->begin = begin;
+ ret->end = end;
+ }
+
+ return ret;
+}
+
+FcRange *
+FcRangeCreateInteger (FcChar32 begin, FcChar32 end)
+{
+ FcRange *ret = malloc (sizeof (FcRange));
+
+ if (ret)
+ {
+ ret->begin = begin;
+ ret->end = end;
+ }
+
+ return ret;
+}
+
+void
+FcRangeDestroy (FcRange *range)
+{
+ free (range);
+}
+
+FcRange *
+FcRangeCopy (const FcRange *range)
+{
+ return FcRangeCreateDouble (range->begin, range->end);
+}
+
+FcBool
+FcRangeGetDouble(const FcRange *range, double *begin, double *end)
+{
+ if (!range)
+ return FcFalse;
+ if (begin)
+ *begin = range->begin;
+ if (end)
+ *end = range->end;
+
+ return FcTrue;
+}
+
+FcRange *
+FcRangePromote (double v, FcValuePromotionBuffer *vbuf)
+{
+ typedef struct {
+ FcRange r;
+ } FcRangePromotionBuffer;
+ FcRangePromotionBuffer *buf = (FcRangePromotionBuffer *) vbuf;
+
+ FC_ASSERT_STATIC (sizeof (FcRangePromotionBuffer) <= sizeof (FcValuePromotionBuffer));
+ buf->r.begin = v;
+ buf->r.end = v;
+
+ return &buf->r;
+}
+
+FcBool
+FcRangeIsInRange (const FcRange *a, const FcRange *b)
+{
+ if (!a || !b)
+ return FcFalse;
+
+ return a->begin >= b->begin && a->end <= b->end;
+}
+
+FcBool
+FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b)
+{
+ switch ((int) op) {
+ case FcOpEqual:
+ case FcOpContains:
+ case FcOpListing:
+ return FcRangeIsInRange (a, b);
+ case FcOpNotEqual:
+ case FcOpNotContains:
+ return !FcRangeIsInRange (a, b);
+ case FcOpLess:
+ return a->begin < b->begin;
+ case FcOpLessEqual:
+ return a->begin <= b->begin;
+ case FcOpMore:
+ return a->end > b->end;
+ case FcOpMoreEqual:
+ return a->end >= b->end;
+ default:
+ break;
+ }
+ return FcFalse;
+}
+
+FcChar32
+FcRangeHash (const FcRange *r)
+{
+ int b = (int) (r->begin * 100);
+ int e = (int) (r->end * 100);
+
+ return b ^ (b << 1) ^ (e << 9);
+}
+
+FcBool
+FcRangeSerializeAlloc (FcSerialize *serialize, const FcRange *r)
+{
+ if (!FcSerializeAlloc (serialize, r, sizeof (FcRange)))
+ return FcFalse;
+ return FcTrue;
+}
+
+FcRange *
+FcRangeSerialize (FcSerialize *serialize, const FcRange *r)
+{
+ FcRange *r_serialize = FcSerializePtr (serialize, r);
+
+ if (!r_serialize)
+ return NULL;
+ memcpy (r_serialize, r, sizeof (FcRange));
+
+ return r_serialize;
+}
+
+#define __fcrange__
+#include "fcaliastail.h"
+#undef __fcrange__
diff --git a/chromium/third_party/fontconfig/src/src/fcstat.c b/chromium/third_party/fontconfig/src/src/fcstat.c
index ff8e88455ef..1734fa42358 100644
--- a/chromium/third_party/fontconfig/src/src/fcstat.c
+++ b/chromium/third_party/fontconfig/src/src/fcstat.c
@@ -30,6 +30,9 @@
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
+#ifdef HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
@@ -39,6 +42,7 @@
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
+#include <errno.h>
#ifdef _WIN32
#ifdef __GNUC__
@@ -161,21 +165,86 @@ FcDirChecksumScandirFilter(const struct dirent *entry)
}
#endif
-#ifdef HAVE_SCANDIR
static int
FcDirChecksumScandirSorter(const struct dirent **lhs, const struct dirent **rhs)
{
return strcmp((*lhs)->d_name, (*rhs)->d_name);
}
-#elif HAVE_SCANDIR_VOID_P
-static int
-FcDirChecksumScandirSorter(const void *a, const void *b)
+
+static void
+free_dirent (struct dirent **p)
{
- const struct dirent *lhs = a, *rhs = b;
+ struct dirent **x;
+
+ for (x = p; *x != NULL; x++)
+ free (*x);
- return strcmp(lhs->d_name, rhs->d_name);
+ free (p);
+}
+
+int
+FcScandir (const char *dirp,
+ struct dirent ***namelist,
+ int (*filter) (const struct dirent *),
+ int (*compar) (const struct dirent **, const struct dirent **));
+
+int
+FcScandir (const char *dirp,
+ struct dirent ***namelist,
+ int (*filter) (const struct dirent *),
+ int (*compar) (const struct dirent **, const struct dirent **))
+{
+ DIR *d;
+ struct dirent *dent, *p, **dlist, **dlp;
+ size_t lsize = 128, n = 0;
+
+ d = opendir (dirp);
+ if (!d)
+ return -1;
+
+ dlist = (struct dirent **) malloc (sizeof (struct dirent *) * lsize);
+ if (!dlist)
+ {
+ closedir (d);
+ errno = ENOMEM;
+
+ return -1;
+ }
+ *dlist = NULL;
+ while ((dent = readdir (d)))
+ {
+ if (!filter || (filter) (dent))
+ {
+ size_t dentlen = FcPtrToOffset (dent, dent->d_name) + strlen (dent->d_name) + 1;
+ dentlen = ((dentlen + ALIGNOF_VOID_P - 1) & ~(ALIGNOF_VOID_P - 1));
+ p = (struct dirent *) malloc (dentlen);
+ memcpy (p, dent, dentlen);
+ if ((n + 1) >= lsize)
+ {
+ lsize += 128;
+ dlp = (struct dirent **) realloc (dlist, sizeof (struct dirent *) * lsize);
+ if (!dlp)
+ {
+ free_dirent (dlist);
+ closedir (d);
+ errno = ENOMEM;
+
+ return -1;
+ }
+ dlist = dlp;
+ }
+ dlist[n++] = p;
+ dlist[n] = NULL;
+ }
+ }
+ closedir (d);
+
+ qsort (dlist, n, sizeof (struct dirent *), (int (*) (const void *, const void *))compar);
+
+ *namelist = dlist;
+
+ return n;
}
-#endif
static int
FcDirChecksum (const FcChar8 *dir, time_t *checksum)
@@ -183,14 +252,12 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
struct Adler32 ctx;
struct dirent **files;
int n;
-#ifndef HAVE_STRUCT_DIRENT_D_TYPE
int ret = 0;
size_t len = strlen ((const char *)dir);
-#endif
Adler32Init (&ctx);
- n = scandir ((const char *)dir, &files,
+ n = FcScandir ((const char *)dir, &files,
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
&FcDirChecksumScandirFilter,
#else
@@ -207,7 +274,9 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
dtype = files[n]->d_type;
-#else
+ if (dtype == DT_UNKNOWN)
+ {
+#endif
struct stat statb;
char f[PATH_MAX + 1];
@@ -224,20 +293,18 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
goto bail;
dtype = statb.st_mode;
+#ifdef HAVE_STRUCT_DIRENT_D_TYPE
+ }
#endif
Adler32Update (&ctx, files[n]->d_name, dlen + 1);
Adler32Update (&ctx, (char *)&dtype, sizeof (int));
-#ifndef HAVE_STRUCT_DIRENT_D_TYPE
bail:
-#endif
free (files[n]);
}
free (files);
-#ifndef HAVE_STRUCT_DIRENT_D_TYPE
if (ret == -1)
return -1;
-#endif
*checksum = Adler32Finish (&ctx);
@@ -359,3 +426,7 @@ FcIsFsMtimeBroken (const FcChar8 *dir)
return FcFalse;
}
+
+#define __fcstat__
+#include "fcaliastail.h"
+#undef __fcstat__
diff --git a/chromium/third_party/fontconfig/src/src/fcstr.c b/chromium/third_party/fontconfig/src/src/fcstr.c
index 57071724315..b65492d84af 100644
--- a/chromium/third_party/fontconfig/src/src/fcstr.c
+++ b/chromium/third_party/fontconfig/src/src/fcstr.c
@@ -26,9 +26,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
-#ifdef HAVE_REGEX_H
-#include <regex.h>
-#endif
/* Objects MT-safe for readonly access. */
@@ -242,55 +239,6 @@ FcStrCmp (const FcChar8 *s1, const FcChar8 *s2)
return (int) c1 - (int) c2;
}
-#ifdef USE_REGEX
-static FcBool
-_FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex, int cflags, int eflags)
-{
- int ret = -1;
- regex_t reg;
-
- if ((ret = regcomp (&reg, (const char *)regex, cflags)) != 0)
- {
- if (FcDebug () & FC_DBG_MATCHV)
- {
- char buf[512];
-
- regerror (ret, &reg, buf, 512);
- printf("Regexp compile error: %s\n", buf);
- }
- return FcFalse;
- }
- ret = regexec (&reg, (const char *)s, 0, NULL, eflags);
- if (ret != 0)
- {
- if (FcDebug () & FC_DBG_MATCHV)
- {
- char buf[512];
-
- regerror (ret, &reg, buf, 512);
- printf("Regexp exec error: %s\n", buf);
- }
- }
- regfree (&reg);
-
- return ret == 0 ? FcTrue : FcFalse;
-}
-#else
-# define _FcStrRegexCmp(_s_, _regex_, _cflags_, _eflags_) (FcFalse)
-#endif
-
-FcBool
-FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex)
-{
- return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB, 0);
-}
-
-FcBool
-FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex)
-{
- return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB | REG_ICASE, 0);
-}
-
/*
* Return a hash value for a string
*/
@@ -924,12 +872,16 @@ FcStrBuildFilename (const FcChar8 *path,
...)
{
va_list ap;
- FcStrSet *sset = FcStrSetCreate ();
+ FcStrSet *sset;
FcStrList *list;
FcChar8 *s, *ret = NULL, *p;
size_t len = 0;
- if (!sset || !path)
+ if (!path)
+ return NULL;
+
+ sset = FcStrSetCreateEx (FCSS_ALLOW_DUPLICATES | FCSS_GROW_BY_64);
+ if (!sset)
return NULL;
if (!FcStrSetAdd (sset, path))
@@ -1178,6 +1130,12 @@ FcStrCanonFilename (const FcChar8 *s)
FcStrSet *
FcStrSetCreate (void)
{
+ return FcStrSetCreateEx (FCSS_DEFAULT);
+}
+
+FcStrSet *
+FcStrSetCreateEx (unsigned int control)
+{
FcStrSet *set = malloc (sizeof (FcStrSet));
if (!set)
return 0;
@@ -1185,29 +1143,42 @@ FcStrSetCreate (void)
set->num = 0;
set->size = 0;
set->strs = 0;
+ set->control = control;
return set;
}
static FcBool
+_FcStrSetGrow (FcStrSet *set, int growElements)
+{
+ /* accommodate an additional NULL entry at the end of the array */
+ FcChar8 **strs = malloc ((set->size + growElements + 1) * sizeof (FcChar8 *));
+ if (!strs)
+ return FcFalse;
+ if (set->num)
+ memcpy (strs, set->strs, set->num * sizeof (FcChar8 *));
+ if (set->strs)
+ free (set->strs);
+ set->size = set->size + growElements;
+ set->strs = strs;
+ return FcTrue;
+}
+
+static FcBool
_FcStrSetAppend (FcStrSet *set, FcChar8 *s)
{
- if (FcStrSetMember (set, s))
+ if (!FcStrSetHasControlBit (set, FCSS_ALLOW_DUPLICATES))
{
- FcStrFree (s);
- return FcTrue;
+ if (FcStrSetMember (set, s))
+ {
+ FcStrFree (s);
+ return FcTrue;
+ }
}
if (set->num == set->size)
{
- FcChar8 **strs = malloc ((set->size + 2) * sizeof (FcChar8 *));
-
- if (!strs)
- return FcFalse;
- if (set->num)
- memcpy (strs, set->strs, set->num * sizeof (FcChar8 *));
- if (set->strs)
- free (set->strs);
- set->size = set->size + 1;
- set->strs = strs;
+ int growElements = FcStrSetHasControlBit (set, FCSS_GROW_BY_64) ? 64 : 1;
+ if (!_FcStrSetGrow(set, growElements))
+ return FcFalse;
}
set->strs[set->num++] = s;
set->strs[set->num] = 0;
diff --git a/chromium/third_party/fontconfig/src/src/fcweight.c b/chromium/third_party/fontconfig/src/src/fcweight.c
new file mode 100644
index 00000000000..036a518e8c5
--- /dev/null
+++ b/chromium/third_party/fontconfig/src/src/fcweight.c
@@ -0,0 +1,109 @@
+/*
+ * fontconfig/src/fcweight.c
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "fcint.h"
+
+static const struct {
+ int ot;
+ int fc;
+} map[] = {
+ { 0, FC_WEIGHT_THIN },
+ { 100, FC_WEIGHT_THIN },
+ { 200, FC_WEIGHT_EXTRALIGHT },
+ { 350, FC_WEIGHT_DEMILIGHT },
+ { 300, FC_WEIGHT_LIGHT },
+ { 380, FC_WEIGHT_BOOK },
+ { 400, FC_WEIGHT_REGULAR },
+ { 500, FC_WEIGHT_MEDIUM },
+ { 600, FC_WEIGHT_DEMIBOLD },
+ { 700, FC_WEIGHT_BOLD },
+ { 800, FC_WEIGHT_EXTRABOLD },
+ { 900, FC_WEIGHT_BLACK },
+ {1000, FC_WEIGHT_EXTRABLACK },
+};
+
+static int lerp(int x, int x1, int x2, int y1, int y2)
+{
+ int dx = x2 - x1;
+ int dy = y2 - y1;
+ assert (dx > 0 && dy >= 0 && x1 <= x && x <= x2);
+ return y1 + (dy*(x-x1) + dx/2) / dx;
+}
+
+int
+FcWeightFromOpenType (int ot_weight)
+{
+ int i;
+
+ /* Loosely based on WPF Font Selection Model's advice. */
+
+ if (ot_weight < 0)
+ return -1;
+ else if (1 <= ot_weight && ot_weight <= 9)
+ {
+ /* WPF Font Selection Model says do "ot_weight *= 100",
+ * but Greg Hitchcock revealed that GDI had a mapping
+ * reflected below: */
+ switch (ot_weight) {
+ case 1: ot_weight = 80; break;
+ case 2: ot_weight = 160; break;
+ case 3: ot_weight = 240; break;
+ case 4: ot_weight = 320; break;
+ case 5: ot_weight = 400; break;
+ case 6: ot_weight = 550; break;
+ case 7: ot_weight = 700; break;
+ case 8: ot_weight = 800; break;
+ case 9: ot_weight = 900; break;
+ }
+ }
+ ot_weight = FC_MIN (ot_weight, map[(sizeof (map) / sizeof (map[0])) - 1].ot);
+
+ for (i = 1; ot_weight > map[i].ot; i++)
+ ;
+
+ if (ot_weight == map[i].ot)
+ return map[i].fc;
+
+ /* Interpolate between two items. */
+ return lerp (ot_weight, map[i-1].ot, map[i].ot, map[i-1].fc, map[i].fc);
+}
+
+int
+FcWeightToOpenType (int fc_weight)
+{
+ int i;
+ if (fc_weight < 0 || fc_weight > FC_WEIGHT_EXTRABLACK)
+ return -1;
+
+ for (i = 1; fc_weight > map[i].fc; i++)
+ ;
+
+ if (fc_weight == map[i].fc)
+ return map[i].ot;
+
+ /* Interpolate between two items. */
+ return lerp (fc_weight, map[i-1].fc, map[i].fc, map[i-1].ot, map[i].ot);
+}
+
+#define __fcweight__
+#include "fcaliastail.h"
+#undef __fcweight__
diff --git a/chromium/third_party/fontconfig/src/src/fcwindows.h b/chromium/third_party/fontconfig/src/src/fcwindows.h
index 02489d9dc1b..a0eee675ee9 100644
--- a/chromium/third_party/fontconfig/src/src/fcwindows.h
+++ b/chromium/third_party/fontconfig/src/src/fcwindows.h
@@ -32,8 +32,13 @@
#endif
#ifdef _WIN32
+ /* Request Windows Vista for building. This is required to
+ * get MemoryBarrier on mingw32... */
+# if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
+# undef _WIN32_WINNT
+# endif
# ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0500
+# define _WIN32_WINNT 0x0600
# endif
# define WIN32_LEAN_AND_MEAN
# define WIN32_EXTRA_LEAN
diff --git a/chromium/third_party/fontconfig/src/src/fcxml.c b/chromium/third_party/fontconfig/src/src/fcxml.c
index 8ff10b6e63f..031a7da1f0b 100644
--- a/chromium/third_party/fontconfig/src/src/fcxml.c
+++ b/chromium/third_party/fontconfig/src/src/fcxml.c
@@ -54,8 +54,12 @@
#ifdef _WIN32
#include <mbstring.h>
+extern FcChar8 fontconfig_instprefix[];
#endif
+static FcChar8 *__fc_userdir = NULL;
+static FcChar8 *__fc_userconf = NULL;
+
static void
FcExprDestroy (FcExpr *e);
@@ -78,6 +82,7 @@ FcRuleDestroy (FcRule *rule)
case FcRuleEdit:
FcEditDestroy (rule->u.edit);
break;
+ case FcRuleUnknown:
default:
break;
}
@@ -169,6 +174,18 @@ FcExprCreateMatrix (FcConfig *config, const FcExprMatrix *matrix)
}
static FcExpr *
+FcExprCreateRange (FcConfig *config, FcRange *range)
+{
+ FcExpr *e = FcConfigAllocExpr (config);
+ if (e)
+ {
+ e->op = FcOpRange;
+ e->u.rval = FcRangeCopy (range);
+ }
+ return e;
+}
+
+static FcExpr *
FcExprCreateBool (FcConfig *config, FcBool b)
{
FcExpr *e = FcConfigAllocExpr (config);
@@ -258,6 +275,7 @@ FcExprDestroy (FcExpr *e)
FcExprMatrixFree (e->u.mexpr);
break;
case FcOpRange:
+ FcRangeDestroy (e->u.rval);
break;
case FcOpCharSet:
FcCharSetDestroy (e->u.cval);
@@ -503,7 +521,7 @@ typedef struct _FcVStack {
int integer;
double _double;
FcExprMatrix *matrix;
- FcRange range;
+ FcRange *range;
FcBool bool_;
FcCharSet *charset;
FcLangSet *langset;
@@ -593,6 +611,9 @@ FcTypeName (FcType type)
return "FT_Face";
case FcTypeLangSet:
return "langset";
+ case FcTypeRange:
+ return "range";
+ case FcTypeUnknown:
default:
return "unknown";
}
@@ -608,13 +629,15 @@ FcTypecheckValue (FcConfigParse *parse, FcType value, FcType type)
if (value != type)
{
if ((value == FcTypeLangSet && type == FcTypeString) ||
- (value == FcTypeString && type == FcTypeLangSet))
+ (value == FcTypeString && type == FcTypeLangSet) ||
+ (value == FcTypeInteger && type == FcTypeRange) ||
+ (value == FcTypeDouble && type == FcTypeRange))
return;
- if (type == (FcType) -1)
+ if (type == FcTypeUnknown)
return;
/* It's perfectly fine to use user-define elements in expressions,
* so don't warn in that case. */
- if (value == (FcType) -1)
+ if (value == FcTypeUnknown)
return;
FcConfigMessage (parse, FcSevereWarning, "saw %s, expected %s",
FcTypeName (value), FcTypeName (type));
@@ -651,6 +674,9 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
case FcOpLangSet:
FcTypecheckValue (parse, FcTypeLangSet, type);
break;
+ case FcOpRange:
+ FcTypecheckValue (parse, FcTypeRange, type);
+ break;
case FcOpNil:
break;
case FcOpField:
@@ -785,6 +811,7 @@ FcRuleCreate (FcRuleType type,
case FcRuleEdit:
r->u.edit = (FcEdit *) p;
break;
+ case FcRuleUnknown:
default:
free (r);
r = NULL;
@@ -865,11 +892,10 @@ FcVStackPushMatrix (FcConfigParse *parse, FcExprMatrix *matrix)
static FcBool
FcVStackPushRange (FcConfigParse *parse, FcRange *range)
{
- FcVStack *vstack = FcVStackCreateAndPush (parse);
+ FcVStack *vstack = FcVStackCreateAndPush (parse);
if (!vstack)
return FcFalse;
- vstack->u.range.begin = range->begin;
- vstack->u.range.end = range->end;
+ vstack->u.range = range;
vstack->tag = FcVStackRange;
return FcTrue;
}
@@ -1017,9 +1043,11 @@ FcVStackPopAndDestroy (FcConfigParse *parse)
case FcVStackMatrix:
FcExprMatrixFreeShallow (vstack->u.matrix);
break;
- case FcVStackRange:
case FcVStackBool:
break;
+ case FcVStackRange:
+ FcRangeDestroy (vstack->u.range);
+ break;
case FcVStackCharSet:
FcCharSetDestroy (vstack->u.charset);
break;
@@ -1232,7 +1260,11 @@ static void
FcParseBlank (FcConfigParse *parse)
{
int n = FcVStackElements (parse);
- FcChar32 i;
+#if 0
+ FcChar32 i, begin, end;
+#endif
+
+ FcConfigMessage (parse, FcSevereWarning, "blank doesn't take any effect anymore. please remove it from your fonts.conf");
while (n-- > 0)
{
FcVStack *v = FcVStackFetch (parse, n);
@@ -1244,18 +1276,24 @@ FcParseBlank (FcConfigParse *parse)
}
switch ((int) v->tag) {
case FcVStackInteger:
+#if 0
if (!FcBlanksAdd (parse->config->blanks, v->u.integer))
goto bail;
break;
+#endif
case FcVStackRange:
- if (v->u.range.begin <= v->u.range.end)
+#if 0
+ begin = (FcChar32) v->u.range->begin;
+ end = (FcChar32) v->u.range->end;
+ if (begin <= end)
{
- for (i = v->u.range.begin; i <= v->u.range.end; i++)
+ for (i = begin; i <= end; i++)
{
if (!FcBlanksAdd (parse->config->blanks, i))
goto bail;
}
}
+#endif
break;
default:
FcConfigMessage (parse, FcSevereError, "invalid element in blank");
@@ -1314,7 +1352,11 @@ FcParseInt (FcConfigParse *parse)
static double
FcStrtod (char *s, char **end)
{
+#ifndef __BIONIC__
struct lconv *locale_data;
+#endif
+ const char *decimal_point;
+ int dlen;
char *dot;
double v;
@@ -1322,14 +1364,21 @@ FcStrtod (char *s, char **end)
* Have to swap the decimal point to match the current locale
* if that locale doesn't use 0x2e
*/
+#ifndef __BIONIC__
+ locale_data = localeconv ();
+ decimal_point = locale_data->decimal_point;
+ dlen = strlen (decimal_point);
+#else
+ decimal_point = ".";
+ dlen = 1;
+#endif
+
if ((dot = strchr (s, 0x2e)) &&
- (locale_data = localeconv ()) &&
- (locale_data->decimal_point[0] != 0x2e ||
- locale_data->decimal_point[1] != 0))
+ (decimal_point[0] != 0x2e ||
+ decimal_point[1] != 0))
{
char buf[128];
int slen = strlen (s);
- int dlen = strlen (locale_data->decimal_point);
if (slen + dlen > (int) sizeof (buf))
{
@@ -1343,7 +1392,7 @@ FcStrtod (char *s, char **end)
/* mantissa */
strncpy (buf, s, dot - s);
/* decimal point */
- strcpy (buf + (dot - s), locale_data->decimal_point);
+ strcpy (buf + (dot - s), decimal_point);
/* rest of number */
strcpy (buf + (dot - s) + dlen, dot + 1);
buf_end = 0;
@@ -1463,9 +1512,11 @@ static void
FcParseRange (FcConfigParse *parse)
{
FcVStack *vstack;
- FcRange r = {0, 0};
- FcChar32 n;
+ FcRange *r;
+ FcChar32 n[2] = {0, 0};
int count = 1;
+ double d[2] = {0.0L, 0.0L};
+ FcBool dflag = FcFalse;
while ((vstack = FcVStackPeek (parse)))
{
@@ -1476,31 +1527,52 @@ FcParseRange (FcConfigParse *parse)
}
switch ((int) vstack->tag) {
case FcVStackInteger:
- n = vstack->u.integer;
+ if (dflag)
+ d[count] = (double)vstack->u.integer;
+ else
+ n[count] = vstack->u.integer;
+ break;
+ case FcVStackDouble:
+ if (count == 0 && !dflag)
+ d[1] = (double)n[1];
+ d[count] = vstack->u._double;
+ dflag = FcTrue;
break;
default:
FcConfigMessage (parse, FcSevereError, "invalid element in range");
- n = 0;
+ if (dflag)
+ d[count] = 0.0L;
+ else
+ n[count] = 0;
break;
}
- if (count == 1)
- r.end = n;
- else
- r.begin = n;
count--;
FcVStackPopAndDestroy (parse);
}
- if (count < 0)
+ if (count >= 0)
{
- if (r.begin > r.end)
+ FcConfigMessage (parse, FcSevereError, "invalid range");
+ return;
+ }
+ if (dflag)
+ {
+ if (d[0] > d[1])
{
FcConfigMessage (parse, FcSevereError, "invalid range");
return;
}
- FcVStackPushRange (parse, &r);
+ r = FcRangeCreateDouble (d[0], d[1]);
}
else
- FcConfigMessage (parse, FcSevereError, "invalid range");
+ {
+ if (n[0] > n[1])
+ {
+ FcConfigMessage (parse, FcSevereError, "invalid range");
+ return;
+ }
+ r = FcRangeCreateInteger (n[0], n[1]);
+ }
+ FcVStackPushRange (parse, r);
}
static FcBool
@@ -1536,7 +1608,7 @@ FcParseCharSet (FcConfigParse *parse)
{
FcVStack *vstack;
FcCharSet *charset = FcCharSetCreate ();
- FcChar32 i;
+ FcChar32 i, begin, end;
int n = 0;
while ((vstack = FcVStackPeek (parse)))
@@ -1551,9 +1623,12 @@ FcParseCharSet (FcConfigParse *parse)
n++;
break;
case FcVStackRange:
- if (vstack->u.range.begin <= vstack->u.range.end)
+ begin = (FcChar32) vstack->u.range->begin;
+ end = (FcChar32) vstack->u.range->end;
+
+ if (begin <= end)
{
- for (i = vstack->u.range.begin; i <= vstack->u.range.end; i++)
+ for (i = begin; i <= end; i++)
{
if (!FcCharSetAddChar (charset, i))
{
@@ -1888,6 +1963,7 @@ FcPopExpr (FcConfigParse *parse)
expr = FcExprCreateMatrix (parse->config, vstack->u.matrix);
break;
case FcVStackRange:
+ expr = FcExprCreateRange (parse->config, vstack->u.range);
break;
case FcVStackBool:
expr = FcExprCreateBool (parse->config, vstack->u.bool_);
@@ -1996,7 +2072,14 @@ FcParseDir (FcConfigParse *parse)
attr = FcConfigGetAttribute (parse, "prefix");
if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
+ {
prefix = FcConfigXdgDataHome ();
+ /* home directory might be disabled.
+ * simply ignore this element.
+ */
+ if (!prefix)
+ goto bail;
+ }
data = FcStrBufDoneStatic (&parse->pstack->str);
if (!data)
{
@@ -2087,11 +2170,18 @@ static void
FcParseCacheDir (FcConfigParse *parse)
{
const FcChar8 *attr;
- FcChar8 *prefix = NULL, *p, *data;
+ FcChar8 *prefix = NULL, *p, *data = NULL;
attr = FcConfigGetAttribute (parse, "prefix");
if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
+ {
prefix = FcConfigXdgCacheHome ();
+ /* home directory might be disabled.
+ * simply ignore this element.
+ */
+ if (!prefix)
+ goto bail;
+ }
data = FcStrBufDone (&parse->pstack->str);
if (!data)
{
@@ -2118,7 +2208,25 @@ FcParseCacheDir (FcConfigParse *parse)
data = prefix;
}
#ifdef _WIN32
- if (strcmp ((const char *) data, "WINDOWSTEMPDIR_FONTCONFIG_CACHE") == 0)
+ else if (data[0] == '/' && fontconfig_instprefix[0] != '\0')
+ {
+ size_t plen = strlen ((const char *)fontconfig_instprefix);
+ size_t dlen = strlen ((const char *)data);
+
+ prefix = malloc (plen + 1 + dlen + 1);
+ if (!prefix)
+ {
+ FcConfigMessage (parse, FcSevereError, "out of memory");
+ goto bail;
+ }
+ strcpy ((char *) prefix, (char *) fontconfig_instprefix);
+ prefix[plen] = FC_DIR_SEPARATOR;
+ memcpy (&prefix[plen + 1], data, dlen);
+ prefix[plen + 1 + dlen] = 0;
+ FcStrFree (data);
+ data = prefix;
+ }
+ else if (strcmp ((const char *) data, "WINDOWSTEMPDIR_FONTCONFIG_CACHE") == 0)
{
int rc;
FcStrFree (data);
@@ -2174,16 +2282,35 @@ FcParseCacheDir (FcConfigParse *parse)
FcStrFree (data);
}
+void
+FcConfigPathFini (void)
+{
+ FcChar8 *s;
+
+retry_dir:
+ s = fc_atomic_ptr_get (&__fc_userdir);
+ if (!fc_atomic_ptr_cmpexch (&__fc_userdir, s, NULL))
+ goto retry_dir;
+ free (s);
+
+retry_conf:
+ s = fc_atomic_ptr_get (&__fc_userconf);
+ if (!fc_atomic_ptr_cmpexch (&__fc_userconf, s, NULL))
+ goto retry_conf;
+ free (s);
+}
+
static void
FcParseInclude (FcConfigParse *parse)
{
FcChar8 *s;
const FcChar8 *attr;
FcBool ignore_missing = FcFalse;
+#ifndef _WIN32
FcBool deprecated = FcFalse;
+#endif
FcChar8 *prefix = NULL, *p;
- static FcChar8 *userdir = NULL;
- static FcChar8 *userconf = NULL;
+ FcChar8 *userdir = NULL, *userconf = NULL;
s = FcStrBufDoneStatic (&parse->pstack->str);
if (!s)
@@ -2195,15 +2322,25 @@ FcParseInclude (FcConfigParse *parse)
if (attr && FcConfigLexBool (parse, (FcChar8 *) attr) == FcTrue)
ignore_missing = FcTrue;
attr = FcConfigGetAttribute (parse, "deprecated");
+#ifndef _WIN32
if (attr && FcConfigLexBool (parse, (FcChar8 *) attr) == FcTrue)
deprecated = FcTrue;
+#endif
attr = FcConfigGetAttribute (parse, "prefix");
if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
+ {
prefix = FcConfigXdgConfigHome ();
+ /* home directory might be disabled.
+ * simply ignore this element.
+ */
+ if (!prefix)
+ goto bail;
+ }
if (prefix)
{
size_t plen = strlen ((const char *)prefix);
size_t dlen = strlen ((const char *)s);
+ FcChar8 *u;
p = realloc (prefix, plen + 1 + dlen + 1);
if (!p)
@@ -2219,14 +2356,32 @@ FcParseInclude (FcConfigParse *parse)
if (FcFileIsDir (s))
{
userdir:
+ userdir = fc_atomic_ptr_get (&__fc_userdir);
if (!userdir)
- userdir = FcStrdup (s);
+ {
+ u = FcStrdup (s);
+ if (!fc_atomic_ptr_cmpexch (&__fc_userdir, userdir, u))
+ {
+ free (u);
+ goto userdir;
+ }
+ userdir = u;
+ }
}
else if (FcFileIsFile (s))
{
userconf:
+ userconf = fc_atomic_ptr_get (&__fc_userconf);
if (!userconf)
- userconf = FcStrdup (s);
+ {
+ u = FcStrdup (s);
+ if (!fc_atomic_ptr_cmpexch (&__fc_userconf, userconf, u))
+ {
+ free (u);
+ goto userconf;
+ }
+ userconf = u;
+ }
}
else
{
@@ -2250,6 +2405,7 @@ FcParseInclude (FcConfigParse *parse)
filename = FcConfigFilename(s);
if (deprecated == FcTrue &&
filename != NULL &&
+ userdir != NULL &&
!FcFileIsLink (filename))
{
if (FcFileIsDir (filename))
@@ -2566,6 +2722,11 @@ FcParseMatch (FcConfigParse *parse)
}
FcVStackPopAndDestroy (parse);
}
+ if (!rule)
+ {
+ FcConfigMessage (parse, FcSevereWarning, "No <test> nor <edit> elements in <match>");
+ return;
+ }
if (!FcConfigAddRule (parse->config, rule, kind))
FcConfigMessage (parse, FcSevereError, "out of memory");
}
@@ -2648,6 +2809,11 @@ FcPopValue (FcConfigParse *parse)
if (value.u.l)
value.type = FcTypeLangSet;
break;
+ case FcVStackRange:
+ value.u.r = FcRangeCopy (vstack->u.range);
+ if (value.u.r)
+ value.type = FcTypeRange;
+ break;
default:
FcConfigMessage (parse, FcSevereWarning, "unknown pattern element %d",
vstack->tag);
@@ -3003,7 +3169,7 @@ FcConfigParseAndLoadDir (FcConfig *config,
strcat ((char *) file, "/");
base = file + strlen ((char *) file);
- files = FcStrSetCreate ();
+ files = FcStrSetCreateEx (FCSS_GROW_BY_64);
if (!files)
{
ret = FcFalse;
@@ -3064,11 +3230,12 @@ FcConfigParseAndLoad (FcConfig *config,
{
XML_Parser p;
- FcChar8 *filename;
+ FcChar8 *filename, *f;
int fd;
int len;
FcConfigParse parse;
FcBool error = FcTrue;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
#ifdef ENABLE_LIBXML2
xmlSAXHandler sax;
@@ -3093,9 +3260,14 @@ FcConfigParseAndLoad (FcConfig *config,
}
#endif
- filename = FcConfigFilename (name);
- if (!filename)
+ f = FcConfigFilename (name);
+ if (!f)
goto bail0;
+ if (sysroot)
+ filename = FcStrBuildFilename (sysroot, f, NULL);
+ else
+ filename = FcStrdup (f);
+ FcStrFree (f);
if (FcStrSetMember (config->configFiles, filename))
{
diff --git a/chromium/third_party/gestures/gestures/include/finger_metrics.h b/chromium/third_party/gestures/gestures/include/finger_metrics.h
index 42ecb9e970f..aafddc91251 100644
--- a/chromium/third_party/gestures/gestures/include/finger_metrics.h
+++ b/chromium/third_party/gestures/gestures/include/finger_metrics.h
@@ -5,6 +5,8 @@
#ifndef GESTURES_FINGER_METRICS_H_
#define GESTURES_FINGER_METRICS_H_
+#include <cmath>
+
#include "gestures/include/gestures.h"
#include "gestures/include/prop_registry.h"
#include "gestures/include/vector.h"
diff --git a/chromium/third_party/gestures/gestures/include/immediate_interpreter.h b/chromium/third_party/gestures/gestures/include/immediate_interpreter.h
index 908e2f40235..45737e4c4eb 100644
--- a/chromium/third_party/gestures/gestures/include/immediate_interpreter.h
+++ b/chromium/third_party/gestures/gestures/include/immediate_interpreter.h
@@ -756,6 +756,10 @@ class ImmediateInterpreter : public Interpreter, public PropertyDelegate {
// Distance [mm] a finger must move after fingers change to count as real
// motion
DoubleProperty change_move_distance_;
+ // Speed [mm/s] a finger must move to lock on to that finger
+ DoubleProperty move_lock_speed_;
+ // Distance [mm] a finger must move to report that movement
+ DoubleProperty move_report_distance_;
// Time [s] to block movement after number or identify of fingers change
DoubleProperty change_timeout_;
// Time [s] to wait before locking on to a gesture
@@ -818,6 +822,9 @@ class ImmediateInterpreter : public Interpreter, public PropertyDelegate {
DoubleProperty thumb_click_prevention_timeout_;
// Consider scroll vs pointing if finger moves at least this distance [mm]
DoubleProperty two_finger_scroll_distance_thresh_;
+ // Consider move if there is no scroll and one finger moves at least this
+ // distance [mm]
+ DoubleProperty two_finger_move_distance_thresh_;
// Maximum distance [mm] between the outermost fingers while performing a
// three-finger gesture.
DoubleProperty three_finger_close_distance_thresh_;
@@ -830,11 +837,14 @@ class ImmediateInterpreter : public Interpreter, public PropertyDelegate {
// Minimum distance [mm] one of the four fingers must move to perform a
// four finger swipe gesture.
DoubleProperty four_finger_swipe_distance_thresh_;
+ // Minimum ratio between least and most moving finger to perform a
+ // three finger swipe gesture.
+ DoubleProperty three_finger_swipe_distance_ratio_;
+ // Minimum ratio between least and most moving finger to perform a
+ // four finger swipe gesture.
+ DoubleProperty four_finger_swipe_distance_ratio_;
// If three-finger swipe should be enabled
BoolProperty three_finger_swipe_enable_;
- // During a scroll one finger determines scroll speed and direction.
- // Maximum distance [mm] the other finger can move in opposite direction
- DoubleProperty scroll_stationary_finger_max_distance_;
// Height [mm] of the bottom zone
DoubleProperty bottom_zone_size_;
// Time [s] to after button down to evaluate number of fingers for a click
diff --git a/chromium/third_party/gestures/gestures/include/metrics_filter_interpreter.h b/chromium/third_party/gestures/gestures/include/metrics_filter_interpreter.h
index f0f24f54ba0..cae1c065ccc 100644
--- a/chromium/third_party/gestures/gestures/include/metrics_filter_interpreter.h
+++ b/chromium/third_party/gestures/gestures/include/metrics_filter_interpreter.h
@@ -115,8 +115,8 @@ class MetricsFilterInterpreter : public FilterInterpreter {
// Number of mouse movement sessions that we skip at startup. We do this
// because it takes time for the user to "get used to" the mouse speed when
- // he/she first starts using the mouse. We only want to capture the user
- // metrics after the user have been familiar with his/her mouse.
+ // they first start using the mouse. We only want to capture the user metrics
+ // after the user has been familiar with their mouse.
IntProperty mouse_control_warmup_sessions_;
};
diff --git a/chromium/third_party/gestures/gestures/src/immediate_interpreter.cc b/chromium/third_party/gestures/gestures/src/immediate_interpreter.cc
index af953d236bc..b3c2fae4b10 100644
--- a/chromium/third_party/gestures/gestures/src/immediate_interpreter.cc
+++ b/chromium/third_party/gestures/gestures/src/immediate_interpreter.cc
@@ -1017,8 +1017,10 @@ ImmediateInterpreter::ImmediateInterpreter(PropRegistry* prop_reg,
"T5R2 Three Finger Click Enable",
0),
change_move_distance_(prop_reg, "Change Min Move Distance", 3.0),
+ move_lock_speed_(prop_reg, "Move Lock Speed", 10.0),
+ move_report_distance_(prop_reg, "Move Report Distance", 0.35),
change_timeout_(prop_reg, "Change Timeout", 0.04),
- evaluation_timeout_(prop_reg, "Evaluation Timeout", 0.2),
+ evaluation_timeout_(prop_reg, "Evaluation Timeout", 0.15),
pinch_evaluation_timeout_(prop_reg, "Pinch Evaluation Timeout", 0.3),
thumb_pinch_evaluation_timeout_(prop_reg,
"Thumb Pinch Evaluation Timeout", 0.5),
@@ -1055,25 +1057,32 @@ ImmediateInterpreter::ImmediateInterpreter(PropRegistry* prop_reg,
thumb_pinch_threshold_ratio_(prop_reg,
"Thumb Pinch Threshold Ratio", 0.25),
thumb_click_prevention_timeout_(prop_reg,
- "Thumb Click Prevention Timeout", 0.2),
+ "Thumb Click Prevention Timeout", 0.15),
two_finger_scroll_distance_thresh_(prop_reg,
"Two Finger Scroll Distance Thresh",
- 2.0),
+ 1.5),
+ two_finger_move_distance_thresh_(prop_reg,
+ "Two Finger Move Distance Thresh",
+ 7.0),
three_finger_close_distance_thresh_(prop_reg,
"Three Finger Close Distance Thresh",
- 50.0),
+ 55.0),
four_finger_close_distance_thresh_(prop_reg,
"Four Finger Close Distance Thresh",
60.0),
three_finger_swipe_distance_thresh_(prop_reg,
"Three Finger Swipe Distance Thresh",
- 2.0),
+ 1.5),
four_finger_swipe_distance_thresh_(prop_reg,
"Four Finger Swipe Distance Thresh",
- 2.0),
+ 1.5),
+ three_finger_swipe_distance_ratio_(prop_reg,
+ "Three Finger Swipe Distance Ratio",
+ 0.2),
+ four_finger_swipe_distance_ratio_(prop_reg,
+ "Four Finger Swipe Distance Ratio",
+ 0.2),
three_finger_swipe_enable_(prop_reg, "Three Finger Swipe EnableX", 1),
- scroll_stationary_finger_max_distance_(
- prop_reg, "Scroll Stationary Finger Max Distance", 1.0),
bottom_zone_size_(prop_reg, "Bottom Zone Size", 10.0),
button_evaluation_timeout_(prop_reg, "Button Evaluation Timeout", 0.05),
button_finger_timeout_(prop_reg, "Button Finger Timeout", 0.03),
@@ -1558,6 +1567,12 @@ void ImmediateInterpreter::UpdateThumbState(const HardwareState& hwstate) {
(fs.pressure > min_pressure + two_finger_pressure_diff_thresh_.val_ &&
fs.pressure > min_pressure * two_finger_pressure_diff_factor_.val_ &&
fs.position_y > min_fs->position_y);
+ bool non_gs = (hwstate.timestamp > changed_time_ &&
+ (prev_active_gs_fingers_.find(fs.tracking_id) ==
+ prev_active_gs_fingers_.end()) &&
+ prev_result_.type != kGestureTypeNull);
+ non_gs |= moving_finger_id_ >= 0 && moving_finger_id_ != fs.tracking_id;
+ likely_thumb |= non_gs;
// We sometimes can't decide the thumb state if some fingers are undergoing
// warp moves as the decision could be off (DistanceTravelledSq may
// under-estimate the real distance). The cases that we need to re-evaluate
@@ -1708,6 +1723,7 @@ void ImmediateInterpreter::UpdateCurrentGestureType(
if (AnyGesturingFingerLeft(*state_buffer_.Get(0),
prev_gs_fingers_)) {
current_gesture_type_ = GetFingerLiftGesture(current_gesture_type_);
+ moving_.clear();
return;
}
// fallthrough
@@ -1774,7 +1790,7 @@ void ImmediateInterpreter::UpdateCurrentGestureType(
// ambiguous. Only move if they've been down long enough.
if (new_gs_type == kGestureTypeMove &&
hwstate.timestamp -
- max(origin_timestamps_[fingers[0]->tracking_id],
+ min(origin_timestamps_[fingers[0]->tracking_id],
origin_timestamps_[fingers[1]->tracking_id]) <
evaluation_timeout_.val_)
new_gs_type = kGestureTypeNull;
@@ -2208,12 +2224,17 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
float large_dy = MaxMag(dy1, dy2);
// These compares are okay if d{x,y}1 == d{x,y}2:
short large_dx_id =
- large_dx == dx1 ? finger1.tracking_id : finger2.tracking_id;
+ (large_dx == dx1) ? finger1.tracking_id : finger2.tracking_id;
short large_dy_id =
- large_dy == dy1 ? finger1.tracking_id : finger2.tracking_id;
+ (large_dy == dy1) ? finger1.tracking_id : finger2.tracking_id;
float small_dx = MinMag(dx1, dx2);
float small_dy = MinMag(dy1, dy2);
+ short small_dx_id =
+ (small_dx == dx1) ? finger1.tracking_id : finger2.tracking_id;
+ short small_dy_id =
+ (small_dy == dy1) ? finger1.tracking_id : finger2.tracking_id;
+
bool dampened_zone_occupied = false;
// movements of the finger in the dampened zone. If there are multiple
// fingers in the dampened zone, dx is min(dx_1, dx_2), dy is min(dy_1, dy_2).
@@ -2221,8 +2242,6 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
float damp_dy = INFINITY;
float non_damp_dx = 0.0;
float non_damp_dy = 0.0;
- bool damp_instaneous_moving_x = false;
- bool damp_instaneous_moving_y = false;
if (FingerInDampenedZone(finger1) ||
(finger1.flags & GESTURES_FINGER_POSSIBLE_PALM)) {
dampened_zone_occupied = true;
@@ -2230,8 +2249,6 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
damp_dy = dy1;
non_damp_dx = dx2;
non_damp_dy = dy2;
- damp_instaneous_moving_x = damp_instaneous_moving_y =
- finger1.flags & GESTURES_FINGER_INSTANTANEOUS_MOVING;
}
if (FingerInDampenedZone(finger2) ||
(finger2.flags & GESTURES_FINGER_POSSIBLE_PALM)) {
@@ -2240,14 +2257,6 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
damp_dy = MinMag(damp_dy, dy2);
non_damp_dx = MaxMag(non_damp_dx, dx1);
non_damp_dy = MaxMag(non_damp_dy, dy1);
- damp_instaneous_moving_x =
- damp_dx == dx1
- ? !!(finger1.flags & GESTURES_FINGER_INSTANTANEOUS_MOVING)
- : !!(finger2.flags & GESTURES_FINGER_INSTANTANEOUS_MOVING);
- damp_instaneous_moving_y =
- damp_dy == dy1
- ? !!(finger1.flags & GESTURES_FINGER_INSTANTANEOUS_MOVING)
- : !!(finger2.flags & GESTURES_FINGER_INSTANTANEOUS_MOVING);
}
// Trending in the same direction?
@@ -2264,21 +2273,16 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
bool large_dy_moving =
fabsf(large_dy) >= two_finger_scroll_distance_thresh_.val_ ||
SetContainsValue(moving_, large_dy_id);
- // We use a tighter moving criteria for damped finger here: it needs to be
- // moving in the past a few frames rather than just being moving before.
- bool small_dx_moving = fabsf(damp_dx) >=
- damp_scroll_min_movement_factor_.val_ * fabsf(non_damp_dx) ||
- damp_instaneous_moving_x;
- bool small_dy_moving = fabsf(damp_dy) >=
- damp_scroll_min_movement_factor_.val_ * fabsf(non_damp_dy) ||
- damp_instaneous_moving_y;
- // If not in damp zone, we allow one-finger scrolling
- bool small_dx_scrolling = !dampened_zone_occupied || small_dx_moving;
- bool small_dy_scrolling = !dampened_zone_occupied || small_dy_moving;
+ bool small_dx_moving =
+ fabsf(small_dx) >= two_finger_scroll_distance_thresh_.val_ ||
+ SetContainsValue(moving_, small_dx_id);
+ bool small_dy_moving =
+ fabsf(small_dy) >= two_finger_scroll_distance_thresh_.val_ ||
+ SetContainsValue(moving_, small_dy_id);
bool trend_scrolling_x = (common_trend_flags & kTrendX) &&
- large_dx_moving && small_dx_scrolling;
+ large_dx_moving && small_dx_moving;
bool trend_scrolling_y = (common_trend_flags & kTrendY) &&
- large_dy_moving && small_dy_scrolling;
+ large_dy_moving && small_dy_moving;
if (trend_scrolling_x || trend_scrolling_y) {
if (pinch_enable_.val_ && !ScrollAngle(finger1, finger2))
@@ -2288,17 +2292,22 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
if (fabsf(large_dx) > fabsf(large_dy)) {
// consider horizontal scroll
+ if (fabsf(small_dx) < two_finger_scroll_distance_thresh_.val_)
+ small_dx = 0.0;
+ if (large_dx * small_dx <= 0.0) {
+ // not same direction
+ if (fabsf(large_dx) < two_finger_move_distance_thresh_.val_)
+ return kGestureTypeNull;
+ else
+ return kGestureTypeMove;
+ }
if (fabsf(large_dx) < two_finger_scroll_distance_thresh_.val_)
return kGestureTypeNull;
- if (fabsf(small_dx) < scroll_stationary_finger_max_distance_.val_)
- small_dx = 0.0;
- if (large_dx * small_dx < 0.0)
- return kGestureTypeMove; // not same direction
if (dampened_zone_occupied) {
// Require damp to move at least some amount with the other finger
if (fabsf(damp_dx) <
damp_scroll_min_movement_factor_.val_ * fabsf(non_damp_dx)) {
- return kGestureTypeMove;
+ return kGestureTypeNull;
}
}
if (pinch_enable_.val_ && !ScrollAngle(finger1, finger2))
@@ -2306,17 +2315,19 @@ GestureType ImmediateInterpreter::GetTwoFingerGestureType(
return kGestureTypeScroll;
} else {
// consider vertical scroll
- if (fabsf(large_dy) < two_finger_scroll_distance_thresh_.val_)
- return kGestureTypeNull;
- if (fabsf(small_dy) < scroll_stationary_finger_max_distance_.val_)
+ if (fabsf(small_dy) < two_finger_scroll_distance_thresh_.val_)
small_dy = 0.0;
- if (large_dy * small_dy < 0.0)
- return kGestureTypeMove;
+ if (large_dy * small_dy <= 0.0) {
+ if (fabsf(large_dy) < two_finger_move_distance_thresh_.val_)
+ return kGestureTypeNull;
+ else
+ return kGestureTypeMove;
+ }
if (dampened_zone_occupied) {
// Require damp to move at least some amount with the other finger
if (fabsf(damp_dy) <
damp_scroll_min_movement_factor_.val_ * fabsf(non_damp_dy)) {
- return kGestureTypeMove;
+ return kGestureTypeNull;
}
}
if (pinch_enable_.val_ && !ScrollAngle(finger1, finger2))
@@ -2339,14 +2350,17 @@ GestureType ImmediateInterpreter::GetMultiFingerGestureType(
const FingerState* const fingers[], const int num_fingers) {
float close_distance_thresh;
float swipe_distance_thresh;
+ float swipe_distance_ratio;
GestureType gesture_type;
if (num_fingers == 4) {
close_distance_thresh = four_finger_close_distance_thresh_.val_;
swipe_distance_thresh = four_finger_swipe_distance_thresh_.val_;
+ swipe_distance_ratio = four_finger_swipe_distance_ratio_.val_;
gesture_type = kGestureTypeFourFingerSwipe;
} else if (num_fingers == 3) {
close_distance_thresh = three_finger_close_distance_thresh_.val_;
swipe_distance_thresh = three_finger_swipe_distance_thresh_.val_;
+ swipe_distance_ratio = three_finger_swipe_distance_ratio_.val_;
gesture_type = kGestureTypeSwipe;
} else {
return kGestureTypeNull;
@@ -2395,12 +2409,16 @@ GestureType ImmediateInterpreter::GetMultiFingerGestureType(
}
}
- // One finger must have traveled far enough.
- for (int i = 0; i < num_fingers; i++) {
- if (fabsf(deltas[i]) >= swipe_distance_thresh) {
- return gesture_type;
- }
+ // All fingers must have traveled far enough.
+ float max_delta = fabsf(deltas[0]);
+ float min_delta = fabsf(deltas[0]);
+ for (int i = 1; i < num_fingers; i++) {
+ max_delta = max(max_delta, fabsf(deltas[i]));
+ min_delta = min(min_delta, fabsf(deltas[i]));
}
+ if (max_delta >= swipe_distance_thresh &&
+ min_delta >= swipe_distance_ratio * max_delta)
+ return gesture_type;
return kGestureTypeNull;
}
@@ -3024,22 +3042,30 @@ void ImmediateInterpreter::FillResultGesture(
case kGestureTypeMove: {
if (fingers.empty())
return;
- // Use highest finger (the one closes to the keyboard), excluding
- // palms, to compute motion. First, need to find out which finger that is.
+ // Use the finger which has moved the most to compute motion.
+ // First, need to find out which finger that is.
const FingerState* current = NULL;
if (moving_finger_id_ >= 0)
current = hwstate.GetFingerState(moving_finger_id_);
- if (!current) {
+ const HardwareState* prev_hs = state_buffer_.Get(1);
+ if (prev_hs && !current) {
+ float curr_dist_sq = -1;
for (FingerMap::const_iterator it =
fingers.begin(), e = fingers.end(); it != e; ++it) {
const FingerState* fs = hwstate.GetFingerState(*it);
- if (!current || fs->position_y < current->position_y ||
- (current->flags & GESTURES_FINGER_POSSIBLE_PALM &&
- !(fs->flags & GESTURES_FINGER_POSSIBLE_PALM)))
+ const FingerState* prev_fs = prev_hs->GetFingerState(fs->tracking_id);
+ if (!prev_fs)
+ break;
+ float dist_sq = DistSq(*fs, *prev_fs);
+ if (dist_sq > curr_dist_sq) {
current = fs;
+ curr_dist_sq = dist_sq;
+ }
}
}
+ if (!current)
+ return;
// Find corresponding finger id in previous state
const FingerState* prev =
@@ -3079,10 +3105,23 @@ void ImmediateInterpreter::FillResultGesture(
float dy = current->position_y - prev->position_y;
if (current->flags & GESTURES_FINGER_WARP_Y_MOVE)
dy = 0.0;
- if (dx != 0.0 || dy != 0.0) {
+ float dsq = dx * dx + dy * dy;
+ float dx_total = current->position_x -
+ start_positions_[current->tracking_id].x_;
+ float dy_total = current->position_y -
+ start_positions_[current->tracking_id].y_;
+ float dsq_total = dx_total * dx_total + dy_total * dy_total;
+
+ float dsq_thresh = (move_lock_speed_.val_ * move_lock_speed_.val_) *
+ (dt * dt);
+ if (dsq > dsq_thresh) {
// lock onto this finger
moving_finger_id_ = current->tracking_id;
+ }
+ float dsq_total_thresh =
+ move_report_distance_.val_ * move_report_distance_.val_;
+ if (dsq_total >= dsq_total_thresh && dsq != 0.0) {
result_ = Gesture(kGestureMove,
state_buffer_.Get(1)->timestamp,
hwstate.timestamp,
diff --git a/chromium/third_party/gestures/gestures/src/immediate_interpreter_unittest.cc b/chromium/third_party/gestures/gestures/src/immediate_interpreter_unittest.cc
index ffa11626fd9..7cd9fb8c03a 100644
--- a/chromium/third_party/gestures/gestures/src/immediate_interpreter_unittest.cc
+++ b/chromium/third_party/gestures/gestures/src/immediate_interpreter_unittest.cc
@@ -619,7 +619,7 @@ TEST(ImmediateInterpreterTest, OneFingerThenTwoDelayedStartScrollTest) {
{0, 0, 0, 0, 20, 0, 40, 85, 1, 0},
{0, 0, 0, 0, 20, 0, 60, 83, 2, 0},
- {0, 0, 0, 0, 20, 0, 40, 85, 1, 0},
+ {0, 0, 0, 0, 20, 0, 40, 77, 1, 0},
{0, 0, 0, 0, 20, 0, 60, 75, 2, 0},
};
@@ -1096,7 +1096,7 @@ TEST(ImmediateInterpreterTest, RestingFingerTest) {
TestInterpreterWrapper wrapper(ii.get(), &hwprops);
const float kX = 7;
- float dx = 5;
+ float dx = 7;
const float kRestY = hwprops.bottom - 7;
const float kMoveY = kRestY - 10;
@@ -1769,13 +1769,13 @@ TEST(ImmediateInterpreterTest, TapToClickStateMachineTest) {
{S,{0.00,0,1,1,&fs[0],0,0,0,0},-1,MkSet(91),0,0,kFTB,false},
{C,{0.01,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kTpC,true},
{C,{0.02,0,1,1,&fs[4],0,0,0,0},-1,MkSet(95),0,0,kSTB,false},
- {C,{0.13,0,1,1,&fs[5],0,0,0,0},-1,MkSet(95),kBL,0,kDrg,false},
- {C,{0.14,0,1,1,&fs[6],0,0,0,0},-1,MkSet(95),0,0,kDrg,false},
- {C,{0.15,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
- {C,{0.16,0,1,1,&fs[7],0,0,0,0},-1,MkSet(96),0,0,kDRt,false},
- {C,{0.17,0,1,1,&fs[8],0,0,0,0},-1,MkSet(96),0,0,kDrg,false},
- {C,{0.18,0,1,1,&fs[9],0,0,0,0},-1,MkSet(96),0,0,kDrg,false},
- {C,{0.19,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
+ {C,{0.08,0,1,1,&fs[5],0,0,0,0},-1,MkSet(95),kBL,0,kDrg,false},
+ {C,{0.09,0,1,1,&fs[6],0,0,0,0},-1,MkSet(95),0,0,kDrg,false},
+ {C,{0.10,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
+ {C,{0.11,0,1,1,&fs[7],0,0,0,0},-1,MkSet(96),0,0,kDRt,false},
+ {C,{0.12,0,1,1,&fs[8],0,0,0,0},-1,MkSet(96),0,0,kDrg,false},
+ {C,{0.13,0,1,1,&fs[9],0,0,0,0},-1,MkSet(96),0,0,kDrg,false},
+ {C,{0.14,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
{C,{0.99,0,0,0,NULL,0,0,0,0},.99,MkSet(),0,kBL,kIdl,false},
// 1-finger long press
{S,{0.00,0,1,1,&fs[0],0,0,0,0},-1,MkSet(91),0,0,kFTB,false},
@@ -1883,11 +1883,11 @@ TEST(ImmediateInterpreterTest, TapToClickStateMachineTest) {
{S,{0.00,0,1,1,&fs[0],0,0,0,0},-1,MkSet(91),0,0,kFTB,false},
{C,{0.01,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kTpC,true},
{C,{0.02,0,1,1,&fs[4],0,0,0,0},-1,MkSet(95),0,0,kSTB,false},
- {C,{0.13,0,1,1,&fs[5],0,0,0,0},-1,MkSet(95),kBL,0,kDrg,false},
- {C,{0.14,0,1,1,&fs[6],0,0,0,0},-1,MkSet(95),0,0,kDrg,false},
- {C,{0.15,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
- {C,{0.16,0,2,2,&fs[10],0,0,0,0},-1,MkSet(97,98),0,0,kDRt,false},
- {C,{0.17,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,kBL,kTpC,true},
+ {C,{0.10,0,1,1,&fs[5],0,0,0,0},-1,MkSet(95),kBL,0,kDrg,false},
+ {C,{0.11,0,1,1,&fs[6],0,0,0,0},-1,MkSet(95),0,0,kDrg,false},
+ {C,{0.12,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
+ {C,{0.13,0,2,2,&fs[10],0,0,0,0},-1,MkSet(97,98),0,0,kDRt,false},
+ {C,{0.14,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,kBL,kTpC,true},
{C,{0.99,0,0,0,NULL,0,0,0,0},.99,MkSet(),kBR,kBR,kIdl,false},
// slow double tap
{D,{ 0.00, 0, 1, 1, &fs[0],0,0,0,0}, -1, MkSet(91), 0, 0, kFTB, false },
@@ -2300,13 +2300,13 @@ TEST(ImmediateInterpreterTest, TapToClickEnableTest) {
{S,{0.00,0,1,1,&fs[0],0,0,0,0},-1,MkSet(91),0,0,kFTB,false},
{C,{0.01,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kTpC,true},
{C,{0.02,0,1,1,&fs[1],0,0,0,0},-1,MkSet(92),0,0,kSTB,false},
- {C,{0.13,0,1,1,&fs[2],0,0,0,0},-1,MkSet(92),kBL,0,kDrg,false},
- {C,{0.14,0,1,1,&fs[3],0,0,0,0},-1,MkSet(92),0,0,kDrg,false},
- {C,{0.15,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
- {C,{0.16,0,1,1,&fs[4],0,0,0,0},-1,MkSet(93),0,0,kDRt,false},
- {C,{0.17,0,1,1,&fs[5],0,0,0,0},-1,MkSet(93),0,0,kDrg,false},
- {C,{0.18,0,1,1,&fs[6],0,0,0,0},-1,MkSet(93),0,0,kDrg,false},
- {C,{0.19,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
+ {C,{0.08,0,1,1,&fs[2],0,0,0,0},-1,MkSet(92),kBL,0,kDrg,false},
+ {C,{0.09,0,1,1,&fs[3],0,0,0,0},-1,MkSet(92),0,0,kDrg,false},
+ {C,{0.10,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
+ {C,{0.11,0,1,1,&fs[4],0,0,0,0},-1,MkSet(93),0,0,kDRt,false},
+ {C,{0.12,0,1,1,&fs[5],0,0,0,0},-1,MkSet(93),0,0,kDrg,false},
+ {C,{0.13,0,1,1,&fs[6],0,0,0,0},-1,MkSet(93),0,0,kDrg,false},
+ {C,{0.14,0,0,0,NULL,0,0,0,0},-1,MkSet(),0,0,kDRl,true},
{C,{0.99,0,0,0,NULL,0,0,0,0},.99,MkSet(),0,kBL,kIdl,false}
};
@@ -3442,7 +3442,6 @@ TEST(ImmediateInterpreterTest, ScrollResetTapTest) {
// SemiMt-specific properties
ii.tapping_finger_min_separation_.val_ = 0.0;
- ii.scroll_stationary_finger_max_distance_.val_ = 20.0;
ii.tap_enable_.val_ = 1;
TestInterpreterWrapper wrapper(&ii, &hwprops);
diff --git a/chromium/third_party/libaddressinput/chromium/resources/address_input_strings_tr.xtb b/chromium/third_party/libaddressinput/chromium/resources/address_input_strings_tr.xtb
index 9551c11955f..62a02ce06da 100644
--- a/chromium/third_party/libaddressinput/chromium/resources/address_input_strings_tr.xtb
+++ b/chromium/third_party/libaddressinput/chromium/resources/address_input_strings_tr.xtb
@@ -10,7 +10,7 @@
<translation id="3713769522066937702">Bu posta kodu biçimi tanınmadı. Geçerli bir posta kodu örneği: <ph name="EXAMPLE" />. Posta kodunuzu bilmiyor musunuz? <ph name="BEGIN_LINK" />Buradan<ph name="END_LINK" /> bulabilirsiniz.</translation>
<translation id="3882422586004212847">Bu posta kodu biçimi tanınmadı. Geçerli bir posta kodu örneği: <ph name="EXAMPLE" />.</translation>
<translation id="3885155851504623709">Bucak</translation>
-<translation id="43113324827158664">Bunu boş bırakamazsınız.</translation>
+<translation id="43113324827158664">Bu alanı boş bırakamazsınız.</translation>
<translation id="4376888869070172068">Posta kodu biçimi tanınmadı.</translation>
<translation id="4518701284698680367">Bir posta kodu sağlamalısınız (örneğin, <ph name="EXAMPLE" />). Posta kodunuzu bilmiyor musunuz? <ph name="BEGIN_LINK" />Buradan<ph name="END_LINK" /> bulabilirsiniz.</translation>
<translation id="5089810972385038852">Eyalet</translation>
diff --git a/chromium/third_party/libdrm/src/Android.mk b/chromium/third_party/libdrm/src/Android.mk
index 2aa2bc964df..90cdcb32360 100644
--- a/chromium/third_party/libdrm/src/Android.mk
+++ b/chromium/third_party/libdrm/src/Android.mk
@@ -27,12 +27,10 @@ include $(CLEAR_VARS)
# Import variables LIBDRM_{,H_,INCLUDE_H_,INCLUDE_VMWGFX_H_}FILES
include $(LOCAL_PATH)/Makefile.sources
-#static library for the device (recovery)
-include $(CLEAR_VARS)
LOCAL_MODULE := libdrm
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_FILES))
+LOCAL_SRC_FILES := $(LIBDRM_FILES)
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/include/drm
@@ -43,24 +41,7 @@ LOCAL_C_INCLUDES := \
LOCAL_CFLAGS := \
-DHAVE_VISIBILITY=1 \
-DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
-include $(BUILD_STATIC_LIBRARY)
-
-# Shared library for the device
-include $(CLEAR_VARS)
-LOCAL_MODULE := libdrm
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_FILES))
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
- $(LOCAL_PATH) \
- $(LOCAL_PATH)/include/drm
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include/drm
-
-LOCAL_CFLAGS := \
- -DHAVE_VISIBILITY=1 \
- -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/chromium/third_party/libdrm/src/CleanSpec.mk b/chromium/third_party/libdrm/src/CleanSpec.mk
index 28a11db4e7b..8e23cd25d26 100644
--- a/chromium/third_party/libdrm/src/CleanSpec.mk
+++ b/chromium/third_party/libdrm/src/CleanSpec.mk
@@ -1,4 +1,3 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/include/libdrm)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/include/freedreno)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libdrm_*intermediates)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libdrm_*intermediates)
diff --git a/chromium/third_party/libdrm/src/Makefile.am b/chromium/third_party/libdrm/src/Makefile.am
index fcb21b65bdd..ca415089c4b 100644
--- a/chromium/third_party/libdrm/src/Makefile.am
+++ b/chromium/third_party/libdrm/src/Makefile.am
@@ -29,7 +29,6 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-radeon \
--enable-amdgpu \
--enable-nouveau \
- --enable-vc4 \
--enable-vmwgfx \
--enable-omap-experimental-api \
--enable-exynos-experimental-api \
@@ -80,18 +79,6 @@ if HAVE_TEGRA
TEGRA_SUBDIR = tegra
endif
-if HAVE_VC4
-VC4_SUBDIR = vc4
-endif
-
-if HAVE_ROCKCHIP
-ROCKCHIP_SUBDIR = rockchip
-endif
-
-if HAVE_MEDIATEK
-MEDIATEK_SUBDIR = mediatek
-endif
-
if BUILD_MANPAGES
if HAVE_MANPAGES_STYLESHEET
MAN_SUBDIR = man
@@ -109,9 +96,6 @@ SUBDIRS = \
$(EXYNOS_SUBDIR) \
$(FREEDRENO_SUBDIR) \
$(TEGRA_SUBDIR) \
- $(VC4_SUBDIR) \
- $(ROCKCHIP_SUBDIR) \
- $(MEDIATEK_SUBDIR) \
tests \
$(MAN_SUBDIR)
@@ -130,6 +114,8 @@ libdrm_la_SOURCES = $(LIBDRM_FILES)
libdrmincludedir = ${includedir}
libdrminclude_HEADERS = $(LIBDRM_H_FILES)
+EXTRA_DIST = Android.mk
+
klibdrmincludedir = ${includedir}/libdrm
klibdrminclude_HEADERS = $(LIBDRM_INCLUDE_H_FILES)
diff --git a/chromium/third_party/libdrm/src/Makefile.sources b/chromium/third_party/libdrm/src/Makefile.sources
index 8c7ddace01f..a77f48dee7c 100644
--- a/chromium/third_party/libdrm/src/Makefile.sources
+++ b/chromium/third_party/libdrm/src/Makefile.sources
@@ -21,7 +21,6 @@ LIBDRM_INCLUDE_H_FILES := \
include/drm/drm_fourcc.h \
include/drm/drm_mode.h \
include/drm/drm_sarea.h \
- include/drm/evdi_drm.h \
include/drm/i915_drm.h \
include/drm/mach64_drm.h \
include/drm/mga_drm.h \
@@ -33,10 +32,7 @@ LIBDRM_INCLUDE_H_FILES := \
include/drm/savage_drm.h \
include/drm/sis_drm.h \
include/drm/tegra_drm.h \
- include/drm/vc4_drm.h \
- include/drm/vgem_drm.h \
- include/drm/via_drm.h \
- include/drm/virtgpu_drm.h
+ include/drm/via_drm.h
LIBDRM_INCLUDE_VMWGFX_H_FILES := \
include/drm/vmwgfx_drm.h
diff --git a/chromium/third_party/libdrm/src/PRESUBMIT.cfg b/chromium/third_party/libdrm/src/PRESUBMIT.cfg
deleted file mode 100644
index 9b0d5a48ce8..00000000000
--- a/chromium/third_party/libdrm/src/PRESUBMIT.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-[Hook Overrides]
-cros_license_check: false
-tab_check: false
diff --git a/chromium/third_party/libdrm/src/amdgpu/Android.mk b/chromium/third_party/libdrm/src/amdgpu/Android.mk
index 57c53a7958c..469df1b269d 100644
--- a/chromium/third_party/libdrm/src/amdgpu/Android.mk
+++ b/chromium/third_party/libdrm/src/amdgpu/Android.mk
@@ -9,7 +9,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libdrm
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_AMDGPU_FILES))
+LOCAL_SRC_FILES := $(LIBDRM_AMDGPU_FILES)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_CFLAGS := \
diff --git a/chromium/third_party/libdrm/src/amdgpu/amdgpu-symbol-check b/chromium/third_party/libdrm/src/amdgpu/amdgpu-symbol-check
index 648db9b6c86..9a0b36cb379 100755
--- a/chromium/third_party/libdrm/src/amdgpu/amdgpu-symbol-check
+++ b/chromium/third_party/libdrm/src/amdgpu/amdgpu-symbol-check
@@ -24,15 +24,11 @@ amdgpu_bo_set_metadata
amdgpu_bo_va_op
amdgpu_bo_wait_for_idle
amdgpu_create_bo_from_user_mem
-amdgpu_cs_create_semaphore
amdgpu_cs_ctx_create
amdgpu_cs_ctx_free
-amdgpu_cs_destroy_semaphore
amdgpu_cs_query_fence_status
amdgpu_cs_query_reset_state
-amdgpu_cs_signal_semaphore
amdgpu_cs_submit
-amdgpu_cs_wait_semaphore
amdgpu_device_deinitialize
amdgpu_device_initialize
amdgpu_query_buffer_size_alignment
diff --git a/chromium/third_party/libdrm/src/amdgpu/amdgpu.h b/chromium/third_party/libdrm/src/amdgpu/amdgpu.h
index 5d5a2c67f2a..e44d802b3f5 100644
--- a/chromium/third_party/libdrm/src/amdgpu/amdgpu.h
+++ b/chromium/third_party/libdrm/src/amdgpu/amdgpu.h
@@ -124,11 +124,6 @@ typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
*/
typedef struct amdgpu_va *amdgpu_va_handle;
-/**
- * Define handle for semaphore
- */
-typedef struct amdgpu_semaphore *amdgpu_semaphore_handle;
-
/*--------------------------------------------------------------------------*/
/* -------------------------- Structures ---------------------------------- */
/*--------------------------------------------------------------------------*/
@@ -685,7 +680,7 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
/**
- * Request CPU access to GPU accessible memory
+ * Request CPU access to GPU accessable memory
*
* \param buf_handle - \c [in] Buffer handle
* \param cpu - \c [out] CPU address to be used for access
@@ -851,7 +846,7 @@ int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
* order.
*
* The caller can specify the user fence buffer/location with the fence_info in the
- * cs_request.The sequence number is returned via the 'seq_no' parameter
+ * cs_request.The sequence number is returned via the 'seq_no' paramter
* in ibs_request structure.
*
*
@@ -1185,64 +1180,4 @@ int amdgpu_bo_va_op(amdgpu_bo_handle bo,
uint64_t flags,
uint32_t ops);
-/**
- * create semaphore
- *
- * \param sem - \c [out] semaphore handle
- *
- * \return 0 on success\n
- * <0 - Negative POSIX Error code
- *
-*/
-int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem);
-
-/**
- * signal semaphore
- *
- * \param context - \c [in] GPU Context
- * \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
- * \param ip_instance - \c [in] Index of the IP block of the same type
- * \param ring - \c [in] Specify ring index of the IP
- * \param sem - \c [in] semaphore handle
- *
- * \return 0 on success\n
- * <0 - Negative POSIX Error code
- *
-*/
-int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
- uint32_t ip_type,
- uint32_t ip_instance,
- uint32_t ring,
- amdgpu_semaphore_handle sem);
-
-/**
- * wait semaphore
- *
- * \param context - \c [in] GPU Context
- * \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
- * \param ip_instance - \c [in] Index of the IP block of the same type
- * \param ring - \c [in] Specify ring index of the IP
- * \param sem - \c [in] semaphore handle
- *
- * \return 0 on success\n
- * <0 - Negative POSIX Error code
- *
-*/
-int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
- uint32_t ip_type,
- uint32_t ip_instance,
- uint32_t ring,
- amdgpu_semaphore_handle sem);
-
-/**
- * destroy semaphore
- *
- * \param sem - \c [in] semaphore handle
- *
- * \return 0 on success\n
- * <0 - Negative POSIX Error code
- *
-*/
-int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
-
#endif /* #ifdef _AMDGPU_H_ */
diff --git a/chromium/third_party/libdrm/src/amdgpu/amdgpu_bo.c b/chromium/third_party/libdrm/src/amdgpu/amdgpu_bo.c
index d30fd1e7166..1a5a40117b2 100644
--- a/chromium/third_party/libdrm/src/amdgpu/amdgpu_bo.c
+++ b/chromium/third_party/libdrm/src/amdgpu/amdgpu_bo.c
@@ -537,10 +537,18 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
int r;
struct amdgpu_bo *bo;
struct drm_amdgpu_gem_userptr args;
+ uintptr_t cpu0;
+ uint32_t ps, off;
- args.addr = (uintptr_t)cpu;
- args.flags = AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER |
- AMDGPU_GEM_USERPTR_VALIDATE;
+ memset(&args, 0, sizeof(args));
+ ps = getpagesize();
+
+ cpu0 = ROUND_DOWN((uintptr_t)cpu, ps);
+ off = (uintptr_t)cpu - cpu0;
+ size = ROUND_UP(size + off, ps);
+
+ args.addr = cpu0;
+ args.flags = AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER;
args.size = size;
r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR,
&args, sizeof(args));
diff --git a/chromium/third_party/libdrm/src/amdgpu/amdgpu_cs.c b/chromium/third_party/libdrm/src/amdgpu/amdgpu_cs.c
index fb5b3a8c4bc..6747158c380 100644
--- a/chromium/third_party/libdrm/src/amdgpu/amdgpu_cs.c
+++ b/chromium/third_party/libdrm/src/amdgpu/amdgpu_cs.c
@@ -40,9 +40,6 @@
#include "amdgpu_drm.h"
#include "amdgpu_internal.h"
-static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem);
-static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);
-
/**
* Create command submission context
*
@@ -56,7 +53,6 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
{
struct amdgpu_context *gpu_context;
union drm_amdgpu_ctx args;
- int i, j, k;
int r;
if (NULL == dev)
@@ -70,10 +66,6 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
gpu_context->dev = dev;
- r = pthread_mutex_init(&gpu_context->sequence_mutex, NULL);
- if (r)
- goto error;
-
/* Create the context */
memset(&args, 0, sizeof(args));
args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
@@ -82,16 +74,11 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
goto error;
gpu_context->id = args.out.alloc.ctx_id;
- for (i = 0; i < AMDGPU_HW_IP_NUM; i++)
- for (j = 0; j < AMDGPU_HW_IP_INSTANCE_MAX_COUNT; j++)
- for (k = 0; k < AMDGPU_CS_MAX_RINGS; k++)
- list_inithead(&gpu_context->sem_list[i][j][k]);
*context = (amdgpu_context_handle)gpu_context;
return 0;
error:
- pthread_mutex_destroy(&gpu_context->sequence_mutex);
free(gpu_context);
return r;
}
@@ -107,32 +94,18 @@ error:
int amdgpu_cs_ctx_free(amdgpu_context_handle context)
{
union drm_amdgpu_ctx args;
- int i, j, k;
int r;
if (NULL == context)
return -EINVAL;
- pthread_mutex_destroy(&context->sequence_mutex);
-
/* now deal with kernel side */
memset(&args, 0, sizeof(args));
args.in.op = AMDGPU_CTX_OP_FREE_CTX;
args.in.ctx_id = context->id;
r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CTX,
&args, sizeof(args));
- for (i = 0; i < AMDGPU_HW_IP_NUM; i++) {
- for (j = 0; j < AMDGPU_HW_IP_INSTANCE_MAX_COUNT; j++) {
- for (k = 0; k < AMDGPU_CS_MAX_RINGS; k++) {
- amdgpu_semaphore_handle sem;
- LIST_FOR_EACH_ENTRY(sem, &context->sem_list[i][j][k], list) {
- list_del(&sem->list);
- amdgpu_cs_reset_sem(sem);
- amdgpu_cs_unreference_sem(sem);
- }
- }
- }
- }
+
free(context);
return r;
@@ -177,10 +150,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
struct drm_amdgpu_cs_chunk *chunks;
struct drm_amdgpu_cs_chunk_data *chunk_data;
struct drm_amdgpu_cs_chunk_dep *dependencies = NULL;
- struct drm_amdgpu_cs_chunk_dep *sem_dependencies = NULL;
- struct list_head *sem_list;
- amdgpu_semaphore_handle sem, tmp;
- uint32_t i, size, sem_count = 0;
+ uint32_t i, size;
bool user_fence;
int r = 0;
@@ -190,13 +160,9 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
return -EINVAL;
if (ibs_request->number_of_ibs > AMDGPU_CS_MAX_IBS_PER_SUBMIT)
return -EINVAL;
- if (ibs_request->number_of_ibs == 0) {
- ibs_request->seq_no = AMDGPU_NULL_SUBMIT_SEQ;
- return 0;
- }
user_fence = (ibs_request->fence_info.handle != NULL);
- size = ibs_request->number_of_ibs + (user_fence ? 2 : 1) + 1;
+ size = ibs_request->number_of_ibs + (user_fence ? 2 : 1);
chunk_array = alloca(sizeof(uint64_t) * size);
chunks = alloca(sizeof(struct drm_amdgpu_cs_chunk) * size);
@@ -230,8 +196,6 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
chunk_data[i].ib_data.flags = ib->flags;
}
- pthread_mutex_lock(&context->sequence_mutex);
-
if (user_fence) {
i = cs.in.num_chunks++;
@@ -276,49 +240,15 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
chunks[i].chunk_data = (uint64_t)(uintptr_t)dependencies;
}
- sem_list = &context->sem_list[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring];
- LIST_FOR_EACH_ENTRY(sem, sem_list, list)
- sem_count++;
- if (sem_count) {
- sem_dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count);
- if (!sem_dependencies) {
- r = -ENOMEM;
- goto error_unlock;
- }
- sem_count = 0;
- LIST_FOR_EACH_ENTRY_SAFE(sem, tmp, sem_list, list) {
- struct amdgpu_cs_fence *info = &sem->signal_fence;
- struct drm_amdgpu_cs_chunk_dep *dep = &sem_dependencies[sem_count++];
- dep->ip_type = info->ip_type;
- dep->ip_instance = info->ip_instance;
- dep->ring = info->ring;
- dep->ctx_id = info->context->id;
- dep->handle = info->fence;
-
- list_del(&sem->list);
- amdgpu_cs_reset_sem(sem);
- amdgpu_cs_unreference_sem(sem);
- }
- i = cs.in.num_chunks++;
-
- /* dependencies chunk */
- chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
- chunks[i].chunk_id = AMDGPU_CHUNK_ID_DEPENDENCIES;
- chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_dep) / 4 * sem_count;
- chunks[i].chunk_data = (uint64_t)(uintptr_t)sem_dependencies;
- }
-
r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CS,
&cs, sizeof(cs));
if (r)
goto error_unlock;
ibs_request->seq_no = cs.out.handle;
- context->last_seq[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring] = ibs_request->seq_no;
+
error_unlock:
- pthread_mutex_unlock(&context->sequence_mutex);
free(dependencies);
- free(sem_dependencies);
return r;
}
@@ -426,10 +356,6 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
return -EINVAL;
if (fence->ring >= AMDGPU_CS_MAX_RINGS)
return -EINVAL;
- if (fence->fence == AMDGPU_NULL_SUBMIT_SEQ) {
- *expired = true;
- return 0;
- }
*expired = false;
@@ -443,102 +369,3 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
return r;
}
-int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem)
-{
- struct amdgpu_semaphore *gpu_semaphore;
-
- if (NULL == sem)
- return -EINVAL;
-
- gpu_semaphore = calloc(1, sizeof(struct amdgpu_semaphore));
- if (NULL == gpu_semaphore)
- return -ENOMEM;
-
- atomic_set(&gpu_semaphore->refcount, 1);
- *sem = gpu_semaphore;
-
- return 0;
-}
-
-int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
- uint32_t ip_type,
- uint32_t ip_instance,
- uint32_t ring,
- amdgpu_semaphore_handle sem)
-{
- if (NULL == ctx)
- return -EINVAL;
- if (ip_type >= AMDGPU_HW_IP_NUM)
- return -EINVAL;
- if (ring >= AMDGPU_CS_MAX_RINGS)
- return -EINVAL;
- if (NULL == sem)
- return -EINVAL;
- /* sem has been signaled */
- if (sem->signal_fence.context)
- return -EINVAL;
- pthread_mutex_lock(&ctx->sequence_mutex);
- sem->signal_fence.context = ctx;
- sem->signal_fence.ip_type = ip_type;
- sem->signal_fence.ip_instance = ip_instance;
- sem->signal_fence.ring = ring;
- sem->signal_fence.fence = ctx->last_seq[ip_type][ip_instance][ring];
- update_references(NULL, &sem->refcount);
- pthread_mutex_unlock(&ctx->sequence_mutex);
- return 0;
-}
-
-int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
- uint32_t ip_type,
- uint32_t ip_instance,
- uint32_t ring,
- amdgpu_semaphore_handle sem)
-{
- if (NULL == ctx)
- return -EINVAL;
- if (ip_type >= AMDGPU_HW_IP_NUM)
- return -EINVAL;
- if (ring >= AMDGPU_CS_MAX_RINGS)
- return -EINVAL;
- if (NULL == sem)
- return -EINVAL;
- /* must signal first */
- if (NULL == sem->signal_fence.context)
- return -EINVAL;
-
- pthread_mutex_lock(&ctx->sequence_mutex);
- list_add(&sem->list, &ctx->sem_list[ip_type][ip_instance][ring]);
- pthread_mutex_unlock(&ctx->sequence_mutex);
- return 0;
-}
-
-static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem)
-{
- if (NULL == sem)
- return -EINVAL;
- if (NULL == sem->signal_fence.context)
- return -EINVAL;
-
- sem->signal_fence.context = NULL;;
- sem->signal_fence.ip_type = 0;
- sem->signal_fence.ip_instance = 0;
- sem->signal_fence.ring = 0;
- sem->signal_fence.fence = 0;
-
- return 0;
-}
-
-static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem)
-{
- if (NULL == sem)
- return -EINVAL;
-
- if (update_references(&sem->refcount, NULL))
- free(sem);
- return 0;
-}
-
-int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem)
-{
- return amdgpu_cs_unreference_sem(sem);
-}
diff --git a/chromium/third_party/libdrm/src/amdgpu/amdgpu_internal.h b/chromium/third_party/libdrm/src/amdgpu/amdgpu_internal.h
index 4f039b68fa5..7dd5c1c724a 100644
--- a/chromium/third_party/libdrm/src/amdgpu/amdgpu_internal.h
+++ b/chromium/third_party/libdrm/src/amdgpu/amdgpu_internal.h
@@ -44,7 +44,6 @@
#define ROUND_DOWN(x, y) ((x) & ~__round_mask(x, y))
#define AMDGPU_INVALID_VA_ADDRESS 0xffffffffffffffff
-#define AMDGPU_NULL_SUBMIT_SEQ 0
struct amdgpu_bo_va_hole {
struct list_head list;
@@ -112,23 +111,8 @@ struct amdgpu_bo_list {
struct amdgpu_context {
struct amdgpu_device *dev;
- /** Mutex for accessing fences and to maintain command submissions
- in good sequence. */
- pthread_mutex_t sequence_mutex;
/* context id*/
uint32_t id;
- uint64_t last_seq[AMDGPU_HW_IP_NUM][AMDGPU_HW_IP_INSTANCE_MAX_COUNT][AMDGPU_CS_MAX_RINGS];
- struct list_head sem_list[AMDGPU_HW_IP_NUM][AMDGPU_HW_IP_INSTANCE_MAX_COUNT][AMDGPU_CS_MAX_RINGS];
-};
-
-/**
- * Structure describing sw semaphore based on scheduler
- *
- */
-struct amdgpu_semaphore {
- atomic_t refcount;
- struct list_head list;
- struct amdgpu_cs_fence signal_fence;
};
/**
diff --git a/chromium/third_party/libdrm/src/amdgpu/libdrm_amdgpu.pc.in b/chromium/third_party/libdrm/src/amdgpu/libdrm_amdgpu.pc.in
index f1c552a623f..417865e5764 100644
--- a/chromium/third_party/libdrm/src/amdgpu/libdrm_amdgpu.pc.in
+++ b/chromium/third_party/libdrm/src/amdgpu/libdrm_amdgpu.pc.in
@@ -8,4 +8,3 @@ Description: Userspace interface to kernel DRM services for amdgpu
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ldrm_amdgpu
Cflags: -I${includedir} -I${includedir}/libdrm
-Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/configure.ac b/chromium/third_party/libdrm/src/configure.ac
index 6c069f7b2ff..b929d36a28c 100644
--- a/chromium/third_party/libdrm/src/configure.ac
+++ b/chromium/third_party/libdrm/src/configure.ac
@@ -20,7 +20,7 @@
AC_PREREQ([2.63])
AC_INIT([libdrm],
- [2.4.70],
+ [2.4.65],
[https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
[libdrm])
@@ -53,8 +53,7 @@ AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
AC_FUNC_ALLOCA
-AC_HEADER_MAJOR
-AC_CHECK_HEADERS([sys/sysctl.h sys/select.h])
+AC_CHECK_HEADERS([sys/mkdev.h sys/sysctl.h])
# Initialize libtool
LT_PREREQ([2.2])
@@ -122,26 +121,11 @@ AC_ARG_ENABLE(freedreno-kgsl,
[Enable support for freedreno's to use downstream android kernel API (default: disabled)]),
[FREEDRENO_KGSL=$enableval], [FREEDRENO_KGSL=no])
-AC_ARG_ENABLE(mediatek-experimental-api,
- AS_HELP_STRING([--enable-mediatek-experimental-api],
- [Enable support for Mediatek's experimental API (default: disabled)]),
- [MEDIATEK=$enableval], [MEDIATEK=no])
-
AC_ARG_ENABLE(tegra-experimental-api,
AS_HELP_STRING([--enable-tegra-experimental-api],
[Enable support for Tegra's experimental API (default: disabled)]),
[TEGRA=$enableval], [TEGRA=no])
-AC_ARG_ENABLE(vc4,
- AS_HELP_STRING([--disable-vc4],
- [Enable support for vc4's API (default: auto, enabled on arm)]),
- [VC4=$enableval], [VC4=auto])
-
-AC_ARG_ENABLE(rockchip-experimental-api,
- AS_HELP_STRING([--enable-rockchip-experimental-api],
- [Enable support for rockchip's experimental API (default: disabled)]),
- [ROCKCHIP=$enableval], [ROCKCHIP=no])
-
AC_ARG_ENABLE(install-test-programs,
AS_HELP_STRING([--enable-install-test-programs],
[Install test programs (default: no)]),
@@ -190,8 +174,7 @@ MAYBE_WARN="-Wall -Wextra \
-Wstrict-aliasing=2 -Winit-self \
-Wdeclaration-after-statement -Wold-style-definition \
-Wno-unused-parameter \
--Wno-attributes -Wno-long-long -Winline -Wshadow \
--Wno-missing-field-initializers"
+-Wno-attributes -Wno-long-long -Winline -Wshadow"
# invalidate cached value if MAYBE_WARN has changed
if test "x$libdrm_cv_warn_maybe" != "x$MAYBE_WARN"; then
@@ -306,12 +289,6 @@ else
*) FREEDRENO=no ;;
esac
fi
- if test "x$VC4" = xauto; then
- case $host_cpu in
- arm*|aarch64) VC4=yes ;;
- *) VC4=no ;;
- esac
- fi
fi
if test "x$INTEL" != "xno"; then
@@ -382,23 +359,19 @@ if test "x$RADEON" = xyes; then
AC_DEFINE(HAVE_RADEON, 1, [Have radeon support])
fi
-if test "x$AMDGPU" != xno; then
- # Detect cunit library
- PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
- # If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
- # do this because Debian (Ubuntu) lacks pkg-config file for cunit.
- # fixed in 2.1-2.dfsg-3: http://anonscm.debian.org/cgit/collab-maint/cunit.git/commit/?h=debian
- if test "x${have_cunit}" = "xno"; then
- AC_CHECK_LIB([cunit], [CU_initialize_registry], [have_cunit=yes], [have_cunit=no])
- if test "x${have_cunit}" = "xyes"; then
- CUNIT_LIBS="-lcunit"
- CUNIT_CFLAGS=""
- AC_SUBST([CUNIT_LIBS])
- AC_SUBST([CUNIT_CFLAGS])
- fi
+# Detect cunit library
+PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
+# If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
+# do this because Debian (Ubuntu) lacks pkg-config file for cunit.
+# fixed in 2.1-2.dfsg-3: http://anonscm.debian.org/cgit/collab-maint/cunit.git/commit/?h=debian
+if test "x${have_cunit}" = "xno"; then
+ AC_CHECK_LIB([cunit], [CU_initialize_registry], [have_cunit=yes], [have_cunit=no])
+ if test "x${have_cunit}" = "xyes"; then
+ CUNIT_LIBS="-lcunit"
+ CUNIT_CFLAGS=""
+ AC_SUBST([CUNIT_LIBS])
+ AC_SUBST([CUNIT_CFLAGS])
fi
-else
- have_cunit=no
fi
AM_CONDITIONAL(HAVE_CUNIT, [test "x$have_cunit" != "xno"])
@@ -418,21 +391,6 @@ if test "x$TEGRA" = xyes; then
AC_DEFINE(HAVE_TEGRA, 1, [Have Tegra support])
fi
-AM_CONDITIONAL(HAVE_VC4, [test "x$VC4" = xyes])
-if test "x$VC4" = xyes; then
- AC_DEFINE(HAVE_VC4, 1, [Have VC4 support])
-fi
-
-AM_CONDITIONAL(HAVE_ROCKCHIP, [test "x$ROCKCHIP" = xyes])
-if test "x$ROCKCHIP" = xyes; then
- AC_DEFINE(HAVE_ROCKCHIP, 1, [Have ROCKCHIP support])
-fi
-
-AM_CONDITIONAL(HAVE_MEDIATEK, [test "x$MEDIATEK" = xyes])
-if test "x$MEDIATEK" = xyes; then
- AC_DEFINE(HAVE_MEDIATEK, 1, [Have MEDIATEK support])
-fi
-
AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes])
if test "x$INSTALL_TESTS" = xyes; then
AC_DEFINE(HAVE_INSTALL_TESTS, 1, [Install test programs])
@@ -442,9 +400,7 @@ AC_ARG_ENABLE([cairo-tests],
[AS_HELP_STRING([--enable-cairo-tests],
[Enable support for Cairo rendering in tests (default: auto)])],
[CAIRO=$enableval], [CAIRO=auto])
-if test "x$CAIRO" != xno; then
- PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
-fi
+PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
AC_MSG_CHECKING([whether to enable Cairo tests])
if test "x$CAIRO" = xauto; then
CAIRO="$HAVE_CAIRO"
@@ -489,9 +445,7 @@ AC_ARG_ENABLE(valgrind,
[AS_HELP_STRING([--enable-valgrind],
[Build libdrm with valgrind support (default: auto)])],
[VALGRIND=$enableval], [VALGRIND=auto])
-if test "x$VALGRIND" != xno; then
- PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no])
-fi
+PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no])
AC_MSG_CHECKING([whether to enable Valgrind support])
if test "x$VALGRIND" = xauto; then
VALGRIND="$have_valgrind"
@@ -542,16 +496,9 @@ AC_CONFIG_FILES([
freedreno/libdrm_freedreno.pc
tegra/Makefile
tegra/libdrm_tegra.pc
- vc4/Makefile
- vc4/libdrm_vc4.pc
- rockchip/Makefile
- rockchip/libdrm_rockchip.pc
- mediatek/Makefile
- mediatek/libdrm_mediatek.pc
tests/Makefile
tests/modeprint/Makefile
tests/modetest/Makefile
- tests/kms/Makefile
tests/kmstest/Makefile
tests/proptest/Makefile
tests/radeon/Makefile
@@ -560,7 +507,6 @@ AC_CONFIG_FILES([
tests/exynos/Makefile
tests/tegra/Makefile
tests/nouveau/Makefile
- tests/util/Makefile
man/Makefile
libdrm.pc])
AC_OUTPUT
@@ -578,7 +524,4 @@ echo " OMAP API $OMAP"
echo " EXYNOS API $EXYNOS"
echo " Freedreno API $FREEDRENO (kgsl: $FREEDRENO_KGSL)"
echo " Tegra API $TEGRA"
-echo " VC4 API $VC4"
-echo " Rockchip API $ROCKCHIP"
-echo " Mediatek API $MEDIATEK"
echo ""
diff --git a/chromium/third_party/libdrm/src/exynos/exynos-symbol-check b/chromium/third_party/libdrm/src/exynos/exynos-symbol-check
index 9692caa685b..1a1be89eae7 100755
--- a/chromium/third_party/libdrm/src/exynos/exynos-symbol-check
+++ b/chromium/third_party/libdrm/src/exynos/exynos-symbol-check
@@ -22,15 +22,12 @@ exynos_device_destroy
exynos_prime_fd_to_handle
exynos_prime_handle_to_fd
exynos_vidi_connection
-exynos_handle_event
g2d_blend
g2d_copy
g2d_copy_with_scale
g2d_exec
-g2d_config_event
g2d_fini
g2d_init
-g2d_move
g2d_scale_and_blend
g2d_solid_fill
EOF
diff --git a/chromium/third_party/libdrm/src/exynos/exynos_drm.c b/chromium/third_party/libdrm/src/exynos/exynos_drm.c
index b961e520737..df9b8ed4d39 100644
--- a/chromium/third_party/libdrm/src/exynos/exynos_drm.c
+++ b/chromium/third_party/libdrm/src/exynos/exynos_drm.c
@@ -32,7 +32,6 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include <unistd.h>
#include <sys/mman.h>
#include <linux/stddef.h>
@@ -43,8 +42,6 @@
#include "exynos_drm.h"
#include "exynos_drmif.h"
-#define U642VOID(x) ((void *)(unsigned long)(x))
-
/*
* Create exynos drm device object.
*
@@ -347,7 +344,7 @@ exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, uint32_t *handle)
*
* @dev: a exynos device object.
* @connect: indicate whether connectoin or disconnection request.
- * @ext: indicate whether edid data includes extensions data or not.
+ * @ext: indicate whether edid data includes extentions data or not.
* @edid: a pointer to edid data from Wireless Display device.
*
* this interface is used to request Virtual Display driver connection or
@@ -377,76 +374,3 @@ exynos_vidi_connection(struct exynos_device *dev, uint32_t connect,
return 0;
}
-
-static void
-exynos_handle_vendor(int fd, struct drm_event *e, void *ctx)
-{
- struct drm_exynos_g2d_event *g2d;
- struct exynos_event_context *ectx = ctx;
-
- switch (e->type) {
- case DRM_EXYNOS_G2D_EVENT:
- if (ectx->version < 1 || ectx->g2d_event_handler == NULL)
- break;
- g2d = (struct drm_exynos_g2d_event *)e;
- ectx->g2d_event_handler(fd, g2d->cmdlist_no, g2d->tv_sec,
- g2d->tv_usec, U642VOID(g2d->user_data));
- break;
-
- default:
- break;
- }
-}
-
-int
-exynos_handle_event(struct exynos_device *dev, struct exynos_event_context *ctx)
-{
- char buffer[1024];
- int len, i;
- struct drm_event *e;
- struct drm_event_vblank *vblank;
- drmEventContextPtr evctx = &ctx->base;
-
- /* The DRM read semantics guarantees that we always get only
- * complete events. */
- len = read(dev->fd, buffer, sizeof buffer);
- if (len == 0)
- return 0;
- if (len < (int)sizeof *e)
- return -1;
-
- i = 0;
- while (i < len) {
- e = (struct drm_event *) &buffer[i];
- switch (e->type) {
- case DRM_EVENT_VBLANK:
- if (evctx->version < 1 ||
- evctx->vblank_handler == NULL)
- break;
- vblank = (struct drm_event_vblank *) e;
- evctx->vblank_handler(dev->fd,
- vblank->sequence,
- vblank->tv_sec,
- vblank->tv_usec,
- U642VOID (vblank->user_data));
- break;
- case DRM_EVENT_FLIP_COMPLETE:
- if (evctx->version < 2 ||
- evctx->page_flip_handler == NULL)
- break;
- vblank = (struct drm_event_vblank *) e;
- evctx->page_flip_handler(dev->fd,
- vblank->sequence,
- vblank->tv_sec,
- vblank->tv_usec,
- U642VOID (vblank->user_data));
- break;
- default:
- exynos_handle_vendor(dev->fd, e, evctx);
- break;
- }
- i += e->length;
- }
-
- return 0;
-}
diff --git a/chromium/third_party/libdrm/src/exynos/exynos_drm.h b/chromium/third_party/libdrm/src/exynos/exynos_drm.h
index c3af0ac5f6d..256c02f0250 100644
--- a/chromium/third_party/libdrm/src/exynos/exynos_drm.h
+++ b/chromium/third_party/libdrm/src/exynos/exynos_drm.h
@@ -157,16 +157,4 @@ struct drm_exynos_g2d_exec {
#define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \
DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
-/* EXYNOS specific events */
-#define DRM_EXYNOS_G2D_EVENT 0x80000000
-
-struct drm_exynos_g2d_event {
- struct drm_event base;
- __u64 user_data;
- __u32 tv_sec;
- __u32 tv_usec;
- __u32 cmdlist_no;
- __u32 reserved;
-};
-
#endif
diff --git a/chromium/third_party/libdrm/src/exynos/exynos_drmif.h b/chromium/third_party/libdrm/src/exynos/exynos_drmif.h
index 626e39985a1..c7c1d442b20 100644
--- a/chromium/third_party/libdrm/src/exynos/exynos_drmif.h
+++ b/chromium/third_party/libdrm/src/exynos/exynos_drmif.h
@@ -54,25 +54,6 @@ struct exynos_bo {
uint32_t name;
};
-#define EXYNOS_EVENT_CONTEXT_VERSION 1
-
-/*
- * Exynos Event Context structure.
- *
- * @base: base context (for core events).
- * @version: version info similar to the one in 'drmEventContext'.
- * @g2d_event_handler: handler for G2D events.
- */
-struct exynos_event_context {
- drmEventContext base;
-
- int version;
-
- void (*g2d_event_handler)(int fd, unsigned int cmdlist_no,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data);
-};
-
/*
* device related functions:
*/
@@ -102,11 +83,4 @@ int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd,
int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect,
uint32_t ext, void *edid);
-/*
- * event handling related functions:
- */
-int exynos_handle_event(struct exynos_device *dev,
- struct exynos_event_context *ctx);
-
-
#endif /* EXYNOS_DRMIF_H_ */
diff --git a/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.c b/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.c
index 7f1d105a5cb..e7341449a88 100644
--- a/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.c
+++ b/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.c
@@ -57,7 +57,6 @@ struct g2d_context {
unsigned int cmd_nr;
unsigned int cmd_buf_nr;
unsigned int cmdlist_nr;
- void *event_userdata;
};
enum g2d_base_addr_reg {
@@ -65,44 +64,6 @@ enum g2d_base_addr_reg {
g2d_src
};
-enum e_g2d_dir_mode {
- G2D_DIR_MODE_POSITIVE = 0,
- G2D_DIR_MODE_NEGATIVE = 1
-};
-
-union g2d_direction_val {
- unsigned int val[2];
- struct {
- /* SRC_MSK_DIRECT_REG [0:1] (source) */
- enum e_g2d_dir_mode src_x_direction:1;
- enum e_g2d_dir_mode src_y_direction:1;
-
- /* SRC_MSK_DIRECT_REG [2:3] */
- unsigned int reversed1:2;
-
- /* SRC_MSK_DIRECT_REG [4:5] (mask) */
- enum e_g2d_dir_mode mask_x_direction:1;
- enum e_g2d_dir_mode mask_y_direction:1;
-
- /* SRC_MSK_DIRECT_REG [6:31] */
- unsigned int padding1:26;
-
- /* DST_PAT_DIRECT_REG [0:1] (destination) */
- enum e_g2d_dir_mode dst_x_direction:1;
- enum e_g2d_dir_mode dst_y_direction:1;
-
- /* DST_PAT_DIRECT_REG [2:3] */
- unsigned int reversed2:2;
-
- /* DST_PAT_DIRECT_REG [4:5] (pattern) */
- enum e_g2d_dir_mode pat_x_direction:1;
- enum e_g2d_dir_mode pat_y_direction:1;
-
- /* DST_PAT_DIRECT_REG [6:31] */
- unsigned int padding2:26;
- } data;
-};
-
static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
{
/*
@@ -280,19 +241,6 @@ static void g2d_add_base_addr(struct g2d_context *ctx, struct g2d_image *img,
}
/*
- * g2d_set_direction - setup direction register (useful for overlapping blits).
- *
- * @ctx: a pointer to g2d_context structure.
- * @dir: a pointer to the g2d_direction_val structure.
- */
-static void g2d_set_direction(struct g2d_context *ctx,
- const union g2d_direction_val *dir)
-{
- g2d_add_cmd(ctx, SRC_MASK_DIRECT_REG, dir->val[0]);
- g2d_add_cmd(ctx, DST_PAT_DIRECT_REG, dir->val[1]);
-}
-
-/*
* g2d_reset - reset fimg2d hardware.
*
* @ctx: a pointer to g2d_context structure.
@@ -332,15 +280,8 @@ static int g2d_flush(struct g2d_context *ctx)
cmdlist.cmd_buf = (uint64_t)(uintptr_t)&ctx->cmd_buf[0];
cmdlist.cmd_nr = ctx->cmd_nr;
cmdlist.cmd_buf_nr = ctx->cmd_buf_nr;
-
- if (ctx->event_userdata) {
- cmdlist.event_type = G2D_EVENT_NONSTOP;
- cmdlist.user_data = (uint64_t)(uintptr_t)(ctx->event_userdata);
- ctx->event_userdata = NULL;
- } else {
- cmdlist.event_type = G2D_EVENT_NOT;
- cmdlist.user_data = 0;
- }
+ cmdlist.event_type = G2D_EVENT_NOT;
+ cmdlist.user_data = 0;
ctx->cmd_nr = 0;
ctx->cmd_buf_nr = 0;
@@ -395,22 +336,6 @@ void g2d_fini(struct g2d_context *ctx)
}
/**
- * g2d_config_event - setup userdata configuration for a g2d event.
- * The next invocation of a g2d call (e.g. g2d_solid_fill) is
- * then going to flag the command buffer as 'nonstop'.
- * Completion of the command buffer execution can then be
- * determined by using drmHandleEvent on the DRM fd.
- * The userdata is 'consumed' in the process.
- *
- * @ctx: a pointer to g2d_context structure.
- * @userdata: a pointer to the user data
- */
-void g2d_config_event(struct g2d_context *ctx, void *userdata)
-{
- ctx->event_userdata = userdata;
-}
-
-/**
* g2d_exec - start the dma to process all commands summited by g2d_flush().
*
* @ctx: a pointer to g2d_context structure.
@@ -567,101 +492,6 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
}
/**
- * g2d_move - copy content inside single buffer.
- * Similar to libc's memmove() this copies a rectangular
- * region of the provided buffer to another location, while
- * properly handling the situation where source and
- * destination rectangle overlap.
- *
- * @ctx: a pointer to g2d_context structure.
- * @img: a pointer to g2d_image structure providing
- * buffer information.
- * @src_x: x position of source rectangle.
- * @src_y: y position of source rectangle.
- * @dst_x: x position of destination rectangle.
- * @dst_y: y position of destination rectangle.
- * @w: width of rectangle to move.
- * @h: height of rectangle to move.
- */
-int
-g2d_move(struct g2d_context *ctx, struct g2d_image *img,
- unsigned int src_x, unsigned int src_y,
- unsigned int dst_x, unsigned dst_y, unsigned int w,
- unsigned int h)
-{
- union g2d_rop4_val rop4;
- union g2d_point_val pt;
- union g2d_direction_val dir;
- unsigned int src_w, src_h, dst_w, dst_h;
-
- src_w = w;
- src_h = h;
- if (src_x + img->width > w)
- src_w = img->width - src_x;
- if (src_y + img->height > h)
- src_h = img->height - src_y;
-
- dst_w = w;
- dst_h = w;
- if (dst_x + img->width > w)
- dst_w = img->width - dst_x;
- if (dst_y + img->height > h)
- dst_h = img->height - dst_y;
-
- w = MIN(src_w, dst_w);
- h = MIN(src_h, dst_h);
-
- if (w == 0 || h == 0) {
- fprintf(stderr, MSG_PREFIX "invalid width or height.\n");
- return -EINVAL;
- }
-
- if (g2d_check_space(ctx, 13, 2))
- return -ENOSPC;
-
- g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
- g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
-
- g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img->color_mode);
- g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, img->color_mode);
-
- g2d_add_base_addr(ctx, img, g2d_dst);
- g2d_add_base_addr(ctx, img, g2d_src);
-
- g2d_add_cmd(ctx, DST_STRIDE_REG, img->stride);
- g2d_add_cmd(ctx, SRC_STRIDE_REG, img->stride);
-
- dir.val[0] = dir.val[1] = 0;
-
- if (dst_x >= src_x)
- dir.data.src_x_direction = dir.data.dst_x_direction = 1;
- if (dst_y >= src_y)
- dir.data.src_y_direction = dir.data.dst_y_direction = 1;
-
- g2d_set_direction(ctx, &dir);
-
- pt.data.x = src_x;
- pt.data.y = src_y;
- g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
- pt.data.x = src_x + w;
- pt.data.y = src_y + h;
- g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
-
- pt.data.x = dst_x;
- pt.data.y = dst_y;
- g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
- pt.data.x = dst_x + w;
- pt.data.y = dst_y + h;
- g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
-
- rop4.val = 0;
- rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
- g2d_add_cmd(ctx, ROP4_REG, rop4.val);
-
- return g2d_flush(ctx);
-}
-
-/**
* g2d_copy_with_scale - copy contents in source buffer to destination buffer
* scaling up or down properly.
*
diff --git a/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.h b/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.h
index a825c6831b3..4aa156830ec 100644
--- a/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.h
+++ b/chromium/third_party/libdrm/src/exynos/exynos_fimg2d.h
@@ -290,7 +290,6 @@ struct g2d_context;
struct g2d_context *g2d_init(int fd);
void g2d_fini(struct g2d_context *ctx);
-void g2d_config_event(struct g2d_context *ctx, void *userdata);
int g2d_exec(struct g2d_context *ctx);
int g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img,
unsigned int x, unsigned int y, unsigned int w,
@@ -299,9 +298,6 @@ int g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
struct g2d_image *dst, unsigned int src_x,
unsigned int src_y, unsigned int dst_x, unsigned int dst_y,
unsigned int w, unsigned int h);
-int g2d_move(struct g2d_context *ctx, struct g2d_image *img,
- unsigned int src_x, unsigned int src_y, unsigned int dst_x,
- unsigned dst_y, unsigned int w, unsigned int h);
int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
struct g2d_image *dst, unsigned int src_x,
unsigned int src_y, unsigned int src_w,
diff --git a/chromium/third_party/libdrm/src/exynos/libdrm_exynos.pc.in b/chromium/third_party/libdrm/src/exynos/libdrm_exynos.pc.in
index ff1c43203d0..5ce911866fb 100644
--- a/chromium/third_party/libdrm/src/exynos/libdrm_exynos.pc.in
+++ b/chromium/third_party/libdrm/src/exynos/libdrm_exynos.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
Name: libdrm_exynos
Description: Userspace interface to exynos kernel DRM services
-Version: 0.7
+Version: 0.6
Libs: -L${libdir} -ldrm_exynos
Cflags: -I${includedir} -I${includedir}/libdrm -I${includedir}/exynos
Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/freedreno/Android.mk b/chromium/third_party/libdrm/src/freedreno/Android.mk
index fba48f2f087..2645f7375a4 100644
--- a/chromium/third_party/libdrm/src/freedreno/Android.mk
+++ b/chromium/third_party/libdrm/src/freedreno/Android.mk
@@ -9,7 +9,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libdrm
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_FREEDRENO_FILES))
+LOCAL_SRC_FILES := $(LIBDRM_FREEDRENO_FILES)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_CFLAGS := \
diff --git a/chromium/third_party/libdrm/src/freedreno/Makefile.am b/chromium/third_party/libdrm/src/freedreno/Makefile.am
index 0771d146b95..9b7ec7df9d0 100644
--- a/chromium/third_party/libdrm/src/freedreno/Makefile.am
+++ b/chromium/third_party/libdrm/src/freedreno/Makefile.am
@@ -27,4 +27,4 @@ pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libdrm_freedreno.pc
TESTS = freedreno-symbol-check
-EXTRA_DIST = $(TESTS)
+EXTRA_DIST = Android.mk $(TESTS)
diff --git a/chromium/third_party/libdrm/src/freedreno/Makefile.sources b/chromium/third_party/libdrm/src/freedreno/Makefile.sources
index 68a679bf631..57a8bf1b96e 100644
--- a/chromium/third_party/libdrm/src/freedreno/Makefile.sources
+++ b/chromium/third_party/libdrm/src/freedreno/Makefile.sources
@@ -4,7 +4,6 @@ LIBDRM_FREEDRENO_FILES := \
freedreno_priv.h \
freedreno_ringbuffer.c \
freedreno_bo.c \
- freedreno_bo_cache.c \
msm/msm_bo.c \
msm/msm_device.c \
msm/msm_drm.h \
diff --git a/chromium/third_party/libdrm/src/freedreno/kgsl/README b/chromium/third_party/libdrm/src/freedreno/README
index 56874b42ff2..ae22e013952 100644
--- a/chromium/third_party/libdrm/src/freedreno/kgsl/README
+++ b/chromium/third_party/libdrm/src/freedreno/README
@@ -1,13 +1,3 @@
-This is a historical discription of what is now the kgsl backend
-in libdrm freedreno (before the upstream drm/msm driver). Note
-that the kgsl backend requires the "kgsl-drm" shim driver, which
-usually is in disrepair (QCOM does not build it for android), and
-due to random differences between different downstream android
-kernel branches it may or may not work. So YMMV.
-
-Original README:
-----------------
-
Note that current msm kernel driver is a bit strange. It provides a
DRM interface for GEM, which is basically sufficient to have DRI2
working. But it does not provide KMS. And interface to 2d and 3d
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno-symbol-check b/chromium/third_party/libdrm/src/freedreno/freedreno-symbol-check
index 7b31a347001..f517b6e71cc 100755
--- a/chromium/third_party/libdrm/src/freedreno/freedreno-symbol-check
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno-symbol-check
@@ -29,18 +29,14 @@ fd_device_fd
fd_device_new
fd_device_new_dup
fd_device_ref
-fd_device_version
fd_pipe_del
fd_pipe_get_param
fd_pipe_new
fd_pipe_wait
fd_pipe_wait_timeout
-fd_ringbuffer_cmd_count
fd_ringbuffer_del
fd_ringbuffer_emit_reloc_ring
-fd_ringbuffer_emit_reloc_ring_full
fd_ringbuffer_flush
-fd_ringbuffer_grow
fd_ringbuffer_new
fd_ringbuffer_reloc
fd_ringbuffer_reset
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_bo.c b/chromium/third_party/libdrm/src/freedreno/freedreno_bo.c
index 996d6b95c0c..a23c65d060a 100644
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_bo.c
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno_bo.c
@@ -33,8 +33,9 @@
#include "freedreno_drmif.h"
#include "freedreno_priv.h"
-drm_private pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER;
-drm_private void bo_del(struct fd_bo *bo);
+static pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static void bo_del(struct fd_bo *bo);
/* set buffer name, and add to table, call w/ table_lock held: */
static void set_name(struct fd_bo *bo, uint32_t name)
@@ -82,16 +83,114 @@ static struct fd_bo * bo_from_handle(struct fd_device *dev,
return bo;
}
+/* Frees older cached buffers. Called under table_lock */
+drm_private void fd_cleanup_bo_cache(struct fd_device *dev, time_t time)
+{
+ int i;
+
+ if (dev->time == time)
+ return;
+
+ for (i = 0; i < dev->num_buckets; i++) {
+ struct fd_bo_bucket *bucket = &dev->cache_bucket[i];
+ struct fd_bo *bo;
+
+ while (!LIST_IS_EMPTY(&bucket->list)) {
+ bo = LIST_ENTRY(struct fd_bo, bucket->list.next, list);
+
+ /* keep things in cache for at least 1 second: */
+ if (time && ((time - bo->free_time) <= 1))
+ break;
+
+ list_del(&bo->list);
+ bo_del(bo);
+ }
+ }
+
+ dev->time = time;
+}
+
+static struct fd_bo_bucket * get_bucket(struct fd_device *dev, uint32_t size)
+{
+ int i;
+
+ /* hmm, this is what intel does, but I suppose we could calculate our
+ * way to the correct bucket size rather than looping..
+ */
+ for (i = 0; i < dev->num_buckets; i++) {
+ struct fd_bo_bucket *bucket = &dev->cache_bucket[i];
+ if (bucket->size >= size) {
+ return bucket;
+ }
+ }
+
+ return NULL;
+}
+
+static int is_idle(struct fd_bo *bo)
+{
+ return fd_bo_cpu_prep(bo, NULL,
+ DRM_FREEDRENO_PREP_READ |
+ DRM_FREEDRENO_PREP_WRITE |
+ DRM_FREEDRENO_PREP_NOSYNC) == 0;
+}
+
+static struct fd_bo *find_in_bucket(struct fd_device *dev,
+ struct fd_bo_bucket *bucket, uint32_t flags)
+{
+ struct fd_bo *bo = NULL;
+
+ /* TODO .. if we had an ALLOC_FOR_RENDER flag like intel, we could
+ * skip the busy check.. if it is only going to be a render target
+ * then we probably don't need to stall..
+ *
+ * NOTE that intel takes ALLOC_FOR_RENDER bo's from the list tail
+ * (MRU, since likely to be in GPU cache), rather than head (LRU)..
+ */
+ pthread_mutex_lock(&table_lock);
+ while (!LIST_IS_EMPTY(&bucket->list)) {
+ bo = LIST_ENTRY(struct fd_bo, bucket->list.next, list);
+ if (0 /* TODO: if madvise tells us bo is gone... */) {
+ list_del(&bo->list);
+ bo_del(bo);
+ bo = NULL;
+ continue;
+ }
+ /* TODO check for compatible flags? */
+ if (is_idle(bo)) {
+ list_del(&bo->list);
+ break;
+ }
+ bo = NULL;
+ break;
+ }
+ pthread_mutex_unlock(&table_lock);
+
+ return bo;
+}
+
+
struct fd_bo *
fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags)
{
struct fd_bo *bo = NULL;
+ struct fd_bo_bucket *bucket;
uint32_t handle;
int ret;
- bo = fd_bo_cache_alloc(&dev->bo_cache, &size, flags);
- if (bo)
- return bo;
+ size = ALIGN(size, 4096);
+ bucket = get_bucket(dev, size);
+
+ /* see if we can be green and recycle: */
+ if (bucket) {
+ size = bucket->size;
+ bo = find_in_bucket(dev, bucket, flags);
+ if (bo) {
+ atomic_set(&bo->refcnt, 1);
+ fd_device_ref(bo->dev);
+ return bo;
+ }
+ }
ret = dev->funcs->bo_new_handle(dev, size, flags, &handle);
if (ret)
@@ -99,7 +198,7 @@ fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags)
pthread_mutex_lock(&table_lock);
bo = bo_from_handle(dev, size, handle);
- bo->bo_reuse = TRUE;
+ bo->bo_reuse = 1;
pthread_mutex_unlock(&table_lock);
return bo;
@@ -201,17 +300,35 @@ void fd_bo_del(struct fd_bo *bo)
pthread_mutex_lock(&table_lock);
- if (bo->bo_reuse && (fd_bo_cache_free(&dev->bo_cache, bo) == 0))
- goto out;
+ if (bo->bo_reuse) {
+ struct fd_bo_bucket *bucket = get_bucket(dev, bo->size);
+
+ /* see if we can be green and recycle: */
+ if (bucket) {
+ struct timespec time;
+
+ clock_gettime(CLOCK_MONOTONIC, &time);
+
+ bo->free_time = time.tv_sec;
+ list_addtail(&bo->list, &bucket->list);
+ fd_cleanup_bo_cache(dev, time.tv_sec);
+
+ /* bo's in the bucket cache don't have a ref and
+ * don't hold a ref to the dev:
+ */
+
+ goto out;
+ }
+ }
bo_del(bo);
- fd_device_del_locked(dev);
out:
+ fd_device_del_locked(dev);
pthread_mutex_unlock(&table_lock);
}
/* Called under table_lock */
-drm_private void bo_del(struct fd_bo *bo)
+static void bo_del(struct fd_bo *bo)
{
if (bo->map)
drm_munmap(bo->map, bo->size);
@@ -249,7 +366,7 @@ int fd_bo_get_name(struct fd_bo *bo, uint32_t *name)
pthread_mutex_lock(&table_lock);
set_name(bo, req.name);
pthread_mutex_unlock(&table_lock);
- bo->bo_reuse = FALSE;
+ bo->bo_reuse = 0;
}
*name = bo->name;
@@ -273,7 +390,7 @@ int fd_bo_dmabuf(struct fd_bo *bo)
return ret;
}
- bo->bo_reuse = FALSE;
+ bo->bo_reuse = 0;
return prime_fd;
}
@@ -314,10 +431,3 @@ void fd_bo_cpu_fini(struct fd_bo *bo)
{
bo->funcs->cpu_fini(bo);
}
-
-#ifndef HAVE_FREEDRENO_KGSL
-struct fd_bo * fd_bo_from_fbdev(struct fd_pipe *pipe, int fbfd, uint32_t size)
-{
- return NULL;
-}
-#endif
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_bo_cache.c b/chromium/third_party/libdrm/src/freedreno/freedreno_bo_cache.c
deleted file mode 100644
index 7becb0d6410..00000000000
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_bo_cache.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
-
-/*
- * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Authors:
- * Rob Clark <robclark@freedesktop.org>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "freedreno_drmif.h"
-#include "freedreno_priv.h"
-
-
-drm_private void bo_del(struct fd_bo *bo);
-drm_private extern pthread_mutex_t table_lock;
-
-static void
-add_bucket(struct fd_bo_cache *cache, int size)
-{
- unsigned int i = cache->num_buckets;
-
- assert(i < ARRAY_SIZE(cache->cache_bucket));
-
- list_inithead(&cache->cache_bucket[i].list);
- cache->cache_bucket[i].size = size;
- cache->num_buckets++;
-}
-
-/**
- * @coarse: if true, only power-of-two bucket sizes, otherwise
- * fill in for a bit smoother size curve..
- */
-drm_private void
-fd_bo_cache_init(struct fd_bo_cache *cache, int course)
-{
- unsigned long size, cache_max_size = 64 * 1024 * 1024;
-
- /* OK, so power of two buckets was too wasteful of memory.
- * Give 3 other sizes between each power of two, to hopefully
- * cover things accurately enough. (The alternative is
- * probably to just go for exact matching of sizes, and assume
- * that for things like composited window resize the tiled
- * width/height alignment and rounding of sizes to pages will
- * get us useful cache hit rates anyway)
- */
- add_bucket(cache, 4096);
- add_bucket(cache, 4096 * 2);
- if (!course)
- add_bucket(cache, 4096 * 3);
-
- /* Initialize the linked lists for BO reuse cache. */
- for (size = 4 * 4096; size <= cache_max_size; size *= 2) {
- add_bucket(cache, size);
- if (!course) {
- add_bucket(cache, size + size * 1 / 4);
- add_bucket(cache, size + size * 2 / 4);
- add_bucket(cache, size + size * 3 / 4);
- }
- }
-}
-
-/* Frees older cached buffers. Called under table_lock */
-drm_private void
-fd_bo_cache_cleanup(struct fd_bo_cache *cache, time_t time)
-{
- int i;
-
- if (cache->time == time)
- return;
-
- for (i = 0; i < cache->num_buckets; i++) {
- struct fd_bo_bucket *bucket = &cache->cache_bucket[i];
- struct fd_bo *bo;
-
- while (!LIST_IS_EMPTY(&bucket->list)) {
- bo = LIST_ENTRY(struct fd_bo, bucket->list.next, list);
-
- /* keep things in cache for at least 1 second: */
- if (time && ((time - bo->free_time) <= 1))
- break;
-
- list_del(&bo->list);
- bo_del(bo);
- }
- }
-
- cache->time = time;
-}
-
-static struct fd_bo_bucket * get_bucket(struct fd_bo_cache *cache, uint32_t size)
-{
- int i;
-
- /* hmm, this is what intel does, but I suppose we could calculate our
- * way to the correct bucket size rather than looping..
- */
- for (i = 0; i < cache->num_buckets; i++) {
- struct fd_bo_bucket *bucket = &cache->cache_bucket[i];
- if (bucket->size >= size) {
- return bucket;
- }
- }
-
- return NULL;
-}
-
-static int is_idle(struct fd_bo *bo)
-{
- return fd_bo_cpu_prep(bo, NULL,
- DRM_FREEDRENO_PREP_READ |
- DRM_FREEDRENO_PREP_WRITE |
- DRM_FREEDRENO_PREP_NOSYNC) == 0;
-}
-
-static struct fd_bo *find_in_bucket(struct fd_bo_bucket *bucket, uint32_t flags)
-{
- struct fd_bo *bo = NULL;
-
- /* TODO .. if we had an ALLOC_FOR_RENDER flag like intel, we could
- * skip the busy check.. if it is only going to be a render target
- * then we probably don't need to stall..
- *
- * NOTE that intel takes ALLOC_FOR_RENDER bo's from the list tail
- * (MRU, since likely to be in GPU cache), rather than head (LRU)..
- */
- pthread_mutex_lock(&table_lock);
- if (!LIST_IS_EMPTY(&bucket->list)) {
- bo = LIST_ENTRY(struct fd_bo, bucket->list.next, list);
- /* TODO check for compatible flags? */
- if (is_idle(bo)) {
- list_del(&bo->list);
- } else {
- bo = NULL;
- }
- }
- pthread_mutex_unlock(&table_lock);
-
- return bo;
-}
-
-/* NOTE: size is potentially rounded up to bucket size: */
-drm_private struct fd_bo *
-fd_bo_cache_alloc(struct fd_bo_cache *cache, uint32_t *size, uint32_t flags)
-{
- struct fd_bo *bo = NULL;
- struct fd_bo_bucket *bucket;
-
- *size = ALIGN(*size, 4096);
- bucket = get_bucket(cache, *size);
-
- /* see if we can be green and recycle: */
-retry:
- if (bucket) {
- *size = bucket->size;
- bo = find_in_bucket(bucket, flags);
- if (bo) {
- if (bo->funcs->madvise(bo, TRUE) <= 0) {
- /* we've lost the backing pages, delete and try again: */
- pthread_mutex_lock(&table_lock);
- bo_del(bo);
- pthread_mutex_unlock(&table_lock);
- goto retry;
- }
- atomic_set(&bo->refcnt, 1);
- fd_device_ref(bo->dev);
- return bo;
- }
- }
-
- return NULL;
-}
-
-drm_private int
-fd_bo_cache_free(struct fd_bo_cache *cache, struct fd_bo *bo)
-{
- struct fd_bo_bucket *bucket = get_bucket(cache, bo->size);
-
- /* see if we can be green and recycle: */
- if (bucket) {
- struct timespec time;
-
- bo->funcs->madvise(bo, FALSE);
-
- clock_gettime(CLOCK_MONOTONIC, &time);
-
- bo->free_time = time.tv_sec;
- list_addtail(&bo->list, &bucket->list);
- fd_bo_cache_cleanup(cache, time.tv_sec);
-
- /* bo's in the bucket cache don't have a ref and
- * don't hold a ref to the dev:
- */
- fd_device_del_locked(bo->dev);
-
- return 0;
- }
-
- return -1;
-}
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_device.c b/chromium/third_party/libdrm/src/freedreno/freedreno_device.c
index fcbf1402ad6..ddb95455149 100644
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_device.c
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno_device.c
@@ -42,6 +42,44 @@ static pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER;
struct fd_device * kgsl_device_new(int fd);
struct fd_device * msm_device_new(int fd);
+static void
+add_bucket(struct fd_device *dev, int size)
+{
+ unsigned int i = dev->num_buckets;
+
+ assert(i < ARRAY_SIZE(dev->cache_bucket));
+
+ list_inithead(&dev->cache_bucket[i].list);
+ dev->cache_bucket[i].size = size;
+ dev->num_buckets++;
+}
+
+static void
+init_cache_buckets(struct fd_device *dev)
+{
+ unsigned long size, cache_max_size = 64 * 1024 * 1024;
+
+ /* OK, so power of two buckets was too wasteful of memory.
+ * Give 3 other sizes between each power of two, to hopefully
+ * cover things accurately enough. (The alternative is
+ * probably to just go for exact matching of sizes, and assume
+ * that for things like composited window resize the tiled
+ * width/height alignment and rounding of sizes to pages will
+ * get us useful cache hit rates anyway)
+ */
+ add_bucket(dev, 4096);
+ add_bucket(dev, 4096 * 2);
+ add_bucket(dev, 4096 * 3);
+
+ /* Initialize the linked lists for BO reuse cache. */
+ for (size = 4 * 4096; size <= cache_max_size; size *= 2) {
+ add_bucket(dev, size);
+ add_bucket(dev, size + size * 1 / 4);
+ add_bucket(dev, size + size * 2 / 4);
+ add_bucket(dev, size + size * 3 / 4);
+ }
+}
+
struct fd_device * fd_device_new(int fd)
{
struct fd_device *dev;
@@ -56,15 +94,7 @@ struct fd_device * fd_device_new(int fd)
if (!strcmp(version->name, "msm")) {
DEBUG_MSG("msm DRM device");
- if (version->version_major != 1) {
- ERROR_MSG("unsupported version: %u.%u.%u", version->version_major,
- version->version_minor, version->version_patchlevel);
- dev = NULL;
- goto out;
- }
-
dev = msm_device_new(fd);
- dev->version = version->version_minor;
#ifdef HAVE_FREEDRENO_KGSL
} else if (!strcmp(version->name, "kgsl")) {
DEBUG_MSG("kgsl DRM device");
@@ -74,8 +104,6 @@ struct fd_device * fd_device_new(int fd)
ERROR_MSG("unknown device: %s", version->name);
dev = NULL;
}
-
-out:
drmFreeVersion(version);
if (!dev)
@@ -85,7 +113,7 @@ out:
dev->fd = fd;
dev->handle_table = drmHashCreate();
dev->name_table = drmHashCreate();
- fd_bo_cache_init(&dev->bo_cache, FALSE);
+ init_cache_buckets(dev);
return dev;
}
@@ -95,12 +123,9 @@ out:
*/
struct fd_device * fd_device_new_dup(int fd)
{
- int dup_fd = dup(fd);
- struct fd_device *dev = fd_device_new(dup_fd);
+ struct fd_device *dev = fd_device_new(dup(fd));
if (dev)
dev->closefd = 1;
- else
- close(dup_fd);
return dev;
}
@@ -112,7 +137,7 @@ struct fd_device * fd_device_ref(struct fd_device *dev)
static void fd_device_del_impl(struct fd_device *dev)
{
- fd_bo_cache_cleanup(&dev->bo_cache, 0);
+ fd_cleanup_bo_cache(dev, 0);
drmHashDestroy(dev->handle_table);
drmHashDestroy(dev->name_table);
if (dev->closefd)
@@ -140,8 +165,3 @@ int fd_device_fd(struct fd_device *dev)
{
return dev->fd;
}
-
-enum fd_version fd_device_version(struct fd_device *dev)
-{
- return dev->version;
-}
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_drmif.h b/chromium/third_party/libdrm/src/freedreno/freedreno_drmif.h
index 2d913e6ca7f..5547e9439b0 100644
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_drmif.h
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno_drmif.h
@@ -32,15 +32,6 @@
#include <xf86drm.h>
#include <stdint.h>
-#if defined(__GNUC__)
-# define drm_deprecated __attribute__((__deprecated__))
-#else
-# define drm_deprecated
-#endif
-
-/* an empty marker for things that will be deprecated in the future: */
-#define will_be_deprecated
-
struct fd_bo;
struct fd_pipe;
struct fd_device;
@@ -59,8 +50,6 @@ enum fd_param_id {
FD_GMEM_SIZE,
FD_GPU_ID,
FD_CHIP_ID,
- FD_MAX_FREQ,
- FD_TIMESTAMP,
};
/* bo flags: */
@@ -89,11 +78,6 @@ struct fd_device * fd_device_ref(struct fd_device *dev);
void fd_device_del(struct fd_device *dev);
int fd_device_fd(struct fd_device *dev);
-enum fd_version {
- FD_VERSION_MADVISE = 1, /* kernel supports madvise */
- FD_VERSION_UNLIMITED_CMDS = 1, /* submits w/ >4 cmd buffers (growable ringbuffer) */
-};
-enum fd_version fd_device_version(struct fd_device *dev);
/* pipe functions:
*/
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_priv.h b/chromium/third_party/libdrm/src/freedreno/freedreno_priv.h
index cdfdbe8dbd7..53817b1977e 100644
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_priv.h
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno_priv.h
@@ -54,13 +54,6 @@
#include "freedreno_ringbuffer.h"
#include "drm.h"
-#ifndef TRUE
-# define TRUE 1
-#endif
-#ifndef FALSE
-# define FALSE 0
-#endif
-
struct fd_device_funcs {
int (*bo_new_handle)(struct fd_device *dev, uint32_t size,
uint32_t flags, uint32_t *handle);
@@ -75,15 +68,8 @@ struct fd_bo_bucket {
struct list_head list;
};
-struct fd_bo_cache {
- struct fd_bo_bucket cache_bucket[14 * 4];
- int num_buckets;
- time_t time;
-};
-
struct fd_device {
int fd;
- enum fd_version version;
atomic_t refcnt;
/* tables to keep track of bo's, to avoid "evil-twin" fd_bo objects:
@@ -99,16 +85,14 @@ struct fd_device {
const struct fd_device_funcs *funcs;
- struct fd_bo_cache bo_cache;
+ struct fd_bo_bucket cache_bucket[14 * 4];
+ int num_buckets;
+ time_t time;
int closefd; /* call close(fd) upon destruction */
};
-drm_private void fd_bo_cache_init(struct fd_bo_cache *cache, int coarse);
-drm_private void fd_bo_cache_cleanup(struct fd_bo_cache *cache, time_t time);
-drm_private struct fd_bo * fd_bo_cache_alloc(struct fd_bo_cache *cache,
- uint32_t *size, uint32_t flags);
-drm_private int fd_bo_cache_free(struct fd_bo_cache *cache, struct fd_bo *bo);
+drm_private void fd_cleanup_bo_cache(struct fd_device *dev, time_t time);
/* for where @table_lock is already held: */
drm_private void fd_device_del_locked(struct fd_device *dev);
@@ -134,14 +118,11 @@ struct fd_ringmarker {
struct fd_ringbuffer_funcs {
void * (*hostptr)(struct fd_ringbuffer *ring);
int (*flush)(struct fd_ringbuffer *ring, uint32_t *last_start);
- void (*grow)(struct fd_ringbuffer *ring, uint32_t size);
void (*reset)(struct fd_ringbuffer *ring);
void (*emit_reloc)(struct fd_ringbuffer *ring,
const struct fd_reloc *reloc);
- uint32_t (*emit_reloc_ring)(struct fd_ringbuffer *ring,
- struct fd_ringbuffer *target, uint32_t cmd_idx,
- uint32_t submit_offset, uint32_t size);
- uint32_t (*cmd_count)(struct fd_ringbuffer *ring);
+ void (*emit_reloc_ring)(struct fd_ringbuffer *ring,
+ struct fd_ringmarker *target, struct fd_ringmarker *end);
void (*destroy)(struct fd_ringbuffer *ring);
};
@@ -149,7 +130,6 @@ struct fd_bo_funcs {
int (*offset)(struct fd_bo *bo, uint64_t *offset);
int (*cpu_prep)(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op);
void (*cpu_fini)(struct fd_bo *bo);
- int (*madvise)(struct fd_bo *bo, int willneed);
void (*destroy)(struct fd_bo *bo);
};
@@ -188,10 +168,4 @@ struct fd_bo {
#define U642VOID(x) ((void *)(unsigned long)(x))
#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
-static inline uint32_t
-offset_bytes(void *end, void *start)
-{
- return ((char *)end) - ((char *)start);
-}
-
#endif /* FREEDRENO_PRIV_H_ */
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.c b/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.c
index 22dafb394f2..984da241c89 100644
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.c
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.c
@@ -45,9 +45,10 @@ fd_ringbuffer_new(struct fd_pipe *pipe, uint32_t size)
if (!ring)
return NULL;
+ ring->size = size;
ring->pipe = pipe;
ring->start = ring->funcs->hostptr(ring);
- ring->end = &(ring->start[ring->size/4]);
+ ring->end = &(ring->start[size/4]);
ring->cur = ring->last_start = ring->start;
@@ -56,7 +57,6 @@ fd_ringbuffer_new(struct fd_pipe *pipe, uint32_t size)
void fd_ringbuffer_del(struct fd_ringbuffer *ring)
{
- fd_ringbuffer_reset(ring);
ring->funcs->destroy(ring);
}
@@ -86,22 +86,6 @@ int fd_ringbuffer_flush(struct fd_ringbuffer *ring)
return ring->funcs->flush(ring, ring->last_start);
}
-void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords)
-{
- assert(ring->funcs->grow); /* unsupported on kgsl */
-
- /* there is an upper bound on IB size, which appears to be 0x100000 */
- if (ring->size < 0x100000)
- ring->size *= 2;
-
- ring->funcs->grow(ring, ring->size);
-
- ring->start = ring->funcs->hostptr(ring);
- ring->end = &(ring->start[ring->size/4]);
-
- ring->cur = ring->last_start = ring->start;
-}
-
uint32_t fd_ringbuffer_timestamp(struct fd_ringbuffer *ring)
{
return ring->last_timestamp;
@@ -113,32 +97,13 @@ void fd_ringbuffer_reloc(struct fd_ringbuffer *ring,
ring->funcs->emit_reloc(ring, reloc);
}
-void fd_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
- struct fd_ringmarker *target, struct fd_ringmarker *end)
+void
+fd_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
+ struct fd_ringmarker *target,
+ struct fd_ringmarker *end)
{
- uint32_t submit_offset, size;
-
assert(target->ring == end->ring);
-
- submit_offset = offset_bytes(target->cur, target->ring->start);
- size = offset_bytes(end->cur, target->cur);
-
- ring->funcs->emit_reloc_ring(ring, target->ring, 0, submit_offset, size);
-}
-
-uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring)
-{
- if (!ring->funcs->cmd_count)
- return 1;
- return ring->funcs->cmd_count(ring);
-}
-
-uint32_t
-fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring,
- struct fd_ringbuffer *target, uint32_t cmd_idx)
-{
- uint32_t size = offset_bytes(target->cur, target->start);
- return ring->funcs->emit_reloc_ring(ring, target, cmd_idx, 0, size);
+ ring->funcs->emit_reloc_ring(ring, target, end);
}
struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring)
@@ -153,7 +118,7 @@ struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring)
marker->ring = ring;
- marker->cur = marker->ring->cur;
+ fd_ringmarker_mark(marker);
return marker;
}
diff --git a/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.h b/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.h
index 8899b5de4a0..578cdb243cf 100644
--- a/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.h
+++ b/chromium/third_party/libdrm/src/freedreno/freedreno_ringbuffer.h
@@ -56,7 +56,6 @@ void fd_ringbuffer_set_parent(struct fd_ringbuffer *ring,
struct fd_ringbuffer *parent);
void fd_ringbuffer_reset(struct fd_ringbuffer *ring);
int fd_ringbuffer_flush(struct fd_ringbuffer *ring);
-void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords);
uint32_t fd_ringbuffer_timestamp(struct fd_ringbuffer *ring);
static inline void fd_ringbuffer_emit(struct fd_ringbuffer *ring,
@@ -76,17 +75,14 @@ struct fd_reloc {
};
void fd_ringbuffer_reloc(struct fd_ringbuffer *ring, const struct fd_reloc *reloc);
-will_be_deprecated void fd_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
+void fd_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
struct fd_ringmarker *target, struct fd_ringmarker *end);
-uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring);
-uint32_t fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring,
- struct fd_ringbuffer *target, uint32_t cmd_idx);
-will_be_deprecated struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring);
-will_be_deprecated void fd_ringmarker_del(struct fd_ringmarker *marker);
-will_be_deprecated void fd_ringmarker_mark(struct fd_ringmarker *marker);
-will_be_deprecated uint32_t fd_ringmarker_dwords(struct fd_ringmarker *start,
+struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring);
+void fd_ringmarker_del(struct fd_ringmarker *marker);
+void fd_ringmarker_mark(struct fd_ringmarker *marker);
+uint32_t fd_ringmarker_dwords(struct fd_ringmarker *start,
struct fd_ringmarker *end);
-will_be_deprecated int fd_ringmarker_flush(struct fd_ringmarker *marker);
+int fd_ringmarker_flush(struct fd_ringmarker *marker);
#endif /* FREEDRENO_RINGBUFFER_H_ */
diff --git a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_bo.c b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_bo.c
index ab3485e36b1..2b45b5e20c4 100644
--- a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_bo.c
+++ b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_bo.c
@@ -116,11 +116,6 @@ static void kgsl_bo_cpu_fini(struct fd_bo *bo)
{
}
-static int kgsl_bo_madvise(struct fd_bo *bo, int willneed)
-{
- return willneed; /* not supported by kgsl */
-}
-
static void kgsl_bo_destroy(struct fd_bo *bo)
{
struct kgsl_bo *kgsl_bo = to_kgsl_bo(bo);
@@ -132,7 +127,6 @@ static const struct fd_bo_funcs funcs = {
.offset = kgsl_bo_offset,
.cpu_prep = kgsl_bo_cpu_prep,
.cpu_fini = kgsl_bo_cpu_fini,
- .madvise = kgsl_bo_madvise,
.destroy = kgsl_bo_destroy,
};
diff --git a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_drm.h b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_drm.h
index 281978ea3fc..f1c7f4e22f3 100644
--- a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_drm.h
+++ b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_drm.h
@@ -81,7 +81,7 @@ struct drm_kgsl_gem_create_fd)
/* Memory types - these define the source and caching policies
of the GEM memory chunk */
-/* Legacy definitions left for compatibility */
+/* Legacy definitions left for compatability */
#define DRM_KGSL_GEM_TYPE_EBI 0
#define DRM_KGSL_GEM_TYPE_SMI 1
diff --git a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_pipe.c b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_pipe.c
index 3546718db2e..58b3b4d50e5 100644
--- a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_pipe.c
+++ b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_pipe.c
@@ -50,10 +50,6 @@ static int kgsl_pipe_get_param(struct fd_pipe *pipe,
case FD_CHIP_ID:
*value = kgsl_pipe->devinfo.chip_id;
return 0;
- case FD_MAX_FREQ:
- case FD_TIMESTAMP:
- /* unsupported on kgsl */
- return -1;
default:
ERROR_MSG("invalid param id: %d", param);
return -1;
diff --git a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_ringbuffer.c b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_ringbuffer.c
index 7b3298abd01..6f68f2f304b 100644
--- a/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_ringbuffer.c
+++ b/chromium/third_party/libdrm/src/freedreno/kgsl/kgsl_ringbuffer.c
@@ -173,14 +173,12 @@ static void kgsl_ringbuffer_emit_reloc(struct fd_ringbuffer *ring,
kgsl_pipe_add_submit(to_kgsl_pipe(ring->pipe), kgsl_bo);
}
-static uint32_t kgsl_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
- struct fd_ringbuffer *target, uint32_t cmd_idx,
- uint32_t submit_offset, uint32_t size)
+static void kgsl_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
+ struct fd_ringmarker *target, struct fd_ringmarker *end)
{
- struct kgsl_ringbuffer *target_ring = to_kgsl_ringbuffer(target);
- assert(cmd_idx == 0);
- (*ring->cur++) = target_ring->bo->gpuaddr + submit_offset;
- return size;
+ struct kgsl_ringbuffer *target_ring = to_kgsl_ringbuffer(target->ring);
+ (*ring->cur++) = target_ring->bo->gpuaddr +
+ (uint8_t *)target->cur - (uint8_t *)target->ring->start;
}
static void kgsl_ringbuffer_destroy(struct fd_ringbuffer *ring)
@@ -215,7 +213,6 @@ drm_private struct fd_ringbuffer * kgsl_ringbuffer_new(struct fd_pipe *pipe,
ring = &kgsl_ring->base;
ring->funcs = &funcs;
- ring->size = size;
kgsl_ring->bo = kgsl_rb_bo_new(to_kgsl_pipe(pipe), size);
if (!kgsl_ring->bo) {
diff --git a/chromium/third_party/libdrm/src/freedreno/kgsl/msm_kgsl.h b/chromium/third_party/libdrm/src/freedreno/kgsl/msm_kgsl.h
index 5b36eeb43f2..e67190f07d4 100644
--- a/chromium/third_party/libdrm/src/freedreno/kgsl/msm_kgsl.h
+++ b/chromium/third_party/libdrm/src/freedreno/kgsl/msm_kgsl.h
@@ -31,7 +31,7 @@
#define KGSL_FLAGS_SOFT_RESET 0x00000100
#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200
-/* Clock flags to show which clocks should be controlled by a given platform */
+/* Clock flags to show which clocks should be controled by a given platform */
#define KGSL_CLK_SRC 0x00000001
#define KGSL_CLK_CORE 0x00000002
#define KGSL_CLK_IFACE 0x00000004
@@ -295,7 +295,7 @@ struct kgsl_cmdstream_freememontimestamp {
/* Previous versions of this header had incorrectly defined
IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead
- of a write only ioctl. To ensure binary compatibility, the following
+ of a write only ioctl. To ensure binary compatability, the following
#define will be used to intercept the incorrect ioctl
*/
diff --git a/chromium/third_party/libdrm/src/freedreno/msm/msm_bo.c b/chromium/third_party/libdrm/src/freedreno/msm/msm_bo.c
index 72471df65b2..cd05a6cd4e9 100644
--- a/chromium/third_party/libdrm/src/freedreno/msm/msm_bo.c
+++ b/chromium/third_party/libdrm/src/freedreno/msm/msm_bo.c
@@ -89,25 +89,6 @@ static void msm_bo_cpu_fini(struct fd_bo *bo)
drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_CPU_FINI, &req, sizeof(req));
}
-static int msm_bo_madvise(struct fd_bo *bo, int willneed)
-{
- struct drm_msm_gem_madvise req = {
- .handle = bo->handle,
- .madv = willneed ? MSM_MADV_WILLNEED : MSM_MADV_DONTNEED,
- };
- int ret;
-
- /* older kernels do not support this: */
- if (bo->dev->version < FD_VERSION_MADVISE)
- return willneed;
-
- ret = drmCommandWriteRead(bo->dev->fd, DRM_MSM_GEM_MADVISE, &req, sizeof(req));
- if (ret)
- return ret;
-
- return req.retained;
-}
-
static void msm_bo_destroy(struct fd_bo *bo)
{
struct msm_bo *msm_bo = to_msm_bo(bo);
@@ -119,7 +100,6 @@ static const struct fd_bo_funcs funcs = {
.offset = msm_bo_offset,
.cpu_prep = msm_bo_cpu_prep,
.cpu_fini = msm_bo_cpu_fini,
- .madvise = msm_bo_madvise,
.destroy = msm_bo_destroy,
};
diff --git a/chromium/third_party/libdrm/src/freedreno/msm/msm_device.c b/chromium/third_party/libdrm/src/freedreno/msm/msm_device.c
index 727baa44326..25c097c2522 100644
--- a/chromium/third_party/libdrm/src/freedreno/msm/msm_device.c
+++ b/chromium/third_party/libdrm/src/freedreno/msm/msm_device.c
@@ -39,7 +39,6 @@
static void msm_device_destroy(struct fd_device *dev)
{
struct msm_device *msm_dev = to_msm_device(dev);
- fd_bo_cache_cleanup(&msm_dev->ring_cache, 0);
free(msm_dev);
}
@@ -62,7 +61,5 @@ drm_private struct fd_device * msm_device_new(int fd)
dev = &msm_dev->base;
dev->funcs = &funcs;
- fd_bo_cache_init(&msm_dev->ring_cache, TRUE);
-
return dev;
}
diff --git a/chromium/third_party/libdrm/src/freedreno/msm/msm_drm.h b/chromium/third_party/libdrm/src/freedreno/msm/msm_drm.h
index cbf75c3d52f..f7474c59487 100644
--- a/chromium/third_party/libdrm/src/freedreno/msm/msm_drm.h
+++ b/chromium/third_party/libdrm/src/freedreno/msm/msm_drm.h
@@ -28,13 +28,9 @@
#include <stddef.h>
#include "drm.h"
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
/* Please note that modifications to all structs defined here are
* subject to backwards-compatibility constraints:
- * 1) Do not use pointers, use __u64 instead for 32 bit / 64 bit
+ * 1) Do not use pointers, use uint64_t instead for 32 bit / 64 bit
* user/kernel compatibility
* 2) Keep fields aligned to their size
* 3) Because of how drm_ioctl() works, we can add new fields at
@@ -55,20 +51,18 @@ extern "C" {
* same as 'struct timespec' but 32/64b ABI safe.
*/
struct drm_msm_timespec {
- __s64 tv_sec; /* seconds */
- __s64 tv_nsec; /* nanoseconds */
+ int64_t tv_sec; /* seconds */
+ int64_t tv_nsec; /* nanoseconds */
};
#define MSM_PARAM_GPU_ID 0x01
#define MSM_PARAM_GMEM_SIZE 0x02
#define MSM_PARAM_CHIP_ID 0x03
-#define MSM_PARAM_MAX_FREQ 0x04
-#define MSM_PARAM_TIMESTAMP 0x05
struct drm_msm_param {
- __u32 pipe; /* in, MSM_PIPE_x */
- __u32 param; /* in, MSM_PARAM_x */
- __u64 value; /* out (get_param) or in (set_param) */
+ uint32_t pipe; /* in, MSM_PIPE_x */
+ uint32_t param; /* in, MSM_PARAM_x */
+ uint64_t value; /* out (get_param) or in (set_param) */
};
/*
@@ -90,15 +84,15 @@ struct drm_msm_param {
MSM_BO_UNCACHED)
struct drm_msm_gem_new {
- __u64 size; /* in */
- __u32 flags; /* in, mask of MSM_BO_x */
- __u32 handle; /* out */
+ uint64_t size; /* in */
+ uint32_t flags; /* in, mask of MSM_BO_x */
+ uint32_t handle; /* out */
};
struct drm_msm_gem_info {
- __u32 handle; /* in */
- __u32 pad;
- __u64 offset; /* out, offset to pass to mmap() */
+ uint32_t handle; /* in */
+ uint32_t pad;
+ uint64_t offset; /* out, offset to pass to mmap() */
};
#define MSM_PREP_READ 0x01
@@ -108,13 +102,13 @@ struct drm_msm_gem_info {
#define MSM_PREP_FLAGS (MSM_PREP_READ | MSM_PREP_WRITE | MSM_PREP_NOSYNC)
struct drm_msm_gem_cpu_prep {
- __u32 handle; /* in */
- __u32 op; /* in, mask of MSM_PREP_x */
+ uint32_t handle; /* in */
+ uint32_t op; /* in, mask of MSM_PREP_x */
struct drm_msm_timespec timeout; /* in */
};
struct drm_msm_gem_cpu_fini {
- __u32 handle; /* in */
+ uint32_t handle; /* in */
};
/*
@@ -133,11 +127,11 @@ struct drm_msm_gem_cpu_fini {
* otherwise EINVAL.
*/
struct drm_msm_gem_submit_reloc {
- __u32 submit_offset; /* in, offset from submit_bo */
- __u32 or; /* in, value OR'd with result */
- __s32 shift; /* in, amount of left shift (can be negative) */
- __u32 reloc_idx; /* in, index of reloc_bo buffer */
- __u64 reloc_offset; /* in, offset from start of reloc_bo */
+ uint32_t submit_offset; /* in, offset from submit_bo */
+ uint32_t or; /* in, value OR'd with result */
+ int32_t shift; /* in, amount of left shift (can be negative) */
+ uint32_t reloc_idx; /* in, index of reloc_bo buffer */
+ uint64_t reloc_offset; /* in, offset from start of reloc_bo */
};
/* submit-types:
@@ -152,13 +146,13 @@ struct drm_msm_gem_submit_reloc {
#define MSM_SUBMIT_CMD_IB_TARGET_BUF 0x0002
#define MSM_SUBMIT_CMD_CTX_RESTORE_BUF 0x0003
struct drm_msm_gem_submit_cmd {
- __u32 type; /* in, one of MSM_SUBMIT_CMD_x */
- __u32 submit_idx; /* in, index of submit_bo cmdstream buffer */
- __u32 submit_offset; /* in, offset into submit_bo */
- __u32 size; /* in, cmdstream size */
- __u32 pad;
- __u32 nr_relocs; /* in, number of submit_reloc's */
- __u64 __user relocs; /* in, ptr to array of submit_reloc's */
+ uint32_t type; /* in, one of MSM_SUBMIT_CMD_x */
+ uint32_t submit_idx; /* in, index of submit_bo cmdstream buffer */
+ uint32_t submit_offset; /* in, offset into submit_bo */
+ uint32_t size; /* in, cmdstream size */
+ uint32_t pad;
+ uint32_t nr_relocs; /* in, number of submit_reloc's */
+ uint64_t __user relocs; /* in, ptr to array of submit_reloc's */
};
/* Each buffer referenced elsewhere in the cmdstream submit (ie. the
@@ -178,9 +172,9 @@ struct drm_msm_gem_submit_cmd {
#define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE)
struct drm_msm_gem_submit_bo {
- __u32 flags; /* in, mask of MSM_SUBMIT_BO_x */
- __u32 handle; /* in, GEM handle */
- __u64 presumed; /* in/out, presumed buffer address */
+ uint32_t flags; /* in, mask of MSM_SUBMIT_BO_x */
+ uint32_t handle; /* in, GEM handle */
+ uint64_t presumed; /* in/out, presumed buffer address */
};
/* Each cmdstream submit consists of a table of buffers involved, and
@@ -188,12 +182,12 @@ struct drm_msm_gem_submit_bo {
* (context-restore), and IB buffers needed for per tile/bin draw cmds.
*/
struct drm_msm_gem_submit {
- __u32 pipe; /* in, MSM_PIPE_x */
- __u32 fence; /* out */
- __u32 nr_bos; /* in, number of submit_bo's */
- __u32 nr_cmds; /* in, number of submit_cmd's */
- __u64 __user bos; /* in, ptr to array of submit_bo's */
- __u64 __user cmds; /* in, ptr to array of submit_cmd's */
+ uint32_t pipe; /* in, MSM_PIPE_x */
+ uint32_t fence; /* out */
+ uint32_t nr_bos; /* in, number of submit_bo's */
+ uint32_t nr_cmds; /* in, number of submit_cmd's */
+ uint64_t __user bos; /* in, ptr to array of submit_bo's */
+ uint64_t __user cmds; /* in, ptr to array of submit_cmd's */
};
/* The normal way to synchronize with the GPU is just to CPU_PREP on
@@ -204,32 +198,11 @@ struct drm_msm_gem_submit {
* APIs without requiring a dummy bo to synchronize on.
*/
struct drm_msm_wait_fence {
- __u32 fence; /* in */
- __u32 pad;
+ uint32_t fence; /* in */
+ uint32_t pad;
struct drm_msm_timespec timeout; /* in */
};
-/* madvise provides a way to tell the kernel in case a buffers contents
- * can be discarded under memory pressure, which is useful for userspace
- * bo cache where we want to optimistically hold on to buffer allocate
- * and potential mmap, but allow the pages to be discarded under memory
- * pressure.
- *
- * Typical usage would involve madvise(DONTNEED) when buffer enters BO
- * cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.
- * In the WILLNEED case, 'retained' indicates to userspace whether the
- * backing pages still exist.
- */
-#define MSM_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */
-#define MSM_MADV_DONTNEED 1 /* backing pages not needed */
-#define __MSM_MADV_PURGED 2 /* internal state */
-
-struct drm_msm_gem_madvise {
- __u32 handle; /* in, GEM handle */
- __u32 madv; /* in, MSM_MADV_x */
- __u32 retained; /* out, whether backing store still exists */
-};
-
#define DRM_MSM_GET_PARAM 0x00
/* placeholder:
#define DRM_MSM_SET_PARAM 0x01
@@ -240,8 +213,7 @@ struct drm_msm_gem_madvise {
#define DRM_MSM_GEM_CPU_FINI 0x05
#define DRM_MSM_GEM_SUBMIT 0x06
#define DRM_MSM_WAIT_FENCE 0x07
-#define DRM_MSM_GEM_MADVISE 0x08
-#define DRM_MSM_NUM_IOCTLS 0x09
+#define DRM_MSM_NUM_IOCTLS 0x08
#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
#define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
@@ -250,10 +222,5 @@ struct drm_msm_gem_madvise {
#define DRM_IOCTL_MSM_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_FINI, struct drm_msm_gem_cpu_fini)
#define DRM_IOCTL_MSM_GEM_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_SUBMIT, struct drm_msm_gem_submit)
#define DRM_IOCTL_MSM_WAIT_FENCE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_WAIT_FENCE, struct drm_msm_wait_fence)
-#define DRM_IOCTL_MSM_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_MADVISE, struct drm_msm_gem_madvise)
-
-#if defined(__cplusplus)
-}
-#endif
#endif /* __MSM_DRM_H__ */
diff --git a/chromium/third_party/libdrm/src/freedreno/msm/msm_pipe.c b/chromium/third_party/libdrm/src/freedreno/msm/msm_pipe.c
index f872e245927..aa0866b4aac 100644
--- a/chromium/third_party/libdrm/src/freedreno/msm/msm_pipe.c
+++ b/chromium/third_party/libdrm/src/freedreno/msm/msm_pipe.c
@@ -32,25 +32,6 @@
#include "msm_priv.h"
-static int query_param(struct fd_pipe *pipe, uint32_t param,
- uint64_t *value)
-{
- struct msm_pipe *msm_pipe = to_msm_pipe(pipe);
- struct drm_msm_param req = {
- .pipe = msm_pipe->pipe,
- .param = param,
- };
- int ret;
-
- ret = drmCommandWriteRead(pipe->dev->fd, DRM_MSM_GET_PARAM,
- &req, sizeof(req));
- if (ret)
- return ret;
-
- *value = req.value;
-
- return 0;
-}
static int msm_pipe_get_param(struct fd_pipe *pipe,
enum fd_param_id param, uint64_t *value)
@@ -67,10 +48,6 @@ static int msm_pipe_get_param(struct fd_pipe *pipe,
case FD_CHIP_ID:
*value = msm_pipe->chip_id;
return 0;
- case FD_MAX_FREQ:
- return query_param(pipe, MSM_PARAM_MAX_FREQ, value);
- case FD_TIMESTAMP:
- return query_param(pipe, MSM_PARAM_TIMESTAMP, value);
default:
ERROR_MSG("invalid param id: %d", param);
return -1;
@@ -110,15 +87,21 @@ static const struct fd_pipe_funcs funcs = {
.destroy = msm_pipe_destroy,
};
-static uint64_t get_param(struct fd_pipe *pipe, uint32_t param)
+static uint64_t get_param(struct fd_device *dev, uint32_t pipe, uint32_t param)
{
- uint64_t value;
- int ret = query_param(pipe, param, &value);
+ struct drm_msm_param req = {
+ .pipe = pipe,
+ .param = param,
+ };
+ int ret;
+
+ ret = drmCommandWriteRead(dev->fd, DRM_MSM_GET_PARAM, &req, sizeof(req));
if (ret) {
ERROR_MSG("get-param failed! %d (%s)", ret, strerror(errno));
return 0;
}
- return value;
+
+ return req.value;
}
drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
@@ -140,14 +123,10 @@ drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
pipe = &msm_pipe->base;
pipe->funcs = &funcs;
- /* initialize before get_param(): */
- pipe->dev = dev;
msm_pipe->pipe = pipe_id[id];
-
- /* these params should be supported since the first version of drm/msm: */
- msm_pipe->gpu_id = get_param(pipe, MSM_PARAM_GPU_ID);
- msm_pipe->gmem = get_param(pipe, MSM_PARAM_GMEM_SIZE);
- msm_pipe->chip_id = get_param(pipe, MSM_PARAM_CHIP_ID);
+ msm_pipe->gpu_id = get_param(dev, pipe_id[id], MSM_PARAM_GPU_ID);
+ msm_pipe->gmem = get_param(dev, pipe_id[id], MSM_PARAM_GMEM_SIZE);
+ msm_pipe->chip_id = get_param(dev, pipe_id[id], MSM_PARAM_CHIP_ID);
if (! msm_pipe->gpu_id)
goto fail;
diff --git a/chromium/third_party/libdrm/src/freedreno/msm/msm_priv.h b/chromium/third_party/libdrm/src/freedreno/msm/msm_priv.h
index 6d670aab254..e499b3b878e 100644
--- a/chromium/third_party/libdrm/src/freedreno/msm/msm_priv.h
+++ b/chromium/third_party/libdrm/src/freedreno/msm/msm_priv.h
@@ -39,8 +39,6 @@
struct msm_device {
struct fd_device base;
- struct fd_bo_cache ring_cache;
- unsigned ring_cnt;
};
static inline struct msm_device * to_msm_device(struct fd_device *x)
@@ -73,11 +71,18 @@ struct msm_bo {
struct fd_bo base;
uint64_t offset;
uint64_t presumed;
- /* to avoid excess hashtable lookups, cache the ring this bo was
- * last emitted on (since that will probably also be the next ring
- * it is emitted on)
+ /* in the common case, a bo won't be referenced by more than a single
+ * (parent) ring[*]. So to avoid looping over all the bo's in the
+ * reloc table to find the idx of a bo that might already be in the
+ * table, we cache the idx in the bo. But in order to detect the
+ * slow-path where bo is ref'd in multiple rb's, we also must track
+ * the current_ring for which the idx is valid. See bo2idx().
+ *
+ * [*] in case multiple ringbuffers, ie. one toplevel and other rb(s)
+ * used for IB target(s), the toplevel rb is the parent which is
+ * tracking bo's for the submit
*/
- unsigned current_ring_seqno;
+ struct fd_ringbuffer *current_ring;
uint32_t idx;
};
diff --git a/chromium/third_party/libdrm/src/freedreno/msm/msm_ringbuffer.c b/chromium/third_party/libdrm/src/freedreno/msm/msm_ringbuffer.c
index a78806c88bc..becf2458940 100644
--- a/chromium/third_party/libdrm/src/freedreno/msm/msm_ringbuffer.c
+++ b/chromium/third_party/libdrm/src/freedreno/msm/msm_ringbuffer.c
@@ -36,30 +36,11 @@
#include "freedreno_ringbuffer.h"
#include "msm_priv.h"
-/* represents a single cmd buffer in the submit ioctl. Each cmd buffer has
- * a backing bo, and a reloc table.
- */
-struct msm_cmd {
- struct list_head list;
-
- struct fd_ringbuffer *ring;
- struct fd_bo *ring_bo;
-
- /* reloc's table: */
- struct drm_msm_gem_submit_reloc *relocs;
- uint32_t nr_relocs, max_relocs;
-
- uint32_t size;
-};
-
struct msm_ringbuffer {
struct fd_ringbuffer base;
+ struct fd_bo *ring_bo;
- /* submit ioctl related tables:
- * Note that bos and cmds are tracked by the parent ringbuffer, since
- * that is global to the submit ioctl call. The reloc's table is tracked
- * per cmd-buffer.
- */
+ /* submit ioctl related tables: */
struct {
/* bo's table: */
struct drm_msm_gem_submit_bo *bos;
@@ -68,111 +49,22 @@ struct msm_ringbuffer {
/* cmd's table: */
struct drm_msm_gem_submit_cmd *cmds;
uint32_t nr_cmds, max_cmds;
+
+ /* reloc's table: */
+ struct drm_msm_gem_submit_reloc *relocs;
+ uint32_t nr_relocs, max_relocs;
} submit;
/* should have matching entries in submit.bos: */
- /* Note, only in parent ringbuffer */
struct fd_bo **bos;
uint32_t nr_bos, max_bos;
/* should have matching entries in submit.cmds: */
- struct msm_cmd **cmds;
- uint32_t nr_cmds, max_cmds;
-
- /* List of physical cmdstream buffers (msm_cmd) assocated with this
- * logical fd_ringbuffer.
- *
- * Note that this is different from msm_ringbuffer::cmds (which
- * shadows msm_ringbuffer::submit::cmds for tracking submit ioctl
- * related stuff, and *only* is tracked in the parent ringbuffer.
- * And only has "completed" cmd buffers (ie. we already know the
- * size) added via get_cmd().
- */
- struct list_head cmd_list;
-
- int is_growable;
- unsigned cmd_count;
-
- unsigned seqno;
-
- /* maps fd_bo to idx: */
- void *bo_table;
+ struct fd_ringbuffer **rings;
+ uint32_t nr_rings, max_rings;
};
-static inline struct msm_ringbuffer * to_msm_ringbuffer(struct fd_ringbuffer *x)
-{
- return (struct msm_ringbuffer *)x;
-}
-
-#define INIT_SIZE 0x1000
-
static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER;
-drm_private extern pthread_mutex_t table_lock;
-
-static void ring_bo_del(struct fd_device *dev, struct fd_bo *bo)
-{
- int ret;
-
- pthread_mutex_lock(&table_lock);
- ret = fd_bo_cache_free(&to_msm_device(dev)->ring_cache, bo);
- pthread_mutex_unlock(&table_lock);
-
- if (ret == 0)
- return;
-
- fd_bo_del(bo);
-}
-
-static struct fd_bo * ring_bo_new(struct fd_device *dev, uint32_t size)
-{
- struct fd_bo *bo;
-
- bo = fd_bo_cache_alloc(&to_msm_device(dev)->ring_cache, &size, 0);
- if (bo)
- return bo;
-
- bo = fd_bo_new(dev, size, 0);
- if (!bo)
- return NULL;
-
- /* keep ringbuffer bo's out of the normal bo cache: */
- bo->bo_reuse = FALSE;
-
- return bo;
-}
-
-static void ring_cmd_del(struct msm_cmd *cmd)
-{
- if (cmd->ring_bo)
- ring_bo_del(cmd->ring->pipe->dev, cmd->ring_bo);
- list_del(&cmd->list);
- to_msm_ringbuffer(cmd->ring)->cmd_count--;
- free(cmd->relocs);
- free(cmd);
-}
-
-static struct msm_cmd * ring_cmd_new(struct fd_ringbuffer *ring, uint32_t size)
-{
- struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
- struct msm_cmd *cmd = calloc(1, sizeof(*cmd));
-
- if (!cmd)
- return NULL;
-
- cmd->ring = ring;
- cmd->ring_bo = ring_bo_new(ring->pipe->dev, size);
- if (!cmd->ring_bo)
- goto fail;
-
- list_addtail(&cmd->list, &msm_ring->cmd_list);
- msm_ring->cmd_count++;
-
- return cmd;
-
-fail:
- ring_cmd_del(cmd);
- return NULL;
-}
static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
{
@@ -191,11 +83,9 @@ static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
(x)->nr_ ## name ++; \
})
-static struct msm_cmd *current_cmd(struct fd_ringbuffer *ring)
+static inline struct msm_ringbuffer * to_msm_ringbuffer(struct fd_ringbuffer *x)
{
- struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
- assert(!LIST_IS_EMPTY(&msm_ring->cmd_list));
- return LIST_LAST_ENTRY(&msm_ring->cmd_list, struct msm_cmd, list);
+ return (struct msm_ringbuffer *)x;
}
static uint32_t append_bo(struct fd_ringbuffer *ring, struct fd_bo *bo)
@@ -222,24 +112,21 @@ static uint32_t bo2idx(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t fl
struct msm_bo *msm_bo = to_msm_bo(bo);
uint32_t idx;
pthread_mutex_lock(&idx_lock);
- if (msm_bo->current_ring_seqno == msm_ring->seqno) {
+ if (!msm_bo->current_ring) {
+ idx = append_bo(ring, bo);
+ msm_bo->current_ring = ring;
+ msm_bo->idx = idx;
+ } else if (msm_bo->current_ring == ring) {
idx = msm_bo->idx;
} else {
- void *val;
-
- if (!msm_ring->bo_table)
- msm_ring->bo_table = drmHashCreate();
-
- if (!drmHashLookup(msm_ring->bo_table, bo->handle, &val)) {
- /* found */
- idx = (uint32_t)(uintptr_t)val;
- } else {
+ /* slow-path: */
+ for (idx = 0; idx < msm_ring->nr_bos; idx++)
+ if (msm_ring->bos[idx] == bo)
+ break;
+ if (idx == msm_ring->nr_bos) {
+ /* not found */
idx = append_bo(ring, bo);
- val = (void *)(uintptr_t)idx;
- drmHashInsert(msm_ring->bo_table, bo->handle, val);
}
- msm_bo->current_ring_seqno = msm_ring->seqno;
- msm_bo->idx = idx;
}
pthread_mutex_unlock(&idx_lock);
if (flags & FD_RELOC_READ)
@@ -256,14 +143,17 @@ static int check_cmd_bo(struct fd_ringbuffer *ring,
return msm_ring->submit.bos[cmd->submit_idx].handle == bo->handle;
}
-/* Ensure that submit has corresponding entry in cmds table for the
- * target cmdstream buffer:
- */
-static void get_cmd(struct fd_ringbuffer *ring, struct msm_cmd *target_cmd,
+static uint32_t offset_bytes(void *end, void *start)
+{
+ return ((char *)end) - ((char *)start);
+}
+
+static struct drm_msm_gem_submit_cmd * get_cmd(struct fd_ringbuffer *ring,
+ struct fd_ringbuffer *target_ring, struct fd_bo *target_bo,
uint32_t submit_offset, uint32_t size, uint32_t type)
{
struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
- struct drm_msm_gem_submit_cmd *cmd;
+ struct drm_msm_gem_submit_cmd *cmd = NULL;
uint32_t i;
/* figure out if we already have a cmd buf: */
@@ -272,37 +162,41 @@ static void get_cmd(struct fd_ringbuffer *ring, struct msm_cmd *target_cmd,
if ((cmd->submit_offset == submit_offset) &&
(cmd->size == size) &&
(cmd->type == type) &&
- check_cmd_bo(ring, cmd, target_cmd->ring_bo))
- return;
+ check_cmd_bo(ring, cmd, target_bo))
+ break;
+ cmd = NULL;
}
/* create cmd buf if not: */
- i = APPEND(&msm_ring->submit, cmds);
- APPEND(msm_ring, cmds);
- msm_ring->cmds[i] = target_cmd;
- cmd = &msm_ring->submit.cmds[i];
- cmd->type = type;
- cmd->submit_idx = bo2idx(ring, target_cmd->ring_bo, FD_RELOC_READ);
- cmd->submit_offset = submit_offset;
- cmd->size = size;
- cmd->pad = 0;
-
- target_cmd->size = size;
+ if (!cmd) {
+ uint32_t idx = APPEND(&msm_ring->submit, cmds);
+ APPEND(msm_ring, rings);
+ msm_ring->rings[idx] = target_ring;
+ cmd = &msm_ring->submit.cmds[idx];
+ cmd->type = type;
+ cmd->submit_idx = bo2idx(ring, target_bo, FD_RELOC_READ);
+ cmd->submit_offset = submit_offset;
+ cmd->size = size;
+ cmd->pad = 0;
+ }
+
+ return cmd;
}
static void * msm_ringbuffer_hostptr(struct fd_ringbuffer *ring)
{
- return fd_bo_map(current_cmd(ring)->ring_bo);
+ struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
+ return fd_bo_map(msm_ring->ring_bo);
}
-static uint32_t find_next_reloc_idx(struct msm_cmd *msm_cmd,
+static uint32_t find_next_reloc_idx(struct msm_ringbuffer *msm_ring,
uint32_t start, uint32_t offset)
{
uint32_t i;
/* a binary search would be more clever.. */
- for (i = start; i < msm_cmd->nr_relocs; i++) {
- struct drm_msm_gem_submit_reloc *reloc = &msm_cmd->relocs[i];
+ for (i = start; i < msm_ring->submit.nr_relocs; i++) {
+ struct drm_msm_gem_submit_reloc *reloc = &msm_ring->submit.relocs[i];
if (reloc->submit_offset >= offset)
return i;
}
@@ -310,101 +204,38 @@ static uint32_t find_next_reloc_idx(struct msm_cmd *msm_cmd,
return i;
}
-static void delete_cmds(struct msm_ringbuffer *msm_ring)
-{
- struct msm_cmd *cmd, *tmp;
-
- LIST_FOR_EACH_ENTRY_SAFE(cmd, tmp, &msm_ring->cmd_list, list) {
- ring_cmd_del(cmd);
- }
-}
-
static void flush_reset(struct fd_ringbuffer *ring)
{
struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
unsigned i;
- for (i = 0; i < msm_ring->nr_bos; i++) {
- struct msm_bo *msm_bo = to_msm_bo(msm_ring->bos[i]);
- msm_bo->current_ring_seqno = 0;
- fd_bo_del(&msm_bo->base);
- }
-
/* for each of the cmd buffers, clear their reloc's: */
for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
- struct msm_cmd *target_cmd = msm_ring->cmds[i];
- target_cmd->nr_relocs = 0;
+ struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]);
+ target_ring->submit.nr_relocs = 0;
}
+ msm_ring->submit.nr_relocs = 0;
msm_ring->submit.nr_cmds = 0;
msm_ring->submit.nr_bos = 0;
- msm_ring->nr_cmds = 0;
+ msm_ring->nr_rings = 0;
msm_ring->nr_bos = 0;
-
- if (msm_ring->bo_table) {
- drmHashDestroy(msm_ring->bo_table);
- msm_ring->bo_table = NULL;
- }
-
- if (msm_ring->is_growable) {
- delete_cmds(msm_ring);
- } else {
- /* in old mode, just reset the # of relocs: */
- current_cmd(ring)->nr_relocs = 0;
- }
-}
-
-static void finalize_current_cmd(struct fd_ringbuffer *ring, uint32_t *last_start)
-{
- uint32_t submit_offset, size, type;
- struct fd_ringbuffer *parent;
-
- if (ring->parent) {
- parent = ring->parent;
- type = MSM_SUBMIT_CMD_IB_TARGET_BUF;
- } else {
- parent = ring;
- type = MSM_SUBMIT_CMD_BUF;
- }
-
- submit_offset = offset_bytes(last_start, ring->start);
- size = offset_bytes(ring->cur, last_start);
-
- get_cmd(parent, current_cmd(ring), submit_offset, size, type);
-}
-
-static void dump_submit(struct msm_ringbuffer *msm_ring)
-{
- uint32_t i, j;
-
- for (i = 0; i < msm_ring->submit.nr_bos; i++) {
- struct drm_msm_gem_submit_bo *bo = &msm_ring->submit.bos[i];
- ERROR_MSG(" bos[%d]: handle=%u, flags=%x", i, bo->handle, bo->flags);
- }
- for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
- struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i];
- struct drm_msm_gem_submit_reloc *relocs = U642VOID(cmd->relocs);
- ERROR_MSG(" cmd[%d]: type=%u, submit_idx=%u, submit_offset=%u, size=%u",
- i, cmd->type, cmd->submit_idx, cmd->submit_offset, cmd->size);
- for (j = 0; j < cmd->nr_relocs; j++) {
- struct drm_msm_gem_submit_reloc *r = &relocs[j];
- ERROR_MSG(" reloc[%d]: submit_offset=%u, or=%08x, shift=%d, reloc_idx=%u"
- ", reloc_offset=%"PRIu64, j, r->submit_offset, r->or, r->shift,
- r->reloc_idx, r->reloc_offset);
- }
- }
}
static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start)
{
struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
+ struct fd_bo *ring_bo = msm_ring->ring_bo;
struct drm_msm_gem_submit req = {
.pipe = to_msm_pipe(ring->pipe)->pipe,
};
- uint32_t i;
+ uint32_t i, j, submit_offset, size;
int ret;
- finalize_current_cmd(ring, last_start);
+ submit_offset = offset_bytes(last_start, ring->start);
+ size = offset_bytes(ring->cur, last_start);
+
+ get_cmd(ring, ring, ring_bo, submit_offset, size, MSM_SUBMIT_CMD_BUF);
/* needs to be after get_cmd() as that could create bos/cmds table: */
req.bos = VOID2U64(msm_ring->submit.bos),
@@ -415,10 +246,10 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
/* for each of the cmd's fix up their reloc's: */
for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i];
- struct msm_cmd *msm_cmd = msm_ring->cmds[i];
- uint32_t a = find_next_reloc_idx(msm_cmd, 0, cmd->submit_offset);
- uint32_t b = find_next_reloc_idx(msm_cmd, a, cmd->submit_offset + cmd->size);
- cmd->relocs = VOID2U64(&msm_cmd->relocs[a]);
+ struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]);
+ uint32_t a = find_next_reloc_idx(target_ring, 0, cmd->submit_offset);
+ uint32_t b = find_next_reloc_idx(target_ring, a, cmd->submit_offset + cmd->size);
+ cmd->relocs = VOID2U64(&target_ring->submit.relocs[a]);
cmd->nr_relocs = (b > a) ? b - a : 0;
}
@@ -428,27 +259,43 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
&req, sizeof(req));
if (ret) {
ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));
- dump_submit(msm_ring);
- } else if (!ret) {
+ ERROR_MSG(" pipe: %u", req.pipe);
+ for (i = 0; i < msm_ring->submit.nr_bos; i++) {
+ struct drm_msm_gem_submit_bo *bo = &msm_ring->submit.bos[i];
+ ERROR_MSG(" bos[%d]: handle=%u, flags=%x", i, bo->handle, bo->flags);
+ }
+ for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
+ struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i];
+ struct drm_msm_gem_submit_reloc *relocs = U642VOID(cmd->relocs);
+ ERROR_MSG(" cmd[%d]: type=%u, submit_idx=%u, submit_offset=%u, size=%u",
+ i, cmd->type, cmd->submit_idx, cmd->submit_offset, cmd->size);
+ for (j = 0; j < cmd->nr_relocs; j++) {
+ struct drm_msm_gem_submit_reloc *r = &relocs[j];
+ ERROR_MSG(" reloc[%d]: submit_offset=%u, or=%08x, shift=%d, reloc_idx=%u"
+ ", reloc_offset=%"PRIu64, j, r->submit_offset, r->or, r->shift,
+ r->reloc_idx, r->reloc_offset);
+ }
+ }
+ } else {
/* update timestamp on all rings associated with submit: */
for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
- struct msm_cmd *msm_cmd = msm_ring->cmds[i];
- msm_cmd->ring->last_timestamp = req.fence;
+ struct fd_ringbuffer *target_ring = msm_ring->rings[i];
+ if (!ret)
+ target_ring->last_timestamp = req.fence;
}
}
+ for (i = 0; i < msm_ring->nr_bos; i++) {
+ struct msm_bo *msm_bo = to_msm_bo(msm_ring->bos[i]);
+ msm_bo->current_ring = NULL;
+ fd_bo_del(&msm_bo->base);
+ }
+
flush_reset(ring);
return ret;
}
-static void msm_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t size)
-{
- assert(to_msm_ringbuffer(ring)->is_growable);
- finalize_current_cmd(ring, ring->last_start);
- ring_cmd_new(ring, size);
-}
-
static void msm_ringbuffer_reset(struct fd_ringbuffer *ring)
{
flush_reset(ring);
@@ -457,14 +304,14 @@ static void msm_ringbuffer_reset(struct fd_ringbuffer *ring)
static void msm_ringbuffer_emit_reloc(struct fd_ringbuffer *ring,
const struct fd_reloc *r)
{
+ struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
struct fd_ringbuffer *parent = ring->parent ? ring->parent : ring;
struct msm_bo *msm_bo = to_msm_bo(r->bo);
struct drm_msm_gem_submit_reloc *reloc;
- struct msm_cmd *cmd = current_cmd(ring);
- uint32_t idx = APPEND(cmd, relocs);
+ uint32_t idx = APPEND(&msm_ring->submit, relocs);
uint32_t addr;
- reloc = &cmd->relocs[idx];
+ reloc = &msm_ring->submit.relocs[idx];
reloc->reloc_idx = bo2idx(parent, r->bo, r->flags);
reloc->reloc_offset = r->offset;
@@ -480,68 +327,41 @@ static void msm_ringbuffer_emit_reloc(struct fd_ringbuffer *ring,
(*ring->cur++) = addr | r->or;
}
-static uint32_t msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
- struct fd_ringbuffer *target, uint32_t cmd_idx,
- uint32_t submit_offset, uint32_t size)
+static void msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
+ struct fd_ringmarker *target, struct fd_ringmarker *end)
{
- struct msm_cmd *cmd = NULL;
- uint32_t idx = 0;
-
- LIST_FOR_EACH_ENTRY(cmd, &to_msm_ringbuffer(target)->cmd_list, list) {
- if (idx == cmd_idx)
- break;
- idx++;
- }
+ struct fd_bo *target_bo = to_msm_ringbuffer(target->ring)->ring_bo;
+ struct drm_msm_gem_submit_cmd *cmd;
+ uint32_t submit_offset, size;
- assert(cmd && (idx == cmd_idx));
+ submit_offset = offset_bytes(target->cur, target->ring->start);
+ size = offset_bytes(end->cur, target->cur);
- if (idx < (to_msm_ringbuffer(target)->cmd_count - 1)) {
- /* All but the last cmd buffer is fully "baked" (ie. already has
- * done get_cmd() to add it to the cmds table). But in this case,
- * the size we get is invalid (since it is calculated from the
- * last cmd buffer):
- */
- size = cmd->size;
- } else {
- get_cmd(ring, cmd, submit_offset, size, MSM_SUBMIT_CMD_IB_TARGET_BUF);
- }
+ cmd = get_cmd(ring, target->ring, target_bo, submit_offset, size,
+ MSM_SUBMIT_CMD_IB_TARGET_BUF);
+ assert(cmd);
msm_ringbuffer_emit_reloc(ring, &(struct fd_reloc){
- .bo = cmd->ring_bo,
+ .bo = target_bo,
.flags = FD_RELOC_READ,
.offset = submit_offset,
});
-
- return size;
-}
-
-static uint32_t msm_ringbuffer_cmd_count(struct fd_ringbuffer *ring)
-{
- return to_msm_ringbuffer(ring)->cmd_count;
}
static void msm_ringbuffer_destroy(struct fd_ringbuffer *ring)
{
struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
-
- flush_reset(ring);
- delete_cmds(msm_ring);
-
- free(msm_ring->submit.cmds);
- free(msm_ring->submit.bos);
- free(msm_ring->bos);
- free(msm_ring->cmds);
+ if (msm_ring->ring_bo)
+ fd_bo_del(msm_ring->ring_bo);
free(msm_ring);
}
static const struct fd_ringbuffer_funcs funcs = {
.hostptr = msm_ringbuffer_hostptr,
.flush = msm_ringbuffer_flush,
- .grow = msm_ringbuffer_grow,
.reset = msm_ringbuffer_reset,
.emit_reloc = msm_ringbuffer_emit_reloc,
.emit_reloc_ring = msm_ringbuffer_emit_reloc_ring,
- .cmd_count = msm_ringbuffer_cmd_count,
.destroy = msm_ringbuffer_destroy,
};
@@ -557,21 +377,14 @@ drm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe,
goto fail;
}
- if (size == 0) {
- assert(pipe->dev->version >= FD_VERSION_UNLIMITED_CMDS);
- size = INIT_SIZE;
- msm_ring->is_growable = TRUE;
- }
-
- list_inithead(&msm_ring->cmd_list);
- msm_ring->seqno = ++to_msm_device(pipe->dev)->ring_cnt;
-
ring = &msm_ring->base;
ring->funcs = &funcs;
- ring->size = size;
- ring->pipe = pipe; /* needed in ring_cmd_new() */
- ring_cmd_new(ring, size);
+ msm_ring->ring_bo = fd_bo_new(pipe->dev, size, 0);
+ if (!msm_ring->ring_bo) {
+ ERROR_MSG("ringbuffer allocation failed");
+ goto fail;
+ }
return ring;
fail:
diff --git a/chromium/third_party/libdrm/src/include/drm/drm.h b/chromium/third_party/libdrm/src/include/drm/drm.h
index a7b1a636938..a950b580cd1 100644
--- a/chromium/third_party/libdrm/src/include/drm/drm.h
+++ b/chromium/third_party/libdrm/src/include/drm/drm.h
@@ -36,7 +36,7 @@
#ifndef _DRM_H_
#define _DRM_H_
-#if defined(__linux__)
+#if defined(__linux__)
#include <linux/types.h>
#include <asm/ioctl.h>
@@ -54,7 +54,6 @@ typedef int32_t __s32;
typedef uint32_t __u32;
typedef int64_t __s64;
typedef uint64_t __u64;
-typedef size_t __kernel_size_t;
typedef unsigned long drm_handle_t;
#endif
@@ -130,11 +129,11 @@ struct drm_version {
int version_major; /**< Major version */
int version_minor; /**< Minor version */
int version_patchlevel; /**< Patch level */
- __kernel_size_t name_len; /**< Length of name buffer */
+ size_t name_len; /**< Length of name buffer */
char *name; /**< Name of driver */
- __kernel_size_t date_len; /**< Length of date buffer */
+ size_t date_len; /**< Length of date buffer */
char *date; /**< User-space buffer to hold date */
- __kernel_size_t desc_len; /**< Length of desc buffer */
+ size_t desc_len; /**< Length of desc buffer */
char *desc; /**< User-space buffer to hold desc */
};
@@ -144,7 +143,7 @@ struct drm_version {
* \sa drmGetBusid() and drmSetBusId().
*/
struct drm_unique {
- __kernel_size_t unique_len; /**< Length of unique */
+ size_t unique_len; /**< Length of unique */
char *unique; /**< Unique name for driver instantiation */
};
@@ -181,7 +180,8 @@ enum drm_map_type {
_DRM_SHM = 2, /**< shared, cached */
_DRM_AGP = 3, /**< AGP/GART */
_DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */
- _DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */
+ _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */
+ _DRM_GEM = 6 /**< GEM object */
};
/**
@@ -467,15 +467,12 @@ struct drm_irq_busid {
enum drm_vblank_seq_type {
_DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
_DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
- /* bits 1-6 are reserved for high crtcs */
- _DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
_DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */
_DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */
_DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
_DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */
_DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */
};
-#define _DRM_VBLANK_HIGH_CRTC_SHIFT 1
#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \
@@ -615,28 +612,6 @@ struct drm_gem_open {
__u64 size;
};
-#define DRM_CAP_DUMB_BUFFER 0x1
-#define DRM_CAP_VBLANK_HIGH_CRTC 0x2
-#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
-#define DRM_CAP_DUMB_PREFER_SHADOW 0x4
-#define DRM_CAP_PRIME 0x5
-#define DRM_PRIME_CAP_IMPORT 0x1
-#define DRM_PRIME_CAP_EXPORT 0x2
-#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
-#define DRM_CAP_ASYNC_PAGE_FLIP 0x7
-/*
- * The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight
- * combination for the hardware cursor. The intention is that a hardware
- * agnostic userspace can query a cursor plane size to use.
- *
- * Note that the cross-driver contract is to merely return a valid size;
- * drivers are free to attach another meaning on top, eg. i915 returns the
- * maximum plane size.
- */
-#define DRM_CAP_CURSOR_WIDTH 0x8
-#define DRM_CAP_CURSOR_HEIGHT 0x9
-#define DRM_CAP_ADDFB2_MODIFIERS 0x10
-
/** DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap {
__u64 capability;
@@ -655,17 +630,17 @@ struct drm_get_cap {
/**
* DRM_CLIENT_CAP_UNIVERSAL_PLANES
*
- * If set to 1, the DRM core will expose all planes (overlay, primary, and
- * cursor) to userspace.
+ * if set to 1, the DRM core will expose the full universal plane list
+ * (including primary and cursor planes).
*/
-#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
+#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
/**
* DRM_CLIENT_CAP_ATOMIC
*
- * If set to 1, the DRM core will expose atomic properties to userspace
+ * If set to 1, the DRM core will allow atomic modesetting requests.
*/
-#define DRM_CLIENT_CAP_ATOMIC 3
+#define DRM_CLIENT_CAP_ATOMIC 3
/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
struct drm_set_client_cap {
@@ -673,7 +648,6 @@ struct drm_set_client_cap {
__u64 value;
};
-#define DRM_RDWR O_RDWR
#define DRM_CLOEXEC O_CLOEXEC
struct drm_prime_handle {
__u32 handle;
@@ -769,8 +743,8 @@ struct drm_prime_handle {
#define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut)
#define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder)
#define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector)
-#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd) /* deprecated (never worked) */
-#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) /* deprecated (never worked) */
+#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd)
+#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd)
#define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property)
#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property)
@@ -786,7 +760,6 @@ struct drm_prime_handle {
#define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
#define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane)
-#define DRM_IOCTL_MODE_GETPLANE2 DRM_IOWR(0xB6, struct drm_mode_get_plane2)
#define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane)
#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
@@ -798,7 +771,7 @@ struct drm_prime_handle {
/**
* Device specific ioctls should only be in their respective headers
- * The device specific ioctl range is from 0x40 to 0x9f.
+ * The device specific ioctl range is from 0x40 to 0x99.
* Generic IOCTLS restart at 0xA0.
*
* \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and
@@ -836,6 +809,18 @@ struct drm_event_vblank {
__u32 reserved;
};
+#define DRM_CAP_DUMB_BUFFER 0x1
+#define DRM_CAP_VBLANK_HIGH_CRTC 0x2
+#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
+#define DRM_CAP_DUMB_PREFER_SHADOW 0x4
+#define DRM_CAP_PRIME 0x5
+#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
+#define DRM_CAP_ASYNC_PAGE_FLIP 0x7
+#define DRM_CAP_ADDFB2_MODIFIERS 0x10
+
+#define DRM_PRIME_CAP_IMPORT 0x1
+#define DRM_PRIME_CAP_EXPORT 0x2
+
/* typedef area */
typedef struct drm_clip_rect drm_clip_rect_t;
typedef struct drm_drawable_info drm_drawable_info_t;
diff --git a/chromium/third_party/libdrm/src/include/drm/drm_fourcc.h b/chromium/third_party/libdrm/src/include/drm/drm_fourcc.h
index d26d01b523f..e741b09a00f 100644
--- a/chromium/third_party/libdrm/src/include/drm/drm_fourcc.h
+++ b/chromium/third_party/libdrm/src/include/drm/drm_fourcc.h
@@ -24,23 +24,16 @@
#ifndef DRM_FOURCC_H
#define DRM_FOURCC_H
-#include "drm.h"
+#include <inttypes.h>
-#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
- ((__u32)(c) << 16) | ((__u32)(d) << 24))
+#define fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
+ ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
#define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */
/* color index */
#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
-/* 8 bpp Red */
-#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
-
-/* 16 bpp RG */
-#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */
-#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */
-
/* 8 bpp RGB */
#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
@@ -113,10 +106,6 @@
#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */
#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */
#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */
-#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
-#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
-
-#define DRM_FORMAT_MT21 fourcc_code('M', 'T', '2', '1') /* Mediatek Block Mode */
/*
* 3 plane YCbCr
@@ -159,9 +148,6 @@
#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05
/* add more to the end as needed */
-/* Vendor ID for downstream, interim ChromeOS specific modifiers. */
-#define DRM_FORMAT_MOD_VENDOR_CHROMEOS 0xf0
-
#define fourcc_mod_code(vendor, val) \
((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL))
@@ -230,22 +216,8 @@
* - multiple of 128 pixels for the width
* - multiple of 32 pixels for the height
*
- * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html
+ * For more information: see http://linuxtv.org/downloads/v4l-dvb-apis/re32.html
*/
#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1)
-/*
- * Rockchip ARM Framebuffer Compression (AFBC)
- *
- * This modifier identifies the specific variant of AFBC supported by the
- * Rockchip display hardware. It's technically a two-plane format: first a
- * header with 16 bytes per block, followed by the block data aligned to 1024
- * bytes. Each block is 16x16 pixels.
- *
- * Eventually ARM should define modifiers for the various AFBC types, but
- * we'll use this in the meantime. We use the CHROMEOS vendor ID to make sure
- * we don't clash with future vendor modifiers.
- */
-#define DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC fourcc_mod_code(CHROMEOS, 1)
-
#endif /* DRM_FOURCC_H */
diff --git a/chromium/third_party/libdrm/src/include/drm/drm_mode.h b/chromium/third_party/libdrm/src/include/drm/drm_mode.h
index 6ea17ebe013..115f36e452d 100644
--- a/chromium/third_party/libdrm/src/include/drm/drm_mode.h
+++ b/chromium/third_party/libdrm/src/include/drm/drm_mode.h
@@ -27,8 +27,6 @@
#ifndef _DRM_MODE_H
#define _DRM_MODE_H
-#include "drm.h"
-
#define DRM_DISPLAY_INFO_LEN 32
#define DRM_CONNECTOR_NAME_LEN 32
#define DRM_DISPLAY_MODE_LEN 32
@@ -58,10 +56,6 @@
#define DRM_MODE_FLAG_PIXMUX (1<<11)
#define DRM_MODE_FLAG_DBLCLK (1<<12)
#define DRM_MODE_FLAG_CLKDIV2 (1<<13)
- /*
- * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
- * (define not exposed to user space).
- */
#define DRM_MODE_FLAG_3D_MASK (0x1f<<14)
#define DRM_MODE_FLAG_3D_NONE (0<<14)
#define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
@@ -88,11 +82,6 @@
#define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */
#define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */
-/* Picture aspect ratio options */
-#define DRM_MODE_PICTURE_ASPECT_NONE 0
-#define DRM_MODE_PICTURE_ASPECT_4_3 1
-#define DRM_MODE_PICTURE_ASPECT_16_9 2
-
/* Dithering mode options */
#define DRM_MODE_DITHERING_OFF 0
#define DRM_MODE_DITHERING_ON 1
@@ -105,16 +94,8 @@
struct drm_mode_modeinfo {
__u32 clock;
- __u16 hdisplay;
- __u16 hsync_start;
- __u16 hsync_end;
- __u16 htotal;
- __u16 hskew;
- __u16 vdisplay;
- __u16 vsync_start;
- __u16 vsync_end;
- __u16 vtotal;
- __u16 vscan;
+ __u16 hdisplay, hsync_start, hsync_end, htotal, hskew;
+ __u16 vdisplay, vsync_start, vsync_end, vtotal, vscan;
__u32 vrefresh;
@@ -132,10 +113,8 @@ struct drm_mode_card_res {
__u32 count_crtcs;
__u32 count_connectors;
__u32 count_encoders;
- __u32 min_width;
- __u32 max_width;
- __u32 min_height;
- __u32 max_height;
+ __u32 min_width, max_width;
+ __u32 min_height, max_height;
};
struct drm_mode_crtc {
@@ -145,35 +124,30 @@ struct drm_mode_crtc {
__u32 crtc_id; /**< Id */
__u32 fb_id; /**< Id of framebuffer */
- __u32 x; /**< x Position on the framebuffer */
- __u32 y; /**< y Position on the framebuffer */
+ __u32 x, y; /**< Position on the frameuffer */
__u32 gamma_size;
__u32 mode_valid;
struct drm_mode_modeinfo mode;
};
-#define DRM_MODE_PRESENT_TOP_FIELD (1<<0)
-#define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1)
+#define DRM_MODE_PRESENT_TOP_FIELD (1<<0)
+#define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1)
/* Planes blend with or override other bits on the CRTC */
struct drm_mode_set_plane {
__u32 plane_id;
__u32 crtc_id;
__u32 fb_id; /* fb object contains surface format type */
- __u32 flags; /* see above flags */
+ __u32 flags;
/* Signed dest location allows it to be partially off screen */
- __s32 crtc_x;
- __s32 crtc_y;
- __u32 crtc_w;
- __u32 crtc_h;
+ __s32 crtc_x, crtc_y;
+ __u32 crtc_w, crtc_h;
/* Source values are 16.16 fixed point */
- __u32 src_x;
- __u32 src_y;
- __u32 src_h;
- __u32 src_w;
+ __u32 src_x, src_y;
+ __u32 src_h, src_w;
};
struct drm_mode_get_plane {
@@ -189,33 +163,6 @@ struct drm_mode_get_plane {
__u64 format_type_ptr;
};
-struct drm_format_modifier {
- /* Bitmask of formats in get_plane format list this info
- * applies to. */
- __u64 formats;
-
- /* This modifier can be used with the format for this plane. */
- __u64 modifier;
-};
-
-struct drm_mode_get_plane2 {
- __u32 plane_id;
-
- __u32 crtc_id;
- __u32 fb_id;
-
- __u32 possible_crtcs;
- __u32 gamma_size;
-
- __u32 count_format_types;
- __u64 format_type_ptr;
-
- /* New in v2 */
- __u32 count_format_modifiers;
- __u32 flags;
- __u64 format_modifier_ptr;
-};
-
struct drm_mode_get_plane_res {
__u64 plane_id_ptr;
__u32 count_planes;
@@ -286,11 +233,8 @@ struct drm_mode_get_connector {
__u32 connector_type_id;
__u32 connection;
- __u32 mm_width; /**< width in millimeters */
- __u32 mm_height; /**< height in millimeters */
+ __u32 mm_width, mm_height; /**< HxW in millimeters */
__u32 subpixel;
-
- __u32 pad;
};
#define DRM_MODE_PROP_PENDING (1<<0)
@@ -315,13 +259,6 @@ struct drm_mode_get_connector {
#define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
#define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
-/* the PROP_ATOMIC flag is used to hide properties from userspace that
- * is not aware of atomic properties. This is mostly to work around
- * older userspace (DDX drivers) that read/write each prop they find,
- * witout being aware that this could be triggering a lengthy modeset.
- */
-#define DRM_MODE_PROP_ATOMIC 0x80000000
-
struct drm_mode_property_enum {
__u64 value;
char name[DRM_PROP_NAME_LEN];
@@ -336,8 +273,6 @@ struct drm_mode_get_property {
char name[DRM_PROP_NAME_LEN];
__u32 count_values;
- /* This is only used to count enum values, not blobs. The _blobs is
- * simply because of a historical reason, i.e. backwards compat. */
__u32 count_enum_blobs;
};
@@ -355,7 +290,6 @@ struct drm_mode_connector_set_property {
#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
-#define DRM_MODE_OBJECT_ANY 0
struct drm_mode_obj_get_properties {
__u64 props_ptr;
@@ -380,8 +314,7 @@ struct drm_mode_get_blob {
struct drm_mode_fb_cmd {
__u32 fb_id;
- __u32 width;
- __u32 height;
+ __u32 width, height;
__u32 pitch;
__u32 bpp;
__u32 depth;
@@ -394,10 +327,9 @@ struct drm_mode_fb_cmd {
struct drm_mode_fb_cmd2 {
__u32 fb_id;
- __u32 width;
- __u32 height;
+ __u32 width, height;
__u32 pixel_format; /* fourcc code from drm_fourcc.h */
- __u32 flags; /* see above flags */
+ __u32 flags;
/*
* In case of planar formats, this ioctl allows up to 4
@@ -409,9 +341,9 @@ struct drm_mode_fb_cmd2 {
* followed by an interleaved U/V plane containing
* 8 bit 2x2 subsampled colour difference samples.
*
- * So it would consist of Y as offsets[0] and UV as
- * offsets[1]. Note that offsets[0] will generally
- * be 0 (but this is not required).
+ * So it would consist of Y as offset[0] and UV as
+ * offset[1]. Note that offset[0] will generally
+ * be 0.
*
* To accommodate tiled, compressed, etc formats, a per-plane
* modifier can be specified. The default value of zero
@@ -430,8 +362,6 @@ struct drm_mode_fb_cmd2 {
#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
#define DRM_MODE_FB_DIRTY_FLAGS 0x03
-#define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
-
/*
* Mark a region of a framebuffer as dirty.
*
@@ -472,21 +402,20 @@ struct drm_mode_mode_cmd {
struct drm_mode_modeinfo mode;
};
-#define DRM_MODE_CURSOR_BO 0x01
-#define DRM_MODE_CURSOR_MOVE 0x02
-#define DRM_MODE_CURSOR_FLAGS 0x03
+#define DRM_MODE_CURSOR_BO (1<<0)
+#define DRM_MODE_CURSOR_MOVE (1<<1)
/*
- * depending on the value in flags different members are used.
+ * depending on the value in flags diffrent members are used.
*
* CURSOR_BO uses
- * crtc_id
+ * crtc
* width
* height
- * handle - if 0 turns the cursor off
+ * handle - if 0 turns the cursor of
*
* CURSOR_MOVE uses
- * crtc_id
+ * crtc
* x
* y
*/
@@ -524,21 +453,6 @@ struct drm_mode_crtc_lut {
__u64 blue;
};
-struct drm_color_ctm {
- /* Conversion matrix in S31.32 format. */
- __s64 matrix[9];
-};
-
-struct drm_color_lut {
- /*
- * Data is U0.16 fixed point format.
- */
- __u16 red;
- __u16 green;
- __u16 blue;
- __u16 reserved;
-};
-
#define DRM_MODE_PAGE_FLIP_EVENT 0x01
#define DRM_MODE_PAGE_FLIP_ASYNC 0x02
#define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT|DRM_MODE_PAGE_FLIP_ASYNC)
@@ -555,14 +469,11 @@ struct drm_color_lut {
* flip is already pending as the ioctl is called, EBUSY will be
* returned.
*
- * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank
- * event (see drm.h: struct drm_event_vblank) when the page flip is
- * done. The user_data field passed in with this ioctl will be
- * returned as the user_data field in the vblank event struct.
- *
- * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen
- * 'as soon as possible', meaning that it not delay waiting for vblank.
- * This may cause tearing on the screen.
+ * The ioctl supports one flag, DRM_MODE_PAGE_FLIP_EVENT, which will
+ * request that drm sends back a vblank event (see drm.h: struct
+ * drm_event_vblank) when the page flip is done. The user_data field
+ * passed in with this ioctl will be returned as the user_data field
+ * in the vblank event struct.
*
* The reserved field must be zero until we figure out something
* clever to use it for.
@@ -578,27 +489,27 @@ struct drm_mode_crtc_page_flip {
/* create a dumb scanout buffer */
struct drm_mode_create_dumb {
- __u32 height;
- __u32 width;
- __u32 bpp;
- __u32 flags;
- /* handle, pitch, size will be returned */
- __u32 handle;
- __u32 pitch;
- __u64 size;
+ __u32 height;
+ __u32 width;
+ __u32 bpp;
+ __u32 flags;
+ /* handle, pitch, size will be returned */
+ __u32 handle;
+ __u32 pitch;
+ __u64 size;
};
/* set up for mmap of a dumb scanout buffer */
struct drm_mode_map_dumb {
- /** Handle for the object being mapped. */
- __u32 handle;
- __u32 pad;
- /**
- * Fake offset to use for subsequent mmap call
- *
- * This is a fixed-size type for 32/64 compatibility.
- */
- __u64 offset;
+ /** Handle for the object being mapped. */
+ __u32 handle;
+ __u32 pad;
+ /**
+ * Fake offset to use for subsequent mmap call
+ *
+ * This is a fixed-size type for 32/64 compatibility.
+ */
+ __u64 offset;
};
struct drm_mode_destroy_dumb {
@@ -606,16 +517,9 @@ struct drm_mode_destroy_dumb {
};
/* page-flip flags are valid, plus: */
-#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
-#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
-#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
-
-#define DRM_MODE_ATOMIC_FLAGS (\
- DRM_MODE_PAGE_FLIP_EVENT |\
- DRM_MODE_PAGE_FLIP_ASYNC |\
- DRM_MODE_ATOMIC_TEST_ONLY |\
- DRM_MODE_ATOMIC_NONBLOCK |\
- DRM_MODE_ATOMIC_ALLOW_MODESET)
+#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
+#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
+#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
struct drm_mode_atomic {
__u32 flags;
@@ -648,4 +552,5 @@ struct drm_mode_destroy_blob {
__u32 blob_id;
};
+
#endif
diff --git a/chromium/third_party/libdrm/src/include/drm/drm_sarea.h b/chromium/third_party/libdrm/src/include/drm/drm_sarea.h
index 502934edc21..7325558d9cb 100644
--- a/chromium/third_party/libdrm/src/include/drm/drm_sarea.h
+++ b/chromium/third_party/libdrm/src/include/drm/drm_sarea.h
@@ -37,8 +37,6 @@
/* SAREA area needs to be at least a page */
#if defined(__alpha__)
#define SAREA_MAX 0x2000U
-#elif defined(__mips__)
-#define SAREA_MAX 0x4000U
#elif defined(__ia64__)
#define SAREA_MAX 0x10000U /* 64kB */
#else
diff --git a/chromium/third_party/libdrm/src/include/drm/evdi_drm.h b/chromium/third_party/libdrm/src/include/drm/evdi_drm.h
deleted file mode 100644
index 3a00c7fcea8..00000000000
--- a/chromium/third_party/libdrm/src/include/drm/evdi_drm.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 DisplayLink (UK) Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License v2. See the file COPYING in the main directory of this archive for
- * more details.
- */
-
-#ifndef __UAPI_EVDI_DRM_H__
-#define __UAPI_EVDI_DRM_H__
-
-/* Output events sent from driver to evdi lib */
-#define DRM_EVDI_EVENT_UPDATE_READY 0x80000000
-#define DRM_EVDI_EVENT_DPMS 0x80000001
-#define DRM_EVDI_EVENT_MODE_CHANGED 0x80000002
-#define DRM_EVDI_EVENT_CRTC_STATE 0x80000003
-
-struct drm_evdi_event_update_ready {
- struct drm_event base;
-};
-
-struct drm_evdi_event_dpms {
- struct drm_event base;
- int32_t mode;
-};
-
-struct drm_evdi_event_mode_changed {
- struct drm_event base;
- int32_t hdisplay;
- int32_t vdisplay;
- int32_t vrefresh;
- int32_t bits_per_pixel;
- uint32_t pixel_format;
-};
-
-struct drm_evdi_event_crtc_state {
- struct drm_event base;
- int32_t state;
-};
-
-struct drm_evdi_connect {
- int32_t connected;
- int32_t dev_index;
- const unsigned char * __user edid;
- unsigned int edid_length;
-};
-
-struct drm_evdi_mapfifo {
- int32_t reserved;
-};
-
-struct drm_evdi_request_update {
- int32_t reserved;
-};
-
-enum drm_evdi_grabpix_mode {
- EVDI_GRABPIX_MODE_RECTS = 0,
- EVDI_GRABPIX_MODE_DIRTY = 1,
-};
-
-struct drm_evdi_grabpix {
- enum drm_evdi_grabpix_mode mode;
- int32_t buf_width;
- int32_t buf_height;
- int32_t buf_byte_stride;
- unsigned char __user *buffer;
- int32_t num_rects;
- struct drm_clip_rect __user *rects;
-};
-
-/* Input ioctls from evdi lib to driver */
-#define DRM_EVDI_CONNECT 0x00
-#define DRM_EVDI_REQUEST_UPDATE 0x01
-#define DRM_EVDI_GRABPIX 0x02
-/* LAST_IOCTL 0x5F -- 96 driver specific ioctls to use */
-
-#define DRM_IOCTL_EVDI_CONNECT DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_EVDI_CONNECT, struct drm_evdi_connect)
-#define DRM_IOCTL_EVDI_REQUEST_UPDATE DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_EVDI_REQUEST_UPDATE, struct drm_evdi_request_update)
-#define DRM_IOCTL_EVDI_GRABPIX DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_EVDI_GRABPIX, struct drm_evdi_grabpix)
-
-#endif /* __EVDI_UAPI_DRM_H__ */
-
diff --git a/chromium/third_party/libdrm/src/include/drm/i915_drm.h b/chromium/third_party/libdrm/src/include/drm/i915_drm.h
index c4ce6b2c6f8..ded43b1cb11 100644
--- a/chromium/third_party/libdrm/src/include/drm/i915_drm.h
+++ b/chromium/third_party/libdrm/src/include/drm/i915_drm.h
@@ -27,7 +27,7 @@
#ifndef _I915_DRM_H_
#define _I915_DRM_H_
-#include "drm.h"
+#include <drm.h>
/* Please note that modifications to all structs defined here are
* subject to backwards-compatibility constraints.
@@ -171,12 +171,8 @@ typedef struct _drm_i915_sarea {
#define I915_BOX_TEXTURE_LOAD 0x8
#define I915_BOX_LOST_CONTEXT 0x10
-/*
- * i915 specific ioctls.
- *
- * The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie
- * [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset
- * against DRM_COMMAND_BASE and should be between [0x0, 0x60).
+/* I915 specific ioctls
+ * The device specific ioctl range is 0x40 to 0x79.
*/
#define DRM_I915_INIT 0x00
#define DRM_I915_FLUSH 0x01
@@ -274,7 +270,7 @@ typedef struct _drm_i915_sarea {
#define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
#define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
#define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
-#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
+#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
#define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
@@ -354,16 +350,9 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_REVISION 32
#define I915_PARAM_SUBSLICE_TOTAL 33
#define I915_PARAM_EU_TOTAL 34
-#define I915_PARAM_HAS_GPU_RESET 35
-#define I915_PARAM_HAS_RESOURCE_STREAMER 36
-#define I915_PARAM_HAS_EXEC_SOFTPIN 37
typedef struct drm_i915_getparam {
- __s32 param;
- /*
- * WARNING: Using pointers instead of fixed-size u64 means we need to write
- * compat32 code. Don't repeat this mistake.
- */
+ int param;
int *value;
} drm_i915_getparam_t;
@@ -683,21 +672,15 @@ struct drm_i915_gem_exec_object2 {
__u64 alignment;
/**
- * When the EXEC_OBJECT_PINNED flag is specified this is populated by
- * the user with the GTT offset at which this object will be pinned.
- * When the I915_EXEC_NO_RELOC flag is specified this must contain the
- * presumed_offset of the object.
- * During execbuffer2 the kernel populates it with the value of the
- * current GTT offset of the object, for future presumed_offset writes.
+ * Returned value of the updated offset of the object, for future
+ * presumed_offset writes.
*/
__u64 offset;
#define EXEC_OBJECT_NEEDS_FENCE (1<<0)
#define EXEC_OBJECT_NEEDS_GTT (1<<1)
#define EXEC_OBJECT_WRITE (1<<2)
-#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
-#define EXEC_OBJECT_PINNED (1<<4)
-#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_PINNED<<1)
+#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_WRITE<<1)
__u64 flags;
__u64 rsvd1;
@@ -772,19 +755,12 @@ struct drm_i915_gem_execbuffer2 {
#define I915_EXEC_HANDLE_LUT (1<<12)
/** Used for switching BSD rings on the platforms with two BSD rings */
-#define I915_EXEC_BSD_SHIFT (13)
-#define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
-/* default ping-pong mode */
-#define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
-#define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
-#define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
-
-/** Tell the kernel that the batchbuffer is processed by
- * the resource streamer.
- */
-#define I915_EXEC_RESOURCE_STREAMER (1<<15)
+#define I915_EXEC_BSD_MASK (3<<13)
+#define I915_EXEC_BSD_DEFAULT (0<<13) /* default ping-pong mode */
+#define I915_EXEC_BSD_RING1 (1<<13)
+#define I915_EXEC_BSD_RING2 (2<<13)
-#define __I915_EXEC_UNKNOWN_FLAGS -(I915_EXEC_RESOURCE_STREAMER<<1)
+#define __I915_EXEC_UNKNOWN_FLAGS -(1<<15)
#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
#define i915_execbuffer2_set_context_id(eb2, context) \
@@ -814,35 +790,10 @@ struct drm_i915_gem_busy {
/** Handle of the buffer to check for busy */
__u32 handle;
- /** Return busy status
- *
- * A return of 0 implies that the object is idle (after
- * having flushed any pending activity), and a non-zero return that
- * the object is still in-flight on the GPU. (The GPU has not yet
- * signaled completion for all pending requests that reference the
- * object.)
- *
- * The returned dword is split into two fields to indicate both
- * the engines on which the object is being read, and the
- * engine on which it is currently being written (if any).
- *
- * The low word (bits 0:15) indicate if the object is being written
- * to by any engine (there can only be one, as the GEM implicit
- * synchronisation rules force writes to be serialised). Only the
- * engine for the last write is reported.
- *
- * The high word (bits 16:31) are a bitmask of which engines are
- * currently reading from the object. Multiple engines may be
- * reading from the object simultaneously.
- *
- * The value of each engine is the same as specified in the
- * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc.
- * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to
- * the I915_EXEC_RENDER engine for execution, and so it is never
- * reported as active itself. Some hardware may have parallel
- * execution engines, e.g. multiple media engines, which are
- * mapped to the same identifier in the EXECBUFFER2 ioctl and
- * so are not separately reported for busyness.
+ /** Return busy status (1 if busy, 0 if idle).
+ * The high word is used to indicate on which rings the object
+ * currently resides:
+ * 16:31 - busy (r or r/w) rings (16 render, 17 bsd, 18 blt, etc)
*/
__u32 busy;
};
@@ -1045,7 +996,6 @@ struct drm_intel_overlay_put_image {
/* flags */
#define I915_OVERLAY_UPDATE_ATTRS (1<<0)
#define I915_OVERLAY_UPDATE_GAMMA (1<<1)
-#define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)
struct drm_intel_overlay_attrs {
__u32 flags;
__u32 color_key;
@@ -1112,23 +1062,9 @@ struct drm_i915_gem_context_destroy {
};
struct drm_i915_reg_read {
- /*
- * Register offset.
- * For 64bit wide registers where the upper 32bits don't immediately
- * follow the lower 32bits, the offset of the lower 32bits must
- * be specified
- */
__u64 offset;
__u64 val; /* Return value */
};
-/* Known registers:
- *
- * Render engine timestamp - 0x2358 + 64bit - gen7+
- * - Note this register returns an invalid value if using the default
- * single instruction 8byte read, in order to workaround that use
- * offset (0x2538 | 1) instead.
- *
- */
struct drm_i915_reset_stats {
__u32 ctx_id;
@@ -1164,9 +1100,7 @@ struct drm_i915_gem_context_param {
__u32 ctx_id;
__u32 size;
__u64 param;
-#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
-#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
-#define I915_CONTEXT_PARAM_GTT_SIZE 0x3
+#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
__u64 value;
};
diff --git a/chromium/third_party/libdrm/src/include/drm/nouveau_drm.h b/chromium/third_party/libdrm/src/include/drm/nouveau_drm.h
index e418f9f3899..87aefc5e9d2 100644
--- a/chromium/third_party/libdrm/src/include/drm/nouveau_drm.h
+++ b/chromium/third_party/libdrm/src/include/drm/nouveau_drm.h
@@ -200,7 +200,6 @@ struct drm_nouveau_sarea {
#define DRM_NOUVEAU_GROBJ_ALLOC 0x04
#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05
#define DRM_NOUVEAU_GPUOBJ_FREE 0x06
-#define DRM_NOUVEAU_NVIF 0x07
#define DRM_NOUVEAU_GEM_NEW 0x40
#define DRM_NOUVEAU_GEM_PUSHBUF 0x41
#define DRM_NOUVEAU_GEM_CPU_PREP 0x42
diff --git a/chromium/third_party/libdrm/src/include/drm/tegra_drm.h b/chromium/third_party/libdrm/src/include/drm/tegra_drm.h
index 7c0fe0ed511..8dae8f33499 100644
--- a/chromium/third_party/libdrm/src/include/drm/tegra_drm.h
+++ b/chromium/third_party/libdrm/src/include/drm/tegra_drm.h
@@ -36,8 +36,7 @@ struct drm_tegra_gem_create {
struct drm_tegra_gem_mmap {
__u32 handle;
- __u32 pad;
- __u64 offset;
+ __u32 offset;
};
struct drm_tegra_syncpt_read {
diff --git a/chromium/third_party/libdrm/src/include/drm/vc4_drm.h b/chromium/third_party/libdrm/src/include/drm/vc4_drm.h
deleted file mode 100644
index 919eecea762..00000000000
--- a/chromium/third_party/libdrm/src/include/drm/vc4_drm.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright © 2014-2015 Broadcom
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef _VC4_DRM_H_
-#define _VC4_DRM_H_
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#define DRM_VC4_SUBMIT_CL 0x00
-#define DRM_VC4_WAIT_SEQNO 0x01
-#define DRM_VC4_WAIT_BO 0x02
-#define DRM_VC4_CREATE_BO 0x03
-#define DRM_VC4_MMAP_BO 0x04
-#define DRM_VC4_CREATE_SHADER_BO 0x05
-#define DRM_VC4_GET_HANG_STATE 0x06
-#define DRM_VC4_GET_PARAM 0x07
-
-#define DRM_IOCTL_VC4_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
-#define DRM_IOCTL_VC4_WAIT_SEQNO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
-#define DRM_IOCTL_VC4_WAIT_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_BO, struct drm_vc4_wait_bo)
-#define DRM_IOCTL_VC4_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
-#define DRM_IOCTL_VC4_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
-#define DRM_IOCTL_VC4_CREATE_SHADER_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_SHADER_BO, struct drm_vc4_create_shader_bo)
-#define DRM_IOCTL_VC4_GET_HANG_STATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_HANG_STATE, struct drm_vc4_get_hang_state)
-#define DRM_IOCTL_VC4_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_PARAM, struct drm_vc4_get_param)
-
-struct drm_vc4_submit_rcl_surface {
- __u32 hindex; /* Handle index, or ~0 if not present. */
- __u32 offset; /* Offset to start of buffer. */
- /*
- * Bits for either render config (color_write) or load/store packet.
- * Bits should all be 0 for MSAA load/stores.
- */
- __u16 bits;
-
-#define VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES (1 << 0)
- __u16 flags;
-};
-
-/**
- * struct drm_vc4_submit_cl - ioctl argument for submitting commands to the 3D
- * engine.
- *
- * Drivers typically use GPU BOs to store batchbuffers / command lists and
- * their associated state. However, because the VC4 lacks an MMU, we have to
- * do validation of memory accesses by the GPU commands. If we were to store
- * our commands in BOs, we'd need to do uncached readback from them to do the
- * validation process, which is too expensive. Instead, userspace accumulates
- * commands and associated state in plain memory, then the kernel copies the
- * data to its own address space, and then validates and stores it in a GPU
- * BO.
- */
-struct drm_vc4_submit_cl {
- /* Pointer to the binner command list.
- *
- * This is the first set of commands executed, which runs the
- * coordinate shader to determine where primitives land on the screen,
- * then writes out the state updates and draw calls necessary per tile
- * to the tile allocation BO.
- */
- __u64 bin_cl;
-
- /* Pointer to the shader records.
- *
- * Shader records are the structures read by the hardware that contain
- * pointers to uniforms, shaders, and vertex attributes. The
- * reference to the shader record has enough information to determine
- * how many pointers are necessary (fixed number for shaders/uniforms,
- * and an attribute count), so those BO indices into bo_handles are
- * just stored as __u32s before each shader record passed in.
- */
- __u64 shader_rec;
-
- /* Pointer to uniform data and texture handles for the textures
- * referenced by the shader.
- *
- * For each shader state record, there is a set of uniform data in the
- * order referenced by the record (FS, VS, then CS). Each set of
- * uniform data has a __u32 index into bo_handles per texture
- * sample operation, in the order the QPU_W_TMUn_S writes appear in
- * the program. Following the texture BO handle indices is the actual
- * uniform data.
- *
- * The individual uniform state blocks don't have sizes passed in,
- * because the kernel has to determine the sizes anyway during shader
- * code validation.
- */
- __u64 uniforms;
- __u64 bo_handles;
-
- /* Size in bytes of the binner command list. */
- __u32 bin_cl_size;
- /* Size in bytes of the set of shader records. */
- __u32 shader_rec_size;
- /* Number of shader records.
- *
- * This could just be computed from the contents of shader_records and
- * the address bits of references to them from the bin CL, but it
- * keeps the kernel from having to resize some allocations it makes.
- */
- __u32 shader_rec_count;
- /* Size in bytes of the uniform state. */
- __u32 uniforms_size;
-
- /* Number of BO handles passed in (size is that times 4). */
- __u32 bo_handle_count;
-
- /* RCL setup: */
- __u16 width;
- __u16 height;
- __u8 min_x_tile;
- __u8 min_y_tile;
- __u8 max_x_tile;
- __u8 max_y_tile;
- struct drm_vc4_submit_rcl_surface color_read;
- struct drm_vc4_submit_rcl_surface color_write;
- struct drm_vc4_submit_rcl_surface zs_read;
- struct drm_vc4_submit_rcl_surface zs_write;
- struct drm_vc4_submit_rcl_surface msaa_color_write;
- struct drm_vc4_submit_rcl_surface msaa_zs_write;
- __u32 clear_color[2];
- __u32 clear_z;
- __u8 clear_s;
-
- __u32 pad:24;
-
-#define VC4_SUBMIT_CL_USE_CLEAR_COLOR (1 << 0)
- __u32 flags;
-
- /* Returned value of the seqno of this render job (for the
- * wait ioctl).
- */
- __u64 seqno;
-};
-
-/**
- * struct drm_vc4_wait_seqno - ioctl argument for waiting for
- * DRM_VC4_SUBMIT_CL completion using its returned seqno.
- *
- * timeout_ns is the timeout in nanoseconds, where "0" means "don't
- * block, just return the status."
- */
-struct drm_vc4_wait_seqno {
- __u64 seqno;
- __u64 timeout_ns;
-};
-
-/**
- * struct drm_vc4_wait_bo - ioctl argument for waiting for
- * completion of the last DRM_VC4_SUBMIT_CL on a BO.
- *
- * This is useful for cases where multiple processes might be
- * rendering to a BO and you want to wait for all rendering to be
- * completed.
- */
-struct drm_vc4_wait_bo {
- __u32 handle;
- __u32 pad;
- __u64 timeout_ns;
-};
-
-/**
- * struct drm_vc4_create_bo - ioctl argument for creating VC4 BOs.
- *
- * There are currently no values for the flags argument, but it may be
- * used in a future extension.
- */
-struct drm_vc4_create_bo {
- __u32 size;
- __u32 flags;
- /** Returned GEM handle for the BO. */
- __u32 handle;
- __u32 pad;
-};
-
-/**
- * struct drm_vc4_mmap_bo - ioctl argument for mapping VC4 BOs.
- *
- * This doesn't actually perform an mmap. Instead, it returns the
- * offset you need to use in an mmap on the DRM device node. This
- * means that tools like valgrind end up knowing about the mapped
- * memory.
- *
- * There are currently no values for the flags argument, but it may be
- * used in a future extension.
- */
-struct drm_vc4_mmap_bo {
- /** Handle for the object being mapped. */
- __u32 handle;
- __u32 flags;
- /** offset into the drm node to use for subsequent mmap call. */
- __u64 offset;
-};
-
-/**
- * struct drm_vc4_create_shader_bo - ioctl argument for creating VC4
- * shader BOs.
- *
- * Since allowing a shader to be overwritten while it's also being
- * executed from would allow privlege escalation, shaders must be
- * created using this ioctl, and they can't be mmapped later.
- */
-struct drm_vc4_create_shader_bo {
- /* Size of the data argument. */
- __u32 size;
- /* Flags, currently must be 0. */
- __u32 flags;
-
- /* Pointer to the data. */
- __u64 data;
-
- /** Returned GEM handle for the BO. */
- __u32 handle;
- /* Pad, must be 0. */
- __u32 pad;
-};
-
-struct drm_vc4_get_hang_state_bo {
- __u32 handle;
- __u32 paddr;
- __u32 size;
- __u32 pad;
-};
-
-/**
- * struct drm_vc4_hang_state - ioctl argument for collecting state
- * from a GPU hang for analysis.
-*/
-struct drm_vc4_get_hang_state {
- /** Pointer to array of struct drm_vc4_get_hang_state_bo. */
- __u64 bo;
- /**
- * On input, the size of the bo array. Output is the number
- * of bos to be returned.
- */
- __u32 bo_count;
-
- __u32 start_bin, start_render;
-
- __u32 ct0ca, ct0ea;
- __u32 ct1ca, ct1ea;
- __u32 ct0cs, ct1cs;
- __u32 ct0ra0, ct1ra0;
-
- __u32 bpca, bpcs;
- __u32 bpoa, bpos;
-
- __u32 vpmbase;
-
- __u32 dbge;
- __u32 fdbgo;
- __u32 fdbgb;
- __u32 fdbgr;
- __u32 fdbgs;
- __u32 errstat;
-
- /* Pad that we may save more registers into in the future. */
- __u32 pad[16];
-};
-
-#define DRM_VC4_PARAM_V3D_IDENT0 0
-#define DRM_VC4_PARAM_V3D_IDENT1 1
-#define DRM_VC4_PARAM_V3D_IDENT2 2
-#define DRM_VC4_PARAM_SUPPORTS_BRANCHES 3
-
-struct drm_vc4_get_param {
- __u32 param;
- __u32 pad;
- __u64 value;
-};
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* _VC4_DRM_H_ */
diff --git a/chromium/third_party/libdrm/src/include/drm/vgem_drm.h b/chromium/third_party/libdrm/src/include/drm/vgem_drm.h
deleted file mode 100644
index 9be928f4a52..00000000000
--- a/chromium/third_party/libdrm/src/include/drm/vgem_drm.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015 The Chromium OS Authors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _VGEM_DRM_H_
-#define _VGEM_DRM_H_
-
-#include "drm.h"
-
-#define DRM_VGEM_MODE_MAP_DUMB 0x00
-
-#define DRM_IOCTL_VGEM_MODE_MAP_DUMB \
- DRM_IOWR(DRM_COMMAND_BASE + DRM_VGEM_MODE_MAP_DUMB, struct drm_mode_map_dumb)
-
-#endif
diff --git a/chromium/third_party/libdrm/src/include/drm/virtgpu_drm.h b/chromium/third_party/libdrm/src/include/drm/virtgpu_drm.h
index 91a31ffed82..abf11c588af 100644
--- a/chromium/third_party/libdrm/src/include/drm/virtgpu_drm.h
+++ b/chromium/third_party/libdrm/src/include/drm/virtgpu_drm.h
@@ -24,16 +24,13 @@
#ifndef VIRTGPU_DRM_H
#define VIRTGPU_DRM_H
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
+#include <stddef.h>
+#include "drm/drm.h"
/* Please note that modifications to all structs defined here are
* subject to backwards-compatibility constraints.
*
- * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
+ * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel
* compatibility Keep fields aligned to their size
*/
@@ -48,88 +45,88 @@ extern "C" {
#define DRM_VIRTGPU_GET_CAPS 0x09
struct drm_virtgpu_map {
- __u64 offset; /* use for mmap system call */
- __u32 handle;
- __u32 pad;
+ uint64_t offset; /* use for mmap system call */
+ uint32_t handle;
+ uint32_t pad;
};
struct drm_virtgpu_execbuffer {
- __u32 flags; /* for future use */
- __u32 size;
- __u64 command; /* void* */
- __u64 bo_handles;
- __u32 num_bo_handles;
- __u32 pad;
+ uint32_t flags; /* for future use */
+ uint32_t size;
+ uint64_t command; /* void* */
+ uint64_t bo_handles;
+ uint32_t num_bo_handles;
+ uint32_t pad;
};
#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
struct drm_virtgpu_getparam {
- __u64 param;
- __u64 value;
+ uint64_t param;
+ uint64_t value;
};
/* NO_BO flags? NO resource flag? */
/* resource flag for y_0_top */
struct drm_virtgpu_resource_create {
- __u32 target;
- __u32 format;
- __u32 bind;
- __u32 width;
- __u32 height;
- __u32 depth;
- __u32 array_size;
- __u32 last_level;
- __u32 nr_samples;
- __u32 flags;
- __u32 bo_handle; /* if this is set - recreate a new resource attached to this bo ? */
- __u32 res_handle; /* returned by kernel */
- __u32 size; /* validate transfer in the host */
- __u32 stride; /* validate transfer in the host */
+ uint32_t target;
+ uint32_t format;
+ uint32_t bind;
+ uint32_t width;
+ uint32_t height;
+ uint32_t depth;
+ uint32_t array_size;
+ uint32_t last_level;
+ uint32_t nr_samples;
+ uint32_t flags;
+ uint32_t bo_handle; /* if this is set - recreate a new resource attached to this bo ? */
+ uint32_t res_handle; /* returned by kernel */
+ uint32_t size; /* validate transfer in the host */
+ uint32_t stride; /* validate transfer in the host */
};
struct drm_virtgpu_resource_info {
- __u32 bo_handle;
- __u32 res_handle;
- __u32 size;
- __u32 stride;
+ uint32_t bo_handle;
+ uint32_t res_handle;
+ uint32_t size;
+ uint32_t stride;
};
struct drm_virtgpu_3d_box {
- __u32 x;
- __u32 y;
- __u32 z;
- __u32 w;
- __u32 h;
- __u32 d;
+ uint32_t x;
+ uint32_t y;
+ uint32_t z;
+ uint32_t w;
+ uint32_t h;
+ uint32_t d;
};
struct drm_virtgpu_3d_transfer_to_host {
- __u32 bo_handle;
+ uint32_t bo_handle;
struct drm_virtgpu_3d_box box;
- __u32 level;
- __u32 offset;
+ uint32_t level;
+ uint32_t offset;
};
struct drm_virtgpu_3d_transfer_from_host {
- __u32 bo_handle;
+ uint32_t bo_handle;
struct drm_virtgpu_3d_box box;
- __u32 level;
- __u32 offset;
+ uint32_t level;
+ uint32_t offset;
};
#define VIRTGPU_WAIT_NOWAIT 1 /* like it */
struct drm_virtgpu_3d_wait {
- __u32 handle; /* 0 is an invalid handle */
- __u32 flags;
+ uint32_t handle; /* 0 is an invalid handle */
+ uint32_t flags;
};
struct drm_virtgpu_get_caps {
- __u32 cap_set_id;
- __u32 cap_set_ver;
- __u64 addr;
- __u32 size;
- __u32 pad;
+ uint32_t cap_set_id;
+ uint32_t cap_set_ver;
+ uint64_t addr;
+ uint32_t size;
+ uint32_t pad;
};
#define DRM_IOCTL_VIRTGPU_MAP \
@@ -167,8 +164,4 @@ struct drm_virtgpu_get_caps {
DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
struct drm_virtgpu_get_caps)
-#if defined(__cplusplus)
-}
-#endif
-
#endif
diff --git a/chromium/third_party/libdrm/src/include/drm/vmwgfx_drm.h b/chromium/third_party/libdrm/src/include/drm/vmwgfx_drm.h
index 5b68b4d1088..4d0842391ed 100644
--- a/chromium/third_party/libdrm/src/include/drm/vmwgfx_drm.h
+++ b/chromium/third_party/libdrm/src/include/drm/vmwgfx_drm.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA
+ * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,11 +28,10 @@
#ifndef __VMWGFX_DRM_H__
#define __VMWGFX_DRM_H__
-#include "drm.h"
-
#define DRM_VMW_MAX_SURFACE_FACES 6
#define DRM_VMW_MAX_MIP_LEVELS 24
+#define DRM_VMW_EXT_NAME_LEN 128
#define DRM_VMW_GET_PARAM 0
#define DRM_VMW_ALLOC_DMABUF 1
@@ -49,20 +48,11 @@
#define DRM_VMW_UNREF_SURFACE 10
#define DRM_VMW_REF_SURFACE 11
#define DRM_VMW_EXECBUF 12
-#define DRM_VMW_GET_3D_CAP 13
+#define DRM_VMW_FIFO_DEBUG 13
#define DRM_VMW_FENCE_WAIT 14
-#define DRM_VMW_FENCE_SIGNALED 15
-#define DRM_VMW_FENCE_UNREF 16
-#define DRM_VMW_FENCE_EVENT 17
-#define DRM_VMW_PRESENT 18
-#define DRM_VMW_PRESENT_READBACK 19
-#define DRM_VMW_UPDATE_LAYOUT 20
-#define DRM_VMW_CREATE_SHADER 21
-#define DRM_VMW_UNREF_SHADER 22
-#define DRM_VMW_GB_SURFACE_CREATE 23
-#define DRM_VMW_GB_SURFACE_REF 24
-#define DRM_VMW_SYNCCPU 25
-#define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
+/* guarded by minor version >= 2 */
+#define DRM_VMW_UPDATE_LAYOUT 15
+
/*************************************************************************/
/**
@@ -79,25 +69,9 @@
#define DRM_VMW_PARAM_NUM_STREAMS 0
#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
#define DRM_VMW_PARAM_3D 2
-#define DRM_VMW_PARAM_HW_CAPS 3
-#define DRM_VMW_PARAM_FIFO_CAPS 4
-#define DRM_VMW_PARAM_MAX_FB_SIZE 5
-#define DRM_VMW_PARAM_FIFO_HW_VERSION 6
-#define DRM_VMW_PARAM_MAX_SURF_MEMORY 7
-#define DRM_VMW_PARAM_3D_CAPS_SIZE 8
-#define DRM_VMW_PARAM_MAX_MOB_MEMORY 9
-#define DRM_VMW_PARAM_MAX_MOB_SIZE 10
-#define DRM_VMW_PARAM_SCREEN_TARGET 11
-#define DRM_VMW_PARAM_DX 12
-
-/**
- * enum drm_vmw_handle_type - handle type for ref ioctls
- *
- */
-enum drm_vmw_handle_type {
- DRM_VMW_HANDLE_LEGACY = 0,
- DRM_VMW_HANDLE_PRIME = 1
-};
+#define DRM_VMW_PARAM_FIFO_OFFSET 3
+#define DRM_VMW_PARAM_HW_CAPS 4
+#define DRM_VMW_PARAM_FIFO_CAPS 5
/**
* struct drm_vmw_getparam_arg
@@ -109,9 +83,52 @@ enum drm_vmw_handle_type {
*/
struct drm_vmw_getparam_arg {
- __u64 value;
- __u32 param;
- __u32 pad64;
+ uint64_t value;
+ uint32_t param;
+ uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_EXTENSION - Query device extensions.
+ */
+
+/**
+ * struct drm_vmw_extension_rep
+ *
+ * @exists: The queried extension exists.
+ * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
+ * @driver_sarea_offset: Offset to any space in the DRI SAREA
+ * used by the extension.
+ * @major: Major version number of the extension.
+ * @minor: Minor version number of the extension.
+ * @pl: Patch level version number of the extension.
+ *
+ * Output argument to the DRM_VMW_EXTENSION Ioctl.
+ */
+
+struct drm_vmw_extension_rep {
+ int32_t exists;
+ uint32_t driver_ioctl_offset;
+ uint32_t driver_sarea_offset;
+ uint32_t major;
+ uint32_t minor;
+ uint32_t pl;
+ uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_extension_arg
+ *
+ * @extension - Ascii name of the extension to be queried. //In
+ * @rep - Reply as defined above. //Out
+ *
+ * Argument to the DRM_VMW_EXTENSION Ioctl.
+ */
+
+union drm_vmw_extension_arg {
+ char extension[DRM_VMW_EXT_NAME_LEN];
+ struct drm_vmw_extension_rep rep;
};
/*************************************************************************/
@@ -132,8 +149,8 @@ struct drm_vmw_getparam_arg {
*/
struct drm_vmw_context_arg {
- __s32 cid;
- __u32 pad64;
+ int32_t cid;
+ uint32_t pad64;
};
/*************************************************************************/
@@ -163,7 +180,7 @@ struct drm_vmw_context_arg {
* @mip_levels: Number of mip levels for each face.
* An unused face should have 0 encoded.
* @size_addr: Address of a user-space array of sruct drm_vmw_size
- * cast to an __u64 for 32-64 bit compatibility.
+ * cast to an uint64_t for 32-64 bit compatibility.
* The size of the array should equal the total number of mipmap levels.
* @shareable: Boolean whether other clients (as identified by file descriptors)
* may reference this surface.
@@ -175,19 +192,18 @@ struct drm_vmw_context_arg {
*/
struct drm_vmw_surface_create_req {
- __u32 flags;
- __u32 format;
- __u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES];
- __u64 size_addr;
- __s32 shareable;
- __s32 scanout;
+ uint32_t flags;
+ uint32_t format;
+ uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+ uint64_t size_addr;
+ int32_t shareable;
+ int32_t scanout;
};
/**
* struct drm_wmv_surface_arg
*
* @sid: Surface id of created surface or surface to destroy or reference.
- * @handle_type: Handle type for DRM_VMW_REF_SURFACE Ioctl.
*
* Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
* Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
@@ -195,8 +211,8 @@ struct drm_vmw_surface_create_req {
*/
struct drm_vmw_surface_arg {
- __s32 sid;
- enum drm_vmw_handle_type handle_type;
+ int32_t sid;
+ uint32_t pad64;
};
/**
@@ -211,10 +227,10 @@ struct drm_vmw_surface_arg {
*/
struct drm_vmw_size {
- __u32 width;
- __u32 height;
- __u32 depth;
- __u32 pad64;
+ uint32_t width;
+ uint32_t height;
+ uint32_t depth;
+ uint32_t pad64;
};
/**
@@ -275,20 +291,20 @@ union drm_vmw_surface_reference_arg {
* DRM_VMW_EXECBUF
*
* Submit a command buffer for execution on the host, and return a
- * fence seqno that when signaled, indicates that the command buffer has
+ * fence sequence that when signaled, indicates that the command buffer has
* executed.
*/
/**
* struct drm_vmw_execbuf_arg
*
- * @commands: User-space address of a command buffer cast to an __u64.
+ * @commands: User-space address of a command buffer cast to an uint64_t.
* @command-size: Size in bytes of the command buffer.
* @throttle-us: Sleep until software is less than @throttle_us
* microseconds ahead of hardware. The driver may round this value
* to the nearest kernel tick.
* @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
- * __u64.
+ * uint64_t.
* @version: Allows expanding the execbuf ioctl parameters without breaking
* backwards compatibility, since user-space will always tell the kernel
* which version it uses.
@@ -297,32 +313,21 @@ union drm_vmw_surface_reference_arg {
* Argument to the DRM_VMW_EXECBUF Ioctl.
*/
-#define DRM_VMW_EXECBUF_VERSION 2
+#define DRM_VMW_EXECBUF_VERSION 0
struct drm_vmw_execbuf_arg {
- __u64 commands;
- __u32 command_size;
- __u32 throttle_us;
- __u64 fence_rep;
- __u32 version;
- __u32 flags;
- __u32 context_handle;
- __u32 pad64;
+ uint64_t commands;
+ uint32_t command_size;
+ uint32_t throttle_us;
+ uint64_t fence_rep;
+ uint32_t version;
+ uint32_t flags;
};
/**
* struct drm_vmw_fence_rep
*
- * @handle: Fence object handle for fence associated with a command submission.
- * @mask: Fence flags relevant for this fence object.
- * @seqno: Fence sequence number in fifo. A fence object with a lower
- * seqno will signal the EXEC flag before a fence object with a higher
- * seqno. This can be used by user-space to avoid kernel calls to determine
- * whether a fence has signaled the EXEC flag. Note that @seqno will
- * wrap at 32-bit.
- * @passed_seqno: The highest seqno number processed by the hardware
- * so far. This can be used to mark user-space fence objects as signaled, and
- * to determine whether a fence seqno might be stale.
+ * @fence_seq: Fence sequence associated with a command submission.
* @error: This member should've been set to -EFAULT on submission.
* The following actions should be take on completion:
* error == -EFAULT: Fence communication failed. The host is synchronized.
@@ -336,12 +341,9 @@ struct drm_vmw_execbuf_arg {
*/
struct drm_vmw_fence_rep {
- __u32 handle;
- __u32 mask;
- __u32 seqno;
- __u32 passed_seqno;
- __u32 pad64;
- __s32 error;
+ uint64_t fence_seq;
+ int32_t error;
+ uint32_t pad64;
};
/*************************************************************************/
@@ -371,8 +373,8 @@ struct drm_vmw_fence_rep {
*/
struct drm_vmw_alloc_dmabuf_req {
- __u32 size;
- __u32 pad64;
+ uint32_t size;
+ uint32_t pad64;
};
/**
@@ -389,11 +391,11 @@ struct drm_vmw_alloc_dmabuf_req {
*/
struct drm_vmw_dmabuf_rep {
- __u64 map_handle;
- __u32 handle;
- __u32 cur_gmr_id;
- __u32 cur_gmr_offset;
- __u32 pad64;
+ uint64_t map_handle;
+ uint32_t handle;
+ uint32_t cur_gmr_id;
+ uint32_t cur_gmr_offset;
+ uint32_t pad64;
};
/**
@@ -426,8 +428,41 @@ union drm_vmw_alloc_dmabuf_arg {
*/
struct drm_vmw_unref_dmabuf_arg {
- __u32 handle;
- __u32 pad64;
+ uint32_t handle;
+ uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
+ *
+ * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
+ */
+
+/**
+ * struct drm_vmw_fifo_debug_arg
+ *
+ * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
+ * @debug_buffer_size: Size in bytes of debug buffer //In
+ * @used_size: Number of bytes copied to the buffer // Out
+ * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
+ *
+ * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
+ */
+
+struct drm_vmw_fifo_debug_arg {
+ uint64_t debug_buffer;
+ uint32_t debug_buffer_size;
+ uint32_t used_size;
+ int32_t did_not_fit;
+ uint32_t pad64;
+};
+
+struct drm_vmw_fence_wait_arg {
+ uint64_t sequence;
+ uint64_t kernel_cookie;
+ int32_t cookie_valid;
+ int32_t pad64;
};
/*************************************************************************/
@@ -450,10 +485,10 @@ struct drm_vmw_unref_dmabuf_arg {
*/
struct drm_vmw_rect {
- __s32 x;
- __s32 y;
- __u32 w;
- __u32 h;
+ int32_t x;
+ int32_t y;
+ uint32_t w;
+ uint32_t h;
};
/**
@@ -475,21 +510,21 @@ struct drm_vmw_rect {
*/
struct drm_vmw_control_stream_arg {
- __u32 stream_id;
- __u32 enabled;
+ uint32_t stream_id;
+ uint32_t enabled;
- __u32 flags;
- __u32 color_key;
+ uint32_t flags;
+ uint32_t color_key;
- __u32 handle;
- __u32 offset;
- __s32 format;
- __u32 size;
- __u32 width;
- __u32 height;
- __u32 pitch[3];
+ uint32_t handle;
+ uint32_t offset;
+ int32_t format;
+ uint32_t size;
+ uint32_t width;
+ uint32_t height;
+ uint32_t pitch[3];
- __u32 pad64;
+ uint32_t pad64;
struct drm_vmw_rect src;
struct drm_vmw_rect dst;
};
@@ -517,12 +552,12 @@ struct drm_vmw_control_stream_arg {
*/
struct drm_vmw_cursor_bypass_arg {
- __u32 flags;
- __u32 crtc_id;
- __s32 xpos;
- __s32 ypos;
- __s32 xhot;
- __s32 yhot;
+ uint32_t flags;
+ uint32_t crtc_id;
+ int32_t xpos;
+ int32_t ypos;
+ int32_t xhot;
+ int32_t yhot;
};
/*************************************************************************/
@@ -540,8 +575,8 @@ struct drm_vmw_cursor_bypass_arg {
*/
struct drm_vmw_stream_arg {
- __u32 stream_id;
- __u32 pad64;
+ uint32_t stream_id;
+ uint32_t pad64;
};
/*************************************************************************/
@@ -554,537 +589,26 @@ struct drm_vmw_stream_arg {
/*************************************************************************/
/**
- * DRM_VMW_GET_3D_CAP
- *
- * Read 3D capabilities from the FIFO
- *
- */
-
-/**
- * struct drm_vmw_get_3d_cap_arg
- *
- * @buffer: Pointer to a buffer for capability data, cast to an __u64
- * @size: Max size to copy
- *
- * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
- * ioctls.
- */
-
-struct drm_vmw_get_3d_cap_arg {
- __u64 buffer;
- __u32 max_size;
- __u32 pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_FENCE_WAIT
- *
- * Waits for a fence object to signal. The wait is interruptible, so that
- * signals may be delivered during the interrupt. The wait may timeout,
- * in which case the calls returns -EBUSY. If the wait is restarted,
- * that is restarting without resetting @cookie_valid to zero,
- * the timeout is computed from the first call.
- *
- * The flags argument to the DRM_VMW_FENCE_WAIT ioctl indicates what to wait
- * on:
- * DRM_VMW_FENCE_FLAG_EXEC: All commands ahead of the fence in the command
- * stream
- * have executed.
- * DRM_VMW_FENCE_FLAG_QUERY: All query results resulting from query finish
- * commands
- * in the buffer given to the EXECBUF ioctl returning the fence object handle
- * are available to user-space.
- *
- * DRM_VMW_WAIT_OPTION_UNREF: If this wait option is given, and the
- * fenc wait ioctl returns 0, the fence object has been unreferenced after
- * the wait.
- */
-
-#define DRM_VMW_FENCE_FLAG_EXEC (1 << 0)
-#define DRM_VMW_FENCE_FLAG_QUERY (1 << 1)
-
-#define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
-
-/**
- * struct drm_vmw_fence_wait_arg
- *
- * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
- * @cookie_valid: Must be reset to 0 on first call. Left alone on restart.
- * @kernel_cookie: Set to 0 on first call. Left alone on restart.
- * @timeout_us: Wait timeout in microseconds. 0 for indefinite timeout.
- * @lazy: Set to 1 if timing is not critical. Allow more than a kernel tick
- * before returning.
- * @flags: Fence flags to wait on.
- * @wait_options: Options that control the behaviour of the wait ioctl.
- *
- * Input argument to the DRM_VMW_FENCE_WAIT ioctl.
- */
-
-struct drm_vmw_fence_wait_arg {
- __u32 handle;
- __s32 cookie_valid;
- __u64 kernel_cookie;
- __u64 timeout_us;
- __s32 lazy;
- __s32 flags;
- __s32 wait_options;
- __s32 pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_FENCE_SIGNALED
- *
- * Checks if a fence object is signaled..
- */
-
-/**
- * struct drm_vmw_fence_signaled_arg
- *
- * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
- * @flags: Fence object flags input to DRM_VMW_FENCE_SIGNALED ioctl
- * @signaled: Out: Flags signaled.
- * @sequence: Out: Highest sequence passed so far. Can be used to signal the
- * EXEC flag of user-space fence objects.
- *
- * Input/Output argument to the DRM_VMW_FENCE_SIGNALED and DRM_VMW_FENCE_UNREF
- * ioctls.
- */
-
-struct drm_vmw_fence_signaled_arg {
- __u32 handle;
- __u32 flags;
- __s32 signaled;
- __u32 passed_seqno;
- __u32 signaled_flags;
- __u32 pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_FENCE_UNREF
- *
- * Unreferences a fence object, and causes it to be destroyed if there are no
- * other references to it.
- *
- */
-
-/**
- * struct drm_vmw_fence_arg
- *
- * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
- *
- * Input/Output argument to the DRM_VMW_FENCE_UNREF ioctl..
- */
-
-struct drm_vmw_fence_arg {
- __u32 handle;
- __u32 pad64;
-};
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_FENCE_EVENT
- *
- * Queues an event on a fence to be delivered on the drm character device
- * when the fence has signaled the DRM_VMW_FENCE_FLAG_EXEC flag.
- * Optionally the approximate time when the fence signaled is
- * given by the event.
- */
-
-/*
- * The event type
- */
-#define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
-
-struct drm_vmw_event_fence {
- struct drm_event base;
- __u64 user_data;
- __u32 tv_sec;
- __u32 tv_usec;
-};
-
-/*
- * Flags that may be given to the command.
- */
-/* Request fence signaled time on the event. */
-#define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
-
-/**
- * struct drm_vmw_fence_event_arg
- *
- * @fence_rep: Pointer to fence_rep structure cast to __u64 or 0 if
- * the fence is not supposed to be referenced by user-space.
- * @user_info: Info to be delivered with the event.
- * @handle: Attach the event to this fence only.
- * @flags: A set of flags as defined above.
- */
-struct drm_vmw_fence_event_arg {
- __u64 fence_rep;
- __u64 user_data;
- __u32 handle;
- __u32 flags;
-};
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_PRESENT
- *
- * Executes an SVGA present on a given fb for a given surface. The surface
- * is placed on the framebuffer. Cliprects are given relative to the given
- * point (the point disignated by dest_{x|y}).
- *
- */
-
-/**
- * struct drm_vmw_present_arg
- * @fb_id: framebuffer id to present / read back from.
- * @sid: Surface id to present from.
- * @dest_x: X placement coordinate for surface.
- * @dest_y: Y placement coordinate for surface.
- * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
- * @num_clips: Number of cliprects given relative to the framebuffer origin,
- * in the same coordinate space as the frame buffer.
- * @pad64: Unused 64-bit padding.
- *
- * Input argument to the DRM_VMW_PRESENT ioctl.
- */
-
-struct drm_vmw_present_arg {
- __u32 fb_id;
- __u32 sid;
- __s32 dest_x;
- __s32 dest_y;
- __u64 clips_ptr;
- __u32 num_clips;
- __u32 pad64;
-};
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_PRESENT_READBACK
- *
- * Executes an SVGA present readback from a given fb to the dma buffer
- * currently bound as the fb. If there is no dma buffer bound to the fb,
- * an error will be returned.
- *
- */
-
-/**
- * struct drm_vmw_present_arg
- * @fb_id: fb_id to present / read back from.
- * @num_clips: Number of cliprects.
- * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
- * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an __u64.
- * If this member is NULL, then the ioctl should not return a fence.
- */
-
-struct drm_vmw_present_readback_arg {
- __u32 fb_id;
- __u32 num_clips;
- __u64 clips_ptr;
- __u64 fence_rep;
-};
-
-/*************************************************************************/
-/**
* DRM_VMW_UPDATE_LAYOUT - Update layout
*
- * Updates the preferred modes and connection status for connectors. The
- * command consists of one drm_vmw_update_layout_arg pointing to an array
+ * Updates the prefered modes and connection status for connectors. The
+ * command conisits of one drm_vmw_update_layout_arg pointing out a array
* of num_outputs drm_vmw_rect's.
*/
/**
* struct drm_vmw_update_layout_arg
*
- * @num_outputs: number of active connectors
- * @rects: pointer to array of drm_vmw_rect cast to an __u64
+ * @num_outputs: number of active
+ * @rects: pointer to array of drm_vmw_rect
*
* Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
*/
-struct drm_vmw_update_layout_arg {
- __u32 num_outputs;
- __u32 pad64;
- __u64 rects;
-};
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_CREATE_SHADER - Create shader
- *
- * Creates a shader and optionally binds it to a dma buffer containing
- * the shader byte-code.
- */
-
-/**
- * enum drm_vmw_shader_type - Shader types
- */
-enum drm_vmw_shader_type {
- drm_vmw_shader_type_vs = 0,
- drm_vmw_shader_type_ps,
-};
-
-
-/**
- * struct drm_vmw_shader_create_arg
- *
- * @shader_type: Shader type of the shader to create.
- * @size: Size of the byte-code in bytes.
- * where the shader byte-code starts
- * @buffer_handle: Buffer handle identifying the buffer containing the
- * shader byte-code
- * @shader_handle: On successful completion contains a handle that
- * can be used to subsequently identify the shader.
- * @offset: Offset in bytes into the buffer given by @buffer_handle,
- *
- * Input / Output argument to the DRM_VMW_CREATE_SHADER Ioctl.
- */
-struct drm_vmw_shader_create_arg {
- enum drm_vmw_shader_type shader_type;
- __u32 size;
- __u32 buffer_handle;
- __u32 shader_handle;
- __u64 offset;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_SHADER - Unreferences a shader
- *
- * Destroys a user-space reference to a shader, optionally destroying
- * it.
- */
-
-/**
- * struct drm_vmw_shader_arg
- *
- * @handle: Handle identifying the shader to destroy.
- *
- * Input argument to the DRM_VMW_UNREF_SHADER ioctl.
- */
-struct drm_vmw_shader_arg {
- __u32 handle;
- __u32 pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_GB_SURFACE_CREATE - Create a host guest-backed surface.
- *
- * Allocates a surface handle and queues a create surface command
- * for the host on the first use of the surface. The surface ID can
- * be used as the surface ID in commands referencing the surface.
- */
-
-/**
- * enum drm_vmw_surface_flags
- *
- * @drm_vmw_surface_flag_shareable: Whether the surface is shareable
- * @drm_vmw_surface_flag_scanout: Whether the surface is a scanout
- * surface.
- * @drm_vmw_surface_flag_create_buffer: Create a backup buffer if none is
- * given.
- */
-enum drm_vmw_surface_flags {
- drm_vmw_surface_flag_shareable = (1 << 0),
- drm_vmw_surface_flag_scanout = (1 << 1),
- drm_vmw_surface_flag_create_buffer = (1 << 2)
-};
-
-/**
- * struct drm_vmw_gb_surface_create_req
- *
- * @svga3d_flags: SVGA3d surface flags for the device.
- * @format: SVGA3d format.
- * @mip_level: Number of mip levels for all faces.
- * @drm_surface_flags Flags as described above.
- * @multisample_count Future use. Set to 0.
- * @autogen_filter Future use. Set to 0.
- * @buffer_handle Buffer handle of backup buffer. SVGA3D_INVALID_ID
- * if none.
- * @base_size Size of the base mip level for all faces.
- * @array_size Must be zero for non-DX hardware, and if non-zero
- * svga3d_flags must have proper bind flags setup.
- *
- * Input argument to the DRM_VMW_GB_SURFACE_CREATE Ioctl.
- * Part of output argument for the DRM_VMW_GB_SURFACE_REF Ioctl.
- */
-struct drm_vmw_gb_surface_create_req {
- __u32 svga3d_flags;
- __u32 format;
- __u32 mip_levels;
- enum drm_vmw_surface_flags drm_surface_flags;
- __u32 multisample_count;
- __u32 autogen_filter;
- __u32 buffer_handle;
- __u32 array_size;
- struct drm_vmw_size base_size;
-};
-
-/**
- * struct drm_vmw_gb_surface_create_rep
- *
- * @handle: Surface handle.
- * @backup_size: Size of backup buffers for this surface.
- * @buffer_handle: Handle of backup buffer. SVGA3D_INVALID_ID if none.
- * @buffer_size: Actual size of the buffer identified by
- * @buffer_handle
- * @buffer_map_handle: Offset into device address space for the buffer
- * identified by @buffer_handle.
- *
- * Part of output argument for the DRM_VMW_GB_SURFACE_REF ioctl.
- * Output argument for the DRM_VMW_GB_SURFACE_CREATE ioctl.
- */
-struct drm_vmw_gb_surface_create_rep {
- __u32 handle;
- __u32 backup_size;
- __u32 buffer_handle;
- __u32 buffer_size;
- __u64 buffer_map_handle;
-};
-/**
- * union drm_vmw_gb_surface_create_arg
- *
- * @req: Input argument as described above.
- * @rep: Output argument as described above.
- *
- * Argument to the DRM_VMW_GB_SURFACE_CREATE ioctl.
- */
-union drm_vmw_gb_surface_create_arg {
- struct drm_vmw_gb_surface_create_rep rep;
- struct drm_vmw_gb_surface_create_req req;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_GB_SURFACE_REF - Reference a host surface.
- *
- * Puts a reference on a host surface with a given handle, as previously
- * returned by the DRM_VMW_GB_SURFACE_CREATE ioctl.
- * A reference will make sure the surface isn't destroyed while we hold
- * it and will allow the calling client to use the surface handle in
- * the command stream.
- *
- * On successful return, the Ioctl returns the surface information given
- * to and returned from the DRM_VMW_GB_SURFACE_CREATE ioctl.
- */
-
-/**
- * struct drm_vmw_gb_surface_reference_arg
- *
- * @creq: The data used as input when the surface was created, as described
- * above at "struct drm_vmw_gb_surface_create_req"
- * @crep: Additional data output when the surface was created, as described
- * above at "struct drm_vmw_gb_surface_create_rep"
- *
- * Output Argument to the DRM_VMW_GB_SURFACE_REF ioctl.
- */
-struct drm_vmw_gb_surface_ref_rep {
- struct drm_vmw_gb_surface_create_req creq;
- struct drm_vmw_gb_surface_create_rep crep;
-};
-
-/**
- * union drm_vmw_gb_surface_reference_arg
- *
- * @req: Input data as described above at "struct drm_vmw_surface_arg"
- * @rep: Output data as described above at "struct drm_vmw_gb_surface_ref_rep"
- *
- * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
- */
-union drm_vmw_gb_surface_reference_arg {
- struct drm_vmw_gb_surface_ref_rep rep;
- struct drm_vmw_surface_arg req;
-};
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_SYNCCPU - Sync a DMA buffer / MOB for CPU access.
- *
- * Idles any previously submitted GPU operations on the buffer and
- * by default blocks command submissions that reference the buffer.
- * If the file descriptor used to grab a blocking CPU sync is closed, the
- * cpu sync is released.
- * The flags argument indicates how the grab / release operation should be
- * performed:
- */
-
-/**
- * enum drm_vmw_synccpu_flags - Synccpu flags:
- *
- * @drm_vmw_synccpu_read: Sync for read. If sync is done for read only, it's a
- * hint to the kernel to allow command submissions that references the buffer
- * for read-only.
- * @drm_vmw_synccpu_write: Sync for write. Block all command submissions
- * referencing this buffer.
- * @drm_vmw_synccpu_dontblock: Dont wait for GPU idle, but rather return
- * -EBUSY should the buffer be busy.
- * @drm_vmw_synccpu_allow_cs: Allow command submission that touches the buffer
- * while the buffer is synced for CPU. This is similar to the GEM bo idle
- * behavior.
- */
-enum drm_vmw_synccpu_flags {
- drm_vmw_synccpu_read = (1 << 0),
- drm_vmw_synccpu_write = (1 << 1),
- drm_vmw_synccpu_dontblock = (1 << 2),
- drm_vmw_synccpu_allow_cs = (1 << 3)
-};
-
-/**
- * enum drm_vmw_synccpu_op - Synccpu operations:
- *
- * @drm_vmw_synccpu_grab: Grab the buffer for CPU operations
- * @drm_vmw_synccpu_release: Release a previous grab.
- */
-enum drm_vmw_synccpu_op {
- drm_vmw_synccpu_grab,
- drm_vmw_synccpu_release
-};
-
-/**
- * struct drm_vmw_synccpu_arg
- *
- * @op: The synccpu operation as described above.
- * @handle: Handle identifying the buffer object.
- * @flags: Flags as described above.
- */
-struct drm_vmw_synccpu_arg {
- enum drm_vmw_synccpu_op op;
- enum drm_vmw_synccpu_flags flags;
- __u32 handle;
- __u32 pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CREATE_EXTENDED_CONTEXT - Create a host context.
- *
- * Allocates a device unique context id, and queues a create context command
- * for the host. Does not wait for host completion.
- */
-enum drm_vmw_extended_context {
- drm_vmw_context_legacy,
- drm_vmw_context_dx
+struct drm_vmw_update_layout_arg {
+ uint32_t num_outputs;
+ uint32_t pad64;
+ uint64_t rects;
};
-/**
- * union drm_vmw_extended_context_arg
- *
- * @req: Context type.
- * @rep: Context identifier.
- *
- * Argument to the DRM_VMW_CREATE_EXTENDED_CONTEXT Ioctl.
- */
-union drm_vmw_extended_context_arg {
- enum drm_vmw_extended_context req;
- struct drm_vmw_context_arg rep;
-};
#endif
diff --git a/chromium/third_party/libdrm/src/intel/Android.mk b/chromium/third_party/libdrm/src/intel/Android.mk
index 838a93b3b7f..6582dfdee08 100644
--- a/chromium/third_party/libdrm/src/intel/Android.mk
+++ b/chromium/third_party/libdrm/src/intel/Android.mk
@@ -30,7 +30,7 @@ include $(LOCAL_PATH)/Makefile.sources
LOCAL_MODULE := libdrm_intel
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_INTEL_FILES))
+LOCAL_SRC_FILES := $(LIBDRM_INTEL_FILES)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_CFLAGS := \
diff --git a/chromium/third_party/libdrm/src/intel/Makefile.am b/chromium/third_party/libdrm/src/intel/Makefile.am
index c52e8c086a8..d004568450e 100644
--- a/chromium/third_party/libdrm/src/intel/Makefile.am
+++ b/chromium/third_party/libdrm/src/intel/Makefile.am
@@ -66,6 +66,7 @@ EXTRA_DIST = \
$(BATCHES:.batch=.batch-ref.txt) \
$(BATCHES:.batch=.batch-ref.txt) \
tests/test-batch.sh \
+ Android.mk \
$(TESTS)
test_decode_LDADD = libdrm_intel.la ../libdrm.la
diff --git a/chromium/third_party/libdrm/src/intel/intel-symbol-check b/chromium/third_party/libdrm/src/intel/intel-symbol-check
index bde7634c321..c555e6daea8 100755
--- a/chromium/third_party/libdrm/src/intel/intel-symbol-check
+++ b/chromium/third_party/libdrm/src/intel/intel-symbol-check
@@ -34,13 +34,11 @@ drm_intel_bo_mrb_exec
drm_intel_bo_pin
drm_intel_bo_reference
drm_intel_bo_references
-drm_intel_bo_set_softpin_offset
drm_intel_bo_set_tiling
drm_intel_bo_subdata
drm_intel_bo_unmap
drm_intel_bo_unpin
drm_intel_bo_unreference
-drm_intel_bo_use_48b_address_range
drm_intel_bo_wait_rendering
drm_intel_bufmgr_check_aperture_space
drm_intel_bufmgr_destroy
diff --git a/chromium/third_party/libdrm/src/intel/intel_bufmgr.c b/chromium/third_party/libdrm/src/intel/intel_bufmgr.c
index a285340039f..14ea9f9fa4b 100644
--- a/chromium/third_party/libdrm/src/intel/intel_bufmgr.c
+++ b/chromium/third_party/libdrm/src/intel/intel_bufmgr.c
@@ -261,15 +261,6 @@ drm_intel_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
}
int
-drm_intel_bo_set_softpin_offset(drm_intel_bo *bo, uint64_t offset)
-{
- if (bo->bufmgr->bo_set_softpin_offset)
- return bo->bufmgr->bo_set_softpin_offset(bo, offset);
-
- return -ENODEV;
-}
-
-int
drm_intel_bo_disable_reuse(drm_intel_bo *bo)
{
if (bo->bufmgr->bo_disable_reuse)
@@ -302,17 +293,6 @@ drm_intel_bo_madvise(drm_intel_bo *bo, int madv)
}
int
-drm_intel_bo_use_48b_address_range(drm_intel_bo *bo, uint32_t enable)
-{
- if (bo->bufmgr->bo_use_48b_address_range) {
- bo->bufmgr->bo_use_48b_address_range(bo, enable);
- return 0;
- }
-
- return -ENODEV;
-}
-
-int
drm_intel_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo)
{
return bo->bufmgr->bo_references(bo, target_bo);
diff --git a/chromium/third_party/libdrm/src/intel/intel_bufmgr.h b/chromium/third_party/libdrm/src/intel/intel_bufmgr.h
index a1abbcd2b06..95eecb8002c 100644
--- a/chromium/third_party/libdrm/src/intel/intel_bufmgr.h
+++ b/chromium/third_party/libdrm/src/intel/intel_bufmgr.h
@@ -164,8 +164,6 @@ int drm_intel_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
int drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name);
int drm_intel_bo_busy(drm_intel_bo *bo);
int drm_intel_bo_madvise(drm_intel_bo *bo, int madv);
-int drm_intel_bo_use_48b_address_range(drm_intel_bo *bo, uint32_t enable);
-int drm_intel_bo_set_softpin_offset(drm_intel_bo *bo, uint64_t offset);
int drm_intel_bo_disable_reuse(drm_intel_bo *bo);
int drm_intel_bo_is_reusable(drm_intel_bo *bo);
diff --git a/chromium/third_party/libdrm/src/intel/intel_bufmgr_fake.c b/chromium/third_party/libdrm/src/intel/intel_bufmgr_fake.c
index 24b3732aa14..551e05deef2 100644
--- a/chromium/third_party/libdrm/src/intel/intel_bufmgr_fake.c
+++ b/chromium/third_party/libdrm/src/intel/intel_bufmgr_fake.c
@@ -42,7 +42,6 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
-#include <strings.h>
#include <xf86drm.h>
#include <pthread.h>
#include "intel_bufmgr.h"
@@ -312,7 +311,7 @@ _fence_wait_internal(drm_intel_bufmgr_fake *bufmgr_fake, int seq)
*
* Assume that in userland we treat sequence numbers as ints, which
* makes some of the comparisons convenient, since the sequence
- * numbers are all positive signed integers.
+ * numbers are all postive signed integers.
*
* From this we get several cases we need to handle. Here's a timeline.
* 0x2 0x7 0x7ffffff8 0x7ffffffd
diff --git a/chromium/third_party/libdrm/src/intel/intel_bufmgr_gem.c b/chromium/third_party/libdrm/src/intel/intel_bufmgr_gem.c
index 0a4012beec5..63122d099b7 100644
--- a/chromium/third_party/libdrm/src/intel/intel_bufmgr_gem.c
+++ b/chromium/third_party/libdrm/src/intel/intel_bufmgr_gem.c
@@ -83,22 +83,6 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MAX2(A, B) ((A) > (B) ? (A) : (B))
-/**
- * upper_32_bits - return bits 32-63 of a number
- * @n: the number we're accessing
- *
- * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
- * the "right shift count >= width of type" warning when that quantity is
- * 32-bits.
- */
-#define upper_32_bits(n) ((__u32)(((n) >> 16) >> 16))
-
-/**
- * lower_32_bits - return bits 0-31 of a number
- * @n: the number we're accessing
- */
-#define lower_32_bits(n) ((__u32)(n))
-
typedef struct _drm_intel_bo_gem drm_intel_bo_gem;
struct drm_intel_gem_bo_bucket {
@@ -200,13 +184,6 @@ struct _drm_intel_bo_gem {
drm_intel_reloc_target *reloc_target_info;
/** Number of entries in relocs */
int reloc_count;
- /** Array of BOs that are referenced by this buffer and will be softpinned */
- drm_intel_bo **softpin_target;
- /** Number softpinned BOs that are referenced by this buffer */
- int softpin_target_count;
- /** Maximum amount of softpinned BOs that are referenced by this buffer */
- int softpin_target_size;
-
/** Mapped address for the buffer, saved across map/unmap cycles */
void *mem_virtual;
/** GTT virtual address for the buffer, saved across map/unmap cycles */
@@ -260,20 +237,6 @@ struct _drm_intel_bo_gem {
bool is_userptr;
/**
- * Boolean of whether this buffer can be placed in the full 48-bit
- * address range on gen8+.
- *
- * By default, buffers will be keep in a 32-bit range, unless this
- * flag is explicitly set.
- */
- bool use_48b_address_range;
-
- /**
- * Whether this buffer is softpinned at offset specified by the user
- */
- bool is_softpin;
-
- /**
* Size in bytes of this buffer and its relocation descendents.
*
* Used to avoid costly tree walking in
@@ -426,9 +389,8 @@ drm_intel_gem_dump_validation_list(drm_intel_bufmgr_gem *bufmgr_gem)
drm_intel_bo *bo = bufmgr_gem->exec_bos[i];
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
- if (bo_gem->relocs == NULL && bo_gem->softpin_target == NULL) {
- DBG("%2d: %d %s(%s)\n", i, bo_gem->gem_handle,
- bo_gem->is_softpin ? "*" : "",
+ if (bo_gem->relocs == NULL) {
+ DBG("%2d: %d (%s)\n", i, bo_gem->gem_handle,
bo_gem->name);
continue;
}
@@ -438,36 +400,16 @@ drm_intel_gem_dump_validation_list(drm_intel_bufmgr_gem *bufmgr_gem)
drm_intel_bo_gem *target_gem =
(drm_intel_bo_gem *) target_bo;
- DBG("%2d: %d %s(%s)@0x%08x %08x -> "
- "%d (%s)@0x%08x %08x + 0x%08x\n",
+ DBG("%2d: %d (%s)@0x%08llx -> "
+ "%d (%s)@0x%08lx + 0x%08x\n",
i,
- bo_gem->gem_handle,
- bo_gem->is_softpin ? "*" : "",
- bo_gem->name,
- upper_32_bits(bo_gem->relocs[j].offset),
- lower_32_bits(bo_gem->relocs[j].offset),
+ bo_gem->gem_handle, bo_gem->name,
+ (unsigned long long)bo_gem->relocs[j].offset,
target_gem->gem_handle,
target_gem->name,
- upper_32_bits(target_bo->offset64),
- lower_32_bits(target_bo->offset64),
+ target_bo->offset64,
bo_gem->relocs[j].delta);
}
-
- for (j = 0; j < bo_gem->softpin_target_count; j++) {
- drm_intel_bo *target_bo = bo_gem->softpin_target[j];
- drm_intel_bo_gem *target_gem =
- (drm_intel_bo_gem *) target_bo;
- DBG("%2d: %d %s(%s) -> "
- "%d *(%s)@0x%08x %08x\n",
- i,
- bo_gem->gem_handle,
- bo_gem->is_softpin ? "*" : "",
- bo_gem->name,
- target_gem->gem_handle,
- target_gem->name,
- upper_32_bits(target_bo->offset64),
- lower_32_bits(target_bo->offset64));
- }
}
}
@@ -531,17 +473,11 @@ drm_intel_add_validate_buffer2(drm_intel_bo *bo, int need_fence)
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
int index;
- int flags = 0;
-
- if (need_fence)
- flags |= EXEC_OBJECT_NEEDS_FENCE;
- if (bo_gem->use_48b_address_range)
- flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
- if (bo_gem->is_softpin)
- flags |= EXEC_OBJECT_PINNED;
if (bo_gem->validate_index != -1) {
- bufmgr_gem->exec2_objects[bo_gem->validate_index].flags |= flags;
+ if (need_fence)
+ bufmgr_gem->exec2_objects[bo_gem->validate_index].flags |=
+ EXEC_OBJECT_NEEDS_FENCE;
return;
}
@@ -568,12 +504,15 @@ drm_intel_add_validate_buffer2(drm_intel_bo *bo, int need_fence)
bufmgr_gem->exec2_objects[index].relocation_count = bo_gem->reloc_count;
bufmgr_gem->exec2_objects[index].relocs_ptr = (uintptr_t)bo_gem->relocs;
bufmgr_gem->exec2_objects[index].alignment = bo->align;
- bufmgr_gem->exec2_objects[index].offset = bo_gem->is_softpin ?
- bo->offset64 : 0;
+ bufmgr_gem->exec2_objects[index].offset = 0;
bufmgr_gem->exec_bos[index] = bo;
- bufmgr_gem->exec2_objects[index].flags = flags;
+ bufmgr_gem->exec2_objects[index].flags = 0;
bufmgr_gem->exec2_objects[index].rsvd1 = 0;
bufmgr_gem->exec2_objects[index].rsvd2 = 0;
+ if (need_fence) {
+ bufmgr_gem->exec2_objects[index].flags |=
+ EXEC_OBJECT_NEEDS_FENCE;
+ }
bufmgr_gem->exec_count++;
}
@@ -846,7 +785,6 @@ retry:
bo_gem->used_as_reloc_target = false;
bo_gem->has_error = false;
bo_gem->reusable = true;
- bo_gem->use_48b_address_range = false;
drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, alignment);
@@ -993,7 +931,6 @@ drm_intel_gem_bo_alloc_userptr(drm_intel_bufmgr *bufmgr,
bo_gem->used_as_reloc_target = false;
bo_gem->has_error = false;
bo_gem->reusable = false;
- bo_gem->use_48b_address_range = false;
drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, 0);
@@ -1149,7 +1086,6 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
bo_gem->bo.handle = open_arg.handle;
bo_gem->global_name = handle;
bo_gem->reusable = false;
- bo_gem->use_48b_address_range = false;
memclear(get_tiling);
get_tiling.handle = bo_gem->gem_handle;
@@ -1325,12 +1261,8 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
time);
}
}
- for (i = 0; i < bo_gem->softpin_target_count; i++)
- drm_intel_gem_bo_unreference_locked_timed(bo_gem->softpin_target[i],
- time);
bo_gem->reloc_count = 0;
bo_gem->used_as_reloc_target = false;
- bo_gem->softpin_target_count = 0;
DBG("bo_unreference final: %d (%s)\n",
bo_gem->gem_handle, bo_gem->name);
@@ -1344,11 +1276,6 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
free(bo_gem->relocs);
bo_gem->relocs = NULL;
}
- if (bo_gem->softpin_target) {
- free(bo_gem->softpin_target);
- bo_gem->softpin_target = NULL;
- bo_gem->softpin_target_size = 0;
- }
/* Clear any left-over mappings */
if (bo_gem->map_count) {
@@ -1986,6 +1913,14 @@ do_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
bo_gem->reloc_tree_fences += target_bo_gem->reloc_tree_fences;
}
+ bo_gem->relocs[bo_gem->reloc_count].offset = offset;
+ bo_gem->relocs[bo_gem->reloc_count].delta = target_offset;
+ bo_gem->relocs[bo_gem->reloc_count].target_handle =
+ target_bo_gem->gem_handle;
+ bo_gem->relocs[bo_gem->reloc_count].read_domains = read_domains;
+ bo_gem->relocs[bo_gem->reloc_count].write_domain = write_domain;
+ bo_gem->relocs[bo_gem->reloc_count].presumed_offset = target_bo->offset64;
+
bo_gem->reloc_target_info[bo_gem->reloc_count].bo = target_bo;
if (target_bo != bo)
drm_intel_gem_bo_reference(target_bo);
@@ -1995,77 +1930,21 @@ do_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
else
bo_gem->reloc_target_info[bo_gem->reloc_count].flags = 0;
- bo_gem->relocs[bo_gem->reloc_count].offset = offset;
- bo_gem->relocs[bo_gem->reloc_count].delta = target_offset;
- bo_gem->relocs[bo_gem->reloc_count].target_handle =
- target_bo_gem->gem_handle;
- bo_gem->relocs[bo_gem->reloc_count].read_domains = read_domains;
- bo_gem->relocs[bo_gem->reloc_count].write_domain = write_domain;
- bo_gem->relocs[bo_gem->reloc_count].presumed_offset = target_bo->offset64;
bo_gem->reloc_count++;
return 0;
}
-static void
-drm_intel_gem_bo_use_48b_address_range(drm_intel_bo *bo, uint32_t enable)
-{
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
- bo_gem->use_48b_address_range = enable;
-}
-
-static int
-drm_intel_gem_bo_add_softpin_target(drm_intel_bo *bo, drm_intel_bo *target_bo)
-{
- drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
- drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *) target_bo;
- if (bo_gem->has_error)
- return -ENOMEM;
-
- if (target_bo_gem->has_error) {
- bo_gem->has_error = true;
- return -ENOMEM;
- }
-
- if (!target_bo_gem->is_softpin)
- return -EINVAL;
- if (target_bo_gem == bo_gem)
- return -EINVAL;
-
- if (bo_gem->softpin_target_count == bo_gem->softpin_target_size) {
- int new_size = bo_gem->softpin_target_size * 2;
- if (new_size == 0)
- new_size = bufmgr_gem->max_relocs;
-
- bo_gem->softpin_target = realloc(bo_gem->softpin_target, new_size *
- sizeof(drm_intel_bo *));
- if (!bo_gem->softpin_target)
- return -ENOMEM;
-
- bo_gem->softpin_target_size = new_size;
- }
- bo_gem->softpin_target[bo_gem->softpin_target_count] = target_bo;
- drm_intel_gem_bo_reference(target_bo);
- bo_gem->softpin_target_count++;
-
- return 0;
-}
-
static int
drm_intel_gem_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
drm_intel_bo *target_bo, uint32_t target_offset,
uint32_t read_domains, uint32_t write_domain)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
- drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *)target_bo;
- if (target_bo_gem->is_softpin)
- return drm_intel_gem_bo_add_softpin_target(bo, target_bo);
- else
- return do_bo_emit_reloc(bo, offset, target_bo, target_offset,
- read_domains, write_domain,
- !bufmgr_gem->fenced_relocs);
+ return do_bo_emit_reloc(bo, offset, target_bo, target_offset,
+ read_domains, write_domain,
+ !bufmgr_gem->fenced_relocs);
}
static int
@@ -2098,8 +1977,6 @@ drm_intel_gem_bo_get_reloc_count(drm_intel_bo *bo)
*
* Any further drm_intel_bufmgr_check_aperture_space() queries
* involving this buffer in the tree are undefined after this call.
- *
- * This also removes all softpinned targets being referenced by the BO.
*/
void
drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start)
@@ -2126,12 +2003,6 @@ drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start)
}
bo_gem->reloc_count = start;
- for (i = 0; i < bo_gem->softpin_target_count; i++) {
- drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *) bo_gem->softpin_target[i];
- drm_intel_gem_bo_unreference_locked_timed(&target_bo_gem->bo, time.tv_sec);
- }
- bo_gem->softpin_target_count = 0;
-
pthread_mutex_unlock(&bufmgr_gem->lock);
}
@@ -2172,7 +2043,7 @@ drm_intel_gem_bo_process_reloc2(drm_intel_bo *bo)
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
int i;
- if (bo_gem->relocs == NULL && bo_gem->softpin_target == NULL)
+ if (bo_gem->relocs == NULL)
return;
for (i = 0; i < bo_gem->reloc_count; i++) {
@@ -2193,17 +2064,6 @@ drm_intel_gem_bo_process_reloc2(drm_intel_bo *bo)
/* Add the target to the validate list */
drm_intel_add_validate_buffer2(target_bo, need_fence);
}
-
- for (i = 0; i < bo_gem->softpin_target_count; i++) {
- drm_intel_bo *target_bo = bo_gem->softpin_target[i];
-
- if (target_bo == bo)
- continue;
-
- drm_intel_gem_bo_mark_mmaps_incoherent(bo);
- drm_intel_gem_bo_process_reloc2(target_bo);
- drm_intel_add_validate_buffer2(target_bo, false);
- }
}
@@ -2218,12 +2078,10 @@ drm_intel_update_buffer_offsets(drm_intel_bufmgr_gem *bufmgr_gem)
/* Update the buffer offset */
if (bufmgr_gem->exec_objects[i].offset != bo->offset64) {
- DBG("BO %d (%s) migrated: 0x%08x %08x -> 0x%08x %08x\n",
- bo_gem->gem_handle, bo_gem->name,
- upper_32_bits(bo->offset64),
- lower_32_bits(bo->offset64),
- upper_32_bits(bufmgr_gem->exec_objects[i].offset),
- lower_32_bits(bufmgr_gem->exec_objects[i].offset));
+ DBG("BO %d (%s) migrated: 0x%08lx -> 0x%08llx\n",
+ bo_gem->gem_handle, bo_gem->name, bo->offset64,
+ (unsigned long long)bufmgr_gem->exec_objects[i].
+ offset);
bo->offset64 = bufmgr_gem->exec_objects[i].offset;
bo->offset = bufmgr_gem->exec_objects[i].offset;
}
@@ -2241,16 +2099,9 @@ drm_intel_update_buffer_offsets2 (drm_intel_bufmgr_gem *bufmgr_gem)
/* Update the buffer offset */
if (bufmgr_gem->exec2_objects[i].offset != bo->offset64) {
- /* If we're seeing softpinned object here it means that the kernel
- * has relocated our object... Indicating a programming error
- */
- assert(!bo_gem->is_softpin);
- DBG("BO %d (%s) migrated: 0x%08x %08x -> 0x%08x %08x\n",
- bo_gem->gem_handle, bo_gem->name,
- upper_32_bits(bo->offset64),
- lower_32_bits(bo->offset64),
- upper_32_bits(bufmgr_gem->exec2_objects[i].offset),
- lower_32_bits(bufmgr_gem->exec2_objects[i].offset));
+ DBG("BO %d (%s) migrated: 0x%08lx -> 0x%08llx\n",
+ bo_gem->gem_handle, bo_gem->name, bo->offset64,
+ (unsigned long long)bufmgr_gem->exec2_objects[i].offset);
bo->offset64 = bufmgr_gem->exec2_objects[i].offset;
bo->offset = bufmgr_gem->exec2_objects[i].offset;
}
@@ -2572,17 +2423,6 @@ drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
return 0;
}
-static int
-drm_intel_gem_bo_set_softpin_offset(drm_intel_bo *bo, uint64_t offset)
-{
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
-
- bo_gem->is_softpin = true;
- bo->offset64 = offset;
- bo->offset = offset;
- return 0;
-}
-
drm_intel_bo *
drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int size)
{
@@ -2646,7 +2486,6 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
bo_gem->used_as_reloc_target = false;
bo_gem->has_error = false;
bo_gem->reusable = false;
- bo_gem->use_48b_address_range = false;
DRMINITLISTHEAD(&bo_gem->vma_list);
DRMLISTADDTAIL(&bo_gem->name_list, &bufmgr_gem->named);
@@ -2962,13 +2801,6 @@ _drm_intel_gem_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo)
return 1;
}
- for (i = 0; i< bo_gem->softpin_target_count; i++) {
- if (bo_gem->softpin_target[i] == target_bo)
- return 1;
- if (_drm_intel_gem_bo_references(bo_gem->softpin_target[i], target_bo))
- return 1;
- }
-
return 0;
}
@@ -3379,7 +3211,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
bufmgr_gem->gtt_size > 256*1024*1024) {
/* The unmappable part of gtt on gen 3 (i.e. above 256MB) can't
* be used for tiled blits. To simplify the accounting, just
- * subtract the unmappable part (fixed to 256MB on all known
+ * substract the unmappable part (fixed to 256MB on all known
* gen3 devices) if the kernel advertises it. */
bufmgr_gem->gtt_size -= 256*1024*1024;
}
@@ -3425,11 +3257,6 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
bufmgr_gem->has_vebox = (ret == 0) & (*gp.value > 0);
- gp.param = I915_PARAM_HAS_EXEC_SOFTPIN;
- ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
- if (ret == 0 && *gp.value > 0)
- bufmgr_gem->bufmgr.bo_set_softpin_offset = drm_intel_gem_bo_set_softpin_offset;
-
if (bufmgr_gem->gen < 4) {
gp.param = I915_PARAM_NUM_FENCES_AVAIL;
gp.value = &bufmgr_gem->available_fences;
@@ -3456,13 +3283,6 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
}
}
- if (bufmgr_gem->gen >= 8) {
- gp.param = I915_PARAM_HAS_ALIASING_PPGTT;
- ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
- if (ret == 0 && *gp.value == 3)
- bufmgr_gem->bufmgr.bo_use_48b_address_range = drm_intel_gem_bo_use_48b_address_range;
- }
-
/* Let's go with one relocation per every 2 dwords (but round down a bit
* since a power of two will mean an extra page allocation for the reloc
* buffer).
diff --git a/chromium/third_party/libdrm/src/intel/intel_bufmgr_priv.h b/chromium/third_party/libdrm/src/intel/intel_bufmgr_priv.h
index 7e360a0b23d..59ebd18605c 100644
--- a/chromium/third_party/libdrm/src/intel/intel_bufmgr_priv.h
+++ b/chromium/third_party/libdrm/src/intel/intel_bufmgr_priv.h
@@ -152,20 +152,6 @@ struct _drm_intel_bufmgr {
void (*destroy) (drm_intel_bufmgr *bufmgr);
/**
- * Indicate if the buffer can be placed anywhere in the full ppgtt
- * address range (2^48).
- *
- * Any resource used with flat/heapless (0x00000000-0xfffff000)
- * General State Heap (GSH) or Intructions State Heap (ISH) must
- * be in a 32-bit range. 48-bit range will only be used when explicitly
- * requested.
- *
- * \param bo Buffer to set the use_48b_address_range flag.
- * \param enable The flag value.
- */
- void (*bo_use_48b_address_range) (drm_intel_bo *bo, uint32_t enable);
-
- /**
* Add relocation entry in reloc_buf, which will be updated with the
* target buffer's real offset on on command submission.
*
@@ -241,13 +227,6 @@ struct _drm_intel_bufmgr {
uint32_t * swizzle_mode);
/**
- * Set the offset at which this buffer will be softpinned
- * \param bo Buffer to set the softpin offset for
- * \param offset Softpin offset
- */
- int (*bo_set_softpin_offset) (drm_intel_bo *bo, uint64_t offset);
-
- /**
* Create a visible name for a buffer which can be used by other apps
*
* \param buf Buffer to create a name for
diff --git a/chromium/third_party/libdrm/src/intel/intel_chipset.h b/chromium/third_party/libdrm/src/intel/intel_chipset.h
index 514f6594a15..26fbee4db50 100644
--- a/chromium/third_party/libdrm/src/intel/intel_chipset.h
+++ b/chromium/third_party/libdrm/src/intel/intel_chipset.h
@@ -168,7 +168,6 @@
#define PCI_CHIP_SKYLAKE_DT_GT1 0x1902
#define PCI_CHIP_SKYLAKE_ULT_GT1 0x1906
#define PCI_CHIP_SKYLAKE_SRV_GT1 0x190A /* Reserved */
-#define PCI_CHIP_SKYLAKE_H_GT1 0x190B
#define PCI_CHIP_SKYLAKE_ULX_GT1 0x190E /* Reserved */
#define PCI_CHIP_SKYLAKE_DT_GT2 0x1912
#define PCI_CHIP_SKYLAKE_FUSED0_GT2 0x1913 /* Reserved */
@@ -180,43 +179,17 @@
#define PCI_CHIP_SKYLAKE_WKS_GT2 0x191D
#define PCI_CHIP_SKYLAKE_ULX_GT2 0x191E
#define PCI_CHIP_SKYLAKE_MOBILE_GT2 0x1921 /* Reserved */
-#define PCI_CHIP_SKYLAKE_ULT_GT3_0 0x1923
-#define PCI_CHIP_SKYLAKE_ULT_GT3_1 0x1926
-#define PCI_CHIP_SKYLAKE_ULT_GT3_2 0x1927
-#define PCI_CHIP_SKYLAKE_SRV_GT4 0x192A
+#define PCI_CHIP_SKYLAKE_GT3 0x1926
#define PCI_CHIP_SKYLAKE_HALO_GT3 0x192B /* Reserved */
-#define PCI_CHIP_SKYLAKE_SRV_GT3 0x192D
+#define PCI_CHIP_SKYLAKE_SRV_GT4 0x192A
#define PCI_CHIP_SKYLAKE_DT_GT4 0x1932
#define PCI_CHIP_SKYLAKE_SRV_GT4X 0x193A
#define PCI_CHIP_SKYLAKE_H_GT4 0x193B
#define PCI_CHIP_SKYLAKE_WKS_GT4 0x193D
-#define PCI_CHIP_KABYLAKE_ULT_GT2 0x5916
-#define PCI_CHIP_KABYLAKE_ULT_GT1_5 0x5913
-#define PCI_CHIP_KABYLAKE_ULT_GT1 0x5906
-#define PCI_CHIP_KABYLAKE_ULT_GT3_0 0x5923
-#define PCI_CHIP_KABYLAKE_ULT_GT3_1 0x5926
-#define PCI_CHIP_KABYLAKE_ULT_GT3_2 0x5927
-#define PCI_CHIP_KABYLAKE_ULT_GT2F 0x5921
-#define PCI_CHIP_KABYLAKE_ULX_GT1_5 0x5915
-#define PCI_CHIP_KABYLAKE_ULX_GT1 0x590E
-#define PCI_CHIP_KABYLAKE_ULX_GT2 0x591E
-#define PCI_CHIP_KABYLAKE_DT_GT2 0x5912
-#define PCI_CHIP_KABYLAKE_DT_GT1_5 0x5917
-#define PCI_CHIP_KABYLAKE_DT_GT1 0x5902
-#define PCI_CHIP_KABYLAKE_HALO_GT2 0x591B
-#define PCI_CHIP_KABYLAKE_HALO_GT4 0x593B
-#define PCI_CHIP_KABYLAKE_HALO_GT1_0 0x5908
-#define PCI_CHIP_KABYLAKE_HALO_GT1_1 0x590B
-#define PCI_CHIP_KABYLAKE_SRV_GT2 0x591A
-#define PCI_CHIP_KABYLAKE_SRV_GT1 0x590A
-#define PCI_CHIP_KABYLAKE_WKS_GT2 0x591D
-
#define PCI_CHIP_BROXTON_0 0x0A84
#define PCI_CHIP_BROXTON_1 0x1A84
#define PCI_CHIP_BROXTON_2 0x5A84
-#define PCI_CHIP_BROXTON_3 0x1A85
-#define PCI_CHIP_BROXTON_4 0x5A85
#define IS_MOBILE(devid) ((devid) == PCI_CHIP_I855_GM || \
(devid) == PCI_CHIP_I915_GM || \
@@ -377,11 +350,10 @@
#define IS_GEN8(devid) (IS_BROADWELL(devid) || \
IS_CHERRYVIEW(devid))
-#define IS_SKL_GT1(devid) ((devid) == PCI_CHIP_SKYLAKE_DT_GT1 || \
- (devid) == PCI_CHIP_SKYLAKE_ULT_GT1 || \
- (devid) == PCI_CHIP_SKYLAKE_SRV_GT1 || \
- (devid) == PCI_CHIP_SKYLAKE_H_GT1 || \
- (devid) == PCI_CHIP_SKYLAKE_ULX_GT1)
+#define IS_SKL_GT1(devid) ((devid) == PCI_CHIP_SKYLAKE_ULT_GT1 || \
+ (devid) == PCI_CHIP_SKYLAKE_ULX_GT1 || \
+ (devid) == PCI_CHIP_SKYLAKE_DT_GT1 || \
+ (devid) == PCI_CHIP_SKYLAKE_SRV_GT1)
#define IS_SKL_GT2(devid) ((devid) == PCI_CHIP_SKYLAKE_DT_GT2 || \
(devid) == PCI_CHIP_SKYLAKE_FUSED0_GT2 || \
@@ -394,11 +366,8 @@
(devid) == PCI_CHIP_SKYLAKE_ULX_GT2 || \
(devid) == PCI_CHIP_SKYLAKE_MOBILE_GT2)
-#define IS_SKL_GT3(devid) ((devid) == PCI_CHIP_SKYLAKE_ULT_GT3_0 || \
- (devid) == PCI_CHIP_SKYLAKE_ULT_GT3_1 || \
- (devid) == PCI_CHIP_SKYLAKE_ULT_GT3_2 || \
- (devid) == PCI_CHIP_SKYLAKE_HALO_GT3 || \
- (devid) == PCI_CHIP_SKYLAKE_SRV_GT3)
+#define IS_SKL_GT3(devid) ((devid) == PCI_CHIP_SKYLAKE_GT3 || \
+ (devid) == PCI_CHIP_SKYLAKE_HALO_GT3)
#define IS_SKL_GT4(devid) ((devid) == PCI_CHIP_SKYLAKE_SRV_GT4 || \
(devid) == PCI_CHIP_SKYLAKE_DT_GT4 || \
@@ -406,35 +375,6 @@
(devid) == PCI_CHIP_SKYLAKE_H_GT4 || \
(devid) == PCI_CHIP_SKYLAKE_WKS_GT4)
-#define IS_KBL_GT1(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT1_5 || \
- (devid) == PCI_CHIP_KABYLAKE_ULX_GT1_5 || \
- (devid) == PCI_CHIP_KABYLAKE_DT_GT1_5 || \
- (devid) == PCI_CHIP_KABYLAKE_ULT_GT1 || \
- (devid) == PCI_CHIP_KABYLAKE_ULX_GT1 || \
- (devid) == PCI_CHIP_KABYLAKE_DT_GT1 || \
- (devid) == PCI_CHIP_KABYLAKE_HALO_GT1_0 || \
- (devid) == PCI_CHIP_KABYLAKE_HALO_GT1_1 || \
- (devid) == PCI_CHIP_KABYLAKE_SRV_GT1)
-
-#define IS_KBL_GT2(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT2 || \
- (devid) == PCI_CHIP_KABYLAKE_ULT_GT2F || \
- (devid) == PCI_CHIP_KABYLAKE_ULX_GT2 || \
- (devid) == PCI_CHIP_KABYLAKE_DT_GT2 || \
- (devid) == PCI_CHIP_KABYLAKE_HALO_GT2 || \
- (devid) == PCI_CHIP_KABYLAKE_SRV_GT2 || \
- (devid) == PCI_CHIP_KABYLAKE_WKS_GT2)
-
-#define IS_KBL_GT3(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT3_0 || \
- (devid) == PCI_CHIP_KABYLAKE_ULT_GT3_1 || \
- (devid) == PCI_CHIP_KABYLAKE_ULT_GT3_2)
-
-#define IS_KBL_GT4(devid) ((devid) == PCI_CHIP_KABYLAKE_HALO_GT4)
-
-#define IS_KABYLAKE(devid) (IS_KBL_GT1(devid) || \
- IS_KBL_GT2(devid) || \
- IS_KBL_GT3(devid) || \
- IS_KBL_GT4(devid))
-
#define IS_SKYLAKE(devid) (IS_SKL_GT1(devid) || \
IS_SKL_GT2(devid) || \
IS_SKL_GT3(devid) || \
@@ -442,13 +382,10 @@
#define IS_BROXTON(devid) ((devid) == PCI_CHIP_BROXTON_0 || \
(devid) == PCI_CHIP_BROXTON_1 || \
- (devid) == PCI_CHIP_BROXTON_2 || \
- (devid) == PCI_CHIP_BROXTON_3 || \
- (devid) == PCI_CHIP_BROXTON_4)
+ (devid) == PCI_CHIP_BROXTON_2)
#define IS_GEN9(devid) (IS_SKYLAKE(devid) || \
- IS_BROXTON(devid) || \
- IS_KABYLAKE(devid))
+ IS_BROXTON(devid))
#define IS_9XX(dev) (IS_GEN3(dev) || \
IS_GEN4(dev) || \
diff --git a/chromium/third_party/libdrm/src/intel/intel_decode.c b/chromium/third_party/libdrm/src/intel/intel_decode.c
index 803d20293ff..e7aef742afa 100644
--- a/chromium/third_party/libdrm/src/intel/intel_decode.c
+++ b/chromium/third_party/libdrm/src/intel/intel_decode.c
@@ -38,6 +38,8 @@
#include "intel_chipset.h"
#include "intel_bufmgr.h"
+/* The compiler throws ~90 warnings. Do not spam the build, until we fix them. */
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
/* Struct for tracking drm_intel_decode state. */
struct drm_intel_decode {
@@ -3598,7 +3600,7 @@ decode_3d_965(struct drm_intel_decode *ctx)
instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
if (IS_GEN5(devid) || IS_GEN6(devid))
instr_out(ctx, 1,
- "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Separate Stencil %d\n",
+ "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
get_965_surfacetype(data[1] >> 29),
get_965_depthformat((data[1] >> 18) & 0x7),
(data[1] & 0x0001ffff) + 1,
diff --git a/chromium/third_party/libdrm/src/libkms/Android.mk b/chromium/third_party/libdrm/src/libkms/Android.mk
index 5386c6f55ec..4f5e3d2f29c 100644
--- a/chromium/third_party/libdrm/src/libkms/Android.mk
+++ b/chromium/third_party/libdrm/src/libkms/Android.mk
@@ -2,19 +2,13 @@ DRM_GPU_DRIVERS := $(strip $(filter-out swrast, $(BOARD_GPU_DRIVERS)))
intel_drivers := i915 i965 i915g ilo
radeon_drivers := r300g r600g radeonsi
-rockchip_drivers := rockchip
-mediatek_drivers := mediatek
nouveau_drivers := nouveau
-virgl_drivers := virgl
vmwgfx_drivers := vmwgfx
valid_drivers := \
$(intel_drivers) \
$(radeon_drivers) \
- $(rockchip_drivers) \
- $(mediatek_drivers) \
$(nouveau_drivers) \
- $(virgl_drivers) \
$(vmwgfx_drivers)
# warn about invalid drivers
@@ -30,7 +24,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/Makefile.sources
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBKMS_FILES))
+LOCAL_SRC_FILES := $(LIBKMS_FILES)
ifneq ($(filter $(vmwgfx_drivers), $(DRM_GPU_DRIVERS)),)
LOCAL_SRC_FILES += $(LIBKMS_VMWGFX_FILES)
diff --git a/chromium/third_party/libdrm/src/libkms/Makefile.am b/chromium/third_party/libdrm/src/libkms/Makefile.am
index 7b14f958fc3..6c0ab7a2805 100644
--- a/chromium/third_party/libdrm/src/libkms/Makefile.am
+++ b/chromium/third_party/libdrm/src/libkms/Makefile.am
@@ -37,11 +37,6 @@ libkms_la_SOURCES += $(LIBKMS_EXYNOS_FILES)
AM_CFLAGS += -I$(top_srcdir)/exynos
endif
-if HAVE_MEDIATEK
-libkms_la_SOURCES += $(LIBKMS_MEDIATEK_FILES)
-AM_CFLAGS += -I$(top_srcdir)/mediatek
-endif
-
libkmsincludedir = ${includedir}/libkms
libkmsinclude_HEADERS = $(LIBKMS_H_FILES)
@@ -49,4 +44,4 @@ pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libkms.pc
TESTS = kms-symbol-check
-EXTRA_DIST = $(TESTS)
+EXTRA_DIST = Android.mk $(TESTS)
diff --git a/chromium/third_party/libdrm/src/libkms/Makefile.sources b/chromium/third_party/libdrm/src/libkms/Makefile.sources
index 2c1a10a3182..3191f516666 100644
--- a/chromium/third_party/libdrm/src/libkms/Makefile.sources
+++ b/chromium/third_party/libdrm/src/libkms/Makefile.sources
@@ -19,8 +19,5 @@ LIBKMS_RADEON_FILES := \
LIBKMS_EXYNOS_FILES := \
exynos.c
-LIBKMS_MEDIATEK_FILES := \
- mediatek.c
-
LIBKMS_H_FILES := \
libkms.h
diff --git a/chromium/third_party/libdrm/src/libkms/internal.h b/chromium/third_party/libdrm/src/libkms/internal.h
index 845c57d5925..905f5b1705f 100644
--- a/chromium/third_party/libdrm/src/libkms/internal.h
+++ b/chromium/third_party/libdrm/src/libkms/internal.h
@@ -81,6 +81,4 @@ drm_private int radeon_create(int fd, struct kms_driver **out);
drm_private int exynos_create(int fd, struct kms_driver **out);
-drm_private int mediatek_create(int fd, struct kms_driver **out);
-
#endif
diff --git a/chromium/third_party/libdrm/src/libkms/libkms.pc.in b/chromium/third_party/libdrm/src/libkms/libkms.pc.in
index 1421b3eaae5..511535ad5b6 100644
--- a/chromium/third_party/libdrm/src/libkms/libkms.pc.in
+++ b/chromium/third_party/libdrm/src/libkms/libkms.pc.in
@@ -8,4 +8,3 @@ Description: Library that abstract aways the different mm interface for kernel d
Version: 1.0.0
Libs: -L${libdir} -lkms
Cflags: -I${includedir}/libkms
-Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/libkms/linux.c b/chromium/third_party/libdrm/src/libkms/linux.c
index 85e06cdbd6c..6e0da830fd2 100644
--- a/chromium/third_party/libdrm/src/libkms/linux.c
+++ b/chromium/third_party/libdrm/src/libkms/linux.c
@@ -41,12 +41,9 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef MAJOR_IN_MKDEV
+#ifdef HAVE_SYS_MKDEV_H
#include <sys/mkdev.h>
#endif
-#ifdef MAJOR_IN_SYSMACROS
-#include <sys/sysmacros.h>
-#endif
#include "libdrm_macros.h"
#include "internal.h"
@@ -135,11 +132,6 @@ linux_from_sysfs(int fd, struct kms_driver **out)
ret = exynos_create(fd, out);
else
#endif
-#ifdef HAVE_MEDIATEK
- if (!strcmp(name, "mediatek"))
- ret = mediatek_create(fd, out);
- else
-#endif
ret = -ENOSYS;
free(name);
diff --git a/chromium/third_party/libdrm/src/libkms/mediatek.c b/chromium/third_party/libdrm/src/libkms/mediatek.c
deleted file mode 100644
index b1a54c00311..00000000000
--- a/chromium/third_party/libdrm/src/libkms/mediatek.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2015 MediaTek Inc.
- * Author:JB TSAI <jb.tsai@mediatek.com>
- *
- * based on rockchip_drm.c
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "internal.h"
-
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include "xf86drm.h"
-
-#include "mediatek_drm.h"
-
-struct mediatek_bo
-{
- struct kms_bo base;
- unsigned map_count;
-};
-
-static int
-mediatek_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)
-{
- switch (key) {
- case KMS_BO_TYPE:
- *out = KMS_BO_TYPE_SCANOUT_X8R8G8B8 | KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static int
-mediatek_destroy(struct kms_driver *kms)
-{
- free(kms);
- return 0;
-}
-
-static int
-mediatek_bo_create(struct kms_driver *kms,
- const unsigned width, const unsigned height,
- const enum kms_bo_type type, const unsigned *attr,
- struct kms_bo **out)
-{
- struct drm_mtk_gem_create arg;
- unsigned size, pitch;
- struct mediatek_bo *bo;
- int i, ret;
-
- for (i = 0; attr[i]; i += 2) {
- switch (attr[i]) {
- case KMS_WIDTH:
- case KMS_HEIGHT:
- case KMS_BO_TYPE:
- break;
- default:
- return -EINVAL;
- }
- }
-
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return -ENOMEM;
-
- if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
- pitch = 64 * 4;
- size = 64 * 64 * 4;
- } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
- pitch = width * 4;
- pitch = (pitch + 512 - 1) & ~(512 - 1);
- size = pitch * ((height + 4 - 1) & ~(4 - 1));
- } else {
- return -EINVAL;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.size = size;
-
- ret = drmCommandWriteRead(kms->fd, DRM_MTK_GEM_CREATE, &arg, sizeof(arg));
- if (ret)
- goto err_free;
-
- bo->base.kms = kms;
- bo->base.handle = arg.handle;
- bo->base.size = size;
- bo->base.pitch = pitch;
-
- *out = &bo->base;
-
- return 0;
-
-err_free:
- free(bo);
- return ret;
-}
-
-static int
-mediatek_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out)
-{
- switch (key) {
- default:
- return -EINVAL;
- }
-}
-
-static int
-mediatek_bo_map(struct kms_bo *_bo, void **out)
-{
- struct mediatek_bo *bo = (struct mediatek_bo *)_bo;
- struct drm_mtk_gem_map_off arg;
- void *map = NULL;
- int ret;
-
- if (bo->base.ptr) {
- bo->map_count++;
- *out = bo->base.ptr;
- return 0;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = bo->base.handle;
-
- ret = drmCommandWriteRead(bo->base.kms->fd, DRM_MTK_GEM_MAP_OFFSET, &arg, sizeof(arg));
- if (ret)
- return ret;
-
- map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
- if (map == MAP_FAILED)
- return -errno;
-
- bo->base.ptr = map;
- bo->map_count++;
- *out = bo->base.ptr;
-
- return 0;
-}
-
-static int
-mediatek_bo_unmap(struct kms_bo *_bo)
-{
- struct mediatek_bo *bo = (struct mediatek_bo *)_bo;
- bo->map_count--;
- return 0;
-}
-
-static int
-mediatek_bo_destroy(struct kms_bo *_bo)
-{
- struct mediatek_bo *bo = (struct mediatek_bo *)_bo;
- struct drm_gem_close arg;
- int ret;
-
- if (bo->base.ptr) {
- /* XXX Sanity check map_count */
- munmap(bo->base.ptr, bo->base.size);
- bo->base.ptr = NULL;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = bo->base.handle;
-
- ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_GEM_CLOSE, &arg);
- if (ret)
- return -errno;
-
- free(bo);
- return 0;
-}
-
-int
-mediatek_create(int fd, struct kms_driver **out)
-{
- struct kms_driver *kms;
-
- kms = calloc(1, sizeof(*kms));
- if (!kms)
- return -ENOMEM;
-
- kms->fd = fd;
-
- kms->bo_create = mediatek_bo_create;
- kms->bo_map = mediatek_bo_map;
- kms->bo_unmap = mediatek_bo_unmap;
- kms->bo_get_prop = mediatek_bo_get_prop;
- kms->bo_destroy = mediatek_bo_destroy;
- kms->get_prop = mediatek_get_prop;
- kms->destroy = mediatek_destroy;
- *out = kms;
-
- return 0;
-}
diff --git a/chromium/third_party/libdrm/src/man/drm-kms.xml b/chromium/third_party/libdrm/src/man/drm-kms.xml
index ae38dc8d208..5f041578e0f 100644
--- a/chromium/third_party/libdrm/src/man/drm-kms.xml
+++ b/chromium/third_party/libdrm/src/man/drm-kms.xml
@@ -126,7 +126,7 @@
<listitem>
<para><emphasis>Framebuffers</emphasis> are abstract memory objects
that provide a source of pixel data to scanout to a CRTC.
- Applications explicitly request the creation of framebuffers
+ Applications explicitely request the creation of framebuffers
and can control their behavior. Framebuffers rely on the
underneath memory manager for low-level memory operations.
When creating a framebuffer, applications pass a memory handle
diff --git a/chromium/third_party/libdrm/src/mediatek/Android.mk b/chromium/third_party/libdrm/src/mediatek/Android.mk
deleted file mode 100644
index c9ac9f102d0..00000000000
--- a/chromium/third_party/libdrm/src/mediatek/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libdrm_mediatek
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := libdrm
-
-LOCAL_SRC_FILES := mediatek_drm.c
-LOCAL_EXPORT_C_INCLUDE_DIRS += \
- $(LOCAL_PATH)/mediatek
-
-LOCAL_C_INCLUDES := \
- $(LIBDRM_TOP) \
- $(LIBDRM_TOP)/mediatek \
- $(LIBDRM_TOP)/include/drm
-
-# This makes sure mmap64 is used, as mmap offsets can be larger than 32-bit
-LOCAL_CFLAGS := \
- -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 \
- -D_LARGEFILE_SOURCE \
- -D_LARGEFILE64_SOURCE \
- -D_FILE_OFFSET_BITS=64
-
-LOCAL_COPY_HEADERS := mediatek_drm.h mediatek_drmif.h
-LOCAL_COPY_HEADERS_TO := libdrm
-
-LOCAL_SHARED_LIBRARIES := \
- libdrm
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/chromium/third_party/libdrm/src/mediatek/Makefile.am b/chromium/third_party/libdrm/src/mediatek/Makefile.am
deleted file mode 100644
index bb23e46677c..00000000000
--- a/chromium/third_party/libdrm/src/mediatek/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -I$(top_srcdir) \
- -I$(top_srcdir)/mediatek \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_mediatek_la_LTLIBRARIES = libdrm_mediatek.la
-libdrm_mediatek_ladir = $(libdir)
-libdrm_mediatek_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_mediatek_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_mediatek_la_SOURCES = \
- mediatek_drm.c
-
-libdrm_mediatekincludedir = ${includedir}/libdrm
-libdrm_mediatekinclude_HEADERS = mediatek_drmif.h mediatek_drm.h
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_mediatek.pc
diff --git a/chromium/third_party/libdrm/src/mediatek/libdrm_mediatek.pc.in b/chromium/third_party/libdrm/src/mediatek/libdrm_mediatek.pc.in
deleted file mode 100644
index eaba97e372e..00000000000
--- a/chromium/third_party/libdrm/src/mediatek/libdrm_mediatek.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libdrm_mediatek
-Description: Userspace interface to mediatek kernel DRM services
-Version: 0.1
-Libs: -L${libdir} -ldrm_mediatek
-Cflags: -I${includedir} -I${includedir}/libdrm
-Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/mediatek/mediatek_drm.c b/chromium/third_party/libdrm/src/mediatek/mediatek_drm.c
deleted file mode 100644
index 1122b03cde0..00000000000
--- a/chromium/third_party/libdrm/src/mediatek/mediatek_drm.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright (c) 2015 MediaTek Inc.
- * Author:JB TSAI <jb.tsai@mediatek.com>
- *
- * based on rockchip_drm.c
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/mman.h>
-#include <linux/stddef.h>
-
-#include <xf86drm.h>
-
-#include "mediatek_drm.h"
-#include "mediatek_drmif.h"
-
-/*
- * Create mediatek drm device object.
- *
- * @fd: file descriptor to mediatek drm driver opened.
- *
- * if true, return the device object else NULL.
- */
-struct mediatek_device *mediatek_device_create(int fd)
-{
- struct mediatek_device *dev;
-
- dev = calloc(1, sizeof(*dev));
- if (!dev) {
- fprintf(stderr, "failed to create device[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- dev->fd = fd;
-
- return dev;
-}
-
-/*
- * Destroy mediatek drm device object
- *
- * @dev: mediatek drm device object.
- */
-void mediatek_device_destroy(struct mediatek_device *dev)
-{
- free(dev);
-}
-
-/*
- * Create a mediatek buffer object to mediatek drm device.
- *
- * @dev: mediatek drm device object.
- * @size: user-desired size.
- * flags: user-desired memory type.
- * user can set one or more types among several types to memory
- * allocation and cache attribute types. and as default,
- * MEDIATEK_BO_NONCONTIG and MEDIATEK-BO_NONCACHABLE types would
- * be used.
- *
- * if true, return a mediatek buffer object else NULL.
- */
-struct mediatek_bo *mediatek_bo_create(struct mediatek_device *dev,
- size_t size, uint32_t flags)
-{
- struct mediatek_bo *bo;
- struct drm_mtk_gem_create req = {
- .size = size,
- .flags = flags,
- };
-
- if (size == 0) {
- fprintf(stderr, "invalid size.\n");
- return NULL;
- }
-
- bo = calloc(1, sizeof(*bo));
- if (!bo) {
- fprintf(stderr, "failed to create bo[%s].\n",
- strerror(errno));
- goto fail;
- }
-
- bo->dev = dev;
-
- if (drmIoctl(dev->fd, DRM_IOCTL_MTK_GEM_CREATE, &req)){
- fprintf(stderr, "failed to create gem object[%s].\n",
- strerror(errno));
- goto err_free_bo;
- }
-
- bo->handle = req.handle;
- bo->size = size;
- bo->flags = flags;
-
- return bo;
-
-err_free_bo:
- free(bo);
-fail:
- return NULL;
-}
-
-struct mediatek_bo *mediatek_bo_from_handle(struct mediatek_device *dev,
- uint32_t handle, uint32_t flags, uint32_t size)
-{
- struct mediatek_bo *bo;
-
- if (size == 0) {
- fprintf(stderr, "invalid size.\n");
- return NULL;
- }
-
- bo = calloc(1, sizeof(*bo));
- if (!bo) {
- fprintf(stderr, "failed to create bo[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- bo->dev = dev;
- bo->handle = handle;
- bo->size = size;
- bo->flags = flags;
-
- return bo;
-}
-
-/*
- * Destroy a mediatek buffer object.
- *
- * @bo: a mediatek buffer object to be destroyed.
- */
-void mediatek_bo_destroy(struct mediatek_bo *bo)
-{
- if (!bo)
- return;
-
- if (bo->vaddr)
- munmap(bo->vaddr, bo->size);
-
- if (bo->handle) {
- struct drm_gem_close req = {
- .handle = bo->handle,
- };
-
- drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
- }
-
- free(bo);
-}
-
-
-/*
- * Get a mediatek buffer object from a gem global object name.
- *
- * @dev: a mediatek device object.
- * @name: a gem global object name exported by another process.
- *
- * this interface is used to get a mediatek buffer object from a gem
- * global object name sent by another process for buffer sharing.
- *
- * if true, return a mediatek buffer object else NULL.
- *
- */
-struct mediatek_bo *mediatek_bo_from_name(struct mediatek_device *dev,
- uint32_t name)
-{
- struct mediatek_bo *bo;
- struct drm_gem_open req = {
- .name = name,
- };
-
- bo = calloc(1, sizeof(*bo));
- if (!bo) {
- fprintf(stderr, "failed to allocate bo[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- if (drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req)) {
- fprintf(stderr, "failed to open gem object[%s].\n",
- strerror(errno));
- goto err_free_bo;
- }
-
- bo->dev = dev;
- bo->name = name;
- bo->handle = req.handle;
-
- return bo;
-
-err_free_bo:
- free(bo);
- return NULL;
-}
-
-/*
- * Get a gem global object name from a gem object handle.
- *
- * @bo: a mediatek buffer object including gem handle.
- * @name: a gem global object name to be got by kernel driver.
- *
- * this interface is used to get a gem global object name from a gem object
- * handle to a buffer that wants to share it with another process.
- *
- * if true, return 0 else negative.
- */
-int mediatek_bo_get_name(struct mediatek_bo *bo, uint32_t *name)
-{
- if (!bo->name) {
- struct drm_gem_flink req = {
- .handle = bo->handle,
- };
- int ret;
-
- ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req);
- if (ret) {
- fprintf(stderr, "failed to get gem global name[%s].\n",
- strerror(errno));
- return ret;
- }
-
- bo->name = req.name;
- }
-
- *name = bo->name;
-
- return 0;
-}
-
-uint32_t mediatek_bo_handle(struct mediatek_bo *bo)
-{
- return bo->handle;
-}
-
-/*
- * Mmap a buffer to user space.
- *
- * @bo: a mediatek buffer object including a gem object handle to be mmapped
- * to user space.
- *
- * if true, user pointer mmaped else NULL.
- */
-void *mediatek_bo_map(struct mediatek_bo *bo)
-{
- if (!bo->vaddr) {
- struct mediatek_device *dev = bo->dev;
- struct drm_mtk_gem_map_off req = {
- .handle = bo->handle,
- };
- int ret;
-
- ret = drmIoctl(dev->fd, DRM_IOCTL_MTK_GEM_MAP_OFFSET, &req);
- if (ret) {
- fprintf(stderr, "failed to ioctl gem map offset[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- bo->vaddr = mmap(0, bo->size, PROT_READ | PROT_WRITE,
- MAP_SHARED, dev->fd, req.offset);
- if (bo->vaddr == MAP_FAILED) {
- fprintf(stderr, "failed to mmap buffer[%s].\n",
- strerror(errno));
- return NULL;
- }
- }
-
- return bo->vaddr;
-}
diff --git a/chromium/third_party/libdrm/src/mediatek/mediatek_drm.h b/chromium/third_party/libdrm/src/mediatek/mediatek_drm.h
deleted file mode 100644
index 6d87d9c7982..00000000000
--- a/chromium/third_party/libdrm/src/mediatek/mediatek_drm.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2015 MediaTek Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-
-#ifndef _UAPI_MEDIATEK_DRM_H
-#define _UAPI_MEDIATEK_DRM_H
-
-#include "drm.h"
-
-/**
- * User-desired buffer creation information structure.
- *
- * @size: user-desired memory allocation size.
- * - this size value would be page-aligned internally.
- * @flags: user request for setting memory type or cache attributes.
- * @handle: returned a handle to created gem object.
- * - this handle will be set by gem module of kernel side.
- */
-struct drm_mtk_gem_create {
- uint64_t size;
- uint32_t flags;
- uint32_t handle;
-};
-
-/**
- * A structure for getting buffer offset.
- *
- * @handle: a pointer to gem object created.
- * @pad: just padding to be 64-bit aligned.
- * @offset: relatived offset value of the memory region allocated.
- * - this value should be set by user.
- */
-struct drm_mtk_gem_map_off {
- uint32_t handle;
- uint32_t pad;
- uint64_t offset;
-};
-
-#define DRM_MTK_GEM_CREATE 0x00
-#define DRM_MTK_GEM_MAP_OFFSET 0x01
-
-#define DRM_IOCTL_MTK_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_MTK_GEM_CREATE, struct drm_mtk_gem_create)
-
-#define DRM_IOCTL_MTK_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_MTK_GEM_MAP_OFFSET, struct drm_mtk_gem_map_off)
-
-
-#endif /* _UAPI_MEDIATEK_DRM_H */
diff --git a/chromium/third_party/libdrm/src/mediatek/mediatek_drmif.h b/chromium/third_party/libdrm/src/mediatek/mediatek_drmif.h
deleted file mode 100644
index 47cd2d810ab..00000000000
--- a/chromium/third_party/libdrm/src/mediatek/mediatek_drmif.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2015 MediaTek Inc.
- * Author:JB TSAI <jb.tsai@mediatek.com>
- *
- * based on rockchip_drmif.h
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef MEDIATEK_DRMIF_H_
-#define MEDIATEK_DRMIF_H_
-
-#include <xf86drm.h>
-#include <stdint.h>
-#include "mediatek_drm.h"
-
-struct mediatek_device {
- int fd;
-};
-
-/*
- * Mediatek Buffer Object structure.
- *
- * @dev: mediatek device object allocated.
- * @handle: a gem handle to gem object created.
- * @flags: indicate memory allocation and cache attribute types.
- * @size: size to the buffer created.
- * @vaddr: user space address to a gem buffer mmaped.
- * @name: a gem global handle from flink request.
- */
-struct mediatek_bo {
- struct mediatek_device *dev;
- uint32_t handle;
- uint32_t flags;
- size_t size;
- void *vaddr;
- uint32_t name;
-};
-
-/*
- * device related functions:
- */
-struct mediatek_device *mediatek_device_create(int fd);
-void mediatek_device_destroy(struct mediatek_device *dev);
-
-/*
- * buffer-object related functions:
- */
-struct mediatek_bo *mediatek_bo_create(struct mediatek_device *dev,
- size_t size, uint32_t flags);
-int mediatek_bo_get_info(struct mediatek_device *dev, uint32_t handle,
- size_t *size, uint32_t *flags);
-void mediatek_bo_destroy(struct mediatek_bo *bo);
-struct mediatek_bo *mediatek_bo_from_name(struct mediatek_device *dev,
- uint32_t name);
-int mediatek_bo_get_name(struct mediatek_bo *bo, uint32_t *name);
-uint32_t mediatek_bo_handle(struct mediatek_bo *bo);
-struct mediatek_bo *mediatek_bo_from_handle(struct mediatek_device *dev,
- uint32_t handle, uint32_t flags, uint32_t size);
-void *mediatek_bo_map(struct mediatek_bo *bo);
-#endif /* MEDIATEK_DRMIF_H_ */
diff --git a/chromium/third_party/libdrm/src/nouveau/Android.mk b/chromium/third_party/libdrm/src/nouveau/Android.mk
index b67d30fc76e..abc6aef7465 100644
--- a/chromium/third_party/libdrm/src/nouveau/Android.mk
+++ b/chromium/third_party/libdrm/src/nouveau/Android.mk
@@ -9,7 +9,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libdrm
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_NOUVEAU_FILES))
+LOCAL_SRC_FILES := $(LIBDRM_NOUVEAU_FILES)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_CFLAGS := \
diff --git a/chromium/third_party/libdrm/src/nouveau/Makefile.am b/chromium/third_party/libdrm/src/nouveau/Makefile.am
index 344a84454e4..25ea6dc1553 100644
--- a/chromium/third_party/libdrm/src/nouveau/Makefile.am
+++ b/chromium/third_party/libdrm/src/nouveau/Makefile.am
@@ -14,20 +14,11 @@ libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
libdrm_nouveau_la_SOURCES = $(LIBDRM_NOUVEAU_FILES)
-libdrm_nouveauincludedir = ${includedir}/libdrm/nouveau
+libdrm_nouveauincludedir = ${includedir}/libdrm
libdrm_nouveauinclude_HEADERS = $(LIBDRM_NOUVEAU_H_FILES)
-libdrm_nouveaunvifincludedir = ${includedir}/libdrm/nouveau/nvif
-libdrm_nouveaunvifinclude_HEADERS = nvif/class.h \
- nvif/cl0080.h \
- nvif/cl9097.h \
- nvif/if0002.h \
- nvif/if0003.h \
- nvif/ioctl.h \
- nvif/unpack.h
-
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libdrm_nouveau.pc
TESTS = nouveau-symbol-check
-EXTRA_DIST = $(TESTS)
+EXTRA_DIST = Android.mk $(TESTS)
diff --git a/chromium/third_party/libdrm/src/nouveau/abi16.c b/chromium/third_party/libdrm/src/nouveau/abi16.c
index ee38c0cb228..59bc43605cf 100644
--- a/chromium/third_party/libdrm/src/nouveau/abi16.c
+++ b/chromium/third_party/libdrm/src/nouveau/abi16.c
@@ -29,16 +29,14 @@
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
-#include <errno.h>
#include "private.h"
-#include "nvif/class.h"
-static int
+drm_private int
abi16_chan_nv04(struct nouveau_object *obj)
{
- struct nouveau_drm *drm = nouveau_drm(obj);
+ struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
struct nv04_fifo *nv04 = obj->data;
struct drm_nouveau_channel_alloc req = {
.fb_ctxdma_handle = nv04->vram,
@@ -46,7 +44,7 @@ abi16_chan_nv04(struct nouveau_object *obj)
};
int ret;
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -59,15 +57,15 @@ abi16_chan_nv04(struct nouveau_object *obj)
return 0;
}
-static int
+drm_private int
abi16_chan_nvc0(struct nouveau_object *obj)
{
- struct nouveau_drm *drm = nouveau_drm(obj);
+ struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
struct drm_nouveau_channel_alloc req = {};
struct nvc0_fifo *nvc0 = obj->data;
int ret;
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -80,10 +78,10 @@ abi16_chan_nvc0(struct nouveau_object *obj)
return 0;
}
-static int
+drm_private int
abi16_chan_nve0(struct nouveau_object *obj)
{
- struct nouveau_drm *drm = nouveau_drm(obj);
+ struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
struct drm_nouveau_channel_alloc req = {};
struct nve0_fifo *nve0 = obj->data;
int ret;
@@ -93,7 +91,7 @@ abi16_chan_nve0(struct nouveau_object *obj)
req.tt_ctxdma_handle = nve0->engine;
}
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -106,39 +104,19 @@ abi16_chan_nve0(struct nouveau_object *obj)
return 0;
}
-static int
+drm_private int
abi16_engobj(struct nouveau_object *obj)
{
- struct nouveau_drm *drm = nouveau_drm(obj);
struct drm_nouveau_grobj_alloc req = {
.channel = obj->parent->handle,
.handle = obj->handle,
.class = obj->oclass,
};
+ struct nouveau_device *dev;
int ret;
- /* Older kernel versions did not have the concept of nouveau-
- * specific classes and abused some NVIDIA-assigned ones for
- * a SW class. The ABI16 layer has compatibility in place to
- * translate these older identifiers to the newer ones.
- *
- * Clients that have been updated to use NVIF are required to
- * use the newer class identifiers, which means that they'll
- * break if running on an older kernel.
- *
- * To handle this case, when using ABI16, we translate to the
- * older values which work on any kernel.
- */
- switch (req.class) {
- case NVIF_CLASS_SW_NV04 : req.class = 0x006e; break;
- case NVIF_CLASS_SW_NV10 : req.class = 0x016e; break;
- case NVIF_CLASS_SW_NV50 : req.class = 0x506e; break;
- case NVIF_CLASS_SW_GF100: req.class = 0x906e; break;
- default:
- break;
- }
-
- ret = drmCommandWrite(drm->fd, DRM_NOUVEAU_GROBJ_ALLOC,
+ dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
+ ret = drmCommandWrite(dev->fd, DRM_NOUVEAU_GROBJ_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -147,19 +125,20 @@ abi16_engobj(struct nouveau_object *obj)
return 0;
}
-static int
+drm_private int
abi16_ntfy(struct nouveau_object *obj)
{
- struct nouveau_drm *drm = nouveau_drm(obj);
struct nv04_notify *ntfy = obj->data;
struct drm_nouveau_notifierobj_alloc req = {
.channel = obj->parent->handle,
.handle = ntfy->object->handle,
.size = ntfy->length,
};
+ struct nouveau_device *dev;
int ret;
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC,
+ dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -169,110 +148,6 @@ abi16_ntfy(struct nouveau_object *obj)
return 0;
}
-drm_private int
-abi16_sclass(struct nouveau_object *obj, struct nouveau_sclass **psclass)
-{
- struct nouveau_sclass *sclass;
- struct nouveau_device *dev;
-
- if (!(sclass = calloc(8, sizeof(*sclass))))
- return -ENOMEM;
- *psclass = sclass;
-
- switch (obj->oclass) {
- case NOUVEAU_FIFO_CHANNEL_CLASS:
- /* Older kernel versions were exposing the wrong video engine
- * classes on certain G98:GF100 boards. This has since been
- * corrected, but ABI16 has compatibility in place to avoid
- * breaking older userspace.
- *
- * Clients that have been updated to use NVIF are required to
- * use the correct classes, which means that they'll break if
- * running on an older kernel.
- *
- * To handle this issue, if using the older kernel interfaces,
- * we'll magic up a list containing the vdec classes that the
- * kernel will accept for these boards. Clients should make
- * use of this information instead of hardcoding classes for
- * specific chipsets.
- */
- dev = (struct nouveau_device *)obj->parent;
- if (dev->chipset >= 0x98 &&
- dev->chipset != 0xa0 &&
- dev->chipset < 0xc0) {
- *sclass++ = (struct nouveau_sclass){
- GT212_MSVLD, -1, -1
- };
- *sclass++ = (struct nouveau_sclass){
- GT212_MSPDEC, -1, -1
- };
- *sclass++ = (struct nouveau_sclass){
- GT212_MSPPP, -1, -1
- };
- }
- break;
- default:
- break;
- }
-
- return sclass - *psclass;
-}
-
-drm_private void
-abi16_delete(struct nouveau_object *obj)
-{
- struct nouveau_drm *drm = nouveau_drm(obj);
- if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
- struct drm_nouveau_channel_free req;
- req.channel = obj->handle;
- drmCommandWrite(drm->fd, DRM_NOUVEAU_CHANNEL_FREE,
- &req, sizeof(req));
- } else {
- struct drm_nouveau_gpuobj_free req;
- req.channel = obj->parent->handle;
- req.handle = obj->handle;
- drmCommandWrite(drm->fd, DRM_NOUVEAU_GPUOBJ_FREE,
- &req, sizeof(req));
- }
-}
-
-drm_private bool
-abi16_object(struct nouveau_object *obj, int (**func)(struct nouveau_object *))
-{
- struct nouveau_object *parent = obj->parent;
-
- /* nouveau_object::length is (ab)used to determine whether the
- * object is a legacy object (!=0), or a real NVIF object.
- */
- if ((parent->length != 0 && parent->oclass == NOUVEAU_DEVICE_CLASS) ||
- (parent->length == 0 && parent->oclass == NV_DEVICE)) {
- if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
- struct nouveau_device *dev = (void *)parent;
- if (dev->chipset < 0xc0)
- *func = abi16_chan_nv04;
- else
- if (dev->chipset < 0xe0)
- *func = abi16_chan_nvc0;
- else
- *func = abi16_chan_nve0;
- return true;
- }
- } else
- if ((parent->length != 0 &&
- parent->oclass == NOUVEAU_FIFO_CHANNEL_CLASS)) {
- if (obj->oclass == NOUVEAU_NOTIFIER_CLASS) {
- *func = abi16_ntfy;
- return true;
- }
-
- *func = abi16_engobj;
- return false; /* try NVIF, if supported, before calling func */
- }
-
- *func = NULL;
- return false;
-}
-
drm_private void
abi16_bo_info(struct nouveau_bo *bo, struct drm_nouveau_gem_info *info)
{
@@ -312,7 +187,6 @@ abi16_bo_init(struct nouveau_bo *bo, uint32_t alignment,
union nouveau_bo_config *config)
{
struct nouveau_device *dev = bo->device;
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_gem_new req = {};
struct drm_nouveau_gem_info *info = &req.info;
int ret;
@@ -355,7 +229,7 @@ abi16_bo_init(struct nouveau_bo *bo, uint32_t alignment,
if (!nouveau_device(dev)->have_bo_usage)
info->tile_flags &= 0x0000ff00;
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_NEW,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_NEW,
&req, sizeof(req));
if (ret == 0)
abi16_bo_info(bo, &req.info);
diff --git a/chromium/third_party/libdrm/src/nouveau/libdrm_nouveau.pc.in b/chromium/third_party/libdrm/src/nouveau/libdrm_nouveau.pc.in
index 7d0622e9a71..9abfd811d1e 100644
--- a/chromium/third_party/libdrm/src/nouveau/libdrm_nouveau.pc.in
+++ b/chromium/third_party/libdrm/src/nouveau/libdrm_nouveau.pc.in
@@ -7,5 +7,5 @@ Name: libdrm_nouveau
Description: Userspace interface to nouveau kernel DRM services
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ldrm_nouveau
-Cflags: -I${includedir} -I${includedir}/libdrm -I${includedir}/libdrm/nouveau
+Cflags: -I${includedir} -I${includedir}/libdrm
Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/nouveau/nouveau-symbol-check b/chromium/third_party/libdrm/src/nouveau/nouveau-symbol-check
index b265cea466a..0fef56323b4 100755
--- a/chromium/third_party/libdrm/src/nouveau/nouveau-symbol-check
+++ b/chromium/third_party/libdrm/src/nouveau/nouveau-symbol-check
@@ -27,19 +27,13 @@ nouveau_bufctx_reset
nouveau_client_del
nouveau_client_new
nouveau_device_del
-nouveau_device_new
nouveau_device_open
nouveau_device_open_existing
nouveau_device_wrap
-nouveau_drm_del
-nouveau_drm_new
nouveau_getparam
nouveau_object_del
-nouveau_object_mclass
-nouveau_object_mthd
+nouveau_object_find
nouveau_object_new
-nouveau_object_sclass_get
-nouveau_object_sclass_put
nouveau_pushbuf_bufctx
nouveau_pushbuf_data
nouveau_pushbuf_del
diff --git a/chromium/third_party/libdrm/src/nouveau/nouveau.c b/chromium/third_party/libdrm/src/nouveau/nouveau.c
index e113a8fe780..97fd77b932b 100644
--- a/chromium/third_party/libdrm/src/nouveau/nouveau.c
+++ b/chromium/third_party/libdrm/src/nouveau/nouveau.c
@@ -45,11 +45,6 @@
#include "nouveau.h"
#include "private.h"
-#include "nvif/class.h"
-#include "nvif/cl0080.h"
-#include "nvif/ioctl.h"
-#include "nvif/unpack.h"
-
#ifdef DEBUG
drm_private uint32_t nouveau_debug = 0;
@@ -64,295 +59,6 @@ debug_init(char *args)
}
#endif
-static int
-nouveau_object_ioctl(struct nouveau_object *obj, void *data, uint32_t size)
-{
- struct nouveau_drm *drm = nouveau_drm(obj);
- union {
- struct nvif_ioctl_v0 v0;
- } *args = data;
- uint32_t argc = size;
- int ret = -ENOSYS;
-
- if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
- if (!obj->length) {
- if (obj != &drm->client)
- args->v0.object = (unsigned long)(void *)obj;
- else
- args->v0.object = 0;
- args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY;
- args->v0.route = 0x00;
- } else {
- args->v0.route = 0xff;
- args->v0.token = obj->handle;
- }
- } else
- return ret;
-
- return drmCommandWriteRead(drm->fd, DRM_NOUVEAU_NVIF, args, argc);
-}
-
-int
-nouveau_object_mthd(struct nouveau_object *obj,
- uint32_t mthd, void *data, uint32_t size)
-{
- struct nouveau_drm *drm = nouveau_drm(obj);
- struct {
- struct nvif_ioctl_v0 ioctl;
- struct nvif_ioctl_mthd_v0 mthd;
- } *args;
- uint32_t argc = sizeof(*args) + size;
- uint8_t stack[128];
- int ret;
-
- if (!drm->nvif)
- return -ENOSYS;
-
- if (argc > sizeof(stack)) {
- if (!(args = malloc(argc)))
- return -ENOMEM;
- } else {
- args = (void *)stack;
- }
- args->ioctl.version = 0;
- args->ioctl.type = NVIF_IOCTL_V0_MTHD;
- args->mthd.version = 0;
- args->mthd.method = mthd;
-
- memcpy(args->mthd.data, data, size);
- ret = nouveau_object_ioctl(obj, args, argc);
- memcpy(data, args->mthd.data, size);
- if (args != (void *)stack)
- free(args);
- return ret;
-}
-
-void
-nouveau_object_sclass_put(struct nouveau_sclass **psclass)
-{
- free(*psclass);
- *psclass = NULL;
-}
-
-int
-nouveau_object_sclass_get(struct nouveau_object *obj,
- struct nouveau_sclass **psclass)
-{
- struct nouveau_drm *drm = nouveau_drm(obj);
- struct {
- struct nvif_ioctl_v0 ioctl;
- struct nvif_ioctl_sclass_v0 sclass;
- } *args = NULL;
- struct nouveau_sclass *sclass;
- int ret, cnt = 0, i;
- uint32_t size;
-
- if (!drm->nvif)
- return abi16_sclass(obj, psclass);
-
- while (1) {
- size = sizeof(*args) + cnt * sizeof(args->sclass.oclass[0]);
- if (!(args = malloc(size)))
- return -ENOMEM;
- args->ioctl.version = 0;
- args->ioctl.type = NVIF_IOCTL_V0_SCLASS;
- args->sclass.version = 0;
- args->sclass.count = cnt;
-
- ret = nouveau_object_ioctl(obj, args, size);
- if (ret == 0 && args->sclass.count <= cnt)
- break;
- cnt = args->sclass.count;
- free(args);
- if (ret != 0)
- return ret;
- }
-
- if ((sclass = calloc(args->sclass.count, sizeof(*sclass)))) {
- for (i = 0; i < args->sclass.count; i++) {
- sclass[i].oclass = args->sclass.oclass[i].oclass;
- sclass[i].minver = args->sclass.oclass[i].minver;
- sclass[i].maxver = args->sclass.oclass[i].maxver;
- }
- *psclass = sclass;
- ret = args->sclass.count;
- } else {
- ret = -ENOMEM;
- }
-
- free(args);
- return ret;
-}
-
-int
-nouveau_object_mclass(struct nouveau_object *obj,
- const struct nouveau_mclass *mclass)
-{
- struct nouveau_sclass *sclass;
- int ret = -ENODEV;
- int cnt, i, j;
-
- cnt = nouveau_object_sclass_get(obj, &sclass);
- if (cnt < 0)
- return cnt;
-
- for (i = 0; ret < 0 && mclass[i].oclass; i++) {
- for (j = 0; j < cnt; j++) {
- if (mclass[i].oclass == sclass[j].oclass &&
- mclass[i].version >= sclass[j].minver &&
- mclass[i].version <= sclass[j].maxver) {
- ret = i;
- break;
- }
- }
- }
-
- nouveau_object_sclass_put(&sclass);
- return ret;
-}
-
-static void
-nouveau_object_fini(struct nouveau_object *obj)
-{
- struct {
- struct nvif_ioctl_v0 ioctl;
- struct nvif_ioctl_del del;
- } args = {
- .ioctl.type = NVIF_IOCTL_V0_DEL,
- };
-
- if (obj->data) {
- abi16_delete(obj);
- free(obj->data);
- obj->data = NULL;
- return;
- }
-
- nouveau_object_ioctl(obj, &args, sizeof(args));
-}
-
-static int
-nouveau_object_init(struct nouveau_object *parent, uint32_t handle,
- int32_t oclass, void *data, uint32_t size,
- struct nouveau_object *obj)
-{
- struct nouveau_drm *drm = nouveau_drm(parent);
- struct {
- struct nvif_ioctl_v0 ioctl;
- struct nvif_ioctl_new_v0 new;
- } *args;
- uint32_t argc = sizeof(*args) + size;
- int (*func)(struct nouveau_object *);
- int ret = -ENOSYS;
-
- obj->parent = parent;
- obj->handle = handle;
- obj->oclass = oclass;
- obj->length = 0;
- obj->data = NULL;
-
- if (!abi16_object(obj, &func) && drm->nvif) {
- if (!(args = malloc(argc)))
- return -ENOMEM;
- args->ioctl.version = 0;
- args->ioctl.type = NVIF_IOCTL_V0_NEW;
- args->new.version = 0;
- args->new.route = NVIF_IOCTL_V0_ROUTE_NVIF;
- args->new.token = (unsigned long)(void *)obj;
- args->new.object = (unsigned long)(void *)obj;
- args->new.handle = handle;
- args->new.oclass = oclass;
- memcpy(args->new.data, data, size);
- ret = nouveau_object_ioctl(parent, args, argc);
- memcpy(data, args->new.data, size);
- free(args);
- } else
- if (func) {
- obj->length = size ? size : sizeof(struct nouveau_object *);
- if (!(obj->data = malloc(obj->length)))
- return -ENOMEM;
- if (data)
- memcpy(obj->data, data, obj->length);
- *(struct nouveau_object **)obj->data = obj;
-
- ret = func(obj);
- }
-
- if (ret) {
- nouveau_object_fini(obj);
- return ret;
- }
-
- return 0;
-}
-
-int
-nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
- uint32_t oclass, void *data, uint32_t length,
- struct nouveau_object **pobj)
-{
- struct nouveau_object *obj;
- int ret;
-
- if (!(obj = malloc(sizeof(*obj))))
- return -ENOMEM;
-
- ret = nouveau_object_init(parent, handle, oclass, data, length, obj);
- if (ret) {
- free(obj);
- return ret;
- }
-
- *pobj = obj;
- return 0;
-}
-
-void
-nouveau_object_del(struct nouveau_object **pobj)
-{
- struct nouveau_object *obj = *pobj;
- if (obj) {
- nouveau_object_fini(obj);
- free(obj);
- *pobj = NULL;
- }
-}
-
-void
-nouveau_drm_del(struct nouveau_drm **pdrm)
-{
- free(*pdrm);
- *pdrm = NULL;
-}
-
-int
-nouveau_drm_new(int fd, struct nouveau_drm **pdrm)
-{
- struct nouveau_drm *drm;
- drmVersionPtr ver;
-
-#ifdef DEBUG
- debug_init(getenv("NOUVEAU_LIBDRM_DEBUG"));
-#endif
-
- if (!(drm = calloc(1, sizeof(*drm))))
- return -ENOMEM;
- drm->fd = fd;
-
- if (!(ver = drmGetVersion(fd))) {
- nouveau_drm_del(&drm);
- return -EINVAL;
- }
- *pdrm = drm;
-
- drm->version = (ver->version_major << 24) |
- (ver->version_minor << 8) |
- ver->version_patchlevel;
- drm->nvif = (drm->version >= 0x01000301);
- drmFreeVersion(ver);
- return 0;
-}
-
/* this is the old libdrm's version of nouveau_device_wrap(), the symbol
* is kept here to prevent AIGLX from crashing if the DDX is linked against
* the new libdrm, but the DRI driver against the old
@@ -365,124 +71,80 @@ nouveau_device_open_existing(struct nouveau_device **pdev, int close, int fd,
}
int
-nouveau_device_new(struct nouveau_object *parent, int32_t oclass,
- void *data, uint32_t size, struct nouveau_device **pdev)
+nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev)
{
- struct nv_device_info_v0 info = {};
- union {
- struct nv_device_v0 v0;
- } *args = data;
- uint32_t argc = size;
- struct nouveau_drm *drm = nouveau_drm(parent);
- struct nouveau_device_priv *nvdev;
- struct nouveau_device *dev;
- uint64_t v;
+ struct nouveau_device_priv *nvdev = calloc(1, sizeof(*nvdev));
+ struct nouveau_device *dev = &nvdev->base;
+ uint64_t chipset, vram, gart, bousage;
+ drmVersionPtr ver;
+ int ret;
char *tmp;
- int ret = -ENOSYS;
- if (oclass != NV_DEVICE ||
- nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))
- return ret;
+#ifdef DEBUG
+ debug_init(getenv("NOUVEAU_LIBDRM_DEBUG"));
+#endif
- if (!(nvdev = calloc(1, sizeof(*nvdev))))
+ if (!nvdev)
return -ENOMEM;
- dev = *pdev = &nvdev->base;
- dev->fd = -1;
+ ret = pthread_mutex_init(&nvdev->lock, NULL);
+ if (ret) {
+ free(nvdev);
+ return ret;
+ }
- if (drm->nvif) {
- ret = nouveau_object_init(parent, 0, oclass, args, argc,
- &dev->object);
- if (ret)
- goto done;
+ nvdev->base.fd = fd;
- info.version = 0;
+ ver = drmGetVersion(fd);
+ if (ver) dev->drm_version = (ver->version_major << 24) |
+ (ver->version_minor << 8) |
+ ver->version_patchlevel;
+ drmFreeVersion(ver);
- ret = nouveau_object_mthd(&dev->object, NV_DEVICE_V0_INFO,
- &info, sizeof(info));
- if (ret)
- goto done;
-
- nvdev->base.chipset = info.chipset;
- nvdev->have_bo_usage = true;
- } else
- if (args->v0.device == ~0ULL) {
- nvdev->base.object.parent = &drm->client;
- nvdev->base.object.handle = ~0ULL;
- nvdev->base.object.oclass = NOUVEAU_DEVICE_CLASS;
- nvdev->base.object.length = ~0;
-
- ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_CHIPSET_ID, &v);
- if (ret)
- goto done;
- nvdev->base.chipset = v;
+ if ( dev->drm_version != 0x00000010 &&
+ (dev->drm_version < 0x01000000 ||
+ dev->drm_version >= 0x02000000)) {
+ nouveau_device_del(&dev);
+ return -EINVAL;
+ }
- ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_HAS_BO_USAGE, &v);
- if (ret == 0)
- nvdev->have_bo_usage = (v != 0);
- } else
- return -ENOSYS;
+ ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_CHIPSET_ID, &chipset);
+ if (ret == 0)
+ ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_FB_SIZE, &vram);
+ if (ret == 0)
+ ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, &gart);
+ if (ret) {
+ nouveau_device_del(&dev);
+ return ret;
+ }
- ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_FB_SIZE, &v);
- if (ret)
- goto done;
- nvdev->base.vram_size = v;
+ ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_HAS_BO_USAGE, &bousage);
+ if (ret == 0)
+ nvdev->have_bo_usage = (bousage != 0);
- ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, &v);
- if (ret)
- goto done;
- nvdev->base.gart_size = v;
+ nvdev->close = close;
tmp = getenv("NOUVEAU_LIBDRM_VRAM_LIMIT_PERCENT");
if (tmp)
nvdev->vram_limit_percent = atoi(tmp);
else
nvdev->vram_limit_percent = 80;
-
- nvdev->base.vram_limit =
- (nvdev->base.vram_size * nvdev->vram_limit_percent) / 100;
-
tmp = getenv("NOUVEAU_LIBDRM_GART_LIMIT_PERCENT");
if (tmp)
nvdev->gart_limit_percent = atoi(tmp);
else
nvdev->gart_limit_percent = 80;
-
+ DRMINITLISTHEAD(&nvdev->bo_list);
+ nvdev->base.object.oclass = NOUVEAU_DEVICE_CLASS;
+ nvdev->base.lib_version = 0x01000000;
+ nvdev->base.chipset = chipset;
+ nvdev->base.vram_size = vram;
+ nvdev->base.gart_size = gart;
+ nvdev->base.vram_limit =
+ (nvdev->base.vram_size * nvdev->vram_limit_percent) / 100;
nvdev->base.gart_limit =
(nvdev->base.gart_size * nvdev->gart_limit_percent) / 100;
- ret = pthread_mutex_init(&nvdev->lock, NULL);
- DRMINITLISTHEAD(&nvdev->bo_list);
-done:
- if (ret)
- nouveau_device_del(pdev);
- return ret;
-}
-
-int
-nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev)
-{
- struct nouveau_drm *drm;
- struct nouveau_device_priv *nvdev;
- int ret;
-
- ret = nouveau_drm_new(fd, &drm);
- if (ret)
- return ret;
- drm->nvif = false;
-
- ret = nouveau_device_new(&drm->client, NV_DEVICE,
- &(struct nv_device_v0) {
- .device = ~0ULL,
- }, sizeof(struct nv_device_v0), pdev);
- if (ret) {
- nouveau_drm_del(&drm);
- return ret;
- }
-
- nvdev = nouveau_device(*pdev);
- nvdev->base.fd = drm->fd;
- nvdev->base.drm_version = drm->version;
- nvdev->close = close;
+ *pdev = &nvdev->base;
return 0;
}
@@ -503,15 +165,10 @@ nouveau_device_del(struct nouveau_device **pdev)
{
struct nouveau_device_priv *nvdev = nouveau_device(*pdev);
if (nvdev) {
+ if (nvdev->close)
+ drmClose(nvdev->base.fd);
free(nvdev->client);
pthread_mutex_destroy(&nvdev->lock);
- if (nvdev->base.fd >= 0) {
- struct nouveau_drm *drm =
- nouveau_drm(&nvdev->base.object);
- nouveau_drm_del(&drm);
- if (nvdev->close)
- drmClose(nvdev->base.fd);
- }
free(nvdev);
*pdev = NULL;
}
@@ -520,9 +177,8 @@ nouveau_device_del(struct nouveau_device **pdev)
int
nouveau_getparam(struct nouveau_device *dev, uint64_t param, uint64_t *value)
{
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_getparam r = { .param = param };
- int fd = drm->fd, ret =
+ int fd = dev->fd, ret =
drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &r, sizeof(r));
*value = r.value;
return ret;
@@ -531,9 +187,8 @@ nouveau_getparam(struct nouveau_device *dev, uint64_t param, uint64_t *value)
int
nouveau_setparam(struct nouveau_device *dev, uint64_t param, uint64_t value)
{
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_setparam r = { .param = param, .value = value };
- return drmCommandWrite(drm->fd, DRM_NOUVEAU_SETPARAM, &r, sizeof(r));
+ return drmCommandWrite(dev->fd, DRM_NOUVEAU_SETPARAM, &r, sizeof(r));
}
int
@@ -591,10 +246,106 @@ nouveau_client_del(struct nouveau_client **pclient)
}
}
+int
+nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
+ uint32_t oclass, void *data, uint32_t length,
+ struct nouveau_object **pobj)
+{
+ struct nouveau_device *dev;
+ struct nouveau_object *obj;
+ int ret = -EINVAL;
+
+ if (length == 0)
+ length = sizeof(struct nouveau_object *);
+ obj = malloc(sizeof(*obj) + length);
+ obj->parent = parent;
+ obj->handle = handle;
+ obj->oclass = oclass;
+ obj->length = length;
+ obj->data = obj + 1;
+ if (data)
+ memcpy(obj->data, data, length);
+ *(struct nouveau_object **)obj->data = obj;
+
+ dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
+ switch (parent->oclass) {
+ case NOUVEAU_DEVICE_CLASS:
+ switch (obj->oclass) {
+ case NOUVEAU_FIFO_CHANNEL_CLASS:
+ {
+ if (dev->chipset < 0xc0)
+ ret = abi16_chan_nv04(obj);
+ else
+ if (dev->chipset < 0xe0)
+ ret = abi16_chan_nvc0(obj);
+ else
+ ret = abi16_chan_nve0(obj);
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case NOUVEAU_FIFO_CHANNEL_CLASS:
+ switch (obj->oclass) {
+ case NOUVEAU_NOTIFIER_CLASS:
+ ret = abi16_ntfy(obj);
+ break;
+ default:
+ ret = abi16_engobj(obj);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (ret) {
+ free(obj);
+ return ret;
+ }
+
+ *pobj = obj;
+ return 0;
+}
+
+void
+nouveau_object_del(struct nouveau_object **pobj)
+{
+ struct nouveau_object *obj = *pobj;
+ struct nouveau_device *dev;
+ if (obj) {
+ dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
+ if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
+ struct drm_nouveau_channel_free req;
+ req.channel = obj->handle;
+ drmCommandWrite(dev->fd, DRM_NOUVEAU_CHANNEL_FREE,
+ &req, sizeof(req));
+ } else {
+ struct drm_nouveau_gpuobj_free req;
+ req.channel = obj->parent->handle;
+ req.handle = obj->handle;
+ drmCommandWrite(dev->fd, DRM_NOUVEAU_GPUOBJ_FREE,
+ &req, sizeof(req));
+ }
+ }
+ free(obj);
+ *pobj = NULL;
+}
+
+void *
+nouveau_object_find(struct nouveau_object *obj, uint32_t pclass)
+{
+ while (obj && obj->oclass != pclass) {
+ obj = obj->parent;
+ if (pclass == NOUVEAU_PARENT_CLASS)
+ break;
+ }
+ return obj;
+}
+
static void
nouveau_bo_del(struct nouveau_bo *bo)
{
- struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_device_priv *nvdev = nouveau_device(bo->device);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
struct drm_gem_close req = { .handle = bo->handle };
@@ -611,11 +362,11 @@ nouveau_bo_del(struct nouveau_bo *bo)
* might cause the bo to be closed accidentally while
* re-importing.
*/
- drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &req);
+ drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
pthread_mutex_unlock(&nvdev->lock);
} else {
- drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &req);
+ drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
if (bo->map)
drm_munmap(bo->map, bo->size);
@@ -652,7 +403,6 @@ static int
nouveau_bo_wrap_locked(struct nouveau_device *dev, uint32_t handle,
struct nouveau_bo **pbo, int name)
{
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct nouveau_device_priv *nvdev = nouveau_device(dev);
struct drm_nouveau_gem_info req = { .handle = handle };
struct nouveau_bo_priv *nvbo;
@@ -682,7 +432,7 @@ nouveau_bo_wrap_locked(struct nouveau_device *dev, uint32_t handle,
}
}
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_INFO,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_INFO,
&req, sizeof(req));
if (ret)
return ret;
@@ -729,7 +479,6 @@ int
nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name,
struct nouveau_bo **pbo)
{
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct nouveau_device_priv *nvdev = nouveau_device(dev);
struct nouveau_bo_priv *nvbo;
struct drm_gem_open req = { .name = name };
@@ -745,7 +494,7 @@ nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name,
}
}
- ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_OPEN, &req);
+ ret = drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req);
if (ret == 0) {
ret = nouveau_bo_wrap_locked(dev, req.handle, pbo, name);
}
@@ -758,12 +507,11 @@ int
nouveau_bo_name_get(struct nouveau_bo *bo, uint32_t *name)
{
struct drm_gem_flink req = { .handle = bo->handle };
- struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
*name = nvbo->name;
if (!*name) {
- int ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_FLINK, &req);
+ int ret = drmIoctl(bo->device->fd, DRM_IOCTL_GEM_FLINK, &req);
if (ret) {
*name = 0;
@@ -794,7 +542,6 @@ int
nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
struct nouveau_bo **bo)
{
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct nouveau_device_priv *nvdev = nouveau_device(dev);
int ret;
unsigned int handle;
@@ -802,7 +549,7 @@ nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
nouveau_bo_ref(NULL, bo);
pthread_mutex_lock(&nvdev->lock);
- ret = drmPrimeFDToHandle(drm->fd, prime_fd, &handle);
+ ret = drmPrimeFDToHandle(dev->fd, prime_fd, &handle);
if (ret == 0) {
ret = nouveau_bo_wrap_locked(dev, handle, bo, 0);
}
@@ -813,11 +560,10 @@ nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
int
nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd)
{
- struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
int ret;
- ret = drmPrimeHandleToFD(drm->fd, nvbo->base.handle, DRM_CLOEXEC, prime_fd);
+ ret = drmPrimeHandleToFD(bo->device->fd, nvbo->base.handle, DRM_CLOEXEC, prime_fd);
if (ret)
return ret;
@@ -829,7 +575,6 @@ int
nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access,
struct nouveau_client *client)
{
- struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
struct drm_nouveau_gem_cpu_prep req;
struct nouveau_pushbuf *push;
@@ -853,7 +598,7 @@ nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access,
if (access & NOUVEAU_BO_NOBLOCK)
req.flags |= NOUVEAU_GEM_CPU_PREP_NOWAIT;
- ret = drmCommandWrite(drm->fd, DRM_NOUVEAU_GEM_CPU_PREP,
+ ret = drmCommandWrite(bo->device->fd, DRM_NOUVEAU_GEM_CPU_PREP,
&req, sizeof(req));
if (ret == 0)
nvbo->access = 0;
@@ -864,11 +609,10 @@ int
nouveau_bo_map(struct nouveau_bo *bo, uint32_t access,
struct nouveau_client *client)
{
- struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
if (bo->map == NULL) {
bo->map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE,
- MAP_SHARED, drm->fd, nvbo->map_handle);
+ MAP_SHARED, bo->device->fd, nvbo->map_handle);
if (bo->map == MAP_FAILED) {
bo->map = NULL;
return -errno;
diff --git a/chromium/third_party/libdrm/src/nouveau/nouveau.h b/chromium/third_party/libdrm/src/nouveau/nouveau.h
index 335ce77dca7..4adda0e3594 100644
--- a/chromium/third_party/libdrm/src/nouveau/nouveau.h
+++ b/chromium/third_party/libdrm/src/nouveau/nouveau.h
@@ -4,66 +4,76 @@
#include <stdint.h>
#include <stdbool.h>
-/* Supported class information, provided by the kernel */
-struct nouveau_sclass {
- int32_t oclass;
- int minver;
- int maxver;
-};
+#define NOUVEAU_DEVICE_CLASS 0x80000000
+#define NOUVEAU_FIFO_CHANNEL_CLASS 0x80000001
+#define NOUVEAU_NOTIFIER_CLASS 0x80000002
+#define NOUVEAU_PARENT_CLASS 0xffffffff
-/* Client-provided array describing class versions that are desired.
- *
- * These are used to match against the kernel's list of supported classes.
- */
-struct nouveau_mclass {
- int32_t oclass;
- int version;
- void *data;
+struct nouveau_list {
+ struct nouveau_list *prev;
+ struct nouveau_list *next;
};
struct nouveau_object {
struct nouveau_object *parent;
uint64_t handle;
uint32_t oclass;
- uint32_t length; /* deprecated */
- void *data; /* deprecated */
+ uint32_t length;
+ void *data;
};
-int nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
- uint32_t oclass, void *data, uint32_t length,
- struct nouveau_object **);
-void nouveau_object_del(struct nouveau_object **);
-int nouveau_object_mthd(struct nouveau_object *, uint32_t mthd,
- void *data, uint32_t size);
-int nouveau_object_sclass_get(struct nouveau_object *,
- struct nouveau_sclass **);
-void nouveau_object_sclass_put(struct nouveau_sclass **);
-int nouveau_object_mclass(struct nouveau_object *,
- const struct nouveau_mclass *);
+struct nouveau_fifo {
+ struct nouveau_object *object;
+ uint32_t channel;
+ uint32_t pushbuf;
+ uint64_t unused1[3];
+};
-struct nouveau_drm {
- struct nouveau_object client;
- int fd;
- uint32_t version;
- bool nvif;
+struct nv04_fifo {
+ struct nouveau_fifo base;
+ uint32_t vram;
+ uint32_t gart;
+ uint32_t notify;
+};
+
+struct nvc0_fifo {
+ struct nouveau_fifo base;
+ uint32_t notify;
+};
+
+#define NVE0_FIFO_ENGINE_GR 0x00000001
+#define NVE0_FIFO_ENGINE_VP 0x00000002
+#define NVE0_FIFO_ENGINE_PPP 0x00000004
+#define NVE0_FIFO_ENGINE_BSP 0x00000008
+#define NVE0_FIFO_ENGINE_CE0 0x00000010
+#define NVE0_FIFO_ENGINE_CE1 0x00000020
+#define NVE0_FIFO_ENGINE_ENC 0x00000040
+
+struct nve0_fifo {
+ struct {
+ struct nouveau_fifo base;
+ uint32_t notify;
+ };
+ uint32_t engine;
};
-static inline struct nouveau_drm *
-nouveau_drm(struct nouveau_object *obj)
-{
- while (obj && obj->parent)
- obj = obj->parent;
- return (struct nouveau_drm *)obj;
-}
+struct nv04_notify {
+ struct nouveau_object *object;
+ uint32_t offset;
+ uint32_t length;
+};
-int nouveau_drm_new(int fd, struct nouveau_drm **);
-void nouveau_drm_del(struct nouveau_drm **);
+int nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
+ uint32_t oclass, void *data, uint32_t length,
+ struct nouveau_object **);
+void nouveau_object_del(struct nouveau_object **);
+void *nouveau_object_find(struct nouveau_object *, uint32_t parent_class);
struct nouveau_device {
struct nouveau_object object;
- int fd; /* deprecated */
- uint32_t lib_version; /* deprecated */
- uint32_t drm_version; /* deprecated */
+ int fd;
+ uint32_t lib_version;
+ uint32_t drm_version;
uint32_t chipset;
uint64_t vram_size;
uint64_t gart_size;
@@ -71,23 +81,18 @@ struct nouveau_device {
uint64_t gart_limit;
};
-int nouveau_device_new(struct nouveau_object *parent, int32_t oclass,
- void *data, uint32_t size, struct nouveau_device **);
+int nouveau_device_wrap(int fd, int close, struct nouveau_device **);
+int nouveau_device_open(const char *busid, struct nouveau_device **);
void nouveau_device_del(struct nouveau_device **);
-
-int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value);
-int nouveau_setparam(struct nouveau_device *, uint64_t param, uint64_t value);
-
-/* deprecated */
-int nouveau_device_wrap(int fd, int close, struct nouveau_device **);
-int nouveau_device_open(const char *busid, struct nouveau_device **);
+int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value);
+int nouveau_setparam(struct nouveau_device *, uint64_t param, uint64_t value);
struct nouveau_client {
struct nouveau_device *device;
int id;
};
-int nouveau_client_new(struct nouveau_device *, struct nouveau_client **);
+int nouveau_client_new(struct nouveau_device *, struct nouveau_client **);
void nouveau_client_del(struct nouveau_client **);
union nouveau_bo_config {
@@ -134,27 +139,22 @@ struct nouveau_bo {
union nouveau_bo_config config;
};
-int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align,
- uint64_t size, union nouveau_bo_config *,
- struct nouveau_bo **);
-int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle,
+int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align,
+ uint64_t size, union nouveau_bo_config *,
struct nouveau_bo **);
-int nouveau_bo_name_ref(struct nouveau_device *v, uint32_t name,
- struct nouveau_bo **);
-int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name);
+int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle,
+ struct nouveau_bo **);
+int nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name,
+ struct nouveau_bo **);
+int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name);
void nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **);
-int nouveau_bo_map(struct nouveau_bo *, uint32_t access,
- struct nouveau_client *);
-int nouveau_bo_wait(struct nouveau_bo *, uint32_t access,
+int nouveau_bo_map(struct nouveau_bo *, uint32_t access,
struct nouveau_client *);
-int nouveau_bo_prime_handle_ref(struct nouveau_device *, int prime_fd,
- struct nouveau_bo **);
-int nouveau_bo_set_prime(struct nouveau_bo *, int *prime_fd);
-
-struct nouveau_list {
- struct nouveau_list *prev;
- struct nouveau_list *next;
-};
+int nouveau_bo_wait(struct nouveau_bo *, uint32_t access,
+ struct nouveau_client *);
+int nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
+ struct nouveau_bo **);
+int nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd);
struct nouveau_bufref {
struct nouveau_list thead;
@@ -176,8 +176,8 @@ struct nouveau_bufctx {
int relocs;
};
-int nouveau_bufctx_new(struct nouveau_client *, int bins,
- struct nouveau_bufctx **);
+int nouveau_bufctx_new(struct nouveau_client *, int bins,
+ struct nouveau_bufctx **);
void nouveau_bufctx_del(struct nouveau_bufctx **);
struct nouveau_bufref *
nouveau_bufctx_refn(struct nouveau_bufctx *, int bin,
@@ -206,16 +206,16 @@ struct nouveau_pushbuf_refn {
uint32_t flags;
};
-int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *chan,
- int nr, uint32_t size, bool immediate,
- struct nouveau_pushbuf **);
+int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *channel,
+ int nr, uint32_t size, bool immediate,
+ struct nouveau_pushbuf **);
void nouveau_pushbuf_del(struct nouveau_pushbuf **);
-int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords,
- uint32_t relocs, uint32_t pushes);
+int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords,
+ uint32_t relocs, uint32_t pushes);
void nouveau_pushbuf_data(struct nouveau_pushbuf *, struct nouveau_bo *,
uint64_t offset, uint64_t length);
-int nouveau_pushbuf_refn(struct nouveau_pushbuf *,
- struct nouveau_pushbuf_refn *, int nr);
+int nouveau_pushbuf_refn(struct nouveau_pushbuf *,
+ struct nouveau_pushbuf_refn *, int nr);
/* Emits a reloc into the push buffer at the current position, you *must*
* have previously added the referenced buffer to a buffer context, and
* validated it against the current push buffer.
@@ -223,54 +223,10 @@ int nouveau_pushbuf_refn(struct nouveau_pushbuf *,
void nouveau_pushbuf_reloc(struct nouveau_pushbuf *, struct nouveau_bo *,
uint32_t data, uint32_t flags,
uint32_t vor, uint32_t tor);
-int nouveau_pushbuf_validate(struct nouveau_pushbuf *);
+int nouveau_pushbuf_validate(struct nouveau_pushbuf *);
uint32_t nouveau_pushbuf_refd(struct nouveau_pushbuf *, struct nouveau_bo *);
-int nouveau_pushbuf_kick(struct nouveau_pushbuf *, struct nouveau_object *chan);
+int nouveau_pushbuf_kick(struct nouveau_pushbuf *, struct nouveau_object *channel);
struct nouveau_bufctx *
nouveau_pushbuf_bufctx(struct nouveau_pushbuf *, struct nouveau_bufctx *);
-#define NOUVEAU_DEVICE_CLASS 0x80000000
-#define NOUVEAU_FIFO_CHANNEL_CLASS 0x80000001
-#define NOUVEAU_NOTIFIER_CLASS 0x80000002
-
-struct nouveau_fifo {
- struct nouveau_object *object;
- uint32_t channel;
- uint32_t pushbuf;
- uint64_t unused1[3];
-};
-
-struct nv04_fifo {
- struct nouveau_fifo base;
- uint32_t vram;
- uint32_t gart;
- uint32_t notify;
-};
-
-struct nvc0_fifo {
- struct nouveau_fifo base;
- uint32_t notify;
-};
-
-#define NVE0_FIFO_ENGINE_GR 0x00000001
-#define NVE0_FIFO_ENGINE_VP 0x00000002
-#define NVE0_FIFO_ENGINE_PPP 0x00000004
-#define NVE0_FIFO_ENGINE_BSP 0x00000008
-#define NVE0_FIFO_ENGINE_CE0 0x00000010
-#define NVE0_FIFO_ENGINE_CE1 0x00000020
-#define NVE0_FIFO_ENGINE_ENC 0x00000040
-
-struct nve0_fifo {
- struct {
- struct nouveau_fifo base;
- uint32_t notify;
- };
- uint32_t engine;
-};
-
-struct nv04_notify {
- struct nouveau_object *object;
- uint32_t offset;
- uint32_t length;
-};
#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/cl0080.h b/chromium/third_party/libdrm/src/nouveau/nvif/cl0080.h
deleted file mode 100644
index 331620a52af..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/cl0080.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __NVIF_CL0080_H__
-#define __NVIF_CL0080_H__
-
-struct nv_device_v0 {
- __u8 version;
- __u8 pad01[7];
- __u64 device; /* device identifier, ~0 for client default */
-};
-
-#define NV_DEVICE_V0_INFO 0x00
-#define NV_DEVICE_V0_TIME 0x01
-
-struct nv_device_info_v0 {
- __u8 version;
-#define NV_DEVICE_INFO_V0_IGP 0x00
-#define NV_DEVICE_INFO_V0_PCI 0x01
-#define NV_DEVICE_INFO_V0_AGP 0x02
-#define NV_DEVICE_INFO_V0_PCIE 0x03
-#define NV_DEVICE_INFO_V0_SOC 0x04
- __u8 platform;
- __u16 chipset; /* from NV_PMC_BOOT_0 */
- __u8 revision; /* from NV_PMC_BOOT_0 */
-#define NV_DEVICE_INFO_V0_TNT 0x01
-#define NV_DEVICE_INFO_V0_CELSIUS 0x02
-#define NV_DEVICE_INFO_V0_KELVIN 0x03
-#define NV_DEVICE_INFO_V0_RANKINE 0x04
-#define NV_DEVICE_INFO_V0_CURIE 0x05
-#define NV_DEVICE_INFO_V0_TESLA 0x06
-#define NV_DEVICE_INFO_V0_FERMI 0x07
-#define NV_DEVICE_INFO_V0_KEPLER 0x08
-#define NV_DEVICE_INFO_V0_MAXWELL 0x09
- __u8 family;
- __u8 pad06[2];
- __u64 ram_size;
- __u64 ram_user;
- char chip[16];
- char name[64];
-};
-
-struct nv_device_time_v0 {
- __u8 version;
- __u8 pad01[7];
- __u64 time;
-};
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/cl9097.h b/chromium/third_party/libdrm/src/nouveau/nvif/cl9097.h
deleted file mode 100644
index 4057676d298..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/cl9097.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef __NVIF_CL9097_H__
-#define __NVIF_CL9097_H__
-
-#define FERMI_A_ZBC_COLOR 0x00
-#define FERMI_A_ZBC_DEPTH 0x01
-
-struct fermi_a_zbc_color_v0 {
- __u8 version;
-#define FERMI_A_ZBC_COLOR_V0_FMT_ZERO 0x01
-#define FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE 0x02
-#define FERMI_A_ZBC_COLOR_V0_FMT_RF32_GF32_BF32_AF32 0x04
-#define FERMI_A_ZBC_COLOR_V0_FMT_R16_G16_B16_A16 0x08
-#define FERMI_A_ZBC_COLOR_V0_FMT_RN16_GN16_BN16_AN16 0x0c
-#define FERMI_A_ZBC_COLOR_V0_FMT_RS16_GS16_BS16_AS16 0x10
-#define FERMI_A_ZBC_COLOR_V0_FMT_RU16_GU16_BU16_AU16 0x14
-#define FERMI_A_ZBC_COLOR_V0_FMT_RF16_GF16_BF16_AF16 0x16
-#define FERMI_A_ZBC_COLOR_V0_FMT_A8R8G8B8 0x18
-#define FERMI_A_ZBC_COLOR_V0_FMT_A8RL8GL8BL8 0x1c
-#define FERMI_A_ZBC_COLOR_V0_FMT_A2B10G10R10 0x20
-#define FERMI_A_ZBC_COLOR_V0_FMT_AU2BU10GU10RU10 0x24
-#define FERMI_A_ZBC_COLOR_V0_FMT_A8B8G8R8 0x28
-#define FERMI_A_ZBC_COLOR_V0_FMT_A8BL8GL8RL8 0x2c
-#define FERMI_A_ZBC_COLOR_V0_FMT_AN8BN8GN8RN8 0x30
-#define FERMI_A_ZBC_COLOR_V0_FMT_AS8BS8GS8RS8 0x34
-#define FERMI_A_ZBC_COLOR_V0_FMT_AU8BU8GU8RU8 0x38
-#define FERMI_A_ZBC_COLOR_V0_FMT_A2R10G10B10 0x3c
-#define FERMI_A_ZBC_COLOR_V0_FMT_BF10GF11RF11 0x40
- __u8 format;
- __u8 index;
- __u8 pad03[5];
- __u32 ds[4];
- __u32 l2[4];
-};
-
-struct fermi_a_zbc_depth_v0 {
- __u8 version;
-#define FERMI_A_ZBC_DEPTH_V0_FMT_FP32 0x01
- __u8 format;
- __u8 index;
- __u8 pad03[5];
- __u32 ds;
- __u32 l2;
-};
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/class.h b/chromium/third_party/libdrm/src/nouveau/nvif/class.h
deleted file mode 100644
index 4179cd65ac0..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/class.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#ifndef __NVIF_CLASS_H__
-#define __NVIF_CLASS_H__
-
-/* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_CLASS_CONTROL /* if0001.h */ -1
-#define NVIF_CLASS_PERFMON /* if0002.h */ -2
-#define NVIF_CLASS_PERFDOM /* if0003.h */ -3
-#define NVIF_CLASS_SW_NV04 /* if0004.h */ -4
-#define NVIF_CLASS_SW_NV10 /* if0005.h */ -5
-#define NVIF_CLASS_SW_NV50 /* if0005.h */ -6
-#define NVIF_CLASS_SW_GF100 /* if0005.h */ -7
-
-/* the below match nvidia-assigned (either in hw, or sw) class numbers */
-#define NV_DEVICE /* cl0080.h */ 0x00000080
-
-#define NV_DMA_FROM_MEMORY /* cl0002.h */ 0x00000002
-#define NV_DMA_TO_MEMORY /* cl0002.h */ 0x00000003
-#define NV_DMA_IN_MEMORY /* cl0002.h */ 0x0000003d
-
-#define FERMI_TWOD_A 0x0000902d
-
-#define FERMI_MEMORY_TO_MEMORY_FORMAT_A 0x00009039
-
-#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040
-#define KEPLER_INLINE_TO_MEMORY_B 0x0000a140
-
-#define NV04_DISP /* cl0046.h */ 0x00000046
-
-#define NV03_CHANNEL_DMA /* cl506b.h */ 0x0000006b
-#define NV10_CHANNEL_DMA /* cl506b.h */ 0x0000006e
-#define NV17_CHANNEL_DMA /* cl506b.h */ 0x0000176e
-#define NV40_CHANNEL_DMA /* cl506b.h */ 0x0000406e
-#define NV50_CHANNEL_DMA /* cl506e.h */ 0x0000506e
-#define G82_CHANNEL_DMA /* cl826e.h */ 0x0000826e
-
-#define NV50_CHANNEL_GPFIFO /* cl506f.h */ 0x0000506f
-#define G82_CHANNEL_GPFIFO /* cl826f.h */ 0x0000826f
-#define FERMI_CHANNEL_GPFIFO /* cl906f.h */ 0x0000906f
-#define KEPLER_CHANNEL_GPFIFO_A /* cla06f.h */ 0x0000a06f
-#define MAXWELL_CHANNEL_GPFIFO_A /* cla06f.h */ 0x0000b06f
-
-#define NV50_DISP /* cl5070.h */ 0x00005070
-#define G82_DISP /* cl5070.h */ 0x00008270
-#define GT200_DISP /* cl5070.h */ 0x00008370
-#define GT214_DISP /* cl5070.h */ 0x00008570
-#define GT206_DISP /* cl5070.h */ 0x00008870
-#define GF110_DISP /* cl5070.h */ 0x00009070
-#define GK104_DISP /* cl5070.h */ 0x00009170
-#define GK110_DISP /* cl5070.h */ 0x00009270
-#define GM107_DISP /* cl5070.h */ 0x00009470
-#define GM204_DISP /* cl5070.h */ 0x00009570
-
-#define NV31_MPEG 0x00003174
-#define G82_MPEG 0x00008274
-
-#define NV74_VP2 0x00007476
-
-#define NV50_DISP_CURSOR /* cl507a.h */ 0x0000507a
-#define G82_DISP_CURSOR /* cl507a.h */ 0x0000827a
-#define GT214_DISP_CURSOR /* cl507a.h */ 0x0000857a
-#define GF110_DISP_CURSOR /* cl507a.h */ 0x0000907a
-#define GK104_DISP_CURSOR /* cl507a.h */ 0x0000917a
-
-#define NV50_DISP_OVERLAY /* cl507b.h */ 0x0000507b
-#define G82_DISP_OVERLAY /* cl507b.h */ 0x0000827b
-#define GT214_DISP_OVERLAY /* cl507b.h */ 0x0000857b
-#define GF110_DISP_OVERLAY /* cl507b.h */ 0x0000907b
-#define GK104_DISP_OVERLAY /* cl507b.h */ 0x0000917b
-
-#define NV50_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000507c
-#define G82_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000827c
-#define GT200_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000837c
-#define GT214_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000857c
-#define GF110_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000907c
-#define GK104_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000917c
-#define GK110_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000927c
-
-#define NV50_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000507d
-#define G82_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000827d
-#define GT200_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000837d
-#define GT214_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000857d
-#define GT206_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000887d
-#define GF110_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000907d
-#define GK104_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000917d
-#define GK110_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000927d
-#define GM107_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000947d
-#define GM204_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000957d
-
-#define NV50_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000507e
-#define G82_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000827e
-#define GT200_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000837e
-#define GT214_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000857e
-#define GF110_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000907e
-#define GK104_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000917e
-
-#define FERMI_A /* cl9097.h */ 0x00009097
-#define FERMI_B /* cl9097.h */ 0x00009197
-#define FERMI_C /* cl9097.h */ 0x00009297
-
-#define KEPLER_A /* cl9097.h */ 0x0000a097
-#define KEPLER_B /* cl9097.h */ 0x0000a197
-#define KEPLER_C /* cl9097.h */ 0x0000a297
-
-#define MAXWELL_A /* cl9097.h */ 0x0000b097
-#define MAXWELL_B /* cl9097.h */ 0x0000b197
-
-#define NV74_BSP 0x000074b0
-
-#define GT212_MSVLD 0x000085b1
-#define IGT21A_MSVLD 0x000086b1
-#define G98_MSVLD 0x000088b1
-#define GF100_MSVLD 0x000090b1
-#define GK104_MSVLD 0x000095b1
-
-#define GT212_MSPDEC 0x000085b2
-#define G98_MSPDEC 0x000088b2
-#define GF100_MSPDEC 0x000090b2
-#define GK104_MSPDEC 0x000095b2
-
-#define GT212_MSPPP 0x000085b3
-#define G98_MSPPP 0x000088b3
-#define GF100_MSPPP 0x000090b3
-
-#define G98_SEC 0x000088b4
-
-#define GT212_DMA 0x000085b5
-#define FERMI_DMA 0x000090b5
-#define KEPLER_DMA_COPY_A 0x0000a0b5
-#define MAXWELL_DMA_COPY_A 0x0000b0b5
-
-#define FERMI_DECOMPRESS 0x000090b8
-
-#define FERMI_COMPUTE_A 0x000090c0
-#define FERMI_COMPUTE_B 0x000091c0
-#define KEPLER_COMPUTE_A 0x0000a0c0
-#define KEPLER_COMPUTE_B 0x0000a1c0
-#define MAXWELL_COMPUTE_A 0x0000b0c0
-#define MAXWELL_COMPUTE_B 0x0000b1c0
-
-#define NV74_CIPHER 0x000074c1
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/if0002.h b/chromium/third_party/libdrm/src/nouveau/nvif/if0002.h
deleted file mode 100644
index c04c91d0b81..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/if0002.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __NVIF_IF0002_H__
-#define __NVIF_IF0002_H__
-
-#define NVIF_PERFMON_V0_QUERY_DOMAIN 0x00
-#define NVIF_PERFMON_V0_QUERY_SIGNAL 0x01
-#define NVIF_PERFMON_V0_QUERY_SOURCE 0x02
-
-struct nvif_perfmon_query_domain_v0 {
- __u8 version;
- __u8 id;
- __u8 counter_nr;
- __u8 iter;
- __u16 signal_nr;
- __u8 pad05[2];
- char name[64];
-};
-
-struct nvif_perfmon_query_signal_v0 {
- __u8 version;
- __u8 domain;
- __u16 iter;
- __u8 signal;
- __u8 source_nr;
- __u8 pad05[2];
- char name[64];
-};
-
-struct nvif_perfmon_query_source_v0 {
- __u8 version;
- __u8 domain;
- __u8 signal;
- __u8 iter;
- __u8 pad04[4];
- __u32 source;
- __u32 mask;
- char name[64];
-};
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/if0003.h b/chromium/third_party/libdrm/src/nouveau/nvif/if0003.h
deleted file mode 100644
index 0cd03efb80a..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/if0003.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __NVIF_IF0003_H__
-#define __NVIF_IF0003_H__
-
-struct nvif_perfdom_v0 {
- __u8 version;
- __u8 domain;
- __u8 mode;
- __u8 pad03[1];
- struct {
- __u8 signal[4];
- __u64 source[4][8];
- __u16 logic_op;
- } ctr[4];
-};
-
-#define NVIF_PERFDOM_V0_INIT 0x00
-#define NVIF_PERFDOM_V0_SAMPLE 0x01
-#define NVIF_PERFDOM_V0_READ 0x02
-
-struct nvif_perfdom_init {
-};
-
-struct nvif_perfdom_sample {
-};
-
-struct nvif_perfdom_read_v0 {
- __u8 version;
- __u8 pad01[7];
- __u32 ctr[4];
- __u32 clk;
- __u8 pad04[4];
-};
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/ioctl.h b/chromium/third_party/libdrm/src/nouveau/nvif/ioctl.h
deleted file mode 100644
index c5f5eb83a59..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/ioctl.h
+++ /dev/null
@@ -1,132 +0,0 @@
-#ifndef __NVIF_IOCTL_H__
-#define __NVIF_IOCTL_H__
-
-#define NVIF_VERSION_LATEST 0x0000000000000000ULL
-
-struct nvif_ioctl_v0 {
- __u8 version;
-#define NVIF_IOCTL_V0_NOP 0x00
-#define NVIF_IOCTL_V0_SCLASS 0x01
-#define NVIF_IOCTL_V0_NEW 0x02
-#define NVIF_IOCTL_V0_DEL 0x03
-#define NVIF_IOCTL_V0_MTHD 0x04
-#define NVIF_IOCTL_V0_RD 0x05
-#define NVIF_IOCTL_V0_WR 0x06
-#define NVIF_IOCTL_V0_MAP 0x07
-#define NVIF_IOCTL_V0_UNMAP 0x08
-#define NVIF_IOCTL_V0_NTFY_NEW 0x09
-#define NVIF_IOCTL_V0_NTFY_DEL 0x0a
-#define NVIF_IOCTL_V0_NTFY_GET 0x0b
-#define NVIF_IOCTL_V0_NTFY_PUT 0x0c
- __u8 type;
- __u8 pad02[4];
-#define NVIF_IOCTL_V0_OWNER_NVIF 0x00
-#define NVIF_IOCTL_V0_OWNER_ANY 0xff
- __u8 owner;
-#define NVIF_IOCTL_V0_ROUTE_NVIF 0x00
-#define NVIF_IOCTL_V0_ROUTE_HIDDEN 0xff
- __u8 route;
- __u64 token;
- __u64 object;
- __u8 data[]; /* ioctl data (below) */
-};
-
-struct nvif_ioctl_nop_v0 {
- __u64 version;
-};
-
-struct nvif_ioctl_sclass_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 count;
- __u8 pad02[6];
- struct nvif_ioctl_sclass_oclass_v0 {
- __s32 oclass;
- __s16 minver;
- __s16 maxver;
- } oclass[];
-};
-
-struct nvif_ioctl_new_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 pad01[6];
- __u8 route;
- __u64 token;
- __u64 object;
- __u32 handle;
- __s32 oclass;
- __u8 data[]; /* class data (class.h) */
-};
-
-struct nvif_ioctl_del {
-};
-
-struct nvif_ioctl_rd_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 size;
- __u8 pad02[2];
- __u32 data;
- __u64 addr;
-};
-
-struct nvif_ioctl_wr_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 size;
- __u8 pad02[2];
- __u32 data;
- __u64 addr;
-};
-
-struct nvif_ioctl_map_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 pad01[3];
- __u32 length;
- __u64 handle;
-};
-
-struct nvif_ioctl_unmap {
-};
-
-struct nvif_ioctl_ntfy_new_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 event;
- __u8 index;
- __u8 pad03[5];
- __u8 data[]; /* event request data (event.h) */
-};
-
-struct nvif_ioctl_ntfy_del_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 index;
- __u8 pad02[6];
-};
-
-struct nvif_ioctl_ntfy_get_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 index;
- __u8 pad02[6];
-};
-
-struct nvif_ioctl_ntfy_put_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 index;
- __u8 pad02[6];
-};
-
-struct nvif_ioctl_mthd_v0 {
- /* nvif_ioctl ... */
- __u8 version;
- __u8 method;
- __u8 pad02[6];
- __u8 data[]; /* method data (class.h) */
-};
-
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/nvif/unpack.h b/chromium/third_party/libdrm/src/nouveau/nvif/unpack.h
deleted file mode 100644
index 751bcf4930a..00000000000
--- a/chromium/third_party/libdrm/src/nouveau/nvif/unpack.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NVIF_UNPACK_H__
-#define __NVIF_UNPACK_H__
-
-#define nvif_unvers(r,d,s,m) ({ \
- void **_data = (d); __u32 *_size = (s); int _ret = (r); \
- if (_ret == -ENOSYS && *_size == sizeof(m)) { \
- *_data = NULL; \
- *_size = _ret = 0; \
- } \
- _ret; \
-})
-
-#define nvif_unpack(r,d,s,m,vl,vh,x) ({ \
- void **_data = (d); __u32 *_size = (s); \
- int _ret = (r), _vl = (vl), _vh = (vh); \
- if (_ret == -ENOSYS && *_size >= sizeof(m) && \
- (m).version >= _vl && (m).version <= _vh) { \
- *_data = (__u8 *)*_data + sizeof(m); \
- *_size = *_size - sizeof(m); \
- if (_ret = 0, !(x)) { \
- _ret = *_size ? -E2BIG : 0; \
- *_data = NULL; \
- *_size = 0; \
- } \
- } \
- _ret; \
-})
-#endif
diff --git a/chromium/third_party/libdrm/src/nouveau/private.h b/chromium/third_party/libdrm/src/nouveau/private.h
index 83060f96524..e9439f30826 100644
--- a/chromium/third_party/libdrm/src/nouveau/private.h
+++ b/chromium/third_party/libdrm/src/nouveau/private.h
@@ -114,9 +114,11 @@ int
nouveau_device_open_existing(struct nouveau_device **, int, int, drm_context_t);
/* abi16.c */
-drm_private bool abi16_object(struct nouveau_object *, int (**)(struct nouveau_object *));
-drm_private void abi16_delete(struct nouveau_object *);
-drm_private int abi16_sclass(struct nouveau_object *, struct nouveau_sclass **);
+drm_private int abi16_chan_nv04(struct nouveau_object *);
+drm_private int abi16_chan_nvc0(struct nouveau_object *);
+drm_private int abi16_chan_nve0(struct nouveau_object *);
+drm_private int abi16_engobj(struct nouveau_object *);
+drm_private int abi16_ntfy(struct nouveau_object *);
drm_private void abi16_bo_info(struct nouveau_bo *, struct drm_nouveau_gem_info *);
drm_private int abi16_bo_init(struct nouveau_bo *, uint32_t alignment,
union nouveau_bo_config *);
diff --git a/chromium/third_party/libdrm/src/nouveau/pushbuf.c b/chromium/third_party/libdrm/src/nouveau/pushbuf.c
index 035e3019f2c..8e7dcdfaa19 100644
--- a/chromium/third_party/libdrm/src/nouveau/pushbuf.c
+++ b/chromium/third_party/libdrm/src/nouveau/pushbuf.c
@@ -312,7 +312,6 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct nouveau_object *chan)
struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(push);
struct nouveau_pushbuf_krec *krec = nvpb->list;
struct nouveau_device *dev = push->client->device;
- struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_gem_pushbuf_bo_presumed *info;
struct drm_nouveau_gem_pushbuf_bo *kref;
struct drm_nouveau_gem_pushbuf req;
@@ -346,7 +345,7 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct nouveau_object *chan)
pushbuf_dump(krec, krec_id++, fifo->channel);
#ifndef SIMULATE
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_PUSHBUF,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_PUSHBUF,
&req, sizeof(req));
nvpb->suffix0 = req.suffix0;
nvpb->suffix1 = req.suffix1;
@@ -537,7 +536,7 @@ nouveau_pushbuf_new(struct nouveau_client *client, struct nouveau_object *chan,
int nr, uint32_t size, bool immediate,
struct nouveau_pushbuf **ppush)
{
- struct nouveau_drm *drm = nouveau_drm(&client->device->object);
+ struct nouveau_device *dev = client->device;
struct nouveau_fifo *fifo = chan->data;
struct nouveau_pushbuf_priv *nvpb;
struct nouveau_pushbuf *push;
@@ -552,7 +551,7 @@ nouveau_pushbuf_new(struct nouveau_client *client, struct nouveau_object *chan,
*/
req.channel = fifo->channel;
req.nr_push = 0;
- ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_PUSHBUF,
+ ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_PUSHBUF,
&req, sizeof(req));
if (ret)
return ret;
diff --git a/chromium/third_party/libdrm/src/radeon/Android.mk b/chromium/third_party/libdrm/src/radeon/Android.mk
index e70444354de..ace34080fc8 100644
--- a/chromium/third_party/libdrm/src/radeon/Android.mk
+++ b/chromium/third_party/libdrm/src/radeon/Android.mk
@@ -9,7 +9,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libdrm
-LOCAL_SRC_FILES := $(patsubst %.h, , $(LIBDRM_RADEON_FILES))
+LOCAL_SRC_FILES := $(LIBDRM_RADEON_FILES)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_CFLAGS := \
diff --git a/chromium/third_party/libdrm/src/radeon/Makefile.am b/chromium/third_party/libdrm/src/radeon/Makefile.am
index e241531488c..25c03d3cb3c 100644
--- a/chromium/third_party/libdrm/src/radeon/Makefile.am
+++ b/chromium/third_party/libdrm/src/radeon/Makefile.am
@@ -43,5 +43,4 @@ libdrm_radeoninclude_HEADERS = $(LIBDRM_RADEON_H_FILES)
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libdrm_radeon.pc
-TESTS = radeon-symbol-check
-EXTRA_DIST = $(LIBDRM_RADEON_BOF_FILES) $(TESTS)
+EXTRA_DIST = Android.mk $(LIBDRM_RADEON_BOF_FILES) $(TESTS)
diff --git a/chromium/third_party/libdrm/src/radeon/libdrm_radeon.pc.in b/chromium/third_party/libdrm/src/radeon/libdrm_radeon.pc.in
index 432993a376a..68ef0ab1452 100644
--- a/chromium/third_party/libdrm/src/radeon/libdrm_radeon.pc.in
+++ b/chromium/third_party/libdrm/src/radeon/libdrm_radeon.pc.in
@@ -8,4 +8,3 @@ Description: Userspace interface to kernel DRM services for radeon
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ldrm_radeon
Cflags: -I${includedir} -I${includedir}/libdrm
-Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/radeon/radeon_bo_gem.c b/chromium/third_party/libdrm/src/radeon/radeon_bo_gem.c
index fbd453d9c7e..c9fe19ff40c 100644
--- a/chromium/third_party/libdrm/src/radeon/radeon_bo_gem.c
+++ b/chromium/third_party/libdrm/src/radeon/radeon_bo_gem.c
@@ -103,7 +103,7 @@ static struct radeon_bo *bo_open(struct radeon_bo_manager *bom,
args.size = size;
args.alignment = alignment;
args.initial_domain = bo->base.domains;
- args.flags = flags;
+ args.flags = 0;
args.handle = 0;
r = drmCommandWriteRead(bom->fd, DRM_RADEON_GEM_CREATE,
&args, sizeof(args));
diff --git a/chromium/third_party/libdrm/src/radeon/radeon_cs_gem.c b/chromium/third_party/libdrm/src/radeon/radeon_cs_gem.c
index 23f33af4cab..cdec64e0bf1 100644
--- a/chromium/third_party/libdrm/src/radeon/radeon_cs_gem.c
+++ b/chromium/third_party/libdrm/src/radeon/radeon_cs_gem.c
@@ -323,7 +323,7 @@ static int cs_gem_end(struct radeon_cs_int *cs,
return -EPIPE;
}
if (cs->section_ndw != cs->section_cdw) {
- fprintf(stderr, "CS section size mismatch start at (%s,%s,%d) %d vs %d\n",
+ fprintf(stderr, "CS section size missmatch start at (%s,%s,%d) %d vs %d\n",
cs->section_file, cs->section_func, cs->section_line, cs->section_ndw, cs->section_cdw);
fprintf(stderr, "CS section end at (%s,%s,%d)\n",
file, func, line);
diff --git a/chromium/third_party/libdrm/src/radeon/radeon_surface.c b/chromium/third_party/libdrm/src/radeon/radeon_surface.c
index 1424660daae..5ec97454dcd 100644
--- a/chromium/third_party/libdrm/src/radeon/radeon_surface.c
+++ b/chromium/third_party/libdrm/src/radeon/radeon_surface.c
@@ -957,10 +957,8 @@ static int eg_surface_best(struct radeon_surface_manager *surf_man,
}
surf->stencil_tile_split = 64;
} else {
- /* tile split must be >= 256 for colorbuffer surfaces,
- * SAMPLE_SPLIT = tile_split / (bpe * 64), the optimal value is 2
- */
- surf->tile_split = MAX2(2 * surf->bpe * 64, 256);
+ /* tile split must be >= 256 for colorbuffer surfaces */
+ surf->tile_split = MAX2(surf->nsamples * surf->bpe * 64, 256);
if (surf->tile_split > 4096)
surf->tile_split = 4096;
}
diff --git a/chromium/third_party/libdrm/src/rockchip/Android.mk b/chromium/third_party/libdrm/src/rockchip/Android.mk
deleted file mode 100644
index 4569044ea18..00000000000
--- a/chromium/third_party/libdrm/src/rockchip/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libdrm_rockchip
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := libdrm
-
-LOCAL_SRC_FILES := rockchip_drm.c
-LOCAL_EXPORT_C_INCLUDE_DIRS += \
- $(LOCAL_PATH)/rockchip
-
-LOCAL_C_INCLUDES := \
- $(LIBDRM_TOP) \
- $(LIBDRM_TOP)/rockchip \
- $(LIBDRM_TOP)/include/drm
-
-LOCAL_CFLAGS := \
- -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
-
-LOCAL_COPY_HEADERS := rockchip_drm.h rockchip_drmif.h
-LOCAL_COPY_HEADERS_TO := libdrm
-
-LOCAL_SHARED_LIBRARIES := \
- libdrm
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/chromium/third_party/libdrm/src/rockchip/Makefile.am b/chromium/third_party/libdrm/src/rockchip/Makefile.am
deleted file mode 100644
index 2ebb82f18e2..00000000000
--- a/chromium/third_party/libdrm/src/rockchip/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -I$(top_srcdir) \
- -I$(top_srcdir)/rockchip \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_rockchip_la_LTLIBRARIES = libdrm_rockchip.la
-libdrm_rockchip_ladir = $(libdir)
-libdrm_rockchip_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_rockchip_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_rockchip_la_SOURCES = \
- rockchip_drm.c
-
-libdrm_rockchipincludedir = ${includedir}/libdrm
-libdrm_rockchipinclude_HEADERS = rockchip_drmif.h rockchip_drm.h
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_rockchip.pc
diff --git a/chromium/third_party/libdrm/src/rockchip/libdrm_rockchip.pc.in b/chromium/third_party/libdrm/src/rockchip/libdrm_rockchip.pc.in
deleted file mode 100644
index 13f22ac76af..00000000000
--- a/chromium/third_party/libdrm/src/rockchip/libdrm_rockchip.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libdrm_rockchip
-Description: Userspace interface to rockchip kernel DRM services
-Version: 0.1
-Libs: -L${libdir} -ldrm_rockchip
-Cflags: -I${includedir} -I${includedir}/libdrm
-Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/rockchip/rockchip_drm.c b/chromium/third_party/libdrm/src/rockchip/rockchip_drm.c
deleted file mode 100644
index 9433d52afe1..00000000000
--- a/chromium/third_party/libdrm/src/rockchip/rockchip_drm.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright (C) ROCKCHIP, Inc.
- * Author:yzq<yzq@rock-chips.com>
- *
- * based on exynos_drm.c
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/mman.h>
-#include <linux/stddef.h>
-
-#include <xf86drm.h>
-
-#include "rockchip_drm.h"
-#include "rockchip_drmif.h"
-
-/*
- * Create rockchip drm device object.
- *
- * @fd: file descriptor to rockchip drm driver opened.
- *
- * if true, return the device object else NULL.
- */
-struct rockchip_device *rockchip_device_create(int fd)
-{
- struct rockchip_device *dev;
-
- dev = calloc(1, sizeof(*dev));
- if (!dev) {
- fprintf(stderr, "failed to create device[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- dev->fd = fd;
-
- return dev;
-}
-
-/*
- * Destroy rockchip drm device object
- *
- * @dev: rockchip drm device object.
- */
-void rockchip_device_destroy(struct rockchip_device *dev)
-{
- free(dev);
-}
-
-/*
- * Create a rockchip buffer object to rockchip drm device.
- *
- * @dev: rockchip drm device object.
- * @size: user-desired size.
- * flags: user-desired memory type.
- * user can set one or more types among several types to memory
- * allocation and cache attribute types. and as default,
- * ROCKCHIP_BO_NONCONTIG and ROCKCHIP-BO_NONCACHABLE types would
- * be used.
- *
- * if true, return a rockchip buffer object else NULL.
- */
-struct rockchip_bo *rockchip_bo_create(struct rockchip_device *dev,
- size_t size, uint32_t flags)
-{
- struct rockchip_bo *bo;
- struct drm_rockchip_gem_create req = {
- .size = size,
- .flags = flags,
- };
-
- if (size == 0) {
- fprintf(stderr, "invalid size.\n");
- return NULL;
- }
-
- bo = calloc(1, sizeof(*bo));
- if (!bo) {
- fprintf(stderr, "failed to create bo[%s].\n",
- strerror(errno));
- goto fail;
- }
-
- bo->dev = dev;
-
- if (drmIoctl(dev->fd, DRM_IOCTL_ROCKCHIP_GEM_CREATE, &req)){
- fprintf(stderr, "failed to create gem object[%s].\n",
- strerror(errno));
- goto err_free_bo;
- }
-
- bo->handle = req.handle;
- bo->size = size;
- bo->flags = flags;
-
- return bo;
-
-err_free_bo:
- free(bo);
-fail:
- return NULL;
-}
-
-struct rockchip_bo *rockchip_bo_from_handle(struct rockchip_device *dev,
- uint32_t handle, uint32_t flags, uint32_t size)
-{
- struct rockchip_bo *bo;
-
- if (size == 0) {
- fprintf(stderr, "invalid size.\n");
- return NULL;
- }
-
- bo = calloc(1, sizeof(*bo));
- if (!bo) {
- fprintf(stderr, "failed to create bo[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- bo->dev = dev;
- bo->handle = handle;
- bo->size = size;
- bo->flags = flags;
-
- return bo;
-}
-
-/*
- * Destroy a rockchip buffer object.
- *
- * @bo: a rockchip buffer object to be destroyed.
- */
-void rockchip_bo_destroy(struct rockchip_bo *bo)
-{
- if (!bo)
- return;
-
- if (bo->vaddr)
- munmap(bo->vaddr, bo->size);
-
- if (bo->handle) {
- struct drm_gem_close req = {
- .handle = bo->handle,
- };
-
- drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
- }
-
- free(bo);
-}
-
-
-/*
- * Get a rockchip buffer object from a gem global object name.
- *
- * @dev: a rockchip device object.
- * @name: a gem global object name exported by another process.
- *
- * this interface is used to get a rockchip buffer object from a gem
- * global object name sent by another process for buffer sharing.
- *
- * if true, return a rockchip buffer object else NULL.
- *
- */
-struct rockchip_bo *rockchip_bo_from_name(struct rockchip_device *dev,
- uint32_t name)
-{
- struct rockchip_bo *bo;
- struct drm_gem_open req = {
- .name = name,
- };
-
- bo = calloc(1, sizeof(*bo));
- if (!bo) {
- fprintf(stderr, "failed to allocate bo[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- if (drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req)) {
- fprintf(stderr, "failed to open gem object[%s].\n",
- strerror(errno));
- goto err_free_bo;
- }
-
- bo->dev = dev;
- bo->name = name;
- bo->handle = req.handle;
-
- return bo;
-
-err_free_bo:
- free(bo);
- return NULL;
-}
-
-/*
- * Get a gem global object name from a gem object handle.
- *
- * @bo: a rockchip buffer object including gem handle.
- * @name: a gem global object name to be got by kernel driver.
- *
- * this interface is used to get a gem global object name from a gem object
- * handle to a buffer that wants to share it with another process.
- *
- * if true, return 0 else negative.
- */
-int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name)
-{
- if (!bo->name) {
- struct drm_gem_flink req = {
- .handle = bo->handle,
- };
- int ret;
-
- ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req);
- if (ret) {
- fprintf(stderr, "failed to get gem global name[%s].\n",
- strerror(errno));
- return ret;
- }
-
- bo->name = req.name;
- }
-
- *name = bo->name;
-
- return 0;
-}
-
-uint32_t rockchip_bo_handle(struct rockchip_bo *bo)
-{
- return bo->handle;
-}
-
-/*
- * Mmap a buffer to user space.
- *
- * @bo: a rockchip buffer object including a gem object handle to be mmapped
- * to user space.
- *
- * if true, user pointer mmaped else NULL.
- */
-void *rockchip_bo_map(struct rockchip_bo *bo)
-{
- if (!bo->vaddr) {
- struct rockchip_device *dev = bo->dev;
- struct drm_rockchip_gem_map_off req = {
- .handle = bo->handle,
- };
- int ret;
-
- ret = drmIoctl(dev->fd, DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET, &req);
- if (ret) {
- fprintf(stderr, "failed to ioctl gem map offset[%s].\n",
- strerror(errno));
- return NULL;
- }
-
- bo->vaddr = mmap(0, bo->size, PROT_READ | PROT_WRITE,
- MAP_SHARED, dev->fd, req.offset);
- if (bo->vaddr == MAP_FAILED) {
- fprintf(stderr, "failed to mmap buffer[%s].\n",
- strerror(errno));
- return NULL;
- }
- }
-
- return bo->vaddr;
-}
diff --git a/chromium/third_party/libdrm/src/rockchip/rockchip_drm.h b/chromium/third_party/libdrm/src/rockchip/rockchip_drm.h
deleted file mode 100644
index 13977d59975..00000000000
--- a/chromium/third_party/libdrm/src/rockchip/rockchip_drm.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd
- * Authors:
- * Mark Yao <yzq@rock-chips.com>
- *
- * based on exynos_drm.h
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _ROCKCHIP_DRM_H_
-#define _ROCKCHIP_DRM_H_
-
-#include <stdint.h>
-#include "drm.h"
-
-/**
- * User-desired buffer creation information structure.
- *
- * @size: user-desired memory allocation size.
- * - this size value would be page-aligned internally.
- * @flags: user request for setting memory type or cache attributes.
- * @handle: returned a handle to created gem object.
- * - this handle will be set by gem module of kernel side.
- */
-struct drm_rockchip_gem_create {
- uint64_t size;
- uint32_t flags;
- uint32_t handle;
-};
-
-/**
- * A structure for getting buffer offset.
- *
- * @handle: a pointer to gem object created.
- * @pad: just padding to be 64-bit aligned.
- * @offset: relatived offset value of the memory region allocated.
- * - this value should be set by user.
- */
-struct drm_rockchip_gem_map_off {
- uint32_t handle;
- uint32_t pad;
- uint64_t offset;
-};
-
-#define DRM_ROCKCHIP_GEM_CREATE 0x00
-#define DRM_ROCKCHIP_GEM_MAP_OFFSET 0x01
-
-#define DRM_IOCTL_ROCKCHIP_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create)
-
-#define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \
- DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off)
-
-#endif
diff --git a/chromium/third_party/libdrm/src/rockchip/rockchip_drmif.h b/chromium/third_party/libdrm/src/rockchip/rockchip_drmif.h
deleted file mode 100644
index ec3ff843e39..00000000000
--- a/chromium/third_party/libdrm/src/rockchip/rockchip_drmif.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) ROCKCHIP, Inc.
- * Author:yzq<yzq@rock-chips.com>
- *
- * based on exynos_drmif.h
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef ROCKCHIP_DRMIF_H_
-#define ROCKCHIP_DRMIF_H_
-
-#include <xf86drm.h>
-#include <stdint.h>
-#include "rockchip_drm.h"
-
-struct rockchip_device {
- int fd;
-};
-
-/*
- * Rockchip Buffer Object structure.
- *
- * @dev: rockchip device object allocated.
- * @handle: a gem handle to gem object created.
- * @flags: indicate memory allocation and cache attribute types.
- * @size: size to the buffer created.
- * @vaddr: user space address to a gem buffer mmaped.
- * @name: a gem global handle from flink request.
- */
-struct rockchip_bo {
- struct rockchip_device *dev;
- uint32_t handle;
- uint32_t flags;
- size_t size;
- void *vaddr;
- uint32_t name;
-};
-
-/*
- * device related functions:
- */
-struct rockchip_device *rockchip_device_create(int fd);
-void rockchip_device_destroy(struct rockchip_device *dev);
-
-/*
- * buffer-object related functions:
- */
-struct rockchip_bo *rockchip_bo_create(struct rockchip_device *dev,
- size_t size, uint32_t flags);
-void rockchip_bo_destroy(struct rockchip_bo *bo);
-struct rockchip_bo *rockchip_bo_from_name(struct rockchip_device *dev,
- uint32_t name);
-int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name);
-uint32_t rockchip_bo_handle(struct rockchip_bo *bo);
-struct rockchip_bo *rockchip_bo_from_handle(struct rockchip_device *dev,
- uint32_t handle, uint32_t flags, uint32_t size);
-void *rockchip_bo_map(struct rockchip_bo *bo);
-#endif /* ROCKCHIP_DRMIF_H_ */
diff --git a/chromium/third_party/libdrm/src/util_double_list.h b/chromium/third_party/libdrm/src/util_double_list.h
index 7e48b26cb0c..27e0761b20c 100644
--- a/chromium/third_party/libdrm/src/util_double_list.h
+++ b/chromium/third_party/libdrm/src/util_double_list.h
@@ -98,19 +98,13 @@ static inline void list_delinit(struct list_head *item)
#define LIST_ENTRY(__type, __item, __field) \
((__type *)(((char *)(__item)) - offsetof(__type, __field)))
-#define LIST_FIRST_ENTRY(__ptr, __type, __field) \
- LIST_ENTRY(__type, (__ptr)->next, __field)
-
-#define LIST_LAST_ENTRY(__ptr, __type, __field) \
- LIST_ENTRY(__type, (__ptr)->prev, __field)
-
#define LIST_IS_EMPTY(__list) \
((__list)->next == (__list))
#ifndef container_of
#define container_of(ptr, sample, member) \
(void *)((char *)(ptr) \
- - ((char *)&((typeof(sample))0)->member))
+ - ((char *)&(sample)->member - (char *)(sample)))
#endif
#define LIST_FOR_EACH_ENTRY(pos, head, member) \
diff --git a/chromium/third_party/libdrm/src/vc4/Makefile.am b/chromium/third_party/libdrm/src/vc4/Makefile.am
deleted file mode 100644
index 7e486b4d8ea..00000000000
--- a/chromium/third_party/libdrm/src/vc4/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright © 2016 Broadcom
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- $(VALGRIND_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_vc4includedir = ${includedir}/libdrm
-libdrm_vc4include_HEADERS = $(LIBDRM_VC4_H_FILES)
-
-pkgconfig_DATA = libdrm_vc4.pc
diff --git a/chromium/third_party/libdrm/src/vc4/Makefile.sources b/chromium/third_party/libdrm/src/vc4/Makefile.sources
deleted file mode 100644
index 8bf97ff1e80..00000000000
--- a/chromium/third_party/libdrm/src/vc4/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-LIBDRM_VC4_H_FILES := \
- vc4_packet.h \
- vc4_qpu_defines.h
diff --git a/chromium/third_party/libdrm/src/vc4/libdrm_vc4.pc.in b/chromium/third_party/libdrm/src/vc4/libdrm_vc4.pc.in
deleted file mode 100644
index a92678ed6c4..00000000000
--- a/chromium/third_party/libdrm/src/vc4/libdrm_vc4.pc.in
+++ /dev/null
@@ -1,9 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libdrm_vc4
-Description: Userspace interface to vc4 kernel DRM services
-Version: @PACKAGE_VERSION@
-Requires.private: libdrm
diff --git a/chromium/third_party/libdrm/src/vc4/vc4_packet.h b/chromium/third_party/libdrm/src/vc4/vc4_packet.h
deleted file mode 100644
index e18e0bdf6d8..00000000000
--- a/chromium/third_party/libdrm/src/vc4/vc4_packet.h
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Copyright © 2014 Broadcom
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef VC4_PACKET_H
-#define VC4_PACKET_H
-
-enum vc4_packet {
- VC4_PACKET_HALT = 0,
- VC4_PACKET_NOP = 1,
-
- VC4_PACKET_FLUSH = 4,
- VC4_PACKET_FLUSH_ALL = 5,
- VC4_PACKET_START_TILE_BINNING = 6,
- VC4_PACKET_INCREMENT_SEMAPHORE = 7,
- VC4_PACKET_WAIT_ON_SEMAPHORE = 8,
-
- VC4_PACKET_BRANCH = 16,
- VC4_PACKET_BRANCH_TO_SUB_LIST = 17,
- VC4_PACKET_RETURN_FROM_SUB_LIST = 18,
-
- VC4_PACKET_STORE_MS_TILE_BUFFER = 24,
- VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF = 25,
- VC4_PACKET_STORE_FULL_RES_TILE_BUFFER = 26,
- VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER = 27,
- VC4_PACKET_STORE_TILE_BUFFER_GENERAL = 28,
- VC4_PACKET_LOAD_TILE_BUFFER_GENERAL = 29,
-
- VC4_PACKET_GL_INDEXED_PRIMITIVE = 32,
- VC4_PACKET_GL_ARRAY_PRIMITIVE = 33,
-
- VC4_PACKET_COMPRESSED_PRIMITIVE = 48,
- VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE = 49,
-
- VC4_PACKET_PRIMITIVE_LIST_FORMAT = 56,
-
- VC4_PACKET_GL_SHADER_STATE = 64,
- VC4_PACKET_NV_SHADER_STATE = 65,
- VC4_PACKET_VG_SHADER_STATE = 66,
-
- VC4_PACKET_CONFIGURATION_BITS = 96,
- VC4_PACKET_FLAT_SHADE_FLAGS = 97,
- VC4_PACKET_POINT_SIZE = 98,
- VC4_PACKET_LINE_WIDTH = 99,
- VC4_PACKET_RHT_X_BOUNDARY = 100,
- VC4_PACKET_DEPTH_OFFSET = 101,
- VC4_PACKET_CLIP_WINDOW = 102,
- VC4_PACKET_VIEWPORT_OFFSET = 103,
- VC4_PACKET_Z_CLIPPING = 104,
- VC4_PACKET_CLIPPER_XY_SCALING = 105,
- VC4_PACKET_CLIPPER_Z_SCALING = 106,
-
- VC4_PACKET_TILE_BINNING_MODE_CONFIG = 112,
- VC4_PACKET_TILE_RENDERING_MODE_CONFIG = 113,
- VC4_PACKET_CLEAR_COLORS = 114,
- VC4_PACKET_TILE_COORDINATES = 115,
-
- /* Not an actual hardware packet -- this is what we use to put
- * references to GEM bos in the command stream, since we need the u32
- * int the actual address packet in order to store the offset from the
- * start of the BO.
- */
- VC4_PACKET_GEM_HANDLES = 254,
-} __attribute__ ((__packed__));
-
-#define VC4_PACKET_HALT_SIZE 1
-#define VC4_PACKET_NOP_SIZE 1
-#define VC4_PACKET_FLUSH_SIZE 1
-#define VC4_PACKET_FLUSH_ALL_SIZE 1
-#define VC4_PACKET_START_TILE_BINNING_SIZE 1
-#define VC4_PACKET_INCREMENT_SEMAPHORE_SIZE 1
-#define VC4_PACKET_WAIT_ON_SEMAPHORE_SIZE 1
-#define VC4_PACKET_BRANCH_SIZE 5
-#define VC4_PACKET_BRANCH_TO_SUB_LIST_SIZE 5
-#define VC4_PACKET_RETURN_FROM_SUB_LIST_SIZE 1
-#define VC4_PACKET_STORE_MS_TILE_BUFFER_SIZE 1
-#define VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF_SIZE 1
-#define VC4_PACKET_STORE_FULL_RES_TILE_BUFFER_SIZE 5
-#define VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER_SIZE 5
-#define VC4_PACKET_STORE_TILE_BUFFER_GENERAL_SIZE 7
-#define VC4_PACKET_LOAD_TILE_BUFFER_GENERAL_SIZE 7
-#define VC4_PACKET_GL_INDEXED_PRIMITIVE_SIZE 14
-#define VC4_PACKET_GL_ARRAY_PRIMITIVE_SIZE 10
-#define VC4_PACKET_COMPRESSED_PRIMITIVE_SIZE 1
-#define VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE_SIZE 1
-#define VC4_PACKET_PRIMITIVE_LIST_FORMAT_SIZE 2
-#define VC4_PACKET_GL_SHADER_STATE_SIZE 5
-#define VC4_PACKET_NV_SHADER_STATE_SIZE 5
-#define VC4_PACKET_VG_SHADER_STATE_SIZE 5
-#define VC4_PACKET_CONFIGURATION_BITS_SIZE 4
-#define VC4_PACKET_FLAT_SHADE_FLAGS_SIZE 5
-#define VC4_PACKET_POINT_SIZE_SIZE 5
-#define VC4_PACKET_LINE_WIDTH_SIZE 5
-#define VC4_PACKET_RHT_X_BOUNDARY_SIZE 3
-#define VC4_PACKET_DEPTH_OFFSET_SIZE 5
-#define VC4_PACKET_CLIP_WINDOW_SIZE 9
-#define VC4_PACKET_VIEWPORT_OFFSET_SIZE 5
-#define VC4_PACKET_Z_CLIPPING_SIZE 9
-#define VC4_PACKET_CLIPPER_XY_SCALING_SIZE 9
-#define VC4_PACKET_CLIPPER_Z_SCALING_SIZE 9
-#define VC4_PACKET_TILE_BINNING_MODE_CONFIG_SIZE 16
-#define VC4_PACKET_TILE_RENDERING_MODE_CONFIG_SIZE 11
-#define VC4_PACKET_CLEAR_COLORS_SIZE 14
-#define VC4_PACKET_TILE_COORDINATES_SIZE 3
-#define VC4_PACKET_GEM_HANDLES_SIZE 9
-
-#define VC4_MASK(high, low) (((1 << ((high) - (low) + 1)) - 1) << (low))
-/* Using the GNU statement expression extension */
-#define VC4_SET_FIELD(value, field) \
- ({ \
- uint32_t fieldval = (value) << field ## _SHIFT; \
- assert((fieldval & ~ field ## _MASK) == 0); \
- fieldval & field ## _MASK; \
- })
-
-#define VC4_GET_FIELD(word, field) (((word) & field ## _MASK) >> field ## _SHIFT)
-
-/** @{
- * Bits used by packets like VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
- * VC4_PACKET_TILE_RENDERING_MODE_CONFIG.
-*/
-#define VC4_TILING_FORMAT_LINEAR 0
-#define VC4_TILING_FORMAT_T 1
-#define VC4_TILING_FORMAT_LT 2
-/** @} */
-
-/** @{
- *
- * low bits of VC4_PACKET_STORE_FULL_RES_TILE_BUFFER and
- * VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER.
- */
-#define VC4_LOADSTORE_FULL_RES_EOF (1 << 3)
-#define VC4_LOADSTORE_FULL_RES_DISABLE_CLEAR_ALL (1 << 2)
-#define VC4_LOADSTORE_FULL_RES_DISABLE_ZS (1 << 1)
-#define VC4_LOADSTORE_FULL_RES_DISABLE_COLOR (1 << 0)
-
-/** @{
- *
- * byte 2 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
- * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL (low bits of the address)
- */
-
-#define VC4_LOADSTORE_TILE_BUFFER_EOF (1 << 3)
-#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_VG_MASK (1 << 2)
-#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_ZS (1 << 1)
-#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_COLOR (1 << 0)
-
-/** @} */
-
-/** @{
- *
- * byte 0-1 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
- * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
- */
-#define VC4_STORE_TILE_BUFFER_DISABLE_VG_MASK_CLEAR (1 << 15)
-#define VC4_STORE_TILE_BUFFER_DISABLE_ZS_CLEAR (1 << 14)
-#define VC4_STORE_TILE_BUFFER_DISABLE_COLOR_CLEAR (1 << 13)
-#define VC4_STORE_TILE_BUFFER_DISABLE_SWAP (1 << 12)
-
-#define VC4_LOADSTORE_TILE_BUFFER_FORMAT_MASK VC4_MASK(9, 8)
-#define VC4_LOADSTORE_TILE_BUFFER_FORMAT_SHIFT 8
-#define VC4_LOADSTORE_TILE_BUFFER_RGBA8888 0
-#define VC4_LOADSTORE_TILE_BUFFER_BGR565_DITHER 1
-#define VC4_LOADSTORE_TILE_BUFFER_BGR565 2
-/** @} */
-
-/** @{
- *
- * byte 0 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
- * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
- */
-#define VC4_STORE_TILE_BUFFER_MODE_MASK VC4_MASK(7, 6)
-#define VC4_STORE_TILE_BUFFER_MODE_SHIFT 6
-#define VC4_STORE_TILE_BUFFER_MODE_SAMPLE0 (0 << 6)
-#define VC4_STORE_TILE_BUFFER_MODE_DECIMATE_X4 (1 << 6)
-#define VC4_STORE_TILE_BUFFER_MODE_DECIMATE_X16 (2 << 6)
-
-/** The values of the field are VC4_TILING_FORMAT_* */
-#define VC4_LOADSTORE_TILE_BUFFER_TILING_MASK VC4_MASK(5, 4)
-#define VC4_LOADSTORE_TILE_BUFFER_TILING_SHIFT 4
-
-#define VC4_LOADSTORE_TILE_BUFFER_BUFFER_MASK VC4_MASK(2, 0)
-#define VC4_LOADSTORE_TILE_BUFFER_BUFFER_SHIFT 0
-#define VC4_LOADSTORE_TILE_BUFFER_NONE 0
-#define VC4_LOADSTORE_TILE_BUFFER_COLOR 1
-#define VC4_LOADSTORE_TILE_BUFFER_ZS 2
-#define VC4_LOADSTORE_TILE_BUFFER_Z 3
-#define VC4_LOADSTORE_TILE_BUFFER_VG_MASK 4
-#define VC4_LOADSTORE_TILE_BUFFER_FULL 5
-/** @} */
-
-#define VC4_INDEX_BUFFER_U8 (0 << 4)
-#define VC4_INDEX_BUFFER_U16 (1 << 4)
-
-/* This flag is only present in NV shader state. */
-#define VC4_SHADER_FLAG_SHADED_CLIP_COORDS (1 << 3)
-#define VC4_SHADER_FLAG_ENABLE_CLIPPING (1 << 2)
-#define VC4_SHADER_FLAG_VS_POINT_SIZE (1 << 1)
-#define VC4_SHADER_FLAG_FS_SINGLE_THREAD (1 << 0)
-
-/** @{ byte 2 of config bits. */
-#define VC4_CONFIG_BITS_EARLY_Z_UPDATE (1 << 1)
-#define VC4_CONFIG_BITS_EARLY_Z (1 << 0)
-/** @} */
-
-/** @{ byte 1 of config bits. */
-#define VC4_CONFIG_BITS_Z_UPDATE (1 << 7)
-/** same values in this 3-bit field as PIPE_FUNC_* */
-#define VC4_CONFIG_BITS_DEPTH_FUNC_SHIFT 4
-#define VC4_CONFIG_BITS_COVERAGE_READ_LEAVE (1 << 3)
-
-#define VC4_CONFIG_BITS_COVERAGE_UPDATE_NONZERO (0 << 1)
-#define VC4_CONFIG_BITS_COVERAGE_UPDATE_ODD (1 << 1)
-#define VC4_CONFIG_BITS_COVERAGE_UPDATE_OR (2 << 1)
-#define VC4_CONFIG_BITS_COVERAGE_UPDATE_ZERO (3 << 1)
-
-#define VC4_CONFIG_BITS_COVERAGE_PIPE_SELECT (1 << 0)
-/** @} */
-
-/** @{ byte 0 of config bits. */
-#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_NONE (0 << 6)
-#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_4X (1 << 6)
-#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_16X (2 << 6)
-#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_MASK (3 << 6)
-
-#define VC4_CONFIG_BITS_AA_POINTS_AND_LINES (1 << 4)
-#define VC4_CONFIG_BITS_ENABLE_DEPTH_OFFSET (1 << 3)
-#define VC4_CONFIG_BITS_CW_PRIMITIVES (1 << 2)
-#define VC4_CONFIG_BITS_ENABLE_PRIM_BACK (1 << 1)
-#define VC4_CONFIG_BITS_ENABLE_PRIM_FRONT (1 << 0)
-/** @} */
-
-/** @{ bits in the last u8 of VC4_PACKET_TILE_BINNING_MODE_CONFIG */
-#define VC4_BIN_CONFIG_DB_NON_MS (1 << 7)
-
-#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_MASK VC4_MASK(6, 5)
-#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_SHIFT 5
-#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_32 0
-#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_64 1
-#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_128 2
-#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_256 3
-
-#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_MASK VC4_MASK(4, 3)
-#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_SHIFT 3
-#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_32 0
-#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_64 1
-#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_128 2
-#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_256 3
-
-#define VC4_BIN_CONFIG_AUTO_INIT_TSDA (1 << 2)
-#define VC4_BIN_CONFIG_TILE_BUFFER_64BIT (1 << 1)
-#define VC4_BIN_CONFIG_MS_MODE_4X (1 << 0)
-/** @} */
-
-/** @{ bits in the last u16 of VC4_PACKET_TILE_RENDERING_MODE_CONFIG */
-#define VC4_RENDER_CONFIG_DB_NON_MS (1 << 12)
-#define VC4_RENDER_CONFIG_EARLY_Z_COVERAGE_DISABLE (1 << 11)
-#define VC4_RENDER_CONFIG_EARLY_Z_DIRECTION_G (1 << 10)
-#define VC4_RENDER_CONFIG_COVERAGE_MODE (1 << 9)
-#define VC4_RENDER_CONFIG_ENABLE_VG_MASK (1 << 8)
-
-/** The values of the field are VC4_TILING_FORMAT_* */
-#define VC4_RENDER_CONFIG_MEMORY_FORMAT_MASK VC4_MASK(7, 6)
-#define VC4_RENDER_CONFIG_MEMORY_FORMAT_SHIFT 6
-
-#define VC4_RENDER_CONFIG_DECIMATE_MODE_1X (0 << 4)
-#define VC4_RENDER_CONFIG_DECIMATE_MODE_4X (1 << 4)
-#define VC4_RENDER_CONFIG_DECIMATE_MODE_16X (2 << 4)
-#define VC4_RENDER_CONFIG_DECIMATE_MODE_MASK (3 << 4)
-
-#define VC4_RENDER_CONFIG_FORMAT_MASK VC4_MASK(3, 2)
-#define VC4_RENDER_CONFIG_FORMAT_SHIFT 2
-#define VC4_RENDER_CONFIG_FORMAT_BGR565_DITHERED 0
-#define VC4_RENDER_CONFIG_FORMAT_RGBA8888 1
-#define VC4_RENDER_CONFIG_FORMAT_BGR565 2
-
-#define VC4_RENDER_CONFIG_TILE_BUFFER_64BIT (1 << 1)
-#define VC4_RENDER_CONFIG_MS_MODE_4X (1 << 0)
-
-#define VC4_PRIMITIVE_LIST_FORMAT_16_INDEX (1 << 4)
-#define VC4_PRIMITIVE_LIST_FORMAT_32_XY (3 << 4)
-#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_POINTS (0 << 0)
-#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_LINES (1 << 0)
-#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_TRIANGLES (2 << 0)
-#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_RHT (3 << 0)
-
-enum vc4_texture_data_type {
- VC4_TEXTURE_TYPE_RGBA8888 = 0,
- VC4_TEXTURE_TYPE_RGBX8888 = 1,
- VC4_TEXTURE_TYPE_RGBA4444 = 2,
- VC4_TEXTURE_TYPE_RGBA5551 = 3,
- VC4_TEXTURE_TYPE_RGB565 = 4,
- VC4_TEXTURE_TYPE_LUMINANCE = 5,
- VC4_TEXTURE_TYPE_ALPHA = 6,
- VC4_TEXTURE_TYPE_LUMALPHA = 7,
- VC4_TEXTURE_TYPE_ETC1 = 8,
- VC4_TEXTURE_TYPE_S16F = 9,
- VC4_TEXTURE_TYPE_S8 = 10,
- VC4_TEXTURE_TYPE_S16 = 11,
- VC4_TEXTURE_TYPE_BW1 = 12,
- VC4_TEXTURE_TYPE_A4 = 13,
- VC4_TEXTURE_TYPE_A1 = 14,
- VC4_TEXTURE_TYPE_RGBA64 = 15,
- VC4_TEXTURE_TYPE_RGBA32R = 16,
- VC4_TEXTURE_TYPE_YUV422R = 17,
-};
-
-#define VC4_TEX_P0_OFFSET_MASK VC4_MASK(31, 12)
-#define VC4_TEX_P0_OFFSET_SHIFT 12
-#define VC4_TEX_P0_CSWIZ_MASK VC4_MASK(11, 10)
-#define VC4_TEX_P0_CSWIZ_SHIFT 10
-#define VC4_TEX_P0_CMMODE_MASK VC4_MASK(9, 9)
-#define VC4_TEX_P0_CMMODE_SHIFT 9
-#define VC4_TEX_P0_FLIPY_MASK VC4_MASK(8, 8)
-#define VC4_TEX_P0_FLIPY_SHIFT 8
-#define VC4_TEX_P0_TYPE_MASK VC4_MASK(7, 4)
-#define VC4_TEX_P0_TYPE_SHIFT 4
-#define VC4_TEX_P0_MIPLVLS_MASK VC4_MASK(3, 0)
-#define VC4_TEX_P0_MIPLVLS_SHIFT 0
-
-#define VC4_TEX_P1_TYPE4_MASK VC4_MASK(31, 31)
-#define VC4_TEX_P1_TYPE4_SHIFT 31
-#define VC4_TEX_P1_HEIGHT_MASK VC4_MASK(30, 20)
-#define VC4_TEX_P1_HEIGHT_SHIFT 20
-#define VC4_TEX_P1_ETCFLIP_MASK VC4_MASK(19, 19)
-#define VC4_TEX_P1_ETCFLIP_SHIFT 19
-#define VC4_TEX_P1_WIDTH_MASK VC4_MASK(18, 8)
-#define VC4_TEX_P1_WIDTH_SHIFT 8
-
-#define VC4_TEX_P1_MAGFILT_MASK VC4_MASK(7, 7)
-#define VC4_TEX_P1_MAGFILT_SHIFT 7
-# define VC4_TEX_P1_MAGFILT_LINEAR 0
-# define VC4_TEX_P1_MAGFILT_NEAREST 1
-
-#define VC4_TEX_P1_MINFILT_MASK VC4_MASK(6, 4)
-#define VC4_TEX_P1_MINFILT_SHIFT 4
-# define VC4_TEX_P1_MINFILT_LINEAR 0
-# define VC4_TEX_P1_MINFILT_NEAREST 1
-# define VC4_TEX_P1_MINFILT_NEAR_MIP_NEAR 2
-# define VC4_TEX_P1_MINFILT_NEAR_MIP_LIN 3
-# define VC4_TEX_P1_MINFILT_LIN_MIP_NEAR 4
-# define VC4_TEX_P1_MINFILT_LIN_MIP_LIN 5
-
-#define VC4_TEX_P1_WRAP_T_MASK VC4_MASK(3, 2)
-#define VC4_TEX_P1_WRAP_T_SHIFT 2
-#define VC4_TEX_P1_WRAP_S_MASK VC4_MASK(1, 0)
-#define VC4_TEX_P1_WRAP_S_SHIFT 0
-# define VC4_TEX_P1_WRAP_REPEAT 0
-# define VC4_TEX_P1_WRAP_CLAMP 1
-# define VC4_TEX_P1_WRAP_MIRROR 2
-# define VC4_TEX_P1_WRAP_BORDER 3
-
-#define VC4_TEX_P2_PTYPE_MASK VC4_MASK(31, 30)
-#define VC4_TEX_P2_PTYPE_SHIFT 30
-# define VC4_TEX_P2_PTYPE_IGNORED 0
-# define VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE 1
-# define VC4_TEX_P2_PTYPE_CHILD_IMAGE_DIMENSIONS 2
-# define VC4_TEX_P2_PTYPE_CHILD_IMAGE_OFFSETS 3
-
-/* VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE bits */
-#define VC4_TEX_P2_CMST_MASK VC4_MASK(29, 12)
-#define VC4_TEX_P2_CMST_SHIFT 12
-#define VC4_TEX_P2_BSLOD_MASK VC4_MASK(0, 0)
-#define VC4_TEX_P2_BSLOD_SHIFT 0
-
-/* VC4_TEX_P2_PTYPE_CHILD_IMAGE_DIMENSIONS */
-#define VC4_TEX_P2_CHEIGHT_MASK VC4_MASK(22, 12)
-#define VC4_TEX_P2_CHEIGHT_SHIFT 12
-#define VC4_TEX_P2_CWIDTH_MASK VC4_MASK(10, 0)
-#define VC4_TEX_P2_CWIDTH_SHIFT 0
-
-/* VC4_TEX_P2_PTYPE_CHILD_IMAGE_OFFSETS */
-#define VC4_TEX_P2_CYOFF_MASK VC4_MASK(22, 12)
-#define VC4_TEX_P2_CYOFF_SHIFT 12
-#define VC4_TEX_P2_CXOFF_MASK VC4_MASK(10, 0)
-#define VC4_TEX_P2_CXOFF_SHIFT 0
-
-#endif /* VC4_PACKET_H */
diff --git a/chromium/third_party/libdrm/src/vc4/vc4_qpu_defines.h b/chromium/third_party/libdrm/src/vc4/vc4_qpu_defines.h
deleted file mode 100644
index 26fcf505fe4..00000000000
--- a/chromium/third_party/libdrm/src/vc4/vc4_qpu_defines.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright © 2014 Broadcom
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef VC4_QPU_DEFINES_H
-#define VC4_QPU_DEFINES_H
-
-enum qpu_op_add {
- QPU_A_NOP,
- QPU_A_FADD,
- QPU_A_FSUB,
- QPU_A_FMIN,
- QPU_A_FMAX,
- QPU_A_FMINABS,
- QPU_A_FMAXABS,
- QPU_A_FTOI,
- QPU_A_ITOF,
- QPU_A_ADD = 12,
- QPU_A_SUB,
- QPU_A_SHR,
- QPU_A_ASR,
- QPU_A_ROR,
- QPU_A_SHL,
- QPU_A_MIN,
- QPU_A_MAX,
- QPU_A_AND,
- QPU_A_OR,
- QPU_A_XOR,
- QPU_A_NOT,
- QPU_A_CLZ,
- QPU_A_V8ADDS = 30,
- QPU_A_V8SUBS = 31,
-};
-
-enum qpu_op_mul {
- QPU_M_NOP,
- QPU_M_FMUL,
- QPU_M_MUL24,
- QPU_M_V8MULD,
- QPU_M_V8MIN,
- QPU_M_V8MAX,
- QPU_M_V8ADDS,
- QPU_M_V8SUBS,
-};
-
-enum qpu_raddr {
- QPU_R_FRAG_PAYLOAD_ZW = 15, /* W for A file, Z for B file */
- /* 0-31 are the plain regfile a or b fields */
- QPU_R_UNIF = 32,
- QPU_R_VARY = 35,
- QPU_R_ELEM_QPU = 38,
- QPU_R_NOP,
- QPU_R_XY_PIXEL_COORD = 41,
- QPU_R_MS_REV_FLAGS = 42,
- QPU_R_VPM = 48,
- QPU_R_VPM_LD_BUSY,
- QPU_R_VPM_LD_WAIT,
- QPU_R_MUTEX_ACQUIRE,
-};
-
-enum qpu_waddr {
- /* 0-31 are the plain regfile a or b fields */
- QPU_W_ACC0 = 32, /* aka r0 */
- QPU_W_ACC1,
- QPU_W_ACC2,
- QPU_W_ACC3,
- QPU_W_TMU_NOSWAP,
- QPU_W_ACC5,
- QPU_W_HOST_INT,
- QPU_W_NOP,
- QPU_W_UNIFORMS_ADDRESS,
- QPU_W_QUAD_XY, /* X for regfile a, Y for regfile b */
- QPU_W_MS_FLAGS = 42,
- QPU_W_REV_FLAG = 42,
- QPU_W_TLB_STENCIL_SETUP = 43,
- QPU_W_TLB_Z,
- QPU_W_TLB_COLOR_MS,
- QPU_W_TLB_COLOR_ALL,
- QPU_W_TLB_ALPHA_MASK,
- QPU_W_VPM,
- QPU_W_VPMVCD_SETUP, /* LD for regfile a, ST for regfile b */
- QPU_W_VPM_ADDR, /* LD for regfile a, ST for regfile b */
- QPU_W_MUTEX_RELEASE,
- QPU_W_SFU_RECIP,
- QPU_W_SFU_RECIPSQRT,
- QPU_W_SFU_EXP,
- QPU_W_SFU_LOG,
- QPU_W_TMU0_S,
- QPU_W_TMU0_T,
- QPU_W_TMU0_R,
- QPU_W_TMU0_B,
- QPU_W_TMU1_S,
- QPU_W_TMU1_T,
- QPU_W_TMU1_R,
- QPU_W_TMU1_B,
-};
-
-enum qpu_sig_bits {
- QPU_SIG_SW_BREAKPOINT,
- QPU_SIG_NONE,
- QPU_SIG_THREAD_SWITCH,
- QPU_SIG_PROG_END,
- QPU_SIG_WAIT_FOR_SCOREBOARD,
- QPU_SIG_SCOREBOARD_UNLOCK,
- QPU_SIG_LAST_THREAD_SWITCH,
- QPU_SIG_COVERAGE_LOAD,
- QPU_SIG_COLOR_LOAD,
- QPU_SIG_COLOR_LOAD_END,
- QPU_SIG_LOAD_TMU0,
- QPU_SIG_LOAD_TMU1,
- QPU_SIG_ALPHA_MASK_LOAD,
- QPU_SIG_SMALL_IMM,
- QPU_SIG_LOAD_IMM,
- QPU_SIG_BRANCH
-};
-
-enum qpu_mux {
- /* hardware mux values */
- QPU_MUX_R0,
- QPU_MUX_R1,
- QPU_MUX_R2,
- QPU_MUX_R3,
- QPU_MUX_R4,
- QPU_MUX_R5,
- QPU_MUX_A,
- QPU_MUX_B,
-
- /**
- * Non-hardware mux value, stores a small immediate field to be
- * programmed into raddr_b in the qpu_reg.index.
- */
- QPU_MUX_SMALL_IMM,
-};
-
-enum qpu_cond {
- QPU_COND_NEVER,
- QPU_COND_ALWAYS,
- QPU_COND_ZS,
- QPU_COND_ZC,
- QPU_COND_NS,
- QPU_COND_NC,
- QPU_COND_CS,
- QPU_COND_CC,
-};
-
-enum qpu_pack_mul {
- QPU_PACK_MUL_NOP,
- QPU_PACK_MUL_8888 = 3, /* replicated to each 8 bits of the 32-bit dst. */
- QPU_PACK_MUL_8A,
- QPU_PACK_MUL_8B,
- QPU_PACK_MUL_8C,
- QPU_PACK_MUL_8D,
-};
-
-enum qpu_pack_a {
- QPU_PACK_A_NOP,
- /* convert to 16 bit float if float input, or to int16. */
- QPU_PACK_A_16A,
- QPU_PACK_A_16B,
- /* replicated to each 8 bits of the 32-bit dst. */
- QPU_PACK_A_8888,
- /* Convert to 8-bit unsigned int. */
- QPU_PACK_A_8A,
- QPU_PACK_A_8B,
- QPU_PACK_A_8C,
- QPU_PACK_A_8D,
-
- /* Saturating variants of the previous instructions. */
- QPU_PACK_A_32_SAT, /* int-only */
- QPU_PACK_A_16A_SAT, /* int or float */
- QPU_PACK_A_16B_SAT,
- QPU_PACK_A_8888_SAT,
- QPU_PACK_A_8A_SAT,
- QPU_PACK_A_8B_SAT,
- QPU_PACK_A_8C_SAT,
- QPU_PACK_A_8D_SAT,
-};
-
-enum qpu_unpack {
- QPU_UNPACK_NOP,
- QPU_UNPACK_16A,
- QPU_UNPACK_16B,
- QPU_UNPACK_8D_REP,
- QPU_UNPACK_8A,
- QPU_UNPACK_8B,
- QPU_UNPACK_8C,
- QPU_UNPACK_8D,
-};
-
-#define QPU_MASK(high, low) ((((uint64_t)1<<((high)-(low)+1))-1)<<(low))
-/* Using the GNU statement expression extension */
-#define QPU_SET_FIELD(value, field) \
- ({ \
- uint64_t fieldval = (uint64_t)(value) << field ## _SHIFT; \
- assert((fieldval & ~ field ## _MASK) == 0); \
- fieldval & field ## _MASK; \
- })
-
-#define QPU_GET_FIELD(word, field) ((uint32_t)(((word) & field ## _MASK) >> field ## _SHIFT))
-
-#define QPU_UPDATE_FIELD(inst, value, field) \
- (((inst) & ~(field ## _MASK)) | QPU_SET_FIELD(value, field))
-
-#define QPU_SIG_SHIFT 60
-#define QPU_SIG_MASK QPU_MASK(63, 60)
-
-#define QPU_UNPACK_SHIFT 57
-#define QPU_UNPACK_MASK QPU_MASK(59, 57)
-
-/**
- * If set, the pack field means PACK_MUL or R4 packing, instead of normal
- * regfile a packing.
- */
-#define QPU_PM ((uint64_t)1 << 56)
-
-#define QPU_PACK_SHIFT 52
-#define QPU_PACK_MASK QPU_MASK(55, 52)
-
-#define QPU_COND_ADD_SHIFT 49
-#define QPU_COND_ADD_MASK QPU_MASK(51, 49)
-#define QPU_COND_MUL_SHIFT 46
-#define QPU_COND_MUL_MASK QPU_MASK(48, 46)
-
-#define QPU_SF ((uint64_t)1 << 45)
-
-#define QPU_WADDR_ADD_SHIFT 38
-#define QPU_WADDR_ADD_MASK QPU_MASK(43, 38)
-#define QPU_WADDR_MUL_SHIFT 32
-#define QPU_WADDR_MUL_MASK QPU_MASK(37, 32)
-
-#define QPU_OP_MUL_SHIFT 29
-#define QPU_OP_MUL_MASK QPU_MASK(31, 29)
-
-#define QPU_RADDR_A_SHIFT 18
-#define QPU_RADDR_A_MASK QPU_MASK(23, 18)
-#define QPU_RADDR_B_SHIFT 12
-#define QPU_RADDR_B_MASK QPU_MASK(17, 12)
-#define QPU_SMALL_IMM_SHIFT 12
-#define QPU_SMALL_IMM_MASK QPU_MASK(17, 12)
-
-#define QPU_ADD_A_SHIFT 9
-#define QPU_ADD_A_MASK QPU_MASK(11, 9)
-#define QPU_ADD_B_SHIFT 6
-#define QPU_ADD_B_MASK QPU_MASK(8, 6)
-#define QPU_MUL_A_SHIFT 3
-#define QPU_MUL_A_MASK QPU_MASK(5, 3)
-#define QPU_MUL_B_SHIFT 0
-#define QPU_MUL_B_MASK QPU_MASK(2, 0)
-
-#define QPU_WS ((uint64_t)1 << 44)
-
-#define QPU_OP_ADD_SHIFT 24
-#define QPU_OP_ADD_MASK QPU_MASK(28, 24)
-
-#endif /* VC4_QPU_DEFINES_H */
diff --git a/chromium/third_party/libdrm/src/xf86drm.c b/chromium/third_party/libdrm/src/xf86drm.c
index 9b52889e4ce..7e28b4f7b1c 100644
--- a/chromium/third_party/libdrm/src/xf86drm.c
+++ b/chromium/third_party/libdrm/src/xf86drm.c
@@ -1,5 +1,5 @@
/**
- * \file xf86drm.c
+ * \file xf86drm.c
* User-level interface to DRM device
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
@@ -54,11 +54,8 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include <stdarg.h>
-#ifdef MAJOR_IN_MKDEV
-#include <sys/mkdev.h>
-#endif
-#ifdef MAJOR_IN_SYSMACROS
-#include <sys/sysmacros.h>
+#ifdef HAVE_SYS_MKDEV_H
+# include <sys/mkdev.h> /* defines major(), minor(), and makedev() on Solaris */
#endif
#include <math.h>
@@ -73,13 +70,13 @@
#include "util_math.h"
#ifdef __OpenBSD__
-#define DRM_PRIMARY_MINOR_NAME "drm"
-#define DRM_CONTROL_MINOR_NAME "drmC"
-#define DRM_RENDER_MINOR_NAME "drmR"
+#define DRM_PRIMARY_MINOR_NAME "drm"
+#define DRM_CONTROL_MINOR_NAME "drmC"
+#define DRM_RENDER_MINOR_NAME "drmR"
#else
-#define DRM_PRIMARY_MINOR_NAME "card"
-#define DRM_CONTROL_MINOR_NAME "controlD"
-#define DRM_RENDER_MINOR_NAME "renderD"
+#define DRM_PRIMARY_MINOR_NAME "card"
+#define DRM_CONTROL_MINOR_NAME "controlD"
+#define DRM_RENDER_MINOR_NAME "renderD"
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
@@ -99,7 +96,7 @@
#endif /* __OpenBSD__ */
#ifndef DRM_MAJOR
-#define DRM_MAJOR 226 /* Linux */
+#define DRM_MAJOR 226 /* Linux */
#endif
#define DRM_MSG_VERBOSITY 3
@@ -131,18 +128,18 @@ drmDebugPrint(const char *format, va_list ap)
void
drmMsg(const char *format, ...)
{
- va_list ap;
+ va_list ap;
const char *env;
if (((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) ||
(drm_server_info && drm_server_info->debug_print))
{
- va_start(ap, format);
- if (drm_server_info) {
- drm_server_info->debug_print(format,ap);
- } else {
- drmDebugPrint(format, ap);
- }
- va_end(ap);
+ va_start(ap, format);
+ if (drm_server_info) {
+ drm_server_info->debug_print(format,ap);
+ } else {
+ drmDebugPrint(format, ap);
+ }
+ va_end(ap);
}
}
@@ -169,10 +166,10 @@ void drmFree(void *pt)
int
drmIoctl(int fd, unsigned long request, void *arg)
{
- int ret;
+ int ret;
do {
- ret = ioctl(fd, request, arg);
+ ret = ioctl(fd, request, arg);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
return ret;
}
@@ -193,16 +190,16 @@ drmHashEntry *drmGetEntry(int fd)
drmHashEntry *entry;
if (!drmHashTable)
- drmHashTable = drmHashCreate();
+ drmHashTable = drmHashCreate();
if (drmHashLookup(drmHashTable, key, &value)) {
- entry = drmMalloc(sizeof(*entry));
- entry->fd = fd;
- entry->f = NULL;
- entry->tagTable = drmHashCreate();
- drmHashInsert(drmHashTable, key, entry);
+ entry = drmMalloc(sizeof(*entry));
+ entry->fd = fd;
+ entry->f = NULL;
+ entry->tagTable = drmHashCreate();
+ drmHashInsert(drmHashTable, key, entry);
} else {
- entry = value;
+ entry = value;
}
return entry;
}
@@ -224,41 +221,41 @@ static int drmMatchBusID(const char *id1, const char *id2, int pci_domain_ok)
{
/* First, check if the IDs are exactly the same */
if (strcasecmp(id1, id2) == 0)
- return 1;
+ return 1;
/* Try to match old/new-style PCI bus IDs. */
if (strncasecmp(id1, "pci", 3) == 0) {
- unsigned int o1, b1, d1, f1;
- unsigned int o2, b2, d2, f2;
- int ret;
-
- ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1);
- if (ret != 4) {
- o1 = 0;
- ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1);
- if (ret != 3)
- return 0;
- }
-
- ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2);
- if (ret != 4) {
- o2 = 0;
- ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2);
- if (ret != 3)
- return 0;
- }
-
- /* If domains aren't properly supported by the kernel interface,
- * just ignore them, which sucks less than picking a totally random
- * card with "open by name"
- */
- if (!pci_domain_ok)
- o1 = o2 = 0;
-
- if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2))
- return 0;
- else
- return 1;
+ unsigned int o1, b1, d1, f1;
+ unsigned int o2, b2, d2, f2;
+ int ret;
+
+ ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1);
+ if (ret != 4) {
+ o1 = 0;
+ ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1);
+ if (ret != 3)
+ return 0;
+ }
+
+ ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2);
+ if (ret != 4) {
+ o2 = 0;
+ ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2);
+ if (ret != 3)
+ return 0;
+ }
+
+ /* If domains aren't properly supported by the kernel interface,
+ * just ignore them, which sucks less than picking a totally random
+ * card with "open by name"
+ */
+ if (!pci_domain_ok)
+ o1 = o2 = 0;
+
+ if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2))
+ return 0;
+ else
+ return 1;
}
return 0;
}
@@ -280,18 +277,18 @@ static int drmMatchBusID(const char *id1, const char *id2, int pci_domain_ok)
#if !defined(UDEV)
static int chown_check_return(const char *path, uid_t owner, gid_t group)
{
- int rv;
+ int rv;
- do {
- rv = chown(path, owner, group);
- } while (rv != 0 && errno == EINTR);
+ do {
+ rv = chown(path, owner, group);
+ } while (rv != 0 && errno == EINTR);
- if (rv == 0)
- return 0;
+ if (rv == 0)
+ return 0;
- drmMsg("Failed to change owner or group for file %s! %d: %s\n",
- path, errno, strerror(errno));
- return -1;
+ drmMsg("Failed to change owner or group for file %s! %d: %s\n",
+ path, errno, strerror(errno));
+ return -1;
}
#endif
@@ -300,7 +297,7 @@ static int chown_check_return(const char *path, uid_t owner, gid_t group)
*
* \param dev major and minor numbers of the device.
* \param minor minor number of the device.
- *
+ *
* \return a file descriptor on success, or a negative value on error.
*
* \internal
@@ -324,99 +321,99 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
switch (type) {
case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
+ dev_name = DRM_DEV_NAME;
+ break;
case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
+ dev_name = DRM_CONTROL_DEV_NAME;
+ break;
case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
+ dev_name = DRM_RENDER_DEV_NAME;
+ break;
default:
- return -EINVAL;
+ return -EINVAL;
};
sprintf(buf, dev_name, DRM_DIR_NAME, minor);
drmMsg("drmOpenDevice: node name is %s\n", buf);
if (drm_server_info && drm_server_info->get_perms) {
- drm_server_info->get_perms(&serv_group, &serv_mode);
- devmode = serv_mode ? serv_mode : DRM_DEV_MODE;
- devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
+ drm_server_info->get_perms(&serv_group, &serv_mode);
+ devmode = serv_mode ? serv_mode : DRM_DEV_MODE;
+ devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
}
#if !defined(UDEV)
if (stat(DRM_DIR_NAME, &st)) {
- if (!isroot)
- return DRM_ERR_NOT_ROOT;
- mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE);
- chown_check_return(DRM_DIR_NAME, 0, 0); /* root:root */
- chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE);
+ if (!isroot)
+ return DRM_ERR_NOT_ROOT;
+ mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE);
+ chown_check_return(DRM_DIR_NAME, 0, 0); /* root:root */
+ chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE);
}
/* Check if the device node exists and create it if necessary. */
if (stat(buf, &st)) {
- if (!isroot)
- return DRM_ERR_NOT_ROOT;
- remove(buf);
- mknod(buf, S_IFCHR | devmode, dev);
+ if (!isroot)
+ return DRM_ERR_NOT_ROOT;
+ remove(buf);
+ mknod(buf, S_IFCHR | devmode, dev);
}
if (drm_server_info && drm_server_info->get_perms) {
- group = ((int)serv_group >= 0) ? serv_group : DRM_DEV_GID;
- chown_check_return(buf, user, group);
- chmod(buf, devmode);
+ group = ((int)serv_group >= 0) ? serv_group : DRM_DEV_GID;
+ chown_check_return(buf, user, group);
+ chmod(buf, devmode);
}
#else
/* if we modprobed then wait for udev */
{
- int udev_count = 0;
+ int udev_count = 0;
wait_for_udev:
if (stat(DRM_DIR_NAME, &st)) {
- usleep(20);
- udev_count++;
-
- if (udev_count == 50)
- return -1;
- goto wait_for_udev;
- }
-
- if (stat(buf, &st)) {
- usleep(20);
- udev_count++;
-
- if (udev_count == 50)
- return -1;
- goto wait_for_udev;
- }
+ usleep(20);
+ udev_count++;
+
+ if (udev_count == 50)
+ return -1;
+ goto wait_for_udev;
+ }
+
+ if (stat(buf, &st)) {
+ usleep(20);
+ udev_count++;
+
+ if (udev_count == 50)
+ return -1;
+ goto wait_for_udev;
+ }
}
#endif
fd = open(buf, O_RDWR, 0);
drmMsg("drmOpenDevice: open result is %d, (%s)\n",
- fd, fd < 0 ? strerror(errno) : "OK");
+ fd, fd < 0 ? strerror(errno) : "OK");
if (fd >= 0)
- return fd;
+ return fd;
#if !defined(UDEV)
/* Check if the device node is not what we expect it to be, and recreate it
* and try again if so.
*/
if (st.st_rdev != dev) {
- if (!isroot)
- return DRM_ERR_NOT_ROOT;
- remove(buf);
- mknod(buf, S_IFCHR | devmode, dev);
- if (drm_server_info && drm_server_info->get_perms) {
- chown_check_return(buf, user, group);
- chmod(buf, devmode);
- }
+ if (!isroot)
+ return DRM_ERR_NOT_ROOT;
+ remove(buf);
+ mknod(buf, S_IFCHR | devmode, dev);
+ if (drm_server_info && drm_server_info->get_perms) {
+ chown_check_return(buf, user, group);
+ chmod(buf, devmode);
+ }
}
fd = open(buf, O_RDWR, 0);
drmMsg("drmOpenDevice: open result is %d, (%s)\n",
- fd, fd < 0 ? strerror(errno) : "OK");
+ fd, fd < 0 ? strerror(errno) : "OK");
if (fd >= 0)
- return fd;
+ return fd;
drmMsg("drmOpenDevice: Open failed\n");
remove(buf);
@@ -432,7 +429,7 @@ wait_for_udev:
* \param create allow to create the device if set.
*
* \return a file descriptor on success, or a negative value on error.
- *
+ *
* \internal
* Calls drmOpenDevice() if \p create is set, otherwise assembles the device
* name from \p minor and opens it.
@@ -442,37 +439,37 @@ static int drmOpenMinor(int minor, int create, int type)
int fd;
char buf[64];
const char *dev_name;
-
+
if (create)
- return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type);
-
+ return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type);
+
switch (type) {
case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
+ dev_name = DRM_DEV_NAME;
+ break;
case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
+ dev_name = DRM_CONTROL_DEV_NAME;
+ break;
case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
+ dev_name = DRM_RENDER_DEV_NAME;
+ break;
default:
- return -EINVAL;
+ return -EINVAL;
};
sprintf(buf, dev_name, DRM_DIR_NAME, minor);
if ((fd = open(buf, O_RDWR, 0)) >= 0)
- return fd;
+ return fd;
return -errno;
}
/**
* Determine whether the DRM kernel driver has been loaded.
- *
+ *
* \return 1 if the DRM driver is loaded, 0 otherwise.
*
- * \internal
+ * \internal
* Determine the presence of the kernel driver by attempting to open the 0
* minor and get version information. For backward compatibility with older
* Linux implementations, /proc/dri is also checked.
@@ -485,16 +482,16 @@ int drmAvailable(void)
if ((fd = drmOpenMinor(0, 1, DRM_NODE_PRIMARY)) < 0) {
#ifdef __linux__
- /* Try proc for backward Linux compatibility */
- if (!access("/proc/dri/0", R_OK))
- return 1;
+ /* Try proc for backward Linux compatibility */
+ if (!access("/proc/dri/0", R_OK))
+ return 1;
#endif
- return 0;
+ return 0;
}
-
+
if ((version = drmGetVersion(fd))) {
- retval = 1;
- drmFreeVersion(version);
+ retval = 1;
+ drmFreeVersion(version);
}
close(fd);
@@ -573,37 +570,37 @@ static int drmOpenByBusid(const char *busid, int type)
drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
for (i = base; i < base + DRM_MAX_MINOR; i++) {
- fd = drmOpenMinor(i, 1, type);
- drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
- if (fd >= 0) {
- /* We need to try for 1.4 first for proper PCI domain support
- * and if that fails, we know the kernel is busted
- */
- sv.drm_di_major = 1;
- sv.drm_di_minor = 4;
- sv.drm_dd_major = -1; /* Don't care */
- sv.drm_dd_minor = -1; /* Don't care */
- if (drmSetInterfaceVersion(fd, &sv)) {
+ fd = drmOpenMinor(i, 1, type);
+ drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
+ if (fd >= 0) {
+ /* We need to try for 1.4 first for proper PCI domain support
+ * and if that fails, we know the kernel is busted
+ */
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 4;
+ sv.drm_dd_major = -1; /* Don't care */
+ sv.drm_dd_minor = -1; /* Don't care */
+ if (drmSetInterfaceVersion(fd, &sv)) {
#ifndef __alpha__
- pci_domain_ok = 0;
+ pci_domain_ok = 0;
#endif
- sv.drm_di_major = 1;
- sv.drm_di_minor = 1;
- sv.drm_dd_major = -1; /* Don't care */
- sv.drm_dd_minor = -1; /* Don't care */
- drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n");
- drmSetInterfaceVersion(fd, &sv);
- }
- buf = drmGetBusid(fd);
- drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf);
- if (buf && drmMatchBusID(buf, busid, pci_domain_ok)) {
- drmFreeBusid(buf);
- return fd;
- }
- if (buf)
- drmFreeBusid(buf);
- close(fd);
- }
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 1;
+ sv.drm_dd_major = -1; /* Don't care */
+ sv.drm_dd_minor = -1; /* Don't care */
+ drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n");
+ drmSetInterfaceVersion(fd, &sv);
+ }
+ buf = drmGetBusid(fd);
+ drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf);
+ if (buf && drmMatchBusID(buf, busid, pci_domain_ok)) {
+ drmFreeBusid(buf);
+ return fd;
+ }
+ if (buf)
+ drmFreeBusid(buf);
+ close(fd);
+ }
}
return -1;
}
@@ -614,14 +611,14 @@ static int drmOpenByBusid(const char *busid, int type)
*
* \param name driver name.
* \param type the device node type.
- *
+ *
* \return a file descriptor on success, or a negative value on error.
- *
+ *
* \internal
* This function opens the first minor number that matches the driver name and
* isn't already in use. If it's in use it then it will already have a bus ID
* assigned.
- *
+ *
* \sa drmOpenMinor(), drmGetVersion() and drmGetBusid().
*/
static int drmOpenByName(const char *name, int type)
@@ -640,56 +637,56 @@ static int drmOpenByName(const char *name, int type)
* already in use. If it's in use it will have a busid assigned already.
*/
for (i = base; i < base + DRM_MAX_MINOR; i++) {
- if ((fd = drmOpenMinor(i, 1, type)) >= 0) {
- if ((version = drmGetVersion(fd))) {
- if (!strcmp(version->name, name)) {
- drmFreeVersion(version);
- id = drmGetBusid(fd);
- drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
- if (!id || !*id) {
- if (id)
- drmFreeBusid(id);
- return fd;
- } else {
- drmFreeBusid(id);
- }
- } else {
- drmFreeVersion(version);
- }
- }
- close(fd);
- }
+ if ((fd = drmOpenMinor(i, 1, type)) >= 0) {
+ if ((version = drmGetVersion(fd))) {
+ if (!strcmp(version->name, name)) {
+ drmFreeVersion(version);
+ id = drmGetBusid(fd);
+ drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
+ if (!id || !*id) {
+ if (id)
+ drmFreeBusid(id);
+ return fd;
+ } else {
+ drmFreeBusid(id);
+ }
+ } else {
+ drmFreeVersion(version);
+ }
+ }
+ close(fd);
+ }
}
#ifdef __linux__
/* Backward-compatibility /proc support */
for (i = 0; i < 8; i++) {
- char proc_name[64], buf[512];
- char *driver, *pt, *devstring;
- int retcode;
-
- sprintf(proc_name, "/proc/dri/%d/name", i);
- if ((fd = open(proc_name, 0, 0)) >= 0) {
- retcode = read(fd, buf, sizeof(buf)-1);
- close(fd);
- if (retcode) {
- buf[retcode-1] = '\0';
- for (driver = pt = buf; *pt && *pt != ' '; ++pt)
- ;
- if (*pt) { /* Device is next */
- *pt = '\0';
- if (!strcmp(driver, name)) { /* Match */
- for (devstring = ++pt; *pt && *pt != ' '; ++pt)
- ;
- if (*pt) { /* Found busid */
- return drmOpenByBusid(++pt, type);
- } else { /* No busid */
- return drmOpenDevice(strtol(devstring, NULL, 0),i, type);
- }
- }
- }
- }
- }
+ char proc_name[64], buf[512];
+ char *driver, *pt, *devstring;
+ int retcode;
+
+ sprintf(proc_name, "/proc/dri/%d/name", i);
+ if ((fd = open(proc_name, 0, 0)) >= 0) {
+ retcode = read(fd, buf, sizeof(buf)-1);
+ close(fd);
+ if (retcode) {
+ buf[retcode-1] = '\0';
+ for (driver = pt = buf; *pt && *pt != ' '; ++pt)
+ ;
+ if (*pt) { /* Device is next */
+ *pt = '\0';
+ if (!strcmp(driver, name)) { /* Match */
+ for (devstring = ++pt; *pt && *pt != ' '; ++pt)
+ ;
+ if (*pt) { /* Found busid */
+ return drmOpenByBusid(++pt, type);
+ } else { /* No busid */
+ return drmOpenDevice(strtol(devstring, NULL, 0),i, type);
+ }
+ }
+ }
+ }
+ }
}
#endif
@@ -705,9 +702,9 @@ static int drmOpenByName(const char *name, int type)
*
* \param name driver name. Not referenced if bus ID is supplied.
* \param busid bus ID. Zero if not known.
- *
+ *
* \return a file descriptor on success, or a negative value on error.
- *
+ *
* \internal
* It calls drmOpenByBusid() if \p busid is specified or drmOpenByName()
* otherwise.
@@ -737,21 +734,21 @@ int drmOpenWithType(const char *name, const char *busid, int type)
{
if (!drmAvailable() && name != NULL && drm_server_info &&
drm_server_info->load_module) {
- /* try to load the kernel module */
- if (!drm_server_info->load_module(name)) {
- drmMsg("[drm] failed to load kernel module \"%s\"\n", name);
- return -1;
- }
+ /* try to load the kernel module */
+ if (!drm_server_info->load_module(name)) {
+ drmMsg("[drm] failed to load kernel module \"%s\"\n", name);
+ return -1;
+ }
}
if (busid) {
- int fd = drmOpenByBusid(busid, type);
- if (fd >= 0)
- return fd;
+ int fd = drmOpenByBusid(busid, type);
+ if (fd >= 0)
+ return fd;
}
-
+
if (name)
- return drmOpenByName(name, type);
+ return drmOpenByName(name, type);
return -1;
}
@@ -778,7 +775,7 @@ int drmOpenRender(int minor)
void drmFreeVersion(drmVersionPtr v)
{
if (!v)
- return;
+ return;
drmFree(v->name);
drmFree(v->date);
drmFree(v->desc);
@@ -798,7 +795,7 @@ void drmFreeVersion(drmVersionPtr v)
static void drmFreeKernelVersion(drm_version_t *v)
{
if (!v)
- return;
+ return;
drmFree(v->name);
drmFree(v->date);
drmFree(v->desc);
@@ -808,10 +805,10 @@ static void drmFreeKernelVersion(drm_version_t *v)
/**
* Copy version information.
- *
+ *
* \param d destination pointer.
* \param s source pointer.
- *
+ *
* \internal
* Used by drmGetVersion() to translate the information returned by the ioctl
* interface in a private structure into the public structure counterpart.
@@ -834,12 +831,12 @@ static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s)
* Query the driver version information.
*
* \param fd file descriptor.
- *
+ *
* \return pointer to a drmVersion structure which should be freed with
* drmFreeVersion().
- *
+ *
* \note Similar information is available via /proc/dri.
- *
+ *
* \internal
* It gets the version information via successive DRM_IOCTL_VERSION ioctls,
* first with zeros to get the string lengths, and then the actually strings.
@@ -853,21 +850,21 @@ drmVersionPtr drmGetVersion(int fd)
memclear(*version);
if (drmIoctl(fd, DRM_IOCTL_VERSION, version)) {
- drmFreeKernelVersion(version);
- return NULL;
+ drmFreeKernelVersion(version);
+ return NULL;
}
if (version->name_len)
- version->name = drmMalloc(version->name_len + 1);
+ version->name = drmMalloc(version->name_len + 1);
if (version->date_len)
- version->date = drmMalloc(version->date_len + 1);
+ version->date = drmMalloc(version->date_len + 1);
if (version->desc_len)
- version->desc = drmMalloc(version->desc_len + 1);
+ version->desc = drmMalloc(version->desc_len + 1);
if (drmIoctl(fd, DRM_IOCTL_VERSION, version)) {
- drmMsg("DRM_IOCTL_VERSION: %s\n", strerror(errno));
- drmFreeKernelVersion(version);
- return NULL;
+ drmMsg("DRM_IOCTL_VERSION: %s\n", strerror(errno));
+ drmFreeKernelVersion(version);
+ return NULL;
}
/* The results might not be null-terminated strings, so terminate them. */
@@ -884,13 +881,13 @@ drmVersionPtr drmGetVersion(int fd)
/**
* Get version information for the DRM user space library.
- *
+ *
* This version number is driver independent.
- *
+ *
* \param fd file descriptor.
*
* \return version information.
- *
+ *
* \internal
* This function allocates and fills a drm_version structure with a hard coded
* version number.
@@ -918,29 +915,29 @@ drmVersionPtr drmGetLibVersion(int fd)
int drmGetCap(int fd, uint64_t capability, uint64_t *value)
{
- struct drm_get_cap cap;
- int ret;
+ struct drm_get_cap cap;
+ int ret;
- memclear(cap);
- cap.capability = capability;
+ memclear(cap);
+ cap.capability = capability;
- ret = drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap);
- if (ret)
- return ret;
+ ret = drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap);
+ if (ret)
+ return ret;
- *value = cap.value;
- return 0;
+ *value = cap.value;
+ return 0;
}
int drmSetClientCap(int fd, uint64_t capability, uint64_t value)
{
- struct drm_set_client_cap cap;
+ struct drm_set_client_cap cap;
- memclear(cap);
- cap.capability = capability;
- cap.value = value;
+ memclear(cap);
+ cap.capability = capability;
+ cap.value = value;
- return drmIoctl(fd, DRM_IOCTL_SET_CLIENT_CAP, &cap);
+ return drmIoctl(fd, DRM_IOCTL_SET_CLIENT_CAP, &cap);
}
/**
@@ -976,10 +973,10 @@ char *drmGetBusid(int fd)
memclear(u);
if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
- return NULL;
+ return NULL;
u.unique = drmMalloc(u.unique_len + 1);
if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
- return NULL;
+ return NULL;
u.unique[u.unique_len] = '\0';
return u.unique;
@@ -1007,7 +1004,7 @@ int drmSetBusid(int fd, const char *busid)
u.unique_len = strlen(busid);
if (drmIoctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) {
- return -errno;
+ return -errno;
}
return 0;
}
@@ -1020,7 +1017,7 @@ int drmGetMagic(int fd, drm_magic_t * magic)
*magic = 0;
if (drmIoctl(fd, DRM_IOCTL_GET_MAGIC, &auth))
- return -errno;
+ return -errno;
*magic = auth.magic;
return 0;
}
@@ -1032,7 +1029,7 @@ int drmAuthMagic(int fd, drm_magic_t magic)
memclear(auth);
auth.magic = magic;
if (drmIoctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth))
- return -errno;
+ return -errno;
return 0;
}
@@ -1048,7 +1045,7 @@ int drmAuthMagic(int fd, drm_magic_t magic)
* \param flags combination of several flags to modify the function actions.
* \param handle will be set to a value that may be used as the offset
* parameter for mmap().
- *
+ *
* \return zero on success or a negative value on error.
*
* \par Mapping the frame buffer
@@ -1059,7 +1056,7 @@ int drmAuthMagic(int fd, drm_magic_t magic)
*
* \par
* The area mapped will be uncached. If MTRR support is available in the
- * kernel, the frame buffer area will be set to write combining.
+ * kernel, the frame buffer area will be set to write combining.
*
* \par Mapping the MMIO register area
* For the MMIO register area,
@@ -1067,19 +1064,19 @@ int drmAuthMagic(int fd, drm_magic_t magic)
* - \p size will be the size of the register area bytes, and
* - \p type will be DRM_REGISTERS.
* \par
- * The area mapped will be uncached.
- *
+ * The area mapped will be uncached.
+ *
* \par Mapping the SAREA
* For the SAREA,
* - \p offset will be ignored and should be set to zero,
* - \p size will be the desired size of the SAREA in bytes,
* - \p type will be DRM_SHM.
- *
+ *
* \par
* A shared memory area of the requested size will be created and locked in
* kernel memory. This area may be mapped into client-space by using the handle
- * returned.
- *
+ * returned.
+ *
* \note May only be called by root.
*
* \internal
@@ -1087,7 +1084,7 @@ int drmAuthMagic(int fd, drm_magic_t magic)
* the arguments in a drm_map structure.
*/
int drmAddMap(int fd, drm_handle_t offset, drmSize size, drmMapType type,
- drmMapFlags flags, drm_handle_t *handle)
+ drmMapFlags flags, drm_handle_t *handle)
{
drm_map_t map;
@@ -1097,9 +1094,9 @@ int drmAddMap(int fd, drm_handle_t offset, drmSize size, drmMapType type,
map.type = type;
map.flags = flags;
if (drmIoctl(fd, DRM_IOCTL_ADD_MAP, &map))
- return -errno;
+ return -errno;
if (handle)
- *handle = (drm_handle_t)(uintptr_t)map.handle;
+ *handle = (drm_handle_t)(uintptr_t)map.handle;
return 0;
}
@@ -1111,18 +1108,18 @@ int drmRmMap(int fd, drm_handle_t handle)
map.handle = (void *)(uintptr_t)handle;
if(drmIoctl(fd, DRM_IOCTL_RM_MAP, &map))
- return -errno;
+ return -errno;
return 0;
}
/**
* Make buffers available for DMA transfers.
- *
+ *
* \param fd file descriptor.
* \param count number of buffers.
* \param size size of each buffer.
* \param flags buffer allocation flags.
- * \param agp_offset offset in the AGP aperture
+ * \param agp_offset offset in the AGP aperture
*
* \return number of buffers allocated, negative on error.
*
@@ -1132,7 +1129,7 @@ int drmRmMap(int fd, drm_handle_t handle)
* \sa drm_buf_desc.
*/
int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags,
- int agp_offset)
+ int agp_offset)
{
drm_buf_desc_t request;
@@ -1143,7 +1140,7 @@ int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags,
request.agp_start = agp_offset;
if (drmIoctl(fd, DRM_IOCTL_ADD_BUFS, &request))
- return -errno;
+ return -errno;
return request.count;
}
@@ -1155,28 +1152,28 @@ int drmMarkBufs(int fd, double low, double high)
memclear(info);
if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info))
- return -EINVAL;
+ return -EINVAL;
if (!info.count)
- return -EINVAL;
+ return -EINVAL;
if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
- return -ENOMEM;
+ return -ENOMEM;
if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
- int retval = -errno;
- drmFree(info.list);
- return retval;
+ int retval = -errno;
+ drmFree(info.list);
+ return retval;
}
for (i = 0; i < info.count; i++) {
- info.list[i].low_mark = low * info.list[i].count;
- info.list[i].high_mark = high * info.list[i].count;
- if (drmIoctl(fd, DRM_IOCTL_MARK_BUFS, &info.list[i])) {
- int retval = -errno;
- drmFree(info.list);
- return retval;
- }
+ info.list[i].low_mark = low * info.list[i].count;
+ info.list[i].high_mark = high * info.list[i].count;
+ if (drmIoctl(fd, DRM_IOCTL_MARK_BUFS, &info.list[i])) {
+ int retval = -errno;
+ drmFree(info.list);
+ return retval;
+ }
}
drmFree(info.list);
@@ -1191,9 +1188,9 @@ int drmMarkBufs(int fd, double low, double high)
* \param list list of buffers to be freed.
*
* \return zero on success, or a negative value on failure.
- *
+ *
* \note This function is primarily used for debugging.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_FREE_BUFS ioctl, passing
* the arguments in a drm_buf_free structure.
@@ -1206,7 +1203,7 @@ int drmFreeBufs(int fd, int count, int *list)
request.count = count;
request.list = list;
if (drmIoctl(fd, DRM_IOCTL_FREE_BUFS, &request))
- return -errno;
+ return -errno;
return 0;
}
@@ -1246,7 +1243,7 @@ int drmClose(int fd)
* begins.
*
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper for mmap().
*/
@@ -1255,16 +1252,16 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address)
static unsigned long pagesize_mask = 0;
if (fd < 0)
- return -EINVAL;
+ return -EINVAL;
if (!pagesize_mask)
- pagesize_mask = getpagesize() - 1;
+ pagesize_mask = getpagesize() - 1;
size = (size + pagesize_mask) & ~pagesize_mask;
*address = drm_mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle);
if (*address == MAP_FAILED)
- return -errno;
+ return -errno;
return 0;
}
@@ -1274,7 +1271,7 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address)
*
* \param address address as given by drmMap().
* \param size size in bytes. Must match the size used by drmMap().
- *
+ *
* \return zero on success, or a negative value on failure.
*
* \internal
@@ -1294,28 +1291,28 @@ drmBufInfoPtr drmGetBufInfo(int fd)
memclear(info);
if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info))
- return NULL;
+ return NULL;
if (info.count) {
- if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
- return NULL;
-
- if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
- drmFree(info.list);
- return NULL;
- }
-
- retval = drmMalloc(sizeof(*retval));
- retval->count = info.count;
- retval->list = drmMalloc(info.count * sizeof(*retval->list));
- for (i = 0; i < info.count; i++) {
- retval->list[i].count = info.list[i].count;
- retval->list[i].size = info.list[i].size;
- retval->list[i].low_mark = info.list[i].low_mark;
- retval->list[i].high_mark = info.list[i].high_mark;
- }
- drmFree(info.list);
- return retval;
+ if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
+ return NULL;
+
+ if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
+ drmFree(info.list);
+ return NULL;
+ }
+
+ retval = drmMalloc(sizeof(*retval));
+ retval->count = info.count;
+ retval->list = drmMalloc(info.count * sizeof(*retval->list));
+ for (i = 0; i < info.count; i++) {
+ retval->list[i].count = info.list[i].count;
+ retval->list[i].size = info.list[i].size;
+ retval->list[i].low_mark = info.list[i].low_mark;
+ retval->list[i].high_mark = info.list[i].high_mark;
+ }
+ drmFree(info.list);
+ return retval;
}
return NULL;
}
@@ -1329,12 +1326,12 @@ drmBufInfoPtr drmGetBufInfo(int fd)
*
* \note The client may not use these buffers until obtaining buffer indices
* with drmDMA().
- *
+ *
* \internal
* This function calls the DRM_IOCTL_MAP_BUFS ioctl and copies the returned
* information about the buffers in a drm_buf_map structure into the
* client-visible data structures.
- */
+ */
drmBufMapPtr drmMapBufs(int fd)
{
drm_buf_map_t bufs;
@@ -1343,31 +1340,32 @@ drmBufMapPtr drmMapBufs(int fd)
memclear(bufs);
if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs))
- return NULL;
+ return NULL;
if (!bufs.count)
- return NULL;
+ return NULL;
- if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list))))
- return NULL;
+ if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list))))
+ return NULL;
- if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) {
- drmFree(bufs.list);
- return NULL;
- }
+ if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) {
+ drmFree(bufs.list);
+ return NULL;
+ }
- retval = drmMalloc(sizeof(*retval));
- retval->count = bufs.count;
- retval->list = drmMalloc(bufs.count * sizeof(*retval->list));
- for (i = 0; i < bufs.count; i++) {
- retval->list[i].idx = bufs.list[i].idx;
- retval->list[i].total = bufs.list[i].total;
- retval->list[i].used = 0;
- retval->list[i].address = bufs.list[i].address;
- }
+ retval = drmMalloc(sizeof(*retval));
+ retval->count = bufs.count;
+ retval->list = drmMalloc(bufs.count * sizeof(*retval->list));
+ for (i = 0; i < bufs.count; i++) {
+ retval->list[i].idx = bufs.list[i].idx;
+ retval->list[i].total = bufs.list[i].total;
+ retval->list[i].used = 0;
+ retval->list[i].address = bufs.list[i].address;
+ }
- drmFree(bufs.list);
- return retval;
+ drmFree(bufs.list);
+
+ return retval;
}
@@ -1385,23 +1383,24 @@ int drmUnmapBufs(drmBufMapPtr bufs)
int i;
for (i = 0; i < bufs->count; i++) {
- drm_munmap(bufs->list[i].address, bufs->list[i].total);
+ drm_munmap(bufs->list[i].address, bufs->list[i].total);
}
drmFree(bufs->list);
drmFree(bufs);
+
return 0;
}
-#define DRM_DMA_RETRY 16
+#define DRM_DMA_RETRY 16
/**
* Reserve DMA buffers.
*
* \param fd file descriptor.
- * \param request
- *
+ * \param request
+ *
* \return zero on success, or a negative value on failure.
*
* \internal
@@ -1425,14 +1424,14 @@ int drmDMA(int fd, drmDMAReqPtr request)
dma.granted_count = 0;
do {
- ret = ioctl( fd, DRM_IOCTL_DMA, &dma );
+ ret = ioctl( fd, DRM_IOCTL_DMA, &dma );
} while ( ret && errno == EAGAIN && i++ < DRM_DMA_RETRY );
if ( ret == 0 ) {
- request->granted_count = dma.granted_count;
- return 0;
+ request->granted_count = dma.granted_count;
+ return 0;
} else {
- return -errno;
+ return -errno;
}
}
@@ -1444,9 +1443,9 @@ int drmDMA(int fd, drmDMAReqPtr request)
* \param context context.
* \param flags flags that determine the sate of the hardware when the function
* returns.
- *
+ *
* \return always zero.
- *
+ *
* \internal
* This function translates the arguments into a drm_lock structure and issue
* the DRM_IOCTL_LOCK ioctl until the lock is successfully acquired.
@@ -1466,7 +1465,7 @@ int drmGetLock(int fd, drm_context_t context, drmLockFlags flags)
if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES;
while (drmIoctl(fd, DRM_IOCTL_LOCK, &lock))
- ;
+ ;
return 0;
}
@@ -1475,9 +1474,9 @@ int drmGetLock(int fd, drm_context_t context, drmLockFlags flags)
*
* \param fd file descriptor.
* \param context context.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_UNLOCK ioctl, passing the
* argument in a drm_lock structure.
@@ -1500,24 +1499,24 @@ drm_context_t *drmGetReservedContextList(int fd, int *count)
memclear(res);
if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res))
- return NULL;
+ return NULL;
if (!res.count)
- return NULL;
+ return NULL;
if (!(list = drmMalloc(res.count * sizeof(*list))))
- return NULL;
+ return NULL;
if (!(retval = drmMalloc(res.count * sizeof(*retval)))) {
- drmFree(list);
- return NULL;
+ drmFree(list);
+ return NULL;
}
res.contexts = list;
if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res))
- return NULL;
+ return NULL;
for (i = 0; i < res.count; i++)
- retval[i] = list[i].handle;
+ retval[i] = list[i].handle;
drmFree(list);
*count = res.count;
@@ -1538,11 +1537,11 @@ void drmFreeReservedContextList(drm_context_t *pt)
* \param fd file descriptor.
* \param handle is set on success. To be used by the client when requesting DMA
* dispatch with drmDMA().
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \note May only be called by root.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_ADD_CTX ioctl, passing the
* argument in a drm_ctx structure.
@@ -1553,7 +1552,7 @@ int drmCreateContext(int fd, drm_context_t *handle)
memclear(ctx);
if (drmIoctl(fd, DRM_IOCTL_ADD_CTX, &ctx))
- return -errno;
+ return -errno;
*handle = ctx.handle;
return 0;
}
@@ -1565,7 +1564,7 @@ int drmSwitchToContext(int fd, drm_context_t context)
memclear(ctx);
ctx.handle = context;
if (drmIoctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx))
- return -errno;
+ return -errno;
return 0;
}
@@ -1582,11 +1581,11 @@ int drmSetContextFlags(int fd, drm_context_t context, drm_context_tFlags flags)
memclear(ctx);
ctx.handle = context;
if (flags & DRM_CONTEXT_PRESERVED)
- ctx.flags |= _DRM_CONTEXT_PRESERVED;
+ ctx.flags |= _DRM_CONTEXT_PRESERVED;
if (flags & DRM_CONTEXT_2DONLY)
- ctx.flags |= _DRM_CONTEXT_2DONLY;
+ ctx.flags |= _DRM_CONTEXT_2DONLY;
if (drmIoctl(fd, DRM_IOCTL_MOD_CTX, &ctx))
- return -errno;
+ return -errno;
return 0;
}
@@ -1598,12 +1597,12 @@ int drmGetContextFlags(int fd, drm_context_t context,
memclear(ctx);
ctx.handle = context;
if (drmIoctl(fd, DRM_IOCTL_GET_CTX, &ctx))
- return -errno;
+ return -errno;
*flags = 0;
if (ctx.flags & _DRM_CONTEXT_PRESERVED)
- *flags |= DRM_CONTEXT_PRESERVED;
+ *flags |= DRM_CONTEXT_PRESERVED;
if (ctx.flags & _DRM_CONTEXT_2DONLY)
- *flags |= DRM_CONTEXT_2DONLY;
+ *flags |= DRM_CONTEXT_2DONLY;
return 0;
}
@@ -1612,14 +1611,14 @@ int drmGetContextFlags(int fd, drm_context_t context,
*
* Free any kernel-level resources allocated with drmCreateContext() associated
* with the context.
- *
+ *
* \param fd file descriptor.
* \param handle handle given by drmCreateContext().
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \note May only be called by root.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_RM_CTX ioctl, passing the
* argument in a drm_ctx structure.
@@ -1631,7 +1630,7 @@ int drmDestroyContext(int fd, drm_context_t handle)
memclear(ctx);
ctx.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_RM_CTX, &ctx))
- return -errno;
+ return -errno;
return 0;
}
@@ -1641,7 +1640,7 @@ int drmCreateDrawable(int fd, drm_drawable_t *handle)
memclear(draw);
if (drmIoctl(fd, DRM_IOCTL_ADD_DRAW, &draw))
- return -errno;
+ return -errno;
*handle = draw.handle;
return 0;
}
@@ -1653,13 +1652,13 @@ int drmDestroyDrawable(int fd, drm_drawable_t handle)
memclear(draw);
draw.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_RM_DRAW, &draw))
- return -errno;
+ return -errno;
return 0;
}
int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
- drm_drawable_info_type_t type, unsigned int num,
- void *data)
+ drm_drawable_info_type_t type, unsigned int num,
+ void *data)
{
drm_update_draw_t update;
@@ -1670,7 +1669,7 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
update.data = (unsigned long long)(unsigned long)data;
if (drmIoctl(fd, DRM_IOCTL_UPDATE_DRAW, &update))
- return -errno;
+ return -errno;
return 0;
}
@@ -1681,16 +1680,16 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
* Must be called before any of the other AGP related calls.
*
* \param fd file descriptor.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_ACQUIRE ioctl.
*/
int drmAgpAcquire(int fd)
{
if (drmIoctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL))
- return -errno;
+ return -errno;
return 0;
}
@@ -1699,16 +1698,16 @@ int drmAgpAcquire(int fd)
* Release the AGP device.
*
* \param fd file descriptor.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_RELEASE ioctl.
*/
int drmAgpRelease(int fd)
{
if (drmIoctl(fd, DRM_IOCTL_AGP_RELEASE, NULL))
- return -errno;
+ return -errno;
return 0;
}
@@ -1718,9 +1717,9 @@ int drmAgpRelease(int fd)
*
* \param fd file descriptor.
* \param mode AGP mode.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_ENABLE ioctl, passing the
* argument in a drm_agp_mode structure.
@@ -1732,7 +1731,7 @@ int drmAgpEnable(int fd, unsigned long mode)
memclear(m);
m.mode = mode;
if (drmIoctl(fd, DRM_IOCTL_AGP_ENABLE, &m))
- return -errno;
+ return -errno;
return 0;
}
@@ -1746,15 +1745,15 @@ int drmAgpEnable(int fd, unsigned long mode)
* \param address if not zero, will be set to the physical address of the
* allocated memory.
* \param handle on success will be set to a handle of the allocated memory.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_ALLOC ioctl, passing the
* arguments in a drm_agp_buffer structure.
*/
int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
- unsigned long *address, drm_handle_t *handle)
+ unsigned long *address, drm_handle_t *handle)
{
drm_agp_buffer_t b;
@@ -1763,9 +1762,9 @@ int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
b.size = size;
b.type = type;
if (drmIoctl(fd, DRM_IOCTL_AGP_ALLOC, &b))
- return -errno;
+ return -errno;
if (address != 0UL)
- *address = b.physical;
+ *address = b.physical;
*handle = b.handle;
return 0;
}
@@ -1776,9 +1775,9 @@ int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
*
* \param fd file descriptor.
* \param handle handle to the allocated memory, as given by drmAgpAllocate().
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_FREE ioctl, passing the
* argument in a drm_agp_buffer structure.
@@ -1790,7 +1789,7 @@ int drmAgpFree(int fd, drm_handle_t handle)
memclear(b);
b.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_AGP_FREE, &b))
- return -errno;
+ return -errno;
return 0;
}
@@ -1801,9 +1800,9 @@ int drmAgpFree(int fd, drm_handle_t handle)
* \param fd file descriptor.
* \param handle handle to the allocated memory, as given by drmAgpAllocate().
* \param offset offset in bytes. It will round to page boundary.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_BIND ioctl, passing the
* argument in a drm_agp_binding structure.
@@ -1816,7 +1815,7 @@ int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset)
b.handle = handle;
b.offset = offset;
if (drmIoctl(fd, DRM_IOCTL_AGP_BIND, &b))
- return -errno;
+ return -errno;
return 0;
}
@@ -1826,9 +1825,9 @@ int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset)
*
* \param fd file descriptor.
* \param handle handle to the allocated memory, as given by drmAgpAllocate().
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_UNBIND ioctl, passing
* the argument in a drm_agp_binding structure.
@@ -1840,7 +1839,7 @@ int drmAgpUnbind(int fd, drm_handle_t handle)
memclear(b);
b.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_AGP_UNBIND, &b))
- return -errno;
+ return -errno;
return 0;
}
@@ -1849,9 +1848,9 @@ int drmAgpUnbind(int fd, drm_handle_t handle)
* Get AGP driver major version number.
*
* \param fd file descriptor.
- *
+ *
* \return major version number on success, or a negative value on failure..
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -1863,7 +1862,7 @@ int drmAgpVersionMajor(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return -errno;
+ return -errno;
return i.agp_version_major;
}
@@ -1872,9 +1871,9 @@ int drmAgpVersionMajor(int fd)
* Get AGP driver minor version number.
*
* \param fd file descriptor.
- *
+ *
* \return minor version number on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -1886,7 +1885,7 @@ int drmAgpVersionMinor(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return -errno;
+ return -errno;
return i.agp_version_minor;
}
@@ -1895,9 +1894,9 @@ int drmAgpVersionMinor(int fd)
* Get AGP mode.
*
* \param fd file descriptor.
- *
+ *
* \return mode on success, or zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -1909,7 +1908,7 @@ unsigned long drmAgpGetMode(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.mode;
}
@@ -1918,9 +1917,9 @@ unsigned long drmAgpGetMode(int fd)
* Get AGP aperture base.
*
* \param fd file descriptor.
- *
+ *
* \return aperture base on success, zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -1932,7 +1931,7 @@ unsigned long drmAgpBase(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.aperture_base;
}
@@ -1941,9 +1940,9 @@ unsigned long drmAgpBase(int fd)
* Get AGP aperture size.
*
* \param fd file descriptor.
- *
+ *
* \return aperture size on success, zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -1955,7 +1954,7 @@ unsigned long drmAgpSize(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.aperture_size;
}
@@ -1964,9 +1963,9 @@ unsigned long drmAgpSize(int fd)
* Get used AGP memory.
*
* \param fd file descriptor.
- *
+ *
* \return memory used on success, or zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -1978,7 +1977,7 @@ unsigned long drmAgpMemoryUsed(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.memory_used;
}
@@ -1987,9 +1986,9 @@ unsigned long drmAgpMemoryUsed(int fd)
* Get available AGP memory.
*
* \param fd file descriptor.
- *
+ *
* \return memory available on success, or zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -2001,7 +2000,7 @@ unsigned long drmAgpMemoryAvail(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.memory_allowed;
}
@@ -2010,9 +2009,9 @@ unsigned long drmAgpMemoryAvail(int fd)
* Get hardware vendor ID.
*
* \param fd file descriptor.
- *
+ *
* \return vendor ID on success, or zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -2024,7 +2023,7 @@ unsigned int drmAgpVendorId(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.id_vendor;
}
@@ -2033,9 +2032,9 @@ unsigned int drmAgpVendorId(int fd)
* Get hardware device ID.
*
* \param fd file descriptor.
- *
+ *
* \return zero on success, or zero on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
* necessary information in a drm_agp_info structure.
@@ -2047,7 +2046,7 @@ unsigned int drmAgpDeviceId(int fd)
memclear(i);
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
- return 0;
+ return 0;
return i.id_device;
}
@@ -2060,7 +2059,7 @@ int drmScatterGatherAlloc(int fd, unsigned long size, drm_handle_t *handle)
*handle = 0;
sg.size = size;
if (drmIoctl(fd, DRM_IOCTL_SG_ALLOC, &sg))
- return -errno;
+ return -errno;
*handle = sg.handle;
return 0;
}
@@ -2072,7 +2071,7 @@ int drmScatterGatherFree(int fd, drm_handle_t handle)
memclear(sg);
sg.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_SG_FREE, &sg))
- return -errno;
+ return -errno;
return 0;
}
@@ -2081,9 +2080,9 @@ int drmScatterGatherFree(int fd, drm_handle_t handle)
*
* \param fd file descriptor.
* \param vbl pointer to a drmVBlank structure.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_WAIT_VBLANK ioctl.
*/
@@ -2094,8 +2093,8 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl)
ret = clock_gettime(CLOCK_MONOTONIC, &timeout);
if (ret < 0) {
- fprintf(stderr, "clock_gettime failed: %s\n", strerror(errno));
- goto out;
+ fprintf(stderr, "clock_gettime failed: %s\n", strerror(errno));
+ goto out;
}
timeout.tv_sec++;
@@ -2103,15 +2102,15 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl)
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
if (ret && errno == EINTR) {
- clock_gettime(CLOCK_MONOTONIC, &cur);
- /* Timeout after 1s */
- if (cur.tv_sec > timeout.tv_sec + 1 ||
- (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >=
- timeout.tv_nsec)) {
- errno = EBUSY;
- ret = -1;
- break;
- }
+ clock_gettime(CLOCK_MONOTONIC, &cur);
+ /* Timeout after 1s */
+ if (cur.tv_sec > timeout.tv_sec + 1 ||
+ (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >=
+ timeout.tv_nsec)) {
+ errno = EBUSY;
+ ret = -1;
+ break;
+ }
}
} while (ret && errno == EINTR);
@@ -2123,22 +2122,22 @@ int drmError(int err, const char *label)
{
switch (err) {
case DRM_ERR_NO_DEVICE:
- fprintf(stderr, "%s: no device\n", label);
- break;
+ fprintf(stderr, "%s: no device\n", label);
+ break;
case DRM_ERR_NO_ACCESS:
- fprintf(stderr, "%s: no access\n", label);
- break;
+ fprintf(stderr, "%s: no access\n", label);
+ break;
case DRM_ERR_NOT_ROOT:
- fprintf(stderr, "%s: not root\n", label);
- break;
+ fprintf(stderr, "%s: not root\n", label);
+ break;
case DRM_ERR_INVALID:
- fprintf(stderr, "%s: invalid args\n", label);
- break;
+ fprintf(stderr, "%s: invalid args\n", label);
+ break;
default:
- if (err < 0)
- err = -err;
- fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) );
- break;
+ if (err < 0)
+ err = -err;
+ fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) );
+ break;
}
return 1;
@@ -2149,9 +2148,9 @@ int drmError(int err, const char *label)
*
* \param fd file descriptor.
* \param irq IRQ number.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_CONTROL ioctl, passing the
* argument in a drm_control structure.
@@ -2164,7 +2163,7 @@ int drmCtlInstHandler(int fd, int irq)
ctl.func = DRM_INST_HANDLER;
ctl.irq = irq;
if (drmIoctl(fd, DRM_IOCTL_CONTROL, &ctl))
- return -errno;
+ return -errno;
return 0;
}
@@ -2173,9 +2172,9 @@ int drmCtlInstHandler(int fd, int irq)
* Uninstall IRQ handler.
*
* \param fd file descriptor.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_CONTROL ioctl, passing the
* argument in a drm_control structure.
@@ -2188,7 +2187,7 @@ int drmCtlUninstHandler(int fd)
ctl.func = DRM_UNINST_HANDLER;
ctl.irq = 0;
if (drmIoctl(fd, DRM_IOCTL_CONTROL, &ctl))
- return -errno;
+ return -errno;
return 0;
}
@@ -2205,7 +2204,7 @@ int drmFinish(int fd, int context, drmLockFlags flags)
if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES;
if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES;
if (drmIoctl(fd, DRM_IOCTL_FINISH, &lock))
- return -errno;
+ return -errno;
return 0;
}
@@ -2216,9 +2215,9 @@ int drmFinish(int fd, int context, drmLockFlags flags)
* \param busnum bus number.
* \param devnum device number.
* \param funcnum function number.
- *
+ *
* \return IRQ number on success, or a negative value on failure.
- *
+ *
* \internal
* This function is a wrapper around the DRM_IOCTL_IRQ_BUSID ioctl, passing the
* arguments in a drm_irq_busid structure.
@@ -2232,7 +2231,7 @@ int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum)
p.devnum = devnum;
p.funcnum = funcnum;
if (drmIoctl(fd, DRM_IOCTL_IRQ_BUSID, &p))
- return -errno;
+ return -errno;
return p.irq;
}
@@ -2241,8 +2240,8 @@ int drmAddContextTag(int fd, drm_context_t context, void *tag)
drmHashEntry *entry = drmGetEntry(fd);
if (drmHashInsert(entry->tagTable, context, tag)) {
- drmHashDelete(entry->tagTable, context);
- drmHashInsert(entry->tagTable, context, tag);
+ drmHashDelete(entry->tagTable, context);
+ drmHashInsert(entry->tagTable, context, tag);
}
return 0;
}
@@ -2260,7 +2259,7 @@ void *drmGetContextTag(int fd, drm_context_t context)
void *value;
if (drmHashLookup(entry->tagTable, context, &value))
- return NULL;
+ return NULL;
return value;
}
@@ -2275,7 +2274,7 @@ int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
map.handle = (void *)(uintptr_t)handle;
if (drmIoctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map))
- return -errno;
+ return -errno;
return 0;
}
@@ -2288,23 +2287,23 @@ int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
map.ctx_id = ctx_id;
if (drmIoctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map))
- return -errno;
+ return -errno;
if (handle)
- *handle = (drm_handle_t)(uintptr_t)map.handle;
+ *handle = (drm_handle_t)(uintptr_t)map.handle;
return 0;
}
int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size,
- drmMapType *type, drmMapFlags *flags, drm_handle_t *handle,
- int *mtrr)
+ drmMapType *type, drmMapFlags *flags, drm_handle_t *handle,
+ int *mtrr)
{
drm_map_t map;
memclear(map);
map.offset = idx;
if (drmIoctl(fd, DRM_IOCTL_GET_MAP, &map))
- return -errno;
+ return -errno;
*offset = map.offset;
*size = map.size;
*type = map.type;
@@ -2315,14 +2314,14 @@ int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size,
}
int drmGetClient(int fd, int idx, int *auth, int *pid, int *uid,
- unsigned long *magic, unsigned long *iocs)
+ unsigned long *magic, unsigned long *iocs)
{
drm_client_t client;
memclear(client);
client.idx = idx;
if (drmIoctl(fd, DRM_IOCTL_GET_CLIENT, &client))
- return -errno;
+ return -errno;
*auth = client.auth;
*pid = client.pid;
*uid = client.uid;
@@ -2338,12 +2337,12 @@ int drmGetStats(int fd, drmStatsT *stats)
memclear(s);
if (drmIoctl(fd, DRM_IOCTL_GET_STATS, &s))
- return -errno;
+ return -errno;
stats->count = 0;
memset(stats, 0, sizeof(*stats));
if (s.count > sizeof(stats->data)/sizeof(stats->data[0]))
- return -1;
+ return -1;
#define SET_VALUE \
stats->data[i].long_format = "%-20.20s"; \
@@ -2370,87 +2369,87 @@ int drmGetStats(int fd, drmStatsT *stats)
stats->count = s.count;
for (i = 0; i < s.count; i++) {
- stats->data[i].value = s.data[i].value;
- switch (s.data[i].type) {
- case _DRM_STAT_LOCK:
- stats->data[i].long_name = "Lock";
- stats->data[i].rate_name = "Lock";
- SET_VALUE;
- break;
- case _DRM_STAT_OPENS:
- stats->data[i].long_name = "Opens";
- stats->data[i].rate_name = "O";
- SET_COUNT;
- stats->data[i].verbose = 1;
- break;
- case _DRM_STAT_CLOSES:
- stats->data[i].long_name = "Closes";
- stats->data[i].rate_name = "Lock";
- SET_COUNT;
- stats->data[i].verbose = 1;
- break;
- case _DRM_STAT_IOCTLS:
- stats->data[i].long_name = "Ioctls";
- stats->data[i].rate_name = "Ioc/s";
- SET_COUNT;
- break;
- case _DRM_STAT_LOCKS:
- stats->data[i].long_name = "Locks";
- stats->data[i].rate_name = "Lck/s";
- SET_COUNT;
- break;
- case _DRM_STAT_UNLOCKS:
- stats->data[i].long_name = "Unlocks";
- stats->data[i].rate_name = "Unl/s";
- SET_COUNT;
- break;
- case _DRM_STAT_IRQ:
- stats->data[i].long_name = "IRQs";
- stats->data[i].rate_name = "IRQ/s";
- SET_COUNT;
- break;
- case _DRM_STAT_PRIMARY:
- stats->data[i].long_name = "Primary Bytes";
- stats->data[i].rate_name = "PB/s";
- SET_BYTE;
- break;
- case _DRM_STAT_SECONDARY:
- stats->data[i].long_name = "Secondary Bytes";
- stats->data[i].rate_name = "SB/s";
- SET_BYTE;
- break;
- case _DRM_STAT_DMA:
- stats->data[i].long_name = "DMA";
- stats->data[i].rate_name = "DMA/s";
- SET_COUNT;
- break;
- case _DRM_STAT_SPECIAL:
- stats->data[i].long_name = "Special DMA";
- stats->data[i].rate_name = "dma/s";
- SET_COUNT;
- break;
- case _DRM_STAT_MISSED:
- stats->data[i].long_name = "Miss";
- stats->data[i].rate_name = "Ms/s";
- SET_COUNT;
- break;
- case _DRM_STAT_VALUE:
- stats->data[i].long_name = "Value";
- stats->data[i].rate_name = "Value";
- SET_VALUE;
- break;
- case _DRM_STAT_BYTE:
- stats->data[i].long_name = "Bytes";
- stats->data[i].rate_name = "B/s";
- SET_BYTE;
- break;
- case _DRM_STAT_COUNT:
- default:
- stats->data[i].long_name = "Count";
- stats->data[i].rate_name = "Cnt/s";
- SET_COUNT;
- break;
- }
+ stats->data[i].value = s.data[i].value;
+ switch (s.data[i].type) {
+ case _DRM_STAT_LOCK:
+ stats->data[i].long_name = "Lock";
+ stats->data[i].rate_name = "Lock";
+ SET_VALUE;
+ break;
+ case _DRM_STAT_OPENS:
+ stats->data[i].long_name = "Opens";
+ stats->data[i].rate_name = "O";
+ SET_COUNT;
+ stats->data[i].verbose = 1;
+ break;
+ case _DRM_STAT_CLOSES:
+ stats->data[i].long_name = "Closes";
+ stats->data[i].rate_name = "Lock";
+ SET_COUNT;
+ stats->data[i].verbose = 1;
+ break;
+ case _DRM_STAT_IOCTLS:
+ stats->data[i].long_name = "Ioctls";
+ stats->data[i].rate_name = "Ioc/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_LOCKS:
+ stats->data[i].long_name = "Locks";
+ stats->data[i].rate_name = "Lck/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_UNLOCKS:
+ stats->data[i].long_name = "Unlocks";
+ stats->data[i].rate_name = "Unl/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_IRQ:
+ stats->data[i].long_name = "IRQs";
+ stats->data[i].rate_name = "IRQ/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_PRIMARY:
+ stats->data[i].long_name = "Primary Bytes";
+ stats->data[i].rate_name = "PB/s";
+ SET_BYTE;
+ break;
+ case _DRM_STAT_SECONDARY:
+ stats->data[i].long_name = "Secondary Bytes";
+ stats->data[i].rate_name = "SB/s";
+ SET_BYTE;
+ break;
+ case _DRM_STAT_DMA:
+ stats->data[i].long_name = "DMA";
+ stats->data[i].rate_name = "DMA/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_SPECIAL:
+ stats->data[i].long_name = "Special DMA";
+ stats->data[i].rate_name = "dma/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_MISSED:
+ stats->data[i].long_name = "Miss";
+ stats->data[i].rate_name = "Ms/s";
+ SET_COUNT;
+ break;
+ case _DRM_STAT_VALUE:
+ stats->data[i].long_name = "Value";
+ stats->data[i].rate_name = "Value";
+ SET_VALUE;
+ break;
+ case _DRM_STAT_BYTE:
+ stats->data[i].long_name = "Bytes";
+ stats->data[i].rate_name = "B/s";
+ SET_BYTE;
+ break;
+ case _DRM_STAT_COUNT:
+ default:
+ stats->data[i].long_name = "Count";
+ stats->data[i].rate_name = "Cnt/s";
+ SET_COUNT;
+ break;
+ }
}
return 0;
}
@@ -2459,14 +2458,14 @@ int drmGetStats(int fd, drmStatsT *stats)
* Issue a set-version ioctl.
*
* \param fd file descriptor.
- * \param drmCommandIndex command index
+ * \param drmCommandIndex command index
* \param data source pointer of the data to be read and written.
* \param size size of the data to be read and written.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
- * It issues a read-write ioctl given by
+ * It issues a read-write ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
int drmSetInterfaceVersion(int fd, drmSetVersion *version)
@@ -2481,7 +2480,7 @@ int drmSetInterfaceVersion(int fd, drmSetVersion *version)
sv.drm_dd_minor = version->drm_dd_minor;
if (drmIoctl(fd, DRM_IOCTL_SET_VERSION, &sv)) {
- retcode = -errno;
+ retcode = -errno;
}
version->drm_di_major = sv.drm_di_major;
@@ -2496,12 +2495,12 @@ int drmSetInterfaceVersion(int fd, drmSetVersion *version)
* Send a device-specific command.
*
* \param fd file descriptor.
- * \param drmCommandIndex command index
- *
+ * \param drmCommandIndex command index
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
- * It issues a ioctl given by
+ * It issues a ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
int drmCommandNone(int fd, unsigned long drmCommandIndex)
@@ -2511,7 +2510,7 @@ int drmCommandNone(int fd, unsigned long drmCommandIndex)
request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex);
if (drmIoctl(fd, request, NULL)) {
- return -errno;
+ return -errno;
}
return 0;
}
@@ -2521,14 +2520,14 @@ int drmCommandNone(int fd, unsigned long drmCommandIndex)
* Send a device-specific read command.
*
* \param fd file descriptor.
- * \param drmCommandIndex command index
+ * \param drmCommandIndex command index
* \param data destination pointer of the data to be read.
* \param size size of the data to be read.
- *
+ *
* \return zero on success, or a negative value on failure.
*
* \internal
- * It issues a read ioctl given by
+ * It issues a read ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data,
@@ -2536,11 +2535,11 @@ int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data,
{
unsigned long request;
- request = DRM_IOC( DRM_IOC_READ, DRM_IOCTL_BASE,
- DRM_COMMAND_BASE + drmCommandIndex, size);
+ request = DRM_IOC( DRM_IOC_READ, DRM_IOCTL_BASE,
+ DRM_COMMAND_BASE + drmCommandIndex, size);
if (drmIoctl(fd, request, data)) {
- return -errno;
+ return -errno;
}
return 0;
}
@@ -2550,14 +2549,14 @@ int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data,
* Send a device-specific write command.
*
* \param fd file descriptor.
- * \param drmCommandIndex command index
+ * \param drmCommandIndex command index
* \param data source pointer of the data to be written.
* \param size size of the data to be written.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
- * It issues a write ioctl given by
+ * It issues a write ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data,
@@ -2565,11 +2564,11 @@ int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data,
{
unsigned long request;
- request = DRM_IOC( DRM_IOC_WRITE, DRM_IOCTL_BASE,
- DRM_COMMAND_BASE + drmCommandIndex, size);
+ request = DRM_IOC( DRM_IOC_WRITE, DRM_IOCTL_BASE,
+ DRM_COMMAND_BASE + drmCommandIndex, size);
if (drmIoctl(fd, request, data)) {
- return -errno;
+ return -errno;
}
return 0;
}
@@ -2579,14 +2578,14 @@ int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data,
* Send a device-specific read-write command.
*
* \param fd file descriptor.
- * \param drmCommandIndex command index
+ * \param drmCommandIndex command index
* \param data source pointer of the data to be read and written.
* \param size size of the data to be read and written.
- *
+ *
* \return zero on success, or a negative value on failure.
- *
+ *
* \internal
- * It issues a read-write ioctl given by
+ * It issues a read-write ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
@@ -2594,11 +2593,11 @@ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
{
unsigned long request;
- request = DRM_IOC( DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE,
- DRM_COMMAND_BASE + drmCommandIndex, size);
+ request = DRM_IOC( DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE,
+ DRM_COMMAND_BASE + drmCommandIndex, size);
if (drmIoctl(fd, request, data))
- return -errno;
+ return -errno;
return 0;
}
@@ -2612,9 +2611,9 @@ static struct {
static int nr_fds = 0;
-int drmOpenOnce(void *unused,
- const char *BusID,
- int *newlyopened)
+int drmOpenOnce(void *unused,
+ const char *BusID,
+ int *newlyopened)
{
return drmOpenOnceWithType(BusID, newlyopened, DRM_NODE_PRIMARY);
}
@@ -2623,19 +2622,19 @@ int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type)
{
int i;
int fd;
-
+
for (i = 0; i < nr_fds; i++)
- if ((strcmp(BusID, connection[i].BusID) == 0) &&
- (connection[i].type == type)) {
- connection[i].refcount++;
- *newlyopened = 0;
- return connection[i].fd;
- }
+ if ((strcmp(BusID, connection[i].BusID) == 0) &&
+ (connection[i].type == type)) {
+ connection[i].refcount++;
+ *newlyopened = 0;
+ return connection[i].fd;
+ }
fd = drmOpenWithType(NULL, BusID, type);
if (fd < 0 || nr_fds == DRM_MAX_FDS)
- return fd;
-
+ return fd;
+
connection[nr_fds].BusID = strdup(BusID);
connection[nr_fds].fd = fd;
connection[nr_fds].refcount = 1;
@@ -2643,9 +2642,9 @@ int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type)
*newlyopened = 1;
if (0)
- fprintf(stderr, "saved connection %d for %s %d\n",
- nr_fds, connection[nr_fds].BusID,
- strcmp(BusID, connection[nr_fds].BusID));
+ fprintf(stderr, "saved connection %d for %s %d\n",
+ nr_fds, connection[nr_fds].BusID,
+ strcmp(BusID, connection[nr_fds].BusID));
nr_fds++;
@@ -2657,180 +2656,180 @@ void drmCloseOnce(int fd)
int i;
for (i = 0; i < nr_fds; i++) {
- if (fd == connection[i].fd) {
- if (--connection[i].refcount == 0) {
- drmClose(connection[i].fd);
- free(connection[i].BusID);
-
- if (i < --nr_fds)
- connection[i] = connection[nr_fds];
-
- return;
- }
- }
+ if (fd == connection[i].fd) {
+ if (--connection[i].refcount == 0) {
+ drmClose(connection[i].fd);
+ free(connection[i].BusID);
+
+ if (i < --nr_fds)
+ connection[i] = connection[nr_fds];
+
+ return;
+ }
+ }
}
}
int drmSetMaster(int fd)
{
- return drmIoctl(fd, DRM_IOCTL_SET_MASTER, NULL);
+ return drmIoctl(fd, DRM_IOCTL_SET_MASTER, NULL);
}
int drmDropMaster(int fd)
{
- return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, NULL);
+ return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, NULL);
}
char *drmGetDeviceNameFromFd(int fd)
{
- char name[128];
- struct stat sbuf;
- dev_t d;
- int i;
+ char name[128];
+ struct stat sbuf;
+ dev_t d;
+ int i;
- /* The whole drmOpen thing is a fiasco and we need to find a way
- * back to just using open(2). For now, however, lets just make
- * things worse with even more ad hoc directory walking code to
- * discover the device file name. */
+ /* The whole drmOpen thing is a fiasco and we need to find a way
+ * back to just using open(2). For now, however, lets just make
+ * things worse with even more ad hoc directory walking code to
+ * discover the device file name. */
- fstat(fd, &sbuf);
- d = sbuf.st_rdev;
+ fstat(fd, &sbuf);
+ d = sbuf.st_rdev;
- for (i = 0; i < DRM_MAX_MINOR; i++) {
- snprintf(name, sizeof name, DRM_DEV_NAME, DRM_DIR_NAME, i);
- if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d)
- break;
- }
- if (i == DRM_MAX_MINOR)
- return NULL;
+ for (i = 0; i < DRM_MAX_MINOR; i++) {
+ snprintf(name, sizeof name, DRM_DEV_NAME, DRM_DIR_NAME, i);
+ if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d)
+ break;
+ }
+ if (i == DRM_MAX_MINOR)
+ return NULL;
- return strdup(name);
+ return strdup(name);
}
int drmGetNodeTypeFromFd(int fd)
{
- struct stat sbuf;
- int maj, min, type;
+ struct stat sbuf;
+ int maj, min, type;
- if (fstat(fd, &sbuf))
- return -1;
+ if (fstat(fd, &sbuf))
+ return -1;
- maj = major(sbuf.st_rdev);
- min = minor(sbuf.st_rdev);
+ maj = major(sbuf.st_rdev);
+ min = minor(sbuf.st_rdev);
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) {
- errno = EINVAL;
- return -1;
- }
+ if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) {
+ errno = EINVAL;
+ return -1;
+ }
- type = drmGetMinorType(min);
- if (type == -1)
- errno = ENODEV;
- return type;
+ type = drmGetMinorType(min);
+ if (type == -1)
+ errno = ENODEV;
+ return type;
}
int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd)
{
- struct drm_prime_handle args;
- int ret;
+ struct drm_prime_handle args;
+ int ret;
- memclear(args);
- args.fd = -1;
- args.handle = handle;
- args.flags = flags;
- ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
- if (ret)
- return ret;
+ memclear(args);
+ args.fd = -1;
+ args.handle = handle;
+ args.flags = flags;
+ ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
+ if (ret)
+ return ret;
- *prime_fd = args.fd;
- return 0;
+ *prime_fd = args.fd;
+ return 0;
}
int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle)
{
- struct drm_prime_handle args;
- int ret;
+ struct drm_prime_handle args;
+ int ret;
- memclear(args);
- args.fd = prime_fd;
- ret = drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);
- if (ret)
- return ret;
+ memclear(args);
+ args.fd = prime_fd;
+ ret = drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);
+ if (ret)
+ return ret;
- *handle = args.handle;
- return 0;
+ *handle = args.handle;
+ return 0;
}
static char *drmGetMinorNameForFD(int fd, int type)
{
#ifdef __linux__
- DIR *sysdir;
- struct dirent *pent, *ent;
- struct stat sbuf;
- const char *name = drmGetMinorName(type);
- int len;
- char dev_name[64], buf[64];
- long name_max;
- int maj, min;
+ DIR *sysdir;
+ struct dirent *pent, *ent;
+ struct stat sbuf;
+ const char *name = drmGetMinorName(type);
+ int len;
+ char dev_name[64], buf[64];
+ long name_max;
+ int maj, min;
- if (!name)
- return NULL;
+ if (!name)
+ return NULL;
- len = strlen(name);
+ len = strlen(name);
- if (fstat(fd, &sbuf))
- return NULL;
+ if (fstat(fd, &sbuf))
+ return NULL;
- maj = major(sbuf.st_rdev);
- min = minor(sbuf.st_rdev);
+ maj = major(sbuf.st_rdev);
+ min = minor(sbuf.st_rdev);
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
- return NULL;
+ if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
+ return NULL;
- snprintf(buf, sizeof(buf), "/sys/dev/char/%d:%d/device/drm", maj, min);
+ snprintf(buf, sizeof(buf), "/sys/dev/char/%d:%d/device/drm", maj, min);
- sysdir = opendir(buf);
- if (!sysdir)
- return NULL;
+ sysdir = opendir(buf);
+ if (!sysdir)
+ return NULL;
- name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX);
- if (name_max == -1)
- goto out_close_dir;
+ name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX);
+ if (name_max == -1)
+ goto out_close_dir;
- pent = malloc(offsetof(struct dirent, d_name) + name_max + 1);
- if (pent == NULL)
- goto out_close_dir;
+ pent = malloc(offsetof(struct dirent, d_name) + name_max + 1);
+ if (pent == NULL)
+ goto out_close_dir;
- while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
- if (strncmp(ent->d_name, name, len) == 0) {
- snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
- ent->d_name);
+ while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
+ if (strncmp(ent->d_name, name, len) == 0) {
+ snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
+ ent->d_name);
- free(pent);
- closedir(sysdir);
+ free(pent);
+ closedir(sysdir);
- return strdup(dev_name);
- }
- }
+ return strdup(dev_name);
+ }
+ }
- free(pent);
+ free(pent);
out_close_dir:
- closedir(sysdir);
+ closedir(sysdir);
#else
#warning "Missing implementation of drmGetMinorNameForFD"
#endif
- return NULL;
+ return NULL;
}
char *drmGetPrimaryDeviceNameFromFd(int fd)
{
- return drmGetMinorNameForFD(fd, DRM_NODE_PRIMARY);
+ return drmGetMinorNameForFD(fd, DRM_NODE_PRIMARY);
}
char *drmGetRenderDeviceNameFromFd(int fd)
{
- return drmGetMinorNameForFD(fd, DRM_NODE_RENDER);
+ return drmGetMinorNameForFD(fd, DRM_NODE_RENDER);
}
static int drmParseSubsystemType(int maj, int min)
@@ -2864,7 +2863,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
{
#ifdef __linux__
char path[PATH_MAX + 1];
- char data[128 + 1];
+ char data[128];
char *str;
int domain, bus, dev, func;
int fd, ret;
@@ -2875,7 +2874,6 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
return -errno;
ret = read(fd, data, sizeof(data));
- data[128] = '\0';
close(fd);
if (ret < 0)
return -errno;
@@ -2943,7 +2941,7 @@ static int drmGetMaxNodeName(void)
MAX3(sizeof(DRM_PRIMARY_MINOR_NAME),
sizeof(DRM_CONTROL_MINOR_NAME),
sizeof(DRM_RENDER_MINOR_NAME)) +
- 3 /* length of the node number */;
+ 3 /* lenght of the node number */;
}
static int drmParsePciDeviceInfo(const char *d_name,
@@ -2993,28 +2991,27 @@ void drmFreeDevices(drmDevicePtr devices[], int count)
if (devices == NULL)
return;
- for (i = 0; i < count; i++)
- if (devices[i])
- drmFreeDevice(&devices[i]);
+ for (i = 0; i < count && devices[i] != NULL; i++)
+ drmFreeDevice(&devices[i]);
}
static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,
const char *node, int node_type,
int maj, int min, bool fetch_deviceinfo)
{
- const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *));
+ const int max_node_str = drmGetMaxNodeName();
int ret, i;
char *addr;
*device = calloc(1, sizeof(drmDevice) +
- (DRM_NODE_MAX * (sizeof(void *) + max_node_str)) +
- sizeof(drmPciBusInfo) +
- sizeof(drmPciDeviceInfo));
+ (DRM_NODE_MAX * (sizeof(void *) + max_node_str)) +
+ sizeof(drmPciBusInfo) +
+ sizeof(drmPciDeviceInfo));
if (!*device)
return -ENOMEM;
addr = (char*)*device;
-
+
(*device)->bustype = DRM_BUS_PCI;
(*device)->available_nodes = 1 << node_type;
@@ -3051,11 +3048,6 @@ free_device:
return ret;
}
-/* Consider devices located on the same bus as duplicate and fold the respective
- * entries into a single one.
- *
- * Note: this leaves "gaps" in the array, while preserving the length.
- */
static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count)
{
int node_type, i, j;
@@ -3094,7 +3086,6 @@ int drmGetDevice(int fd, drmDevicePtr *device)
int maj, min;
int ret, i, node_count;
int max_count = 16;
- dev_t find_rdev;
if (fd == -1 || device == NULL)
return -EINVAL;
@@ -3102,7 +3093,6 @@ int drmGetDevice(int fd, drmDevicePtr *device)
if (fstat(fd, &sbuf))
return -errno;
- find_rdev = sbuf.st_rdev;
maj = major(sbuf.st_rdev);
min = minor(sbuf.st_rdev);
@@ -3163,26 +3153,20 @@ int drmGetDevice(int fd, drmDevicePtr *device)
local_devices = temp;
}
- /* store target at local_devices[0] for ease to use below */
- if (find_rdev == sbuf.st_rdev && i) {
- local_devices[i] = local_devices[0];
- local_devices[0] = d;
- }
- else
- local_devices[i] = d;
+ local_devices[i] = d;
i++;
}
node_count = i;
+ /* Fold nodes into a single device if they share the same bus info */
drmFoldDuplicatedDevices(local_devices, node_count);
*device = local_devices[0];
- drmFreeDevices(&local_devices[1], node_count - 1);
+ for (i = 1; i < node_count && local_devices[i]; i++)
+ drmFreeDevice(&local_devices[i]);
closedir(sysdir);
free(local_devices);
- if (*device == NULL)
- return -ENODEV;
return 0;
free_devices:
@@ -3278,13 +3262,11 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
}
node_count = i;
+ /* Fold nodes into a single device if they share the same bus info */
drmFoldDuplicatedDevices(local_devices, node_count);
device_count = 0;
- for (i = 0; i < node_count; i++) {
- if (!local_devices[i])
- continue;
-
+ for (i = 0; i < node_count && local_devices[i]; i++) {
if ((devices != NULL) && (device_count < max_devices))
devices[device_count] = local_devices[i];
else
diff --git a/chromium/third_party/libdrm/src/xf86drmMode.c b/chromium/third_party/libdrm/src/xf86drmMode.c
index aaf259b7b1d..ab6b5195e8d 100644
--- a/chromium/third_party/libdrm/src/xf86drmMode.c
+++ b/chromium/third_party/libdrm/src/xf86drmMode.c
@@ -34,7 +34,7 @@
*/
/*
- * TODO the types we are after are defined in different headers on different
+ * TODO the types we are after are defined in diffrent headers on diffrent
* platforms find which headers to include to get uint32_t
*/
@@ -270,10 +270,10 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
return 0;
}
-int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
- uint32_t pixel_format, uint32_t bo_handles[4],
- uint32_t pitches[4], uint32_t offsets[4],
- uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)
+int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
+ uint32_t pixel_format, uint32_t bo_handles[4],
+ uint32_t pitches[4], uint32_t offsets[4],
+ uint32_t *buf_id, uint32_t flags)
{
struct drm_mode_fb_cmd2 f;
int ret;
@@ -286,8 +286,6 @@ int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
- if (modifier)
- memcpy(f.modifier, modifier, 4 * sizeof(modifier[0]));
if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
return ret;
@@ -296,17 +294,6 @@ int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
return 0;
}
-int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
- uint32_t pixel_format, uint32_t bo_handles[4],
- uint32_t pitches[4], uint32_t offsets[4],
- uint32_t *buf_id, uint32_t flags)
-{
- return drmModeAddFB2WithModifiers(fd, width, height,
- pixel_format, bo_handles,
- pitches, offsets, NULL,
- buf_id, flags);
-}
-
int drmModeRmFB(int fd, uint32_t bufferId)
{
return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
@@ -488,13 +475,12 @@ _drmModeGetConnector(int fd, uint32_t connector_id, int probe)
{
struct drm_mode_get_connector conn, counts;
drmModeConnectorPtr r = NULL;
- struct drm_mode_modeinfo stack_mode;
memclear(conn);
conn.connector_id = connector_id;
if (!probe) {
conn.count_modes = 1;
- conn.modes_ptr = VOID2U64(&stack_mode);
+ conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo)));
}
if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
@@ -518,7 +504,7 @@ retry:
goto err_allocs;
} else {
conn.count_modes = 1;
- conn.modes_ptr = VOID2U64(&stack_mode);
+ conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo)));
}
if (conn.count_encoders) {
@@ -539,8 +525,7 @@ retry:
counts.count_encoders < conn.count_encoders) {
drmFree(U642VOID(conn.props_ptr));
drmFree(U642VOID(conn.prop_values_ptr));
- if (U642VOID(conn.modes_ptr) != &stack_mode)
- drmFree(U642VOID(conn.modes_ptr));
+ drmFree(U642VOID(conn.modes_ptr));
drmFree(U642VOID(conn.encoders_ptr));
goto retry;
@@ -582,8 +567,7 @@ retry:
err_allocs:
drmFree(U642VOID(conn.prop_values_ptr));
drmFree(U642VOID(conn.props_ptr));
- if (U642VOID(conn.modes_ptr) != &stack_mode)
- drmFree(U642VOID(conn.modes_ptr));
+ drmFree(U642VOID(conn.modes_ptr));
drmFree(U642VOID(conn.encoders_ptr));
return r;
@@ -974,15 +958,15 @@ int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETPLANE, &s);
}
-static drmModePlanePtr get_plane(unsigned long cmd, int fd, uint32_t plane_id)
+drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id)
{
- struct drm_mode_get_plane2 ovr, counts;
+ struct drm_mode_get_plane ovr, counts;
drmModePlanePtr r = 0;
retry:
memclear(ovr);
ovr.plane_id = plane_id;
- if (drmIoctl(fd, cmd, &ovr))
+ if (drmIoctl(fd, DRM_IOCTL_MODE_GETPLANE, &ovr))
return 0;
counts = ovr;
@@ -994,21 +978,11 @@ retry:
goto err_allocs;
}
- if (ovr.count_format_modifiers) {
- ovr.format_modifier_ptr =
- VOID2U64(drmMalloc(ovr.count_format_modifiers *
- sizeof(struct drm_format_modifier)));
- if (!ovr.format_modifier_ptr)
- goto err_allocs;
- }
-
- if (drmIoctl(fd, cmd, &ovr))
+ if (drmIoctl(fd, DRM_IOCTL_MODE_GETPLANE, &ovr))
goto err_allocs;
- if (counts.count_format_types < ovr.count_format_types ||
- counts.count_format_modifiers < ovr.count_format_modifiers) {
+ if (counts.count_format_types < ovr.count_format_types) {
drmFree(U642VOID(ovr.format_type_ptr));
- drmFree(U642VOID(ovr.format_modifier_ptr));
goto retry;
}
@@ -1016,7 +990,6 @@ retry:
goto err_allocs;
r->count_formats = ovr.count_format_types;
- r->count_format_modifiers = ovr.count_format_modifiers;
r->plane_id = ovr.plane_id;
r->crtc_id = ovr.crtc_id;
r->fb_id = ovr.fb_id;
@@ -1028,48 +1001,20 @@ retry:
drmFree(r->formats);
drmFree(r);
r = 0;
- goto err_allocs;
- }
-
- r->format_modifiers =
- drmAllocCpy(U642VOID(ovr.format_modifier_ptr),
- ovr.count_format_modifiers,
- sizeof(struct drm_format_modifier));
- if (ovr.count_format_modifiers && !r->format_modifiers) {
- drmFree(r->formats);
- drmFree(r);
- r = 0;
}
err_allocs:
drmFree(U642VOID(ovr.format_type_ptr));
- drmFree(U642VOID(ovr.format_modifier_ptr));
return r;
}
-drmModePlanePtr drmModeGetPlane2(int fd, uint32_t plane_id)
-{
- drmModePlanePtr r = get_plane(DRM_IOCTL_MODE_GETPLANE2, fd, plane_id);
-
- if (r || errno != EINVAL)
- return r;
-
- return get_plane(DRM_IOCTL_MODE_GETPLANE, fd, plane_id);
-}
-
-drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id)
-{
- return get_plane(DRM_IOCTL_MODE_GETPLANE, fd, plane_id);
-}
-
void drmModeFreePlane(drmModePlanePtr ptr)
{
if (!ptr)
return;
drmFree(ptr->formats);
- drmFree(ptr->format_modifiers);
drmFree(ptr);
}
diff --git a/chromium/third_party/libdrm/src/xf86drmMode.h b/chromium/third_party/libdrm/src/xf86drmMode.h
index 3ecc2eb4e68..4de7bbbe541 100644
--- a/chromium/third_party/libdrm/src/xf86drmMode.h
+++ b/chromium/third_party/libdrm/src/xf86drmMode.h
@@ -328,9 +328,6 @@ typedef struct _drmModePlane {
uint32_t possible_crtcs;
uint32_t gamma_size;
-
- uint32_t count_format_modifiers;
- struct drm_format_modifier *format_modifiers;
} drmModePlane, *drmModePlanePtr;
typedef struct _drmModePlaneRes {
@@ -372,13 +369,6 @@ extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
uint32_t pixel_format, uint32_t bo_handles[4],
uint32_t pitches[4], uint32_t offsets[4],
uint32_t *buf_id, uint32_t flags);
-
-/* ...with format modifiers */
-int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
- uint32_t pixel_format, uint32_t bo_handles[4],
- uint32_t pitches[4], uint32_t offsets[4],
- uint64_t modifier[4], uint32_t *buf_id, uint32_t flags);
-
/**
* Destroies the given framebuffer.
*/
@@ -479,7 +469,6 @@ extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
extern drmModePlaneResPtr drmModeGetPlaneResources(int fd);
extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id);
-extern drmModePlanePtr drmModeGetPlane2(int fd, uint32_t plane_id);
extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
uint32_t fb_id, uint32_t flags,
int32_t crtc_x, int32_t crtc_y,
diff --git a/chromium/third_party/libxslt/linux/COPYING b/chromium/third_party/libxslt/linux/COPYING
index 0e91a5bd163..627eeff982f 120000..100644
--- a/chromium/third_party/libxslt/linux/COPYING
+++ b/chromium/third_party/libxslt/linux/COPYING
@@ -1 +1,53 @@
-../src/Copyright \ No newline at end of file
+Licence for libxslt except libexslt
+----------------------------------------------------------------------
+ Copyright (C) 2001-2002 Daniel Veillard. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Daniel Veillard shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from him.
+
+----------------------------------------------------------------------
+
+Licence for libexslt
+----------------------------------------------------------------------
+ Copyright (C) 2001-2002 Thomas Broyer, Charlie Bozeman and Daniel Veillard.
+ All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the authors shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from him.
+----------------------------------------------------------------------
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/d3d1x/w32api b/chromium/third_party/mesa/src/src/gallium/state_trackers/d3d1x/w32api
deleted file mode 120000
index e47a1989e10..00000000000
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/d3d1x/w32api
+++ /dev/null
@@ -1 +0,0 @@
-/usr/include/wine/windows \ No newline at end of file
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_context.c b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_context.c
index 5cfbbaeb068..040382698b1 120000..100644
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_context.c
+++ b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_context.c
@@ -1 +1,266 @@
-../common/dri_context.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "utils.h"
+
+#include "dri_screen.h"
+#include "dri_drawable.h"
+#include "dri_context.h"
+#include "state_tracker/drm_driver.h"
+
+#include "pipe/p_context.h"
+#include "state_tracker/st_context.h"
+
+static void
+dri_pp_query(struct dri_context *ctx)
+{
+ unsigned int i;
+
+ for (i = 0; i < PP_FILTERS; i++) {
+ ctx->pp_enabled[i] = driQueryOptioni(&ctx->optionCache, pp_filters[i].name);
+ }
+}
+
+static void dri_fill_st_options(struct st_config_options *options,
+ const struct driOptionCache * optionCache)
+{
+ options->force_glsl_extensions_warn =
+ driQueryOptionb(optionCache, "force_glsl_extensions_warn");
+}
+
+GLboolean
+dri_create_context(gl_api api, const struct gl_config * visual,
+ __DRIcontext * cPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate)
+{
+ __DRIscreen *sPriv = cPriv->driScreenPriv;
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
+ struct dri_context *ctx = NULL;
+ struct st_context_iface *st_share = NULL;
+ struct st_context_attribs attribs;
+ enum st_context_error ctx_err = 0;
+
+ memset(&attribs, 0, sizeof(attribs));
+ switch (api) {
+ case API_OPENGLES:
+ attribs.profile = ST_PROFILE_OPENGL_ES1;
+ break;
+ case API_OPENGLES2:
+ attribs.profile = ST_PROFILE_OPENGL_ES2;
+ break;
+ case API_OPENGL:
+ attribs.profile = ST_PROFILE_DEFAULT;
+ attribs.major = major_version;
+ attribs.minor = minor_version;
+
+ if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
+ attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+
+ if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
+ attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
+ break;
+ default:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ goto fail;
+ }
+
+ if (sharedContextPrivate) {
+ st_share = ((struct dri_context *)sharedContextPrivate)->st;
+ }
+
+ ctx = CALLOC_STRUCT(dri_context);
+ if (ctx == NULL) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
+ goto fail;
+ }
+
+ cPriv->driverPrivate = ctx;
+ ctx->cPriv = cPriv;
+ ctx->sPriv = sPriv;
+
+ driParseConfigFiles(&ctx->optionCache,
+ &screen->optionCache, sPriv->myNum, driver_descriptor.name);
+
+ dri_fill_st_options(&attribs.options, &ctx->optionCache);
+ dri_fill_st_visual(&attribs.visual, screen, visual);
+ ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
+ st_share);
+ if (ctx->st == NULL) {
+ switch (ctx_err) {
+ case ST_CONTEXT_SUCCESS:
+ *error = __DRI_CTX_ERROR_SUCCESS;
+ break;
+ case ST_CONTEXT_ERROR_NO_MEMORY:
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
+ break;
+ case ST_CONTEXT_ERROR_BAD_API:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ break;
+ case ST_CONTEXT_ERROR_BAD_VERSION:
+ *error = __DRI_CTX_ERROR_BAD_VERSION;
+ break;
+ case ST_CONTEXT_ERROR_BAD_FLAG:
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ break;
+ case ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE:
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ break;
+ case ST_CONTEXT_ERROR_UNKNOWN_FLAG:
+ *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+ break;
+ }
+ goto fail;
+ }
+ ctx->st->st_manager_private = (void *) ctx;
+ ctx->stapi = stapi;
+
+ // Context successfully created. See if post-processing is requested.
+ dri_pp_query(ctx);
+
+ ctx->pp = pp_init(screen->base.screen, ctx->pp_enabled);
+
+ *error = __DRI_CTX_ERROR_SUCCESS;
+ return GL_TRUE;
+
+ fail:
+ if (ctx && ctx->st)
+ ctx->st->destroy(ctx->st);
+
+ FREE(ctx);
+ return GL_FALSE;
+}
+
+void
+dri_destroy_context(__DRIcontext * cPriv)
+{
+ struct dri_context *ctx = dri_context(cPriv);
+
+ /* note: we are freeing values and nothing more because
+ * driParseConfigFiles allocated values only - the rest
+ * is owned by screen optionCache.
+ */
+ FREE(ctx->optionCache.values);
+
+ /* No particular reason to wait for command completion before
+ * destroying a context, but we flush the context here
+ * to avoid having to add code elsewhere to cope with flushing a
+ * partially destroyed context.
+ */
+ ctx->st->flush(ctx->st, 0, NULL);
+ ctx->st->destroy(ctx->st);
+
+ if (ctx->pp) pp_free(ctx->pp);
+
+ FREE(ctx);
+}
+
+GLboolean
+dri_unbind_context(__DRIcontext * cPriv)
+{
+ /* dri_util.c ensures cPriv is not null */
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct dri_context *ctx = dri_context(cPriv);
+ struct st_api *stapi = screen->st_api;
+
+ if (--ctx->bind_count == 0) {
+ if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
+ /* For conformance, unbind is supposed to flush the context.
+ * However, if we do it here we might end up flushing a partially
+ * destroyed context. Instead, we flush in dri_make_current and
+ * in dri_destroy_context which should cover all the cases.
+ */
+ stapi->make_current(stapi, NULL, NULL, NULL);
+ }
+ }
+
+ return GL_TRUE;
+}
+
+GLboolean
+dri_make_current(__DRIcontext * cPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv)
+{
+ /* dri_util.c ensures cPriv is not null */
+ struct dri_context *ctx = dri_context(cPriv);
+ struct dri_drawable *draw = dri_drawable(driDrawPriv);
+ struct dri_drawable *read = dri_drawable(driReadPriv);
+ struct st_context_iface *old_st = ctx->stapi->get_current(ctx->stapi);
+
+ /* Flush the old context here so we don't have to flush on unbind() */
+ if (old_st && old_st != ctx->st)
+ old_st->flush(old_st, ST_FLUSH_FRONT, NULL);
+
+ ++ctx->bind_count;
+
+ if (!driDrawPriv && !driReadPriv)
+ return ctx->stapi->make_current(ctx->stapi, ctx->st, NULL, NULL);
+ else if (!driDrawPriv || !driReadPriv)
+ return GL_FALSE;
+
+ if (ctx->dPriv != driDrawPriv) {
+ ctx->dPriv = driDrawPriv;
+ draw->texture_stamp = driDrawPriv->lastStamp - 1;
+ }
+ if (ctx->rPriv != driReadPriv) {
+ ctx->rPriv = driReadPriv;
+ read->texture_stamp = driReadPriv->lastStamp - 1;
+ }
+
+ ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base);
+
+ // This is ok to call here. If they are already init, it's a no-op.
+ if (draw->textures[ST_ATTACHMENT_BACK_LEFT] && draw->textures[ST_ATTACHMENT_DEPTH_STENCIL]
+ && ctx->pp)
+ pp_init_fbos(ctx->pp, draw->textures[ST_ATTACHMENT_BACK_LEFT]->width0,
+ draw->textures[ST_ATTACHMENT_BACK_LEFT]->height0);
+
+ return GL_TRUE;
+}
+
+struct dri_context *
+dri_get_current(__DRIscreen *sPriv)
+{
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
+ struct st_context_iface *st;
+
+ st = stapi->get_current(stapi);
+
+ return (struct dri_context *) (st) ? st->st_manager_private : NULL;
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_drawable.c b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_drawable.c
index 0fc19be6ea6..5a261ddb300 120000..100644
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_drawable.c
+++ b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_drawable.c
@@ -1 +1,402 @@
-../common/dri_drawable.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+
+#include "pipe/p_screen.h"
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+static void
+swap_fences_unref(struct dri_drawable *draw);
+
+static boolean
+dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+ const enum st_attachment_type *statts,
+ unsigned count,
+ struct pipe_resource **out)
+{
+ struct dri_drawable *drawable =
+ (struct dri_drawable *) stfbi->st_manager_private;
+ struct dri_screen *screen = dri_screen(drawable->sPriv);
+ unsigned statt_mask, new_mask;
+ boolean new_stamp;
+ int i;
+ unsigned int lastStamp;
+
+ statt_mask = 0x0;
+ for (i = 0; i < count; i++)
+ statt_mask |= (1 << statts[i]);
+
+ /* record newly allocated textures */
+ new_mask = (statt_mask & ~drawable->texture_mask);
+
+ /*
+ * dPriv->dri2.stamp is the server stamp. dPriv->lastStamp is the
+ * client stamp. It has the value of the server stamp when last
+ * checked.
+ */
+ do {
+ lastStamp = drawable->dPriv->lastStamp;
+ new_stamp = (drawable->texture_stamp != lastStamp);
+
+ if (new_stamp || new_mask || screen->broken_invalidate) {
+ if (new_stamp && drawable->update_drawable_info)
+ drawable->update_drawable_info(drawable);
+
+ drawable->allocate_textures(drawable, statts, count);
+
+ /* add existing textures */
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ if (drawable->textures[i])
+ statt_mask |= (1 << i);
+ }
+
+ drawable->texture_stamp = lastStamp;
+ drawable->texture_mask = statt_mask;
+ }
+ } while (lastStamp != drawable->dPriv->lastStamp);
+
+ if (!out)
+ return TRUE;
+
+ for (i = 0; i < count; i++) {
+ out[i] = NULL;
+ pipe_resource_reference(&out[i], drawable->textures[statts[i]]);
+ }
+
+ return TRUE;
+}
+
+static boolean
+dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
+ enum st_attachment_type statt)
+{
+ struct dri_drawable *drawable =
+ (struct dri_drawable *) stfbi->st_manager_private;
+
+ /* XXX remove this and just set the correct one on the framebuffer */
+ drawable->flush_frontbuffer(drawable, statt);
+
+ return TRUE;
+}
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+boolean
+dri_create_buffer(__DRIscreen * sPriv,
+ __DRIdrawable * dPriv,
+ const struct gl_config * visual, boolean isPixmap)
+{
+ struct dri_screen *screen = sPriv->driverPrivate;
+ struct dri_drawable *drawable = NULL;
+
+ if (isPixmap)
+ goto fail; /* not implemented */
+
+ drawable = CALLOC_STRUCT(dri_drawable);
+ if (drawable == NULL)
+ goto fail;
+
+ dri_fill_st_visual(&drawable->stvis, screen, visual);
+
+ /* setup the st_framebuffer_iface */
+ drawable->base.visual = &drawable->stvis;
+ drawable->base.flush_front = dri_st_framebuffer_flush_front;
+ drawable->base.validate = dri_st_framebuffer_validate;
+ drawable->base.st_manager_private = (void *) drawable;
+
+ drawable->screen = screen;
+ drawable->sPriv = sPriv;
+ drawable->dPriv = dPriv;
+ drawable->desired_fences = screen->default_throttle_frames;
+ if (drawable->desired_fences > DRI_SWAP_FENCES_MAX)
+ drawable->desired_fences = DRI_SWAP_FENCES_MAX;
+
+ dPriv->driverPrivate = (void *)drawable;
+ p_atomic_set(&drawable->base.stamp, 1);
+
+ return GL_TRUE;
+fail:
+ FREE(drawable);
+ return GL_FALSE;
+}
+
+void
+dri_destroy_buffer(__DRIdrawable * dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ int i;
+
+ pipe_surface_reference(&drawable->drisw_surface, NULL);
+
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+ pipe_resource_reference(&drawable->textures[i], NULL);
+
+ swap_fences_unref(drawable);
+
+ FREE(drawable);
+}
+
+/**
+ * Validate the texture at an attachment. Allocate the texture if it does not
+ * exist. Used by the TFP extension.
+ */
+static void
+dri_drawable_validate_att(struct dri_drawable *drawable,
+ enum st_attachment_type statt)
+{
+ enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
+ unsigned i, count = 0;
+
+ /* check if buffer already exists */
+ if (drawable->texture_mask & (1 << statt))
+ return;
+
+ /* make sure DRI2 does not destroy existing buffers */
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ if (drawable->texture_mask & (1 << i)) {
+ statts[count++] = i;
+ }
+ }
+ statts[count++] = statt;
+
+ drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
+
+ drawable->base.validate(&drawable->base, statts, count, NULL);
+}
+
+/**
+ * These are used for GLX_EXT_texture_from_pixmap
+ */
+static void
+dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
+ GLint format, __DRIdrawable *dPriv)
+{
+ struct dri_context *ctx = dri_context(pDRICtx);
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct pipe_resource *pt;
+
+ dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
+
+ /* Use the pipe resource associated with the X drawable */
+ pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
+
+ if (pt) {
+ enum pipe_format internal_format = pt->format;
+
+ if (format == __DRI_TEXTURE_FORMAT_RGB) {
+ /* only need to cover the formats recognized by dri_fill_st_visual */
+ switch (internal_format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ internal_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ break;
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ internal_format = PIPE_FORMAT_X8R8G8B8_UNORM;
+ break;
+ default:
+ break;
+ }
+ }
+
+ drawable->update_tex_buffer(drawable, ctx, pt);
+
+ ctx->st->teximage(ctx->st,
+ (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT,
+ 0, internal_format, pt, FALSE);
+ }
+}
+
+static void
+dri_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
+ __DRIdrawable *dPriv)
+{
+ dri_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
+}
+
+const __DRItexBufferExtension driTexBufferExtension = {
+ { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+ dri_set_tex_buffer,
+ dri_set_tex_buffer2,
+ NULL,
+};
+
+/**
+ * Get the format and binding of an attachment.
+ */
+void
+dri_drawable_get_format(struct dri_drawable *drawable,
+ enum st_attachment_type statt,
+ enum pipe_format *format,
+ unsigned *bind)
+{
+ switch (statt) {
+ case ST_ATTACHMENT_FRONT_LEFT:
+ case ST_ATTACHMENT_BACK_LEFT:
+ case ST_ATTACHMENT_FRONT_RIGHT:
+ case ST_ATTACHMENT_BACK_RIGHT:
+ *format = drawable->stvis.color_format;
+ *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+ case ST_ATTACHMENT_DEPTH_STENCIL:
+ *format = drawable->stvis.depth_stencil_format;
+ *bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
+ break;
+ default:
+ *format = PIPE_FORMAT_NONE;
+ *bind = 0;
+ break;
+ }
+}
+
+
+/**
+ * swap_fences_pop_front - pull a fence from the throttle queue
+ *
+ * If the throttle queue is filled to the desired number of fences,
+ * pull fences off the queue until the number is less than the desired
+ * number of fences, and return the last fence pulled.
+ */
+static struct pipe_fence_handle *
+swap_fences_pop_front(struct dri_drawable *draw)
+{
+ struct pipe_screen *screen = draw->screen->base.screen;
+ struct pipe_fence_handle *fence = NULL;
+
+ if (draw->desired_fences == 0)
+ return NULL;
+
+ if (draw->cur_fences >= draw->desired_fences) {
+ screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]);
+ screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
+ draw->tail &= DRI_SWAP_FENCES_MASK;
+ --draw->cur_fences;
+ }
+ return fence;
+}
+
+
+/**
+ * swap_fences_push_back - push a fence onto the throttle queue
+ *
+ * push a fence onto the throttle queue and pull fences of the queue
+ * so that the desired number of fences are on the queue.
+ */
+static void
+swap_fences_push_back(struct dri_drawable *draw,
+ struct pipe_fence_handle *fence)
+{
+ struct pipe_screen *screen = draw->screen->base.screen;
+
+ if (!fence || draw->desired_fences == 0)
+ return;
+
+ while(draw->cur_fences == draw->desired_fences)
+ swap_fences_pop_front(draw);
+
+ draw->cur_fences++;
+ screen->fence_reference(screen, &draw->swap_fences[draw->head++],
+ fence);
+ draw->head &= DRI_SWAP_FENCES_MASK;
+}
+
+
+/**
+ * swap_fences_unref - empty the throttle queue
+ *
+ * pulls fences of the throttle queue until it is empty.
+ */
+static void
+swap_fences_unref(struct dri_drawable *draw)
+{
+ struct pipe_screen *screen = draw->screen->base.screen;
+
+ while(draw->cur_fences) {
+ screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
+ draw->tail &= DRI_SWAP_FENCES_MASK;
+ --draw->cur_fences;
+ }
+}
+
+
+/**
+ * dri_throttle - A DRI2ThrottleExtension throttling function.
+ *
+ * pulls a fence off the throttling queue and waits for it if the
+ * number of fences on the throttling queue has reached the desired
+ * number.
+ *
+ * Then flushes to insert a fence at the current rendering position, and
+ * pushes that fence on the queue. This requires that the st_context_iface
+ * flush method returns a fence even if there are no commands to flush.
+ */
+static void
+dri_throttle(__DRIcontext *driCtx, __DRIdrawable *dPriv,
+ enum __DRI2throttleReason reason)
+{
+ struct dri_drawable *draw = dri_drawable(dPriv);
+ struct st_context_iface *ctxi;
+ struct pipe_screen *screen = draw->screen->base.screen;
+ struct pipe_fence_handle *fence;
+
+ if (reason != __DRI2_THROTTLE_SWAPBUFFER &&
+ reason != __DRI2_THROTTLE_FLUSHFRONT)
+ return;
+
+ fence = swap_fences_pop_front(draw);
+ if (fence) {
+ (void) screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+
+ if (driCtx == NULL)
+ return;
+
+ ctxi = dri_context(driCtx)->st;
+ ctxi->flush(ctxi, 0, &fence);
+ if (fence) {
+ swap_fences_push_back(draw, fence);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+}
+
+
+const __DRI2throttleExtension dri2ThrottleExtension = {
+ .base = { __DRI2_THROTTLE, __DRI2_THROTTLE_VERSION },
+ .throttle = dri_throttle,
+};
+
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_screen.c b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_screen.c
index 847f6515f25..102a1326133 120000..100644
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_screen.c
+++ b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/drm/dri_screen.c
@@ -1 +1,420 @@
-../common/dri_screen.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "utils.h"
+#include "xmlpool.h"
+
+#include "dri_screen.h"
+
+#include "util/u_inlines.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_format.h"
+#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
+
+#include "util/u_debug.h"
+
+#define MSAA_VISUAL_MAX_SAMPLES 8
+
+#undef false
+
+PUBLIC const char __driConfigOptions[] =
+ DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+
+ DRI_CONF_SECTION_QUALITY
+/* DRI_CONF_FORCE_S3TC_ENABLE(false) */
+ DRI_CONF_ALLOW_LARGE_TEXTURES(1)
+ DRI_CONF_PP_CELSHADE(0)
+ DRI_CONF_PP_NORED(0)
+ DRI_CONF_PP_NOGREEN(0)
+ DRI_CONF_PP_NOBLUE(0)
+ DRI_CONF_PP_JIMENEZMLAA(0, 0, 32)
+ DRI_CONF_PP_JIMENEZMLAA_COLOR(0, 0, 32)
+ DRI_CONF_SECTION_END
+
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN(false)
+ DRI_CONF_SECTION_END
+
+ DRI_CONF_END;
+
+#define false 0
+
+static const uint __driNConfigOptions = 10;
+
+static const __DRIconfig **
+dri_fill_in_modes(struct dri_screen *screen,
+ unsigned pixel_bits)
+{
+ __DRIconfig **configs = NULL;
+ __DRIconfig **configs_r5g6b5 = NULL;
+ __DRIconfig **configs_a8r8g8b8 = NULL;
+ __DRIconfig **configs_x8r8g8b8 = NULL;
+ uint8_t depth_bits_array[5];
+ uint8_t stencil_bits_array[5];
+ uint8_t msaa_samples_array[MSAA_VISUAL_MAX_SAMPLES];
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ unsigned msaa_samples_factor, msaa_samples_max;
+ unsigned i;
+ struct pipe_screen *p_screen = screen->base.screen;
+ boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8;
+ boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
+
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ depth_bits_array[0] = 0;
+ stencil_bits_array[0] = 0;
+ depth_buffer_factor = 1;
+
+ msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS)
+ ? MSAA_VISUAL_MAX_SAMPLES : 1;
+
+ pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_UINT,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_UINT_Z24_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET);
+ pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET);
+ pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET);
+
+ /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
+ if (dri_with_format(screen->sPriv)) {
+ pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ } else {
+ pf_z16 = FALSE;
+ pf_z32 = FALSE;
+ }
+
+ if (pf_z16) {
+ depth_bits_array[depth_buffer_factor] = 16;
+ stencil_bits_array[depth_buffer_factor++] = 0;
+ }
+ if (pf_x8z24 || pf_z24x8) {
+ depth_bits_array[depth_buffer_factor] = 24;
+ stencil_bits_array[depth_buffer_factor++] = 0;
+ screen->d_depth_bits_last = pf_x8z24;
+ }
+ if (pf_s8z24 || pf_z24s8) {
+ depth_bits_array[depth_buffer_factor] = 24;
+ stencil_bits_array[depth_buffer_factor++] = 8;
+ screen->sd_depth_bits_last = pf_s8z24;
+ }
+ if (pf_z32) {
+ depth_bits_array[depth_buffer_factor] = 32;
+ stencil_bits_array[depth_buffer_factor++] = 0;
+ }
+
+ msaa_samples_array[0] = 0;
+ back_buffer_factor = 3;
+
+ /* Also test for color multisample support - just assume it'll work
+ * for all depth buffers.
+ */
+ if (pf_r5g6b5) {
+ msaa_samples_factor = 1;
+ for (i = 2; i <= msaa_samples_max; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET)) {
+ msaa_samples_array[msaa_samples_factor] = i;
+ msaa_samples_factor++;
+ }
+ }
+
+ configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor, back_buffer_modes,
+ back_buffer_factor,
+ msaa_samples_array, msaa_samples_factor,
+ GL_TRUE);
+ }
+
+ if (pf_a8r8g8b8) {
+ msaa_samples_factor = 1;
+ for (i = 2; i <= msaa_samples_max; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET)) {
+ msaa_samples_array[msaa_samples_factor] = i;
+ msaa_samples_factor++;
+ }
+ }
+
+ configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+ depth_bits_array,
+ stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes,
+ back_buffer_factor,
+ msaa_samples_array,
+ msaa_samples_factor,
+ GL_TRUE);
+ }
+
+ if (pf_x8r8g8b8) {
+ msaa_samples_factor = 1;
+ for (i = 2; i <= msaa_samples_max; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET)) {
+ msaa_samples_array[msaa_samples_factor] = i;
+ msaa_samples_factor++;
+ }
+ }
+
+ configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
+ depth_bits_array,
+ stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes,
+ back_buffer_factor,
+ msaa_samples_array,
+ msaa_samples_factor,
+ GL_TRUE);
+ }
+
+ if (pixel_bits == 16) {
+ configs = configs_r5g6b5;
+ configs = driConcatConfigs(configs, configs_a8r8g8b8);
+ configs = driConcatConfigs(configs, configs_x8r8g8b8);
+ } else {
+ configs = configs_a8r8g8b8;
+ configs = driConcatConfigs(configs, configs_x8r8g8b8);
+ configs = driConcatConfigs(configs, configs_r5g6b5);
+ }
+
+ if (configs == NULL) {
+ debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
+ return NULL;
+ }
+
+ return (const __DRIconfig **)configs;
+}
+
+/**
+ * Roughly the converse of dri_fill_in_modes.
+ */
+void
+dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
+ const struct gl_config *mode)
+{
+ memset(stvis, 0, sizeof(*stvis));
+
+ if (!mode)
+ return;
+
+ stvis->samples = mode->samples;
+
+ if (mode->redBits == 8) {
+ if (mode->alphaBits == 8)
+ stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ else
+ stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ } else {
+ stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM;
+ }
+
+ switch (mode->depthBits) {
+ default:
+ case 0:
+ stvis->depth_stencil_format = PIPE_FORMAT_NONE;
+ break;
+ case 16:
+ stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM;
+ break;
+ case 24:
+ if (mode->stencilBits == 0) {
+ stvis->depth_stencil_format = (screen->d_depth_bits_last) ?
+ PIPE_FORMAT_Z24X8_UNORM:
+ PIPE_FORMAT_X8Z24_UNORM;
+ } else {
+ stvis->depth_stencil_format = (screen->sd_depth_bits_last) ?
+ PIPE_FORMAT_Z24_UNORM_S8_UINT:
+ PIPE_FORMAT_S8_UINT_Z24_UNORM;
+ }
+ break;
+ case 32:
+ stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
+ break;
+ }
+
+ stvis->accum_format = (mode->haveAccumBuffer) ?
+ PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE;
+
+ stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK;
+ stvis->render_buffer = ST_ATTACHMENT_FRONT_LEFT;
+ if (mode->doubleBufferMode) {
+ stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
+ stvis->render_buffer = ST_ATTACHMENT_BACK_LEFT;
+ }
+ if (mode->stereoMode) {
+ stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
+ if (mode->doubleBufferMode)
+ stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
+ }
+
+ if (mode->haveDepthBuffer || mode->haveStencilBuffer)
+ stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK;
+ /* let the state tracker allocate the accum buffer */
+}
+
+static boolean
+dri_get_egl_image(struct st_manager *smapi,
+ void *egl_image,
+ struct st_egl_image *stimg)
+{
+ struct dri_screen *screen = (struct dri_screen *)smapi;
+ __DRIimage *img = NULL;
+
+ if (screen->lookup_egl_image) {
+ img = screen->lookup_egl_image(screen, egl_image);
+ }
+
+ if (!img)
+ return FALSE;
+
+ stimg->texture = NULL;
+ pipe_resource_reference(&stimg->texture, img->texture);
+ stimg->level = img->level;
+ stimg->layer = img->layer;
+
+ return TRUE;
+}
+
+static int
+dri_get_param(struct st_manager *smapi,
+ enum st_manager_param param)
+{
+ struct dri_screen *screen = (struct dri_screen *)smapi;
+
+ switch(param) {
+ case ST_MANAGER_BROKEN_INVALIDATE:
+ return screen->broken_invalidate;
+ default:
+ return 0;
+ }
+}
+
+static void
+dri_destroy_option_cache(struct dri_screen * screen)
+{
+ int i;
+
+ if (screen->optionCache.info) {
+ for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
+ FREE(screen->optionCache.info[i].name);
+ FREE(screen->optionCache.info[i].ranges);
+ }
+ FREE(screen->optionCache.info);
+ }
+
+ FREE(screen->optionCache.values);
+}
+
+void
+dri_destroy_screen_helper(struct dri_screen * screen)
+{
+ if (screen->st_api && screen->st_api->destroy)
+ screen->st_api->destroy(screen->st_api);
+
+ if (screen->base.screen)
+ screen->base.screen->destroy(screen->base.screen);
+
+ dri_destroy_option_cache(screen);
+}
+
+void
+dri_destroy_screen(__DRIscreen * sPriv)
+{
+ struct dri_screen *screen = dri_screen(sPriv);
+
+ dri_destroy_screen_helper(screen);
+
+ FREE(screen);
+ sPriv->driverPrivate = NULL;
+ sPriv->extensions = NULL;
+}
+
+const __DRIconfig **
+dri_init_screen_helper(struct dri_screen *screen,
+ struct pipe_screen *pscreen,
+ unsigned pixel_bits)
+{
+ screen->base.screen = pscreen;
+ if (!screen->base.screen) {
+ debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
+ return NULL;
+ }
+
+ screen->base.get_egl_image = dri_get_egl_image;
+ screen->base.get_param = dri_get_param;
+
+ screen->st_api = st_gl_api_create();
+ if (!screen->st_api)
+ return NULL;
+
+ if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))
+ screen->target = PIPE_TEXTURE_2D;
+ else
+ screen->target = PIPE_TEXTURE_RECT;
+
+ driParseOptionInfo(&screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ return dri_fill_in_modes(screen, pixel_bits);
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_context.c b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_context.c
index 5cfbbaeb068..040382698b1 120000..100644
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_context.c
+++ b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_context.c
@@ -1 +1,266 @@
-../common/dri_context.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "utils.h"
+
+#include "dri_screen.h"
+#include "dri_drawable.h"
+#include "dri_context.h"
+#include "state_tracker/drm_driver.h"
+
+#include "pipe/p_context.h"
+#include "state_tracker/st_context.h"
+
+static void
+dri_pp_query(struct dri_context *ctx)
+{
+ unsigned int i;
+
+ for (i = 0; i < PP_FILTERS; i++) {
+ ctx->pp_enabled[i] = driQueryOptioni(&ctx->optionCache, pp_filters[i].name);
+ }
+}
+
+static void dri_fill_st_options(struct st_config_options *options,
+ const struct driOptionCache * optionCache)
+{
+ options->force_glsl_extensions_warn =
+ driQueryOptionb(optionCache, "force_glsl_extensions_warn");
+}
+
+GLboolean
+dri_create_context(gl_api api, const struct gl_config * visual,
+ __DRIcontext * cPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate)
+{
+ __DRIscreen *sPriv = cPriv->driScreenPriv;
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
+ struct dri_context *ctx = NULL;
+ struct st_context_iface *st_share = NULL;
+ struct st_context_attribs attribs;
+ enum st_context_error ctx_err = 0;
+
+ memset(&attribs, 0, sizeof(attribs));
+ switch (api) {
+ case API_OPENGLES:
+ attribs.profile = ST_PROFILE_OPENGL_ES1;
+ break;
+ case API_OPENGLES2:
+ attribs.profile = ST_PROFILE_OPENGL_ES2;
+ break;
+ case API_OPENGL:
+ attribs.profile = ST_PROFILE_DEFAULT;
+ attribs.major = major_version;
+ attribs.minor = minor_version;
+
+ if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
+ attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+
+ if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
+ attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
+ break;
+ default:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ goto fail;
+ }
+
+ if (sharedContextPrivate) {
+ st_share = ((struct dri_context *)sharedContextPrivate)->st;
+ }
+
+ ctx = CALLOC_STRUCT(dri_context);
+ if (ctx == NULL) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
+ goto fail;
+ }
+
+ cPriv->driverPrivate = ctx;
+ ctx->cPriv = cPriv;
+ ctx->sPriv = sPriv;
+
+ driParseConfigFiles(&ctx->optionCache,
+ &screen->optionCache, sPriv->myNum, driver_descriptor.name);
+
+ dri_fill_st_options(&attribs.options, &ctx->optionCache);
+ dri_fill_st_visual(&attribs.visual, screen, visual);
+ ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
+ st_share);
+ if (ctx->st == NULL) {
+ switch (ctx_err) {
+ case ST_CONTEXT_SUCCESS:
+ *error = __DRI_CTX_ERROR_SUCCESS;
+ break;
+ case ST_CONTEXT_ERROR_NO_MEMORY:
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
+ break;
+ case ST_CONTEXT_ERROR_BAD_API:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ break;
+ case ST_CONTEXT_ERROR_BAD_VERSION:
+ *error = __DRI_CTX_ERROR_BAD_VERSION;
+ break;
+ case ST_CONTEXT_ERROR_BAD_FLAG:
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ break;
+ case ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE:
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ break;
+ case ST_CONTEXT_ERROR_UNKNOWN_FLAG:
+ *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+ break;
+ }
+ goto fail;
+ }
+ ctx->st->st_manager_private = (void *) ctx;
+ ctx->stapi = stapi;
+
+ // Context successfully created. See if post-processing is requested.
+ dri_pp_query(ctx);
+
+ ctx->pp = pp_init(screen->base.screen, ctx->pp_enabled);
+
+ *error = __DRI_CTX_ERROR_SUCCESS;
+ return GL_TRUE;
+
+ fail:
+ if (ctx && ctx->st)
+ ctx->st->destroy(ctx->st);
+
+ FREE(ctx);
+ return GL_FALSE;
+}
+
+void
+dri_destroy_context(__DRIcontext * cPriv)
+{
+ struct dri_context *ctx = dri_context(cPriv);
+
+ /* note: we are freeing values and nothing more because
+ * driParseConfigFiles allocated values only - the rest
+ * is owned by screen optionCache.
+ */
+ FREE(ctx->optionCache.values);
+
+ /* No particular reason to wait for command completion before
+ * destroying a context, but we flush the context here
+ * to avoid having to add code elsewhere to cope with flushing a
+ * partially destroyed context.
+ */
+ ctx->st->flush(ctx->st, 0, NULL);
+ ctx->st->destroy(ctx->st);
+
+ if (ctx->pp) pp_free(ctx->pp);
+
+ FREE(ctx);
+}
+
+GLboolean
+dri_unbind_context(__DRIcontext * cPriv)
+{
+ /* dri_util.c ensures cPriv is not null */
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct dri_context *ctx = dri_context(cPriv);
+ struct st_api *stapi = screen->st_api;
+
+ if (--ctx->bind_count == 0) {
+ if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
+ /* For conformance, unbind is supposed to flush the context.
+ * However, if we do it here we might end up flushing a partially
+ * destroyed context. Instead, we flush in dri_make_current and
+ * in dri_destroy_context which should cover all the cases.
+ */
+ stapi->make_current(stapi, NULL, NULL, NULL);
+ }
+ }
+
+ return GL_TRUE;
+}
+
+GLboolean
+dri_make_current(__DRIcontext * cPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv)
+{
+ /* dri_util.c ensures cPriv is not null */
+ struct dri_context *ctx = dri_context(cPriv);
+ struct dri_drawable *draw = dri_drawable(driDrawPriv);
+ struct dri_drawable *read = dri_drawable(driReadPriv);
+ struct st_context_iface *old_st = ctx->stapi->get_current(ctx->stapi);
+
+ /* Flush the old context here so we don't have to flush on unbind() */
+ if (old_st && old_st != ctx->st)
+ old_st->flush(old_st, ST_FLUSH_FRONT, NULL);
+
+ ++ctx->bind_count;
+
+ if (!driDrawPriv && !driReadPriv)
+ return ctx->stapi->make_current(ctx->stapi, ctx->st, NULL, NULL);
+ else if (!driDrawPriv || !driReadPriv)
+ return GL_FALSE;
+
+ if (ctx->dPriv != driDrawPriv) {
+ ctx->dPriv = driDrawPriv;
+ draw->texture_stamp = driDrawPriv->lastStamp - 1;
+ }
+ if (ctx->rPriv != driReadPriv) {
+ ctx->rPriv = driReadPriv;
+ read->texture_stamp = driReadPriv->lastStamp - 1;
+ }
+
+ ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base);
+
+ // This is ok to call here. If they are already init, it's a no-op.
+ if (draw->textures[ST_ATTACHMENT_BACK_LEFT] && draw->textures[ST_ATTACHMENT_DEPTH_STENCIL]
+ && ctx->pp)
+ pp_init_fbos(ctx->pp, draw->textures[ST_ATTACHMENT_BACK_LEFT]->width0,
+ draw->textures[ST_ATTACHMENT_BACK_LEFT]->height0);
+
+ return GL_TRUE;
+}
+
+struct dri_context *
+dri_get_current(__DRIscreen *sPriv)
+{
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
+ struct st_context_iface *st;
+
+ st = stapi->get_current(stapi);
+
+ return (struct dri_context *) (st) ? st->st_manager_private : NULL;
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_drawable.c b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_drawable.c
index 0fc19be6ea6..5a261ddb300 120000..100644
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_drawable.c
+++ b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_drawable.c
@@ -1 +1,402 @@
-../common/dri_drawable.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+
+#include "pipe/p_screen.h"
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+static void
+swap_fences_unref(struct dri_drawable *draw);
+
+static boolean
+dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+ const enum st_attachment_type *statts,
+ unsigned count,
+ struct pipe_resource **out)
+{
+ struct dri_drawable *drawable =
+ (struct dri_drawable *) stfbi->st_manager_private;
+ struct dri_screen *screen = dri_screen(drawable->sPriv);
+ unsigned statt_mask, new_mask;
+ boolean new_stamp;
+ int i;
+ unsigned int lastStamp;
+
+ statt_mask = 0x0;
+ for (i = 0; i < count; i++)
+ statt_mask |= (1 << statts[i]);
+
+ /* record newly allocated textures */
+ new_mask = (statt_mask & ~drawable->texture_mask);
+
+ /*
+ * dPriv->dri2.stamp is the server stamp. dPriv->lastStamp is the
+ * client stamp. It has the value of the server stamp when last
+ * checked.
+ */
+ do {
+ lastStamp = drawable->dPriv->lastStamp;
+ new_stamp = (drawable->texture_stamp != lastStamp);
+
+ if (new_stamp || new_mask || screen->broken_invalidate) {
+ if (new_stamp && drawable->update_drawable_info)
+ drawable->update_drawable_info(drawable);
+
+ drawable->allocate_textures(drawable, statts, count);
+
+ /* add existing textures */
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ if (drawable->textures[i])
+ statt_mask |= (1 << i);
+ }
+
+ drawable->texture_stamp = lastStamp;
+ drawable->texture_mask = statt_mask;
+ }
+ } while (lastStamp != drawable->dPriv->lastStamp);
+
+ if (!out)
+ return TRUE;
+
+ for (i = 0; i < count; i++) {
+ out[i] = NULL;
+ pipe_resource_reference(&out[i], drawable->textures[statts[i]]);
+ }
+
+ return TRUE;
+}
+
+static boolean
+dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
+ enum st_attachment_type statt)
+{
+ struct dri_drawable *drawable =
+ (struct dri_drawable *) stfbi->st_manager_private;
+
+ /* XXX remove this and just set the correct one on the framebuffer */
+ drawable->flush_frontbuffer(drawable, statt);
+
+ return TRUE;
+}
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+boolean
+dri_create_buffer(__DRIscreen * sPriv,
+ __DRIdrawable * dPriv,
+ const struct gl_config * visual, boolean isPixmap)
+{
+ struct dri_screen *screen = sPriv->driverPrivate;
+ struct dri_drawable *drawable = NULL;
+
+ if (isPixmap)
+ goto fail; /* not implemented */
+
+ drawable = CALLOC_STRUCT(dri_drawable);
+ if (drawable == NULL)
+ goto fail;
+
+ dri_fill_st_visual(&drawable->stvis, screen, visual);
+
+ /* setup the st_framebuffer_iface */
+ drawable->base.visual = &drawable->stvis;
+ drawable->base.flush_front = dri_st_framebuffer_flush_front;
+ drawable->base.validate = dri_st_framebuffer_validate;
+ drawable->base.st_manager_private = (void *) drawable;
+
+ drawable->screen = screen;
+ drawable->sPriv = sPriv;
+ drawable->dPriv = dPriv;
+ drawable->desired_fences = screen->default_throttle_frames;
+ if (drawable->desired_fences > DRI_SWAP_FENCES_MAX)
+ drawable->desired_fences = DRI_SWAP_FENCES_MAX;
+
+ dPriv->driverPrivate = (void *)drawable;
+ p_atomic_set(&drawable->base.stamp, 1);
+
+ return GL_TRUE;
+fail:
+ FREE(drawable);
+ return GL_FALSE;
+}
+
+void
+dri_destroy_buffer(__DRIdrawable * dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ int i;
+
+ pipe_surface_reference(&drawable->drisw_surface, NULL);
+
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+ pipe_resource_reference(&drawable->textures[i], NULL);
+
+ swap_fences_unref(drawable);
+
+ FREE(drawable);
+}
+
+/**
+ * Validate the texture at an attachment. Allocate the texture if it does not
+ * exist. Used by the TFP extension.
+ */
+static void
+dri_drawable_validate_att(struct dri_drawable *drawable,
+ enum st_attachment_type statt)
+{
+ enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
+ unsigned i, count = 0;
+
+ /* check if buffer already exists */
+ if (drawable->texture_mask & (1 << statt))
+ return;
+
+ /* make sure DRI2 does not destroy existing buffers */
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ if (drawable->texture_mask & (1 << i)) {
+ statts[count++] = i;
+ }
+ }
+ statts[count++] = statt;
+
+ drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
+
+ drawable->base.validate(&drawable->base, statts, count, NULL);
+}
+
+/**
+ * These are used for GLX_EXT_texture_from_pixmap
+ */
+static void
+dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
+ GLint format, __DRIdrawable *dPriv)
+{
+ struct dri_context *ctx = dri_context(pDRICtx);
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct pipe_resource *pt;
+
+ dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
+
+ /* Use the pipe resource associated with the X drawable */
+ pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
+
+ if (pt) {
+ enum pipe_format internal_format = pt->format;
+
+ if (format == __DRI_TEXTURE_FORMAT_RGB) {
+ /* only need to cover the formats recognized by dri_fill_st_visual */
+ switch (internal_format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ internal_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ break;
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ internal_format = PIPE_FORMAT_X8R8G8B8_UNORM;
+ break;
+ default:
+ break;
+ }
+ }
+
+ drawable->update_tex_buffer(drawable, ctx, pt);
+
+ ctx->st->teximage(ctx->st,
+ (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT,
+ 0, internal_format, pt, FALSE);
+ }
+}
+
+static void
+dri_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
+ __DRIdrawable *dPriv)
+{
+ dri_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
+}
+
+const __DRItexBufferExtension driTexBufferExtension = {
+ { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+ dri_set_tex_buffer,
+ dri_set_tex_buffer2,
+ NULL,
+};
+
+/**
+ * Get the format and binding of an attachment.
+ */
+void
+dri_drawable_get_format(struct dri_drawable *drawable,
+ enum st_attachment_type statt,
+ enum pipe_format *format,
+ unsigned *bind)
+{
+ switch (statt) {
+ case ST_ATTACHMENT_FRONT_LEFT:
+ case ST_ATTACHMENT_BACK_LEFT:
+ case ST_ATTACHMENT_FRONT_RIGHT:
+ case ST_ATTACHMENT_BACK_RIGHT:
+ *format = drawable->stvis.color_format;
+ *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+ case ST_ATTACHMENT_DEPTH_STENCIL:
+ *format = drawable->stvis.depth_stencil_format;
+ *bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
+ break;
+ default:
+ *format = PIPE_FORMAT_NONE;
+ *bind = 0;
+ break;
+ }
+}
+
+
+/**
+ * swap_fences_pop_front - pull a fence from the throttle queue
+ *
+ * If the throttle queue is filled to the desired number of fences,
+ * pull fences off the queue until the number is less than the desired
+ * number of fences, and return the last fence pulled.
+ */
+static struct pipe_fence_handle *
+swap_fences_pop_front(struct dri_drawable *draw)
+{
+ struct pipe_screen *screen = draw->screen->base.screen;
+ struct pipe_fence_handle *fence = NULL;
+
+ if (draw->desired_fences == 0)
+ return NULL;
+
+ if (draw->cur_fences >= draw->desired_fences) {
+ screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]);
+ screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
+ draw->tail &= DRI_SWAP_FENCES_MASK;
+ --draw->cur_fences;
+ }
+ return fence;
+}
+
+
+/**
+ * swap_fences_push_back - push a fence onto the throttle queue
+ *
+ * push a fence onto the throttle queue and pull fences of the queue
+ * so that the desired number of fences are on the queue.
+ */
+static void
+swap_fences_push_back(struct dri_drawable *draw,
+ struct pipe_fence_handle *fence)
+{
+ struct pipe_screen *screen = draw->screen->base.screen;
+
+ if (!fence || draw->desired_fences == 0)
+ return;
+
+ while(draw->cur_fences == draw->desired_fences)
+ swap_fences_pop_front(draw);
+
+ draw->cur_fences++;
+ screen->fence_reference(screen, &draw->swap_fences[draw->head++],
+ fence);
+ draw->head &= DRI_SWAP_FENCES_MASK;
+}
+
+
+/**
+ * swap_fences_unref - empty the throttle queue
+ *
+ * pulls fences of the throttle queue until it is empty.
+ */
+static void
+swap_fences_unref(struct dri_drawable *draw)
+{
+ struct pipe_screen *screen = draw->screen->base.screen;
+
+ while(draw->cur_fences) {
+ screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
+ draw->tail &= DRI_SWAP_FENCES_MASK;
+ --draw->cur_fences;
+ }
+}
+
+
+/**
+ * dri_throttle - A DRI2ThrottleExtension throttling function.
+ *
+ * pulls a fence off the throttling queue and waits for it if the
+ * number of fences on the throttling queue has reached the desired
+ * number.
+ *
+ * Then flushes to insert a fence at the current rendering position, and
+ * pushes that fence on the queue. This requires that the st_context_iface
+ * flush method returns a fence even if there are no commands to flush.
+ */
+static void
+dri_throttle(__DRIcontext *driCtx, __DRIdrawable *dPriv,
+ enum __DRI2throttleReason reason)
+{
+ struct dri_drawable *draw = dri_drawable(dPriv);
+ struct st_context_iface *ctxi;
+ struct pipe_screen *screen = draw->screen->base.screen;
+ struct pipe_fence_handle *fence;
+
+ if (reason != __DRI2_THROTTLE_SWAPBUFFER &&
+ reason != __DRI2_THROTTLE_FLUSHFRONT)
+ return;
+
+ fence = swap_fences_pop_front(draw);
+ if (fence) {
+ (void) screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+
+ if (driCtx == NULL)
+ return;
+
+ ctxi = dri_context(driCtx)->st;
+ ctxi->flush(ctxi, 0, &fence);
+ if (fence) {
+ swap_fences_push_back(draw, fence);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+}
+
+
+const __DRI2throttleExtension dri2ThrottleExtension = {
+ .base = { __DRI2_THROTTLE, __DRI2_THROTTLE_VERSION },
+ .throttle = dri_throttle,
+};
+
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_screen.c b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_screen.c
index 847f6515f25..102a1326133 120000..100644
--- a/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_screen.c
+++ b/chromium/third_party/mesa/src/src/gallium/state_trackers/dri/sw/dri_screen.c
@@ -1 +1,420 @@
-../common/dri_screen.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "utils.h"
+#include "xmlpool.h"
+
+#include "dri_screen.h"
+
+#include "util/u_inlines.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_format.h"
+#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
+
+#include "util/u_debug.h"
+
+#define MSAA_VISUAL_MAX_SAMPLES 8
+
+#undef false
+
+PUBLIC const char __driConfigOptions[] =
+ DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+
+ DRI_CONF_SECTION_QUALITY
+/* DRI_CONF_FORCE_S3TC_ENABLE(false) */
+ DRI_CONF_ALLOW_LARGE_TEXTURES(1)
+ DRI_CONF_PP_CELSHADE(0)
+ DRI_CONF_PP_NORED(0)
+ DRI_CONF_PP_NOGREEN(0)
+ DRI_CONF_PP_NOBLUE(0)
+ DRI_CONF_PP_JIMENEZMLAA(0, 0, 32)
+ DRI_CONF_PP_JIMENEZMLAA_COLOR(0, 0, 32)
+ DRI_CONF_SECTION_END
+
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN(false)
+ DRI_CONF_SECTION_END
+
+ DRI_CONF_END;
+
+#define false 0
+
+static const uint __driNConfigOptions = 10;
+
+static const __DRIconfig **
+dri_fill_in_modes(struct dri_screen *screen,
+ unsigned pixel_bits)
+{
+ __DRIconfig **configs = NULL;
+ __DRIconfig **configs_r5g6b5 = NULL;
+ __DRIconfig **configs_a8r8g8b8 = NULL;
+ __DRIconfig **configs_x8r8g8b8 = NULL;
+ uint8_t depth_bits_array[5];
+ uint8_t stencil_bits_array[5];
+ uint8_t msaa_samples_array[MSAA_VISUAL_MAX_SAMPLES];
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ unsigned msaa_samples_factor, msaa_samples_max;
+ unsigned i;
+ struct pipe_screen *p_screen = screen->base.screen;
+ boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8;
+ boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
+
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ depth_bits_array[0] = 0;
+ stencil_bits_array[0] = 0;
+ depth_buffer_factor = 1;
+
+ msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS)
+ ? MSAA_VISUAL_MAX_SAMPLES : 1;
+
+ pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_UINT,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_UINT_Z24_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET);
+ pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET);
+ pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET);
+
+ /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
+ if (dri_with_format(screen->sPriv)) {
+ pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+ } else {
+ pf_z16 = FALSE;
+ pf_z32 = FALSE;
+ }
+
+ if (pf_z16) {
+ depth_bits_array[depth_buffer_factor] = 16;
+ stencil_bits_array[depth_buffer_factor++] = 0;
+ }
+ if (pf_x8z24 || pf_z24x8) {
+ depth_bits_array[depth_buffer_factor] = 24;
+ stencil_bits_array[depth_buffer_factor++] = 0;
+ screen->d_depth_bits_last = pf_x8z24;
+ }
+ if (pf_s8z24 || pf_z24s8) {
+ depth_bits_array[depth_buffer_factor] = 24;
+ stencil_bits_array[depth_buffer_factor++] = 8;
+ screen->sd_depth_bits_last = pf_s8z24;
+ }
+ if (pf_z32) {
+ depth_bits_array[depth_buffer_factor] = 32;
+ stencil_bits_array[depth_buffer_factor++] = 0;
+ }
+
+ msaa_samples_array[0] = 0;
+ back_buffer_factor = 3;
+
+ /* Also test for color multisample support - just assume it'll work
+ * for all depth buffers.
+ */
+ if (pf_r5g6b5) {
+ msaa_samples_factor = 1;
+ for (i = 2; i <= msaa_samples_max; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET)) {
+ msaa_samples_array[msaa_samples_factor] = i;
+ msaa_samples_factor++;
+ }
+ }
+
+ configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor, back_buffer_modes,
+ back_buffer_factor,
+ msaa_samples_array, msaa_samples_factor,
+ GL_TRUE);
+ }
+
+ if (pf_a8r8g8b8) {
+ msaa_samples_factor = 1;
+ for (i = 2; i <= msaa_samples_max; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET)) {
+ msaa_samples_array[msaa_samples_factor] = i;
+ msaa_samples_factor++;
+ }
+ }
+
+ configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+ depth_bits_array,
+ stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes,
+ back_buffer_factor,
+ msaa_samples_array,
+ msaa_samples_factor,
+ GL_TRUE);
+ }
+
+ if (pf_x8r8g8b8) {
+ msaa_samples_factor = 1;
+ for (i = 2; i <= msaa_samples_max; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET)) {
+ msaa_samples_array[msaa_samples_factor] = i;
+ msaa_samples_factor++;
+ }
+ }
+
+ configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
+ depth_bits_array,
+ stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes,
+ back_buffer_factor,
+ msaa_samples_array,
+ msaa_samples_factor,
+ GL_TRUE);
+ }
+
+ if (pixel_bits == 16) {
+ configs = configs_r5g6b5;
+ configs = driConcatConfigs(configs, configs_a8r8g8b8);
+ configs = driConcatConfigs(configs, configs_x8r8g8b8);
+ } else {
+ configs = configs_a8r8g8b8;
+ configs = driConcatConfigs(configs, configs_x8r8g8b8);
+ configs = driConcatConfigs(configs, configs_r5g6b5);
+ }
+
+ if (configs == NULL) {
+ debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
+ return NULL;
+ }
+
+ return (const __DRIconfig **)configs;
+}
+
+/**
+ * Roughly the converse of dri_fill_in_modes.
+ */
+void
+dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
+ const struct gl_config *mode)
+{
+ memset(stvis, 0, sizeof(*stvis));
+
+ if (!mode)
+ return;
+
+ stvis->samples = mode->samples;
+
+ if (mode->redBits == 8) {
+ if (mode->alphaBits == 8)
+ stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ else
+ stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ } else {
+ stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM;
+ }
+
+ switch (mode->depthBits) {
+ default:
+ case 0:
+ stvis->depth_stencil_format = PIPE_FORMAT_NONE;
+ break;
+ case 16:
+ stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM;
+ break;
+ case 24:
+ if (mode->stencilBits == 0) {
+ stvis->depth_stencil_format = (screen->d_depth_bits_last) ?
+ PIPE_FORMAT_Z24X8_UNORM:
+ PIPE_FORMAT_X8Z24_UNORM;
+ } else {
+ stvis->depth_stencil_format = (screen->sd_depth_bits_last) ?
+ PIPE_FORMAT_Z24_UNORM_S8_UINT:
+ PIPE_FORMAT_S8_UINT_Z24_UNORM;
+ }
+ break;
+ case 32:
+ stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
+ break;
+ }
+
+ stvis->accum_format = (mode->haveAccumBuffer) ?
+ PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE;
+
+ stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK;
+ stvis->render_buffer = ST_ATTACHMENT_FRONT_LEFT;
+ if (mode->doubleBufferMode) {
+ stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
+ stvis->render_buffer = ST_ATTACHMENT_BACK_LEFT;
+ }
+ if (mode->stereoMode) {
+ stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
+ if (mode->doubleBufferMode)
+ stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
+ }
+
+ if (mode->haveDepthBuffer || mode->haveStencilBuffer)
+ stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK;
+ /* let the state tracker allocate the accum buffer */
+}
+
+static boolean
+dri_get_egl_image(struct st_manager *smapi,
+ void *egl_image,
+ struct st_egl_image *stimg)
+{
+ struct dri_screen *screen = (struct dri_screen *)smapi;
+ __DRIimage *img = NULL;
+
+ if (screen->lookup_egl_image) {
+ img = screen->lookup_egl_image(screen, egl_image);
+ }
+
+ if (!img)
+ return FALSE;
+
+ stimg->texture = NULL;
+ pipe_resource_reference(&stimg->texture, img->texture);
+ stimg->level = img->level;
+ stimg->layer = img->layer;
+
+ return TRUE;
+}
+
+static int
+dri_get_param(struct st_manager *smapi,
+ enum st_manager_param param)
+{
+ struct dri_screen *screen = (struct dri_screen *)smapi;
+
+ switch(param) {
+ case ST_MANAGER_BROKEN_INVALIDATE:
+ return screen->broken_invalidate;
+ default:
+ return 0;
+ }
+}
+
+static void
+dri_destroy_option_cache(struct dri_screen * screen)
+{
+ int i;
+
+ if (screen->optionCache.info) {
+ for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
+ FREE(screen->optionCache.info[i].name);
+ FREE(screen->optionCache.info[i].ranges);
+ }
+ FREE(screen->optionCache.info);
+ }
+
+ FREE(screen->optionCache.values);
+}
+
+void
+dri_destroy_screen_helper(struct dri_screen * screen)
+{
+ if (screen->st_api && screen->st_api->destroy)
+ screen->st_api->destroy(screen->st_api);
+
+ if (screen->base.screen)
+ screen->base.screen->destroy(screen->base.screen);
+
+ dri_destroy_option_cache(screen);
+}
+
+void
+dri_destroy_screen(__DRIscreen * sPriv)
+{
+ struct dri_screen *screen = dri_screen(sPriv);
+
+ dri_destroy_screen_helper(screen);
+
+ FREE(screen);
+ sPriv->driverPrivate = NULL;
+ sPriv->extensions = NULL;
+}
+
+const __DRIconfig **
+dri_init_screen_helper(struct dri_screen *screen,
+ struct pipe_screen *pscreen,
+ unsigned pixel_bits)
+{
+ screen->base.screen = pscreen;
+ if (!screen->base.screen) {
+ debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
+ return NULL;
+ }
+
+ screen->base.get_egl_image = dri_get_egl_image;
+ screen->base.get_param = dri_get_param;
+
+ screen->st_api = st_gl_api_create();
+ if (!screen->st_api)
+ return NULL;
+
+ if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))
+ screen->target = PIPE_TEXTURE_2D;
+ else
+ screen->target = PIPE_TEXTURE_RECT;
+
+ driParseOptionInfo(&screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ return dri_fill_in_modes(screen, pixel_bits);
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_batchbuffer.c
index d38cdf31cc6..06cbaecc74d 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_batchbuffer.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_batchbuffer.c
@@ -1 +1,543 @@
-../intel/intel_batchbuffer.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_buffer_objects.h"
+#include "intel_reg.h"
+#include "intel_bufmgr.h"
+#include "intel_buffers.h"
+
+struct cached_batch_item {
+ struct cached_batch_item *next;
+ uint16_t header;
+ uint16_t size;
+};
+
+static void clear_cache( struct intel_context *intel )
+{
+ struct cached_batch_item *item = intel->batch.cached_items;
+
+ while (item) {
+ struct cached_batch_item *next = item->next;
+ free(item);
+ item = next;
+ }
+
+ intel->batch.cached_items = NULL;
+}
+
+void
+intel_batchbuffer_init(struct intel_context *intel)
+{
+ intel_batchbuffer_reset(intel);
+
+ if (intel->gen >= 6) {
+ /* We can't just use brw_state_batch to get a chunk of space for
+ * the gen6 workaround because it involves actually writing to
+ * the buffer, and the kernel doesn't let us write to the batch.
+ */
+ intel->batch.workaround_bo = drm_intel_bo_alloc(intel->bufmgr,
+ "pipe_control workaround",
+ 4096, 4096);
+ }
+}
+
+void
+intel_batchbuffer_reset(struct intel_context *intel)
+{
+ if (intel->batch.last_bo != NULL) {
+ drm_intel_bo_unreference(intel->batch.last_bo);
+ intel->batch.last_bo = NULL;
+ }
+ intel->batch.last_bo = intel->batch.bo;
+
+ clear_cache(intel);
+
+ intel->batch.bo = drm_intel_bo_alloc(intel->bufmgr, "batchbuffer",
+ intel->maxBatchSize, 4096);
+
+ intel->batch.reserved_space = BATCH_RESERVED;
+ intel->batch.state_batch_offset = intel->batch.bo->size;
+ intel->batch.used = 0;
+ intel->batch.needs_sol_reset = false;
+}
+
+void
+intel_batchbuffer_save_state(struct intel_context *intel)
+{
+ intel->batch.saved.used = intel->batch.used;
+ intel->batch.saved.reloc_count =
+ drm_intel_gem_bo_get_reloc_count(intel->batch.bo);
+}
+
+void
+intel_batchbuffer_reset_to_saved(struct intel_context *intel)
+{
+ drm_intel_gem_bo_clear_relocs(intel->batch.bo, intel->batch.saved.reloc_count);
+
+ intel->batch.used = intel->batch.saved.used;
+
+ /* Cached batch state is dead, since we just cleared some unknown part of the
+ * batchbuffer. Assume that the caller resets any other state necessary.
+ */
+ clear_cache(intel);
+}
+
+void
+intel_batchbuffer_free(struct intel_context *intel)
+{
+ drm_intel_bo_unreference(intel->batch.last_bo);
+ drm_intel_bo_unreference(intel->batch.bo);
+ drm_intel_bo_unreference(intel->batch.workaround_bo);
+ clear_cache(intel);
+}
+
+static void
+do_batch_dump(struct intel_context *intel)
+{
+ struct drm_intel_decode *decode;
+ struct intel_batchbuffer *batch = &intel->batch;
+ int ret;
+
+ decode = drm_intel_decode_context_alloc(intel->intelScreen->deviceID);
+ if (!decode)
+ return;
+
+ ret = drm_intel_bo_map(batch->bo, false);
+ if (ret == 0) {
+ drm_intel_decode_set_batch_pointer(decode,
+ batch->bo->virtual,
+ batch->bo->offset,
+ batch->used);
+ } else {
+ fprintf(stderr,
+ "WARNING: failed to map batchbuffer (%s), "
+ "dumping uploaded data instead.\n", strerror(ret));
+
+ drm_intel_decode_set_batch_pointer(decode,
+ batch->map,
+ batch->bo->offset,
+ batch->used);
+ }
+
+ drm_intel_decode(decode);
+
+ drm_intel_decode_context_free(decode);
+
+ if (ret == 0) {
+ drm_intel_bo_unmap(batch->bo);
+
+ if (intel->vtbl.debug_batch != NULL)
+ intel->vtbl.debug_batch(intel);
+ }
+}
+
+/* TODO: Push this whole function into bufmgr.
+ */
+static int
+do_flush_locked(struct intel_context *intel)
+{
+ struct intel_batchbuffer *batch = &intel->batch;
+ int ret = 0;
+
+ ret = drm_intel_bo_subdata(batch->bo, 0, 4*batch->used, batch->map);
+ if (ret == 0 && batch->state_batch_offset != batch->bo->size) {
+ ret = drm_intel_bo_subdata(batch->bo,
+ batch->state_batch_offset,
+ batch->bo->size - batch->state_batch_offset,
+ (char *)batch->map + batch->state_batch_offset);
+ }
+
+ if (!intel->intelScreen->no_hw) {
+ int flags;
+
+ if (intel->gen < 6 || !batch->is_blit) {
+ flags = I915_EXEC_RENDER;
+ } else {
+ flags = I915_EXEC_BLT;
+ }
+
+ if (batch->needs_sol_reset)
+ flags |= I915_EXEC_GEN7_SOL_RESET;
+
+ if (ret == 0) {
+ if (unlikely(INTEL_DEBUG & DEBUG_AUB) && intel->vtbl.annotate_aub)
+ intel->vtbl.annotate_aub(intel);
+ if (intel->hw_ctx == NULL || batch->is_blit) {
+ ret = drm_intel_bo_mrb_exec(batch->bo, 4 * batch->used, NULL, 0, 0,
+ flags);
+ } else {
+ ret = drm_intel_gem_bo_context_exec(batch->bo, intel->hw_ctx,
+ 4 * batch->used, flags);
+ }
+ }
+ }
+
+ if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+ do_batch_dump(intel);
+
+ if (ret != 0) {
+ fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret));
+ exit(1);
+ }
+ intel->vtbl.new_batch(intel);
+
+ return ret;
+}
+
+int
+_intel_batchbuffer_flush(struct intel_context *intel,
+ const char *file, int line)
+{
+ int ret;
+
+ if (intel->batch.used == 0)
+ return 0;
+
+ if (intel->first_post_swapbuffers_batch == NULL) {
+ intel->first_post_swapbuffers_batch = intel->batch.bo;
+ drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
+ }
+
+ if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+ fprintf(stderr, "%s:%d: Batchbuffer flush with %db used\n", file, line,
+ 4*intel->batch.used);
+
+ intel->batch.reserved_space = 0;
+
+ if (intel->vtbl.finish_batch)
+ intel->vtbl.finish_batch(intel);
+
+ /* Mark the end of the buffer. */
+ intel_batchbuffer_emit_dword(intel, MI_BATCH_BUFFER_END);
+ if (intel->batch.used & 1) {
+ /* Round batchbuffer usage to 2 DWORDs. */
+ intel_batchbuffer_emit_dword(intel, MI_NOOP);
+ }
+
+ intel_upload_finish(intel);
+
+ /* Check that we didn't just wrap our batchbuffer at a bad time. */
+ assert(!intel->no_batch_wrap);
+
+ ret = do_flush_locked(intel);
+
+ if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
+ fprintf(stderr, "waiting for idle\n");
+ drm_intel_bo_wait_rendering(intel->batch.bo);
+ }
+
+ /* Reset the buffer:
+ */
+ intel_batchbuffer_reset(intel);
+
+ return ret;
+}
+
+
+/* This is the only way buffers get added to the validate list.
+ */
+bool
+intel_batchbuffer_emit_reloc(struct intel_context *intel,
+ drm_intel_bo *buffer,
+ uint32_t read_domains, uint32_t write_domain,
+ uint32_t delta)
+{
+ int ret;
+
+ ret = drm_intel_bo_emit_reloc(intel->batch.bo, 4*intel->batch.used,
+ buffer, delta,
+ read_domains, write_domain);
+ assert(ret == 0);
+ (void)ret;
+
+ /*
+ * Using the old buffer offset, write in what the right data would be, in case
+ * the buffer doesn't move and we can short-circuit the relocation processing
+ * in the kernel
+ */
+ intel_batchbuffer_emit_dword(intel, buffer->offset + delta);
+
+ return true;
+}
+
+bool
+intel_batchbuffer_emit_reloc_fenced(struct intel_context *intel,
+ drm_intel_bo *buffer,
+ uint32_t read_domains,
+ uint32_t write_domain,
+ uint32_t delta)
+{
+ int ret;
+
+ ret = drm_intel_bo_emit_reloc_fence(intel->batch.bo, 4*intel->batch.used,
+ buffer, delta,
+ read_domains, write_domain);
+ assert(ret == 0);
+ (void)ret;
+
+ /*
+ * Using the old buffer offset, write in what the right data would
+ * be, in case the buffer doesn't move and we can short-circuit the
+ * relocation processing in the kernel
+ */
+ intel_batchbuffer_emit_dword(intel, buffer->offset + delta);
+
+ return true;
+}
+
+void
+intel_batchbuffer_data(struct intel_context *intel,
+ const void *data, GLuint bytes, bool is_blit)
+{
+ assert((bytes & 3) == 0);
+ intel_batchbuffer_require_space(intel, bytes, is_blit);
+ __memcpy(intel->batch.map + intel->batch.used, data, bytes);
+ intel->batch.used += bytes >> 2;
+}
+
+void
+intel_batchbuffer_cached_advance(struct intel_context *intel)
+{
+ struct cached_batch_item **prev = &intel->batch.cached_items, *item;
+ uint32_t sz = (intel->batch.used - intel->batch.emit) * sizeof(uint32_t);
+ uint32_t *start = intel->batch.map + intel->batch.emit;
+ uint16_t op = *start >> 16;
+
+ while (*prev) {
+ uint32_t *old;
+
+ item = *prev;
+ old = intel->batch.map + item->header;
+ if (op == *old >> 16) {
+ if (item->size == sz && memcmp(old, start, sz) == 0) {
+ if (prev != &intel->batch.cached_items) {
+ *prev = item->next;
+ item->next = intel->batch.cached_items;
+ intel->batch.cached_items = item;
+ }
+ intel->batch.used = intel->batch.emit;
+ return;
+ }
+
+ goto emit;
+ }
+ prev = &item->next;
+ }
+
+ item = malloc(sizeof(struct cached_batch_item));
+ if (item == NULL)
+ return;
+
+ item->next = intel->batch.cached_items;
+ intel->batch.cached_items = item;
+
+emit:
+ item->size = sz;
+ item->header = intel->batch.emit;
+}
+
+/**
+ * Restriction [DevSNB, DevIVB]:
+ *
+ * Prior to changing Depth/Stencil Buffer state (i.e. any combination of
+ * 3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS, 3DSTATE_STENCIL_BUFFER,
+ * 3DSTATE_HIER_DEPTH_BUFFER) SW must first issue a pipelined depth stall
+ * (PIPE_CONTROL with Depth Stall bit set), followed by a pipelined depth
+ * cache flush (PIPE_CONTROL with Depth Flush Bit set), followed by
+ * another pipelined depth stall (PIPE_CONTROL with Depth Stall bit set),
+ * unless SW can otherwise guarantee that the pipeline from WM onwards is
+ * already flushed (e.g., via a preceding MI_FLUSH).
+ */
+void
+intel_emit_depth_stall_flushes(struct intel_context *intel)
+{
+ assert(intel->gen >= 6 && intel->gen <= 7);
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH()
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_CACHE_FLUSH);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+}
+
+/**
+ * From the BSpec, volume 2a.03: VS Stage Input / State:
+ * "[DevIVB] A PIPE_CONTROL with Post-Sync Operation set to 1h and a depth
+ * stall needs to be sent just prior to any 3DSTATE_VS, 3DSTATE_URB_VS,
+ * 3DSTATE_CONSTANT_VS, 3DSTATE_BINDING_TABLE_POINTER_VS,
+ * 3DSTATE_SAMPLER_STATE_POINTER_VS command. Only one PIPE_CONTROL needs
+ * to be sent before any combination of VS associated 3DSTATE."
+ */
+void
+gen7_emit_vs_workaround_flush(struct intel_context *intel)
+{
+ assert(intel->gen == 7);
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_STALL | PIPE_CONTROL_WRITE_IMMEDIATE);
+ OUT_RELOC(intel->batch.workaround_bo,
+ I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0);
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+}
+
+/**
+ * Emits a PIPE_CONTROL with a non-zero post-sync operation, for
+ * implementing two workarounds on gen6. From section 1.4.7.1
+ * "PIPE_CONTROL" of the Sandy Bridge PRM volume 2 part 1:
+ *
+ * [DevSNB-C+{W/A}] Before any depth stall flush (including those
+ * produced by non-pipelined state commands), software needs to first
+ * send a PIPE_CONTROL with no bits set except Post-Sync Operation !=
+ * 0.
+ *
+ * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache Flush Enable
+ * =1, a PIPE_CONTROL with any non-zero post-sync-op is required.
+ *
+ * And the workaround for these two requires this workaround first:
+ *
+ * [Dev-SNB{W/A}]: Pipe-control with CS-stall bit set must be sent
+ * BEFORE the pipe-control with a post-sync op and no write-cache
+ * flushes.
+ *
+ * And this last workaround is tricky because of the requirements on
+ * that bit. From section 1.4.7.2.3 "Stall" of the Sandy Bridge PRM
+ * volume 2 part 1:
+ *
+ * "1 of the following must also be set:
+ * - Render Target Cache Flush Enable ([12] of DW1)
+ * - Depth Cache Flush Enable ([0] of DW1)
+ * - Stall at Pixel Scoreboard ([1] of DW1)
+ * - Depth Stall ([13] of DW1)
+ * - Post-Sync Operation ([13] of DW1)
+ * - Notify Enable ([8] of DW1)"
+ *
+ * The cache flushes require the workaround flush that triggered this
+ * one, so we can't use it. Depth stall would trigger the same.
+ * Post-sync nonzero is what triggered this second workaround, so we
+ * can't use that one either. Notify enable is IRQs, which aren't
+ * really our business. That leaves only stall at scoreboard.
+ */
+void
+intel_emit_post_sync_nonzero_flush(struct intel_context *intel)
+{
+ if (!intel->batch.need_workaround_flush)
+ return;
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_CS_STALL |
+ PIPE_CONTROL_STALL_AT_SCOREBOARD);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_WRITE_IMMEDIATE);
+ OUT_RELOC(intel->batch.workaround_bo,
+ I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0);
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+
+ intel->batch.need_workaround_flush = false;
+}
+
+/* Emit a pipelined flush to either flush render and texture cache for
+ * reading from a FBO-drawn texture, or flush so that frontbuffer
+ * render appears on the screen in DRI1.
+ *
+ * This is also used for the always_flush_cache driconf debug option.
+ */
+void
+intel_batchbuffer_emit_mi_flush(struct intel_context *intel)
+{
+ if (intel->gen >= 6) {
+ if (intel->batch.is_blit) {
+ BEGIN_BATCH_BLT(4);
+ OUT_BATCH(MI_FLUSH_DW);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+ ADVANCE_BATCH();
+ } else {
+ if (intel->gen == 6) {
+ /* Hardware workaround: SNB B-Spec says:
+ *
+ * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache
+ * Flush Enable =1, a PIPE_CONTROL with any non-zero
+ * post-sync-op is required.
+ */
+ intel_emit_post_sync_nonzero_flush(intel);
+ }
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_INSTRUCTION_FLUSH |
+ PIPE_CONTROL_WRITE_FLUSH |
+ PIPE_CONTROL_DEPTH_CACHE_FLUSH |
+ PIPE_CONTROL_VF_CACHE_INVALIDATE |
+ PIPE_CONTROL_TC_FLUSH |
+ PIPE_CONTROL_NO_WRITE |
+ PIPE_CONTROL_CS_STALL);
+ OUT_BATCH(0); /* write address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+ }
+ } else if (intel->gen >= 4) {
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2) |
+ PIPE_CONTROL_WRITE_FLUSH |
+ PIPE_CONTROL_NO_WRITE);
+ OUT_BATCH(0); /* write address */
+ OUT_BATCH(0); /* write data */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+ } else {
+ BEGIN_BATCH(1);
+ OUT_BATCH(MI_FLUSH);
+ ADVANCE_BATCH();
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_blit.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_blit.c
index dd6c8d17c28..36a2c6aadac 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_blit.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_blit.c
@@ -1 +1,604 @@
-../intel/intel_blit.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/mtypes.h"
+#include "main/context.h"
+#include "main/enums.h"
+#include "main/colormac.h"
+#include "main/fbobject.h"
+
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_reg.h"
+#include "intel_regions.h"
+#include "intel_batchbuffer.h"
+#include "intel_mipmap_tree.h"
+
+#define FILE_DEBUG_FLAG DEBUG_BLIT
+
+static GLuint translate_raster_op(GLenum logicop)
+{
+ switch(logicop) {
+ case GL_CLEAR: return 0x00;
+ case GL_AND: return 0x88;
+ case GL_AND_REVERSE: return 0x44;
+ case GL_COPY: return 0xCC;
+ case GL_AND_INVERTED: return 0x22;
+ case GL_NOOP: return 0xAA;
+ case GL_XOR: return 0x66;
+ case GL_OR: return 0xEE;
+ case GL_NOR: return 0x11;
+ case GL_EQUIV: return 0x99;
+ case GL_INVERT: return 0x55;
+ case GL_OR_REVERSE: return 0xDD;
+ case GL_COPY_INVERTED: return 0x33;
+ case GL_OR_INVERTED: return 0xBB;
+ case GL_NAND: return 0x77;
+ case GL_SET: return 0xFF;
+ default: return 0;
+ }
+}
+
+static uint32_t
+br13_for_cpp(int cpp)
+{
+ switch (cpp) {
+ case 4:
+ return BR13_8888;
+ break;
+ case 2:
+ return BR13_565;
+ break;
+ case 1:
+ return BR13_8;
+ break;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+/* Copy BitBlt
+ */
+bool
+intelEmitCopyBlit(struct intel_context *intel,
+ GLuint cpp,
+ GLshort src_pitch,
+ drm_intel_bo *src_buffer,
+ GLuint src_offset,
+ uint32_t src_tiling,
+ GLshort dst_pitch,
+ drm_intel_bo *dst_buffer,
+ GLuint dst_offset,
+ uint32_t dst_tiling,
+ GLshort src_x, GLshort src_y,
+ GLshort dst_x, GLshort dst_y,
+ GLshort w, GLshort h,
+ GLenum logic_op)
+{
+ GLuint CMD, BR13, pass = 0;
+ int dst_y2 = dst_y + h;
+ int dst_x2 = dst_x + w;
+ drm_intel_bo *aper_array[3];
+ BATCH_LOCALS;
+
+ if (dst_tiling != I915_TILING_NONE) {
+ if (dst_offset & 4095)
+ return false;
+ if (dst_tiling == I915_TILING_Y)
+ return false;
+ }
+ if (src_tiling != I915_TILING_NONE) {
+ if (src_offset & 4095)
+ return false;
+ if (src_tiling == I915_TILING_Y)
+ return false;
+ }
+
+ /* do space check before going any further */
+ do {
+ aper_array[0] = intel->batch.bo;
+ aper_array[1] = dst_buffer;
+ aper_array[2] = src_buffer;
+
+ if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
+ intel_batchbuffer_flush(intel);
+ pass++;
+ } else
+ break;
+ } while (pass < 2);
+
+ if (pass >= 2)
+ return false;
+
+ intel_batchbuffer_require_space(intel, 8 * 4, true);
+ DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+ __FUNCTION__,
+ src_buffer, src_pitch, src_offset, src_x, src_y,
+ dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h);
+
+ src_pitch *= cpp;
+ dst_pitch *= cpp;
+
+ /* Blit pitch must be dword-aligned. Otherwise, the hardware appears to drop
+ * the low bits.
+ */
+ assert(src_pitch % 4 == 0);
+ assert(dst_pitch % 4 == 0);
+
+ /* For big formats (such as floating point), do the copy using 32bpp and
+ * multiply the coordinates.
+ */
+ if (cpp > 4) {
+ assert(cpp % 4 == 0);
+ dst_x *= cpp / 4;
+ dst_x2 *= cpp / 4;
+ src_x *= cpp / 4;
+ cpp = 4;
+ }
+
+ BR13 = br13_for_cpp(cpp) | translate_raster_op(logic_op) << 16;
+
+ switch (cpp) {
+ case 1:
+ case 2:
+ CMD = XY_SRC_COPY_BLT_CMD;
+ break;
+ case 4:
+ CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+ break;
+ default:
+ return false;
+ }
+
+#ifndef I915
+ if (dst_tiling != I915_TILING_NONE) {
+ CMD |= XY_DST_TILED;
+ dst_pitch /= 4;
+ }
+ if (src_tiling != I915_TILING_NONE) {
+ CMD |= XY_SRC_TILED;
+ src_pitch /= 4;
+ }
+#endif
+
+ if (dst_y2 <= dst_y || dst_x2 <= dst_x) {
+ return true;
+ }
+
+ assert(dst_x < dst_x2);
+ assert(dst_y < dst_y2);
+
+ BEGIN_BATCH_BLT(8);
+ OUT_BATCH(CMD);
+ OUT_BATCH(BR13 | (uint16_t)dst_pitch);
+ OUT_BATCH((dst_y << 16) | dst_x);
+ OUT_BATCH((dst_y2 << 16) | dst_x2);
+ OUT_RELOC_FENCED(dst_buffer,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ dst_offset);
+ OUT_BATCH((src_y << 16) | src_x);
+ OUT_BATCH((uint16_t)src_pitch);
+ OUT_RELOC_FENCED(src_buffer,
+ I915_GEM_DOMAIN_RENDER, 0,
+ src_offset);
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ return true;
+}
+
+
+/**
+ * Use blitting to clear the renderbuffers named by 'flags'.
+ * Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferIndexes field
+ * since that might include software renderbuffers or renderbuffers
+ * which we're clearing with triangles.
+ * \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear
+ */
+GLbitfield
+intelClearWithBlit(struct gl_context *ctx, GLbitfield mask)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ GLuint clear_depth_value, clear_depth_mask;
+ GLint cx, cy, cw, ch;
+ GLbitfield fail_mask = 0;
+ BATCH_LOCALS;
+
+ /*
+ * Compute values for clearing the buffers.
+ */
+ clear_depth_value = 0;
+ clear_depth_mask = 0;
+ if (mask & BUFFER_BIT_DEPTH) {
+ clear_depth_value = (GLuint) (fb->_DepthMax * ctx->Depth.Clear);
+ clear_depth_mask = XY_BLT_WRITE_RGB;
+ }
+ if (mask & BUFFER_BIT_STENCIL) {
+ clear_depth_value |= (ctx->Stencil.Clear & 0xff) << 24;
+ clear_depth_mask |= XY_BLT_WRITE_ALPHA;
+ }
+
+ cx = fb->_Xmin;
+ if (_mesa_is_winsys_fbo(fb))
+ cy = ctx->DrawBuffer->Height - fb->_Ymax;
+ else
+ cy = fb->_Ymin;
+ cw = fb->_Xmax - fb->_Xmin;
+ ch = fb->_Ymax - fb->_Ymin;
+
+ if (cw == 0 || ch == 0)
+ return 0;
+
+ /* Loop over all renderbuffers */
+ mask &= (1 << BUFFER_COUNT) - 1;
+ while (mask) {
+ GLuint buf = ffs(mask) - 1;
+ bool is_depth_stencil = buf == BUFFER_DEPTH || buf == BUFFER_STENCIL;
+ struct intel_renderbuffer *irb;
+ int x1, y1, x2, y2;
+ uint32_t clear_val;
+ uint32_t BR13, CMD;
+ struct intel_region *region;
+ int pitch, cpp;
+ drm_intel_bo *aper_array[2];
+
+ mask &= ~(1 << buf);
+
+ irb = intel_get_renderbuffer(fb, buf);
+ if (irb && irb->mt) {
+ region = irb->mt->region;
+ assert(region);
+ assert(region->bo);
+ } else {
+ fail_mask |= 1 << buf;
+ continue;
+ }
+
+ /* OK, clear this renderbuffer */
+ x1 = cx + irb->draw_x;
+ y1 = cy + irb->draw_y;
+ x2 = cx + cw + irb->draw_x;
+ y2 = cy + ch + irb->draw_y;
+
+ pitch = region->pitch;
+ cpp = region->cpp;
+
+ DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
+ __FUNCTION__,
+ region->bo, (pitch * cpp),
+ x1, y1, x2 - x1, y2 - y1);
+
+ BR13 = 0xf0 << 16;
+ CMD = XY_COLOR_BLT_CMD;
+
+ /* Setup the blit command */
+ if (cpp == 4) {
+ if (is_depth_stencil) {
+ CMD |= clear_depth_mask;
+ } else {
+ /* clearing RGBA */
+ CMD |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+ }
+ }
+
+ assert(region->tiling != I915_TILING_Y);
+
+#ifndef I915
+ if (region->tiling != I915_TILING_NONE) {
+ CMD |= XY_DST_TILED;
+ pitch /= 4;
+ }
+#endif
+ BR13 |= (pitch * cpp);
+
+ if (is_depth_stencil) {
+ clear_val = clear_depth_value;
+ } else {
+ uint8_t clear[4];
+ GLfloat *color = ctx->Color.ClearColor.f;
+
+ _mesa_unclamped_float_rgba_to_ubyte(clear, color);
+
+ switch (intel_rb_format(irb)) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ clear_val = PACK_COLOR_8888(clear[3], clear[0],
+ clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_RGB565:
+ clear_val = PACK_COLOR_565(clear[0], clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_ARGB4444:
+ clear_val = PACK_COLOR_4444(clear[3], clear[0],
+ clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_ARGB1555:
+ clear_val = PACK_COLOR_1555(clear[3], clear[0],
+ clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_A8:
+ clear_val = PACK_COLOR_8888(clear[3], clear[3],
+ clear[3], clear[3]);
+ break;
+ default:
+ fail_mask |= 1 << buf;
+ continue;
+ }
+ }
+
+ BR13 |= br13_for_cpp(cpp);
+
+ assert(x1 < x2);
+ assert(y1 < y2);
+
+ /* do space check before going any further */
+ aper_array[0] = intel->batch.bo;
+ aper_array[1] = region->bo;
+
+ if (drm_intel_bufmgr_check_aperture_space(aper_array,
+ ARRAY_SIZE(aper_array)) != 0) {
+ intel_batchbuffer_flush(intel);
+ }
+
+ BEGIN_BATCH_BLT(6);
+ OUT_BATCH(CMD);
+ OUT_BATCH(BR13);
+ OUT_BATCH((y1 << 16) | x1);
+ OUT_BATCH((y2 << 16) | x2);
+ OUT_RELOC_FENCED(region->bo,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ 0);
+ OUT_BATCH(clear_val);
+ ADVANCE_BATCH();
+
+ if (intel->always_flush_cache)
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL)
+ mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
+ }
+
+ return fail_mask;
+}
+
+bool
+intelEmitImmediateColorExpandBlit(struct intel_context *intel,
+ GLuint cpp,
+ GLubyte *src_bits, GLuint src_size,
+ GLuint fg_color,
+ GLshort dst_pitch,
+ drm_intel_bo *dst_buffer,
+ GLuint dst_offset,
+ uint32_t dst_tiling,
+ GLshort x, GLshort y,
+ GLshort w, GLshort h,
+ GLenum logic_op)
+{
+ int dwords = ALIGN(src_size, 8) / 4;
+ uint32_t opcode, br13, blit_cmd;
+
+ if (dst_tiling != I915_TILING_NONE) {
+ if (dst_offset & 4095)
+ return false;
+ if (dst_tiling == I915_TILING_Y)
+ return false;
+ }
+
+ assert( logic_op - GL_CLEAR >= 0 );
+ assert( logic_op - GL_CLEAR < 0x10 );
+ assert(dst_pitch > 0);
+
+ if (w < 0 || h < 0)
+ return true;
+
+ dst_pitch *= cpp;
+
+ DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d, %d bytes %d dwords\n",
+ __FUNCTION__,
+ dst_buffer, dst_pitch, dst_offset, x, y, w, h, src_size, dwords);
+
+ intel_batchbuffer_require_space(intel,
+ (8 * 4) +
+ (3 * 4) +
+ dwords * 4, true);
+
+ opcode = XY_SETUP_BLT_CMD;
+ if (cpp == 4)
+ opcode |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+#ifndef I915
+ if (dst_tiling != I915_TILING_NONE) {
+ opcode |= XY_DST_TILED;
+ dst_pitch /= 4;
+ }
+#endif
+
+ br13 = dst_pitch | (translate_raster_op(logic_op) << 16) | (1 << 29);
+ br13 |= br13_for_cpp(cpp);
+
+ blit_cmd = XY_TEXT_IMMEDIATE_BLIT_CMD | XY_TEXT_BYTE_PACKED; /* packing? */
+ if (dst_tiling != I915_TILING_NONE)
+ blit_cmd |= XY_DST_TILED;
+
+ BEGIN_BATCH_BLT(8 + 3);
+ OUT_BATCH(opcode);
+ OUT_BATCH(br13);
+ OUT_BATCH((0 << 16) | 0); /* clip x1, y1 */
+ OUT_BATCH((100 << 16) | 100); /* clip x2, y2 */
+ OUT_RELOC_FENCED(dst_buffer,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ dst_offset);
+ OUT_BATCH(0); /* bg */
+ OUT_BATCH(fg_color); /* fg */
+ OUT_BATCH(0); /* pattern base addr */
+
+ OUT_BATCH(blit_cmd | ((3 - 2) + dwords));
+ OUT_BATCH((y << 16) | x);
+ OUT_BATCH(((y + h) << 16) | (x + w));
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_data(intel, src_bits, dwords * 4, true);
+
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ return true;
+}
+
+/* We don't have a memmove-type blit like some other hardware, so we'll do a
+ * rectangular blit covering a large space, then emit 1-scanline blit at the
+ * end to cover the last if we need.
+ */
+void
+intel_emit_linear_blit(struct intel_context *intel,
+ drm_intel_bo *dst_bo,
+ unsigned int dst_offset,
+ drm_intel_bo *src_bo,
+ unsigned int src_offset,
+ unsigned int size)
+{
+ GLuint pitch, height;
+ bool ok;
+
+ /* The pitch given to the GPU must be DWORD aligned, and
+ * we want width to match pitch. Max width is (1 << 15 - 1),
+ * rounding that down to the nearest DWORD is 1 << 15 - 4
+ */
+ pitch = ROUND_DOWN_TO(MIN2(size, (1 << 15) - 1), 4);
+ height = (pitch == 0) ? 1 : size / pitch;
+ ok = intelEmitCopyBlit(intel, 1,
+ pitch, src_bo, src_offset, I915_TILING_NONE,
+ pitch, dst_bo, dst_offset, I915_TILING_NONE,
+ 0, 0, /* src x/y */
+ 0, 0, /* dst x/y */
+ pitch, height, /* w, h */
+ GL_COPY);
+ assert(ok);
+
+ src_offset += pitch * height;
+ dst_offset += pitch * height;
+ size -= pitch * height;
+ assert (size < (1 << 15));
+ pitch = ALIGN(size, 4);
+ if (size != 0) {
+ ok = intelEmitCopyBlit(intel, 1,
+ pitch, src_bo, src_offset, I915_TILING_NONE,
+ pitch, dst_bo, dst_offset, I915_TILING_NONE,
+ 0, 0, /* src x/y */
+ 0, 0, /* dst x/y */
+ size, 1, /* w, h */
+ GL_COPY);
+ assert(ok);
+ }
+}
+
+/**
+ * Used to initialize the alpha value of an ARGB8888 teximage after
+ * loading it from an XRGB8888 source.
+ *
+ * This is very common with glCopyTexImage2D().
+ */
+void
+intel_set_teximage_alpha_to_one(struct gl_context *ctx,
+ struct intel_texture_image *intel_image)
+{
+ struct intel_context *intel = intel_context(ctx);
+ unsigned int image_x, image_y;
+ uint32_t x1, y1, x2, y2;
+ uint32_t BR13, CMD;
+ int pitch, cpp;
+ drm_intel_bo *aper_array[2];
+ struct intel_region *region = intel_image->mt->region;
+ int width, height, depth;
+ BATCH_LOCALS;
+
+ intel_miptree_get_dimensions_for_image(&intel_image->base.Base,
+ &width, &height, &depth);
+ assert(depth == 1);
+
+ assert(intel_image->base.Base.TexFormat == MESA_FORMAT_ARGB8888);
+
+ /* get dest x/y in destination texture */
+ intel_miptree_get_image_offset(intel_image->mt,
+ intel_image->base.Base.Level,
+ intel_image->base.Base.Face,
+ 0,
+ &image_x, &image_y);
+
+ x1 = image_x;
+ y1 = image_y;
+ x2 = image_x + width;
+ y2 = image_y + height;
+
+ pitch = region->pitch;
+ cpp = region->cpp;
+
+ DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
+ __FUNCTION__,
+ intel_image->mt->region->bo, (pitch * cpp),
+ x1, y1, x2 - x1, y2 - y1);
+
+ BR13 = br13_for_cpp(cpp) | 0xf0 << 16;
+ CMD = XY_COLOR_BLT_CMD;
+ CMD |= XY_BLT_WRITE_ALPHA;
+
+ assert(region->tiling != I915_TILING_Y);
+
+#ifndef I915
+ if (region->tiling != I915_TILING_NONE) {
+ CMD |= XY_DST_TILED;
+ pitch /= 4;
+ }
+#endif
+ BR13 |= (pitch * cpp);
+
+ /* do space check before going any further */
+ aper_array[0] = intel->batch.bo;
+ aper_array[1] = region->bo;
+
+ if (drm_intel_bufmgr_check_aperture_space(aper_array,
+ ARRAY_SIZE(aper_array)) != 0) {
+ intel_batchbuffer_flush(intel);
+ }
+
+ BEGIN_BATCH_BLT(6);
+ OUT_BATCH(CMD);
+ OUT_BATCH(BR13);
+ OUT_BATCH((y1 << 16) | x1);
+ OUT_BATCH((y2 << 16) | x2);
+ OUT_RELOC_FENCED(region->bo,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ 0);
+ OUT_BATCH(0xffffffff); /* white, but only alpha gets written */
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_emit_mi_flush(intel);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index e06dd3c8d3c..df8ac7fb301 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -1 +1,849 @@
-../intel/intel_buffer_objects.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/imports.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/bufferobj.h"
+
+#include "intel_blit.h"
+#include "intel_buffer_objects.h"
+#include "intel_batchbuffer.h"
+#include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+
+static GLboolean
+intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj);
+
+/** Allocates a new drm_intel_bo to store the data for the buffer object. */
+static void
+intel_bufferobj_alloc_buffer(struct intel_context *intel,
+ struct intel_buffer_object *intel_obj)
+{
+ intel_obj->buffer = drm_intel_bo_alloc(intel->bufmgr, "bufferobj",
+ intel_obj->Base.Size, 64);
+}
+
+static void
+release_buffer(struct intel_buffer_object *intel_obj)
+{
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_obj->buffer = NULL;
+ intel_obj->offset = 0;
+ intel_obj->source = 0;
+}
+
+/**
+ * There is some duplication between mesa's bufferobjects and our
+ * bufmgr buffers. Both have an integer handle and a hashtable to
+ * lookup an opaque structure. It would be nice if the handles and
+ * internal structure where somehow shared.
+ */
+static struct gl_buffer_object *
+intel_bufferobj_alloc(struct gl_context * ctx, GLuint name, GLenum target)
+{
+ struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object);
+
+ _mesa_initialize_buffer_object(ctx, &obj->Base, name, target);
+
+ obj->buffer = NULL;
+
+ return &obj->Base;
+}
+
+/**
+ * Deallocate/free a vertex/pixel buffer object.
+ * Called via glDeleteBuffersARB().
+ */
+static void
+intel_bufferobj_free(struct gl_context * ctx, struct gl_buffer_object *obj)
+{
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ assert(intel_obj);
+
+ /* Buffer objects are automatically unmapped when deleting according
+ * to the spec, but Mesa doesn't do UnmapBuffer for us at context destroy
+ * (though it does if you call glDeleteBuffers)
+ */
+ if (obj->Pointer)
+ intel_bufferobj_unmap(ctx, obj);
+
+ free(intel_obj->sys_buffer);
+
+ drm_intel_bo_unreference(intel_obj->buffer);
+ free(intel_obj);
+}
+
+
+
+/**
+ * Allocate space for and store data in a buffer object. Any data that was
+ * previously stored in the buffer object is lost. If data is NULL,
+ * memory will be allocated, but no copy will occur.
+ * Called via ctx->Driver.BufferData().
+ * \return true for success, false if out of memory
+ */
+static GLboolean
+intel_bufferobj_data(struct gl_context * ctx,
+ GLenum target,
+ GLsizeiptrARB size,
+ const GLvoid * data,
+ GLenum usage, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ /* Part of the ABI, but this function doesn't use it.
+ */
+#ifndef I915
+ (void) target;
+#endif
+
+ intel_obj->Base.Size = size;
+ intel_obj->Base.Usage = usage;
+
+ assert(!obj->Pointer); /* Mesa should have unmapped it */
+
+ if (intel_obj->buffer != NULL)
+ release_buffer(intel_obj);
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+
+ if (size != 0) {
+#ifdef I915
+ /* On pre-965, stick VBOs in system memory, as we're always doing
+ * swtnl with their contents anyway.
+ */
+ if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
+ intel_obj->sys_buffer = malloc(size);
+ if (intel_obj->sys_buffer != NULL) {
+ if (data != NULL)
+ memcpy(intel_obj->sys_buffer, data, size);
+ return true;
+ }
+ }
+#endif
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ if (!intel_obj->buffer)
+ return false;
+
+ if (data != NULL)
+ drm_intel_bo_subdata(intel_obj->buffer, 0, size, data);
+ }
+
+ return true;
+}
+
+
+/**
+ * Replace data in a subrange of buffer object. If the data range
+ * specified by size + offset extends beyond the end of the buffer or
+ * if data is NULL, no copy is performed.
+ * Called via glBufferSubDataARB().
+ */
+static void
+intel_bufferobj_subdata(struct gl_context * ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ const GLvoid * data, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+ bool busy;
+
+ if (size == 0)
+ return;
+
+ assert(intel_obj);
+
+ /* If we have a single copy in system memory, update that */
+ if (intel_obj->sys_buffer) {
+ if (intel_obj->source)
+ release_buffer(intel_obj);
+
+ if (intel_obj->buffer == NULL) {
+ memcpy((char *)intel_obj->sys_buffer + offset, data, size);
+ return;
+ }
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
+ /* Otherwise we need to update the copy in video memory. */
+ busy =
+ drm_intel_bo_busy(intel_obj->buffer) ||
+ drm_intel_bo_references(intel->batch.bo, intel_obj->buffer);
+
+ if (busy) {
+ if (size == intel_obj->Base.Size) {
+ /* Replace the current busy bo with fresh data. */
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ drm_intel_bo_subdata(intel_obj->buffer, 0, size, data);
+ } else {
+ perf_debug("Using a blit copy to avoid stalling on glBufferSubData() "
+ "to a busy buffer object.\n");
+ drm_intel_bo *temp_bo =
+ drm_intel_bo_alloc(intel->bufmgr, "subdata temp", size, 64);
+
+ drm_intel_bo_subdata(temp_bo, 0, size, data);
+
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, offset,
+ temp_bo, 0,
+ size);
+
+ drm_intel_bo_unreference(temp_bo);
+ }
+ } else {
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (drm_intel_bo_busy(intel_obj->buffer)) {
+ perf_debug("Stalling on the GPU in glBufferSubData().\n");
+ }
+ }
+ drm_intel_bo_subdata(intel_obj->buffer, offset, size, data);
+ }
+}
+
+
+/**
+ * Called via glGetBufferSubDataARB().
+ */
+static void
+intel_bufferobj_get_subdata(struct gl_context * ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ GLvoid * data, struct gl_buffer_object *obj)
+{
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+ struct intel_context *intel = intel_context(ctx);
+
+ assert(intel_obj);
+ if (intel_obj->sys_buffer)
+ memcpy(data, (char *)intel_obj->sys_buffer + offset, size);
+ else {
+ if (drm_intel_bo_references(intel->batch.bo, intel_obj->buffer)) {
+ intel_batchbuffer_flush(intel);
+ }
+ drm_intel_bo_get_subdata(intel_obj->buffer, offset, size, data);
+ }
+}
+
+
+
+/**
+ * Called via glMapBufferRange and glMapBuffer
+ *
+ * The goal of this extension is to allow apps to accumulate their rendering
+ * at the same time as they accumulate their buffer object. Without it,
+ * you'd end up blocking on execution of rendering every time you mapped
+ * the buffer to put new data in.
+ *
+ * We support it in 3 ways: If unsynchronized, then don't bother
+ * flushing the batchbuffer before mapping the buffer, which can save blocking
+ * in many cases. If we would still block, and they allow the whole buffer
+ * to be invalidated, then just allocate a new buffer to replace the old one.
+ * If not, and we'd block, and they allow the subrange of the buffer to be
+ * invalidated, then we can make a new little BO, let them write into that,
+ * and blit it into the real BO at unmap time.
+ */
+static void *
+intel_bufferobj_map_range(struct gl_context * ctx,
+ GLintptr offset, GLsizeiptr length,
+ GLbitfield access, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ assert(intel_obj);
+
+ /* _mesa_MapBufferRange (GL entrypoint) sets these, but the vbo module also
+ * internally uses our functions directly.
+ */
+ obj->Offset = offset;
+ obj->Length = length;
+ obj->AccessFlags = access;
+
+ if (intel_obj->sys_buffer) {
+ const bool read_only =
+ (access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == GL_MAP_READ_BIT;
+
+ if (!read_only && intel_obj->source)
+ release_buffer(intel_obj);
+
+ if (!intel_obj->buffer || intel_obj->source) {
+ obj->Pointer = intel_obj->sys_buffer + offset;
+ return obj->Pointer;
+ }
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
+ if (intel_obj->buffer == NULL) {
+ obj->Pointer = NULL;
+ return NULL;
+ }
+
+ /* If the access is synchronized (like a normal buffer mapping), then get
+ * things flushed out so the later mapping syncs appropriately through GEM.
+ * If the user doesn't care about existing buffer contents and mapping would
+ * cause us to block, then throw out the old buffer.
+ *
+ * If they set INVALIDATE_BUFFER, we can pitch the current contents to
+ * achieve the required synchronization.
+ */
+ if (!(access & GL_MAP_UNSYNCHRONIZED_BIT)) {
+ if (drm_intel_bo_references(intel->batch.bo, intel_obj->buffer)) {
+ if (access & GL_MAP_INVALIDATE_BUFFER_BIT) {
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ } else {
+ intel_flush(ctx);
+ }
+ } else if (drm_intel_bo_busy(intel_obj->buffer) &&
+ (access & GL_MAP_INVALIDATE_BUFFER_BIT)) {
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ }
+ }
+
+ /* If the user is mapping a range of an active buffer object but
+ * doesn't require the current contents of that range, make a new
+ * BO, and we'll copy what they put in there out at unmap or
+ * FlushRange time.
+ */
+ if ((access & GL_MAP_INVALIDATE_RANGE_BIT) &&
+ drm_intel_bo_busy(intel_obj->buffer)) {
+ if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
+ intel_obj->range_map_buffer = malloc(length);
+ obj->Pointer = intel_obj->range_map_buffer;
+ } else {
+ intel_obj->range_map_bo = drm_intel_bo_alloc(intel->bufmgr,
+ "range map",
+ length, 64);
+ if (!(access & GL_MAP_READ_BIT)) {
+ drm_intel_gem_bo_map_gtt(intel_obj->range_map_bo);
+ } else {
+ drm_intel_bo_map(intel_obj->range_map_bo,
+ (access & GL_MAP_WRITE_BIT) != 0);
+ }
+ obj->Pointer = intel_obj->range_map_bo->virtual;
+ }
+ return obj->Pointer;
+ }
+
+ if (access & GL_MAP_UNSYNCHRONIZED_BIT)
+ drm_intel_gem_bo_map_unsynchronized(intel_obj->buffer);
+ else if (!(access & GL_MAP_READ_BIT)) {
+ drm_intel_gem_bo_map_gtt(intel_obj->buffer);
+ } else {
+ drm_intel_bo_map(intel_obj->buffer, (access & GL_MAP_WRITE_BIT) != 0);
+ }
+
+ obj->Pointer = intel_obj->buffer->virtual + offset;
+ return obj->Pointer;
+}
+
+/* Ideally we'd use a BO to avoid taking up cache space for the temporary
+ * data, but FlushMappedBufferRange may be followed by further writes to
+ * the pointer, so we would have to re-map after emitting our blit, which
+ * would defeat the point.
+ */
+static void
+intel_bufferobj_flush_mapped_range(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length,
+ struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+ drm_intel_bo *temp_bo;
+
+ /* Unless we're in the range map using a temporary system buffer,
+ * there's no work to do.
+ */
+ if (intel_obj->range_map_buffer == NULL)
+ return;
+
+ if (length == 0)
+ return;
+
+ temp_bo = drm_intel_bo_alloc(intel->bufmgr, "range map flush", length, 64);
+
+ drm_intel_bo_subdata(temp_bo, 0, length, intel_obj->range_map_buffer);
+
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, obj->Offset + offset,
+ temp_bo, 0,
+ length);
+
+ drm_intel_bo_unreference(temp_bo);
+}
+
+
+/**
+ * Called via glUnmapBuffer().
+ */
+static GLboolean
+intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ assert(intel_obj);
+ assert(obj->Pointer);
+ if (intel_obj->sys_buffer != NULL) {
+ /* always keep the mapping around. */
+ } else if (intel_obj->range_map_buffer != NULL) {
+ /* Since we've emitted some blits to buffers that will (likely) be used
+ * in rendering operations in other cache domains in this batch, emit a
+ * flush. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+ free(intel_obj->range_map_buffer);
+ intel_obj->range_map_buffer = NULL;
+ } else if (intel_obj->range_map_bo != NULL) {
+ drm_intel_bo_unmap(intel_obj->range_map_bo);
+
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, obj->Offset,
+ intel_obj->range_map_bo, 0,
+ obj->Length);
+
+ /* Since we've emitted some blits to buffers that will (likely) be used
+ * in rendering operations in other cache domains in this batch, emit a
+ * flush. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ drm_intel_bo_unreference(intel_obj->range_map_bo);
+ intel_obj->range_map_bo = NULL;
+ } else if (intel_obj->buffer != NULL) {
+ drm_intel_bo_unmap(intel_obj->buffer);
+ }
+ obj->Pointer = NULL;
+ obj->Offset = 0;
+ obj->Length = 0;
+
+ return true;
+}
+
+drm_intel_bo *
+intel_bufferobj_buffer(struct intel_context *intel,
+ struct intel_buffer_object *intel_obj,
+ GLuint flag)
+{
+ if (intel_obj->source)
+ release_buffer(intel_obj);
+
+ if (intel_obj->buffer == NULL) {
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ drm_intel_bo_subdata(intel_obj->buffer,
+ 0, intel_obj->Base.Size,
+ intel_obj->sys_buffer);
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ intel_obj->offset = 0;
+ }
+
+ return intel_obj->buffer;
+}
+
+#define INTEL_UPLOAD_SIZE (64*1024)
+
+void
+intel_upload_finish(struct intel_context *intel)
+{
+ if (!intel->upload.bo)
+ return;
+
+ if (intel->upload.buffer_len) {
+ drm_intel_bo_subdata(intel->upload.bo,
+ intel->upload.buffer_offset,
+ intel->upload.buffer_len,
+ intel->upload.buffer);
+ intel->upload.buffer_len = 0;
+ }
+
+ drm_intel_bo_unreference(intel->upload.bo);
+ intel->upload.bo = NULL;
+}
+
+static void wrap_buffers(struct intel_context *intel, GLuint size)
+{
+ intel_upload_finish(intel);
+
+ if (size < INTEL_UPLOAD_SIZE)
+ size = INTEL_UPLOAD_SIZE;
+
+ intel->upload.bo = drm_intel_bo_alloc(intel->bufmgr, "upload", size, 0);
+ intel->upload.offset = 0;
+}
+
+void intel_upload_data(struct intel_context *intel,
+ const void *ptr, GLuint size, GLuint align,
+ drm_intel_bo **return_bo,
+ GLuint *return_offset)
+{
+ GLuint base, delta;
+
+ base = (intel->upload.offset + align - 1) / align * align;
+ if (intel->upload.bo == NULL || base + size > intel->upload.bo->size) {
+ wrap_buffers(intel, size);
+ base = 0;
+ }
+
+ drm_intel_bo_reference(intel->upload.bo);
+ *return_bo = intel->upload.bo;
+ *return_offset = base;
+
+ delta = base - intel->upload.offset;
+ if (intel->upload.buffer_len &&
+ intel->upload.buffer_len + delta + size > sizeof(intel->upload.buffer))
+ {
+ drm_intel_bo_subdata(intel->upload.bo,
+ intel->upload.buffer_offset,
+ intel->upload.buffer_len,
+ intel->upload.buffer);
+ intel->upload.buffer_len = 0;
+ }
+
+ if (size < sizeof(intel->upload.buffer))
+ {
+ if (intel->upload.buffer_len == 0)
+ intel->upload.buffer_offset = base;
+ else
+ intel->upload.buffer_len += delta;
+
+ memcpy(intel->upload.buffer + intel->upload.buffer_len, ptr, size);
+ intel->upload.buffer_len += size;
+ }
+ else
+ {
+ drm_intel_bo_subdata(intel->upload.bo, base, size, ptr);
+ }
+
+ intel->upload.offset = base + size;
+}
+
+void *intel_upload_map(struct intel_context *intel, GLuint size, GLuint align)
+{
+ GLuint base, delta;
+ char *ptr;
+
+ base = (intel->upload.offset + align - 1) / align * align;
+ if (intel->upload.bo == NULL || base + size > intel->upload.bo->size) {
+ wrap_buffers(intel, size);
+ base = 0;
+ }
+
+ delta = base - intel->upload.offset;
+ if (intel->upload.buffer_len &&
+ intel->upload.buffer_len + delta + size > sizeof(intel->upload.buffer))
+ {
+ drm_intel_bo_subdata(intel->upload.bo,
+ intel->upload.buffer_offset,
+ intel->upload.buffer_len,
+ intel->upload.buffer);
+ intel->upload.buffer_len = 0;
+ }
+
+ if (size <= sizeof(intel->upload.buffer)) {
+ if (intel->upload.buffer_len == 0)
+ intel->upload.buffer_offset = base;
+ else
+ intel->upload.buffer_len += delta;
+
+ ptr = intel->upload.buffer + intel->upload.buffer_len;
+ intel->upload.buffer_len += size;
+ } else
+ ptr = malloc(size);
+
+ return ptr;
+}
+
+void intel_upload_unmap(struct intel_context *intel,
+ const void *ptr, GLuint size, GLuint align,
+ drm_intel_bo **return_bo,
+ GLuint *return_offset)
+{
+ GLuint base;
+
+ base = (intel->upload.offset + align - 1) / align * align;
+ if (size > sizeof(intel->upload.buffer)) {
+ drm_intel_bo_subdata(intel->upload.bo, base, size, ptr);
+ free((void*)ptr);
+ }
+
+ drm_intel_bo_reference(intel->upload.bo);
+ *return_bo = intel->upload.bo;
+ *return_offset = base;
+
+ intel->upload.offset = base + size;
+}
+
+drm_intel_bo *
+intel_bufferobj_source(struct intel_context *intel,
+ struct intel_buffer_object *intel_obj,
+ GLuint align, GLuint *offset)
+{
+ if (intel_obj->buffer == NULL) {
+ intel_upload_data(intel,
+ intel_obj->sys_buffer, intel_obj->Base.Size, align,
+ &intel_obj->buffer, &intel_obj->offset);
+ intel_obj->source = 1;
+ }
+
+ *offset = intel_obj->offset;
+ return intel_obj->buffer;
+}
+
+static void
+intel_bufferobj_copy_subdata(struct gl_context *ctx,
+ struct gl_buffer_object *src,
+ struct gl_buffer_object *dst,
+ GLintptr read_offset, GLintptr write_offset,
+ GLsizeiptr size)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_src = intel_buffer_object(src);
+ struct intel_buffer_object *intel_dst = intel_buffer_object(dst);
+ drm_intel_bo *src_bo, *dst_bo;
+ GLuint src_offset;
+
+ if (size == 0)
+ return;
+
+ /* If we're in system memory, just map and memcpy. */
+ if (intel_src->sys_buffer || intel_dst->sys_buffer) {
+ /* The same buffer may be used, but note that regions copied may
+ * not overlap.
+ */
+ if (src == dst) {
+ char *ptr = intel_bufferobj_map_range(ctx, 0, dst->Size,
+ GL_MAP_READ_BIT |
+ GL_MAP_WRITE_BIT,
+ dst);
+ memmove(ptr + write_offset, ptr + read_offset, size);
+ intel_bufferobj_unmap(ctx, dst);
+ } else {
+ const char *src_ptr;
+ char *dst_ptr;
+
+ src_ptr = intel_bufferobj_map_range(ctx, 0, src->Size,
+ GL_MAP_READ_BIT, src);
+ dst_ptr = intel_bufferobj_map_range(ctx, 0, dst->Size,
+ GL_MAP_WRITE_BIT, dst);
+
+ memcpy(dst_ptr + write_offset, src_ptr + read_offset, size);
+
+ intel_bufferobj_unmap(ctx, src);
+ intel_bufferobj_unmap(ctx, dst);
+ }
+ return;
+ }
+
+ /* Otherwise, we have real BOs, so blit them. */
+
+ dst_bo = intel_bufferobj_buffer(intel, intel_dst, INTEL_WRITE_PART);
+ src_bo = intel_bufferobj_source(intel, intel_src, 64, &src_offset);
+
+ intel_emit_linear_blit(intel,
+ dst_bo, write_offset,
+ src_bo, read_offset + src_offset, size);
+
+ /* Since we've emitted some blits to buffers that will (likely) be used
+ * in rendering operations in other cache domains in this batch, emit a
+ * flush. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+}
+
+#if FEATURE_APPLE_object_purgeable
+static GLenum
+intel_buffer_purgeable(drm_intel_bo *buffer)
+{
+ int retained = 0;
+
+ if (buffer != NULL)
+ retained = drm_intel_bo_madvise (buffer, I915_MADV_DONTNEED);
+
+ return retained ? GL_VOLATILE_APPLE : GL_RELEASED_APPLE;
+}
+
+static GLenum
+intel_buffer_object_purgeable(struct gl_context * ctx,
+ struct gl_buffer_object *obj,
+ GLenum option)
+{
+ struct intel_buffer_object *intel_obj = intel_buffer_object (obj);
+
+ if (intel_obj->buffer != NULL)
+ return intel_buffer_purgeable(intel_obj->buffer);
+
+ if (option == GL_RELEASED_APPLE) {
+ if (intel_obj->sys_buffer != NULL) {
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
+ return GL_RELEASED_APPLE;
+ } else {
+ /* XXX Create the buffer and madvise(MADV_DONTNEED)? */
+ struct intel_context *intel = intel_context(ctx);
+ drm_intel_bo *bo = intel_bufferobj_buffer(intel, intel_obj, INTEL_READ);
+
+ return intel_buffer_purgeable(bo);
+ }
+}
+
+static GLenum
+intel_texture_object_purgeable(struct gl_context * ctx,
+ struct gl_texture_object *obj,
+ GLenum option)
+{
+ struct intel_texture_object *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_texture_object(obj);
+ if (intel->mt == NULL || intel->mt->region == NULL)
+ return GL_RELEASED_APPLE;
+
+ return intel_buffer_purgeable(intel->mt->region->bo);
+}
+
+static GLenum
+intel_render_object_purgeable(struct gl_context * ctx,
+ struct gl_renderbuffer *obj,
+ GLenum option)
+{
+ struct intel_renderbuffer *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_renderbuffer(obj);
+ if (intel->mt == NULL)
+ return GL_RELEASED_APPLE;
+
+ return intel_buffer_purgeable(intel->mt->region->bo);
+}
+
+static GLenum
+intel_buffer_unpurgeable(drm_intel_bo *buffer)
+{
+ int retained;
+
+ retained = 0;
+ if (buffer != NULL)
+ retained = drm_intel_bo_madvise (buffer, I915_MADV_WILLNEED);
+
+ return retained ? GL_RETAINED_APPLE : GL_UNDEFINED_APPLE;
+}
+
+static GLenum
+intel_buffer_object_unpurgeable(struct gl_context * ctx,
+ struct gl_buffer_object *obj,
+ GLenum option)
+{
+ (void) ctx;
+ (void) option;
+
+ return intel_buffer_unpurgeable(intel_buffer_object (obj)->buffer);
+}
+
+static GLenum
+intel_texture_object_unpurgeable(struct gl_context * ctx,
+ struct gl_texture_object *obj,
+ GLenum option)
+{
+ struct intel_texture_object *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_texture_object(obj);
+ if (intel->mt == NULL || intel->mt->region == NULL)
+ return GL_UNDEFINED_APPLE;
+
+ return intel_buffer_unpurgeable(intel->mt->region->bo);
+}
+
+static GLenum
+intel_render_object_unpurgeable(struct gl_context * ctx,
+ struct gl_renderbuffer *obj,
+ GLenum option)
+{
+ struct intel_renderbuffer *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_renderbuffer(obj);
+ if (intel->mt == NULL)
+ return GL_UNDEFINED_APPLE;
+
+ return intel_buffer_unpurgeable(intel->mt->region->bo);
+}
+#endif
+
+void
+intelInitBufferObjectFuncs(struct dd_function_table *functions)
+{
+ functions->NewBufferObject = intel_bufferobj_alloc;
+ functions->DeleteBuffer = intel_bufferobj_free;
+ functions->BufferData = intel_bufferobj_data;
+ functions->BufferSubData = intel_bufferobj_subdata;
+ functions->GetBufferSubData = intel_bufferobj_get_subdata;
+ functions->MapBufferRange = intel_bufferobj_map_range;
+ functions->FlushMappedBufferRange = intel_bufferobj_flush_mapped_range;
+ functions->UnmapBuffer = intel_bufferobj_unmap;
+ functions->CopyBufferSubData = intel_bufferobj_copy_subdata;
+
+#if FEATURE_APPLE_object_purgeable
+ functions->BufferObjectPurgeable = intel_buffer_object_purgeable;
+ functions->TextureObjectPurgeable = intel_texture_object_purgeable;
+ functions->RenderObjectPurgeable = intel_render_object_purgeable;
+
+ functions->BufferObjectUnpurgeable = intel_buffer_object_unpurgeable;
+ functions->TextureObjectUnpurgeable = intel_texture_object_unpurgeable;
+ functions->RenderObjectUnpurgeable = intel_render_object_unpurgeable;
+#endif
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffers.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffers.c
index c86daa49f47..9a9a259c9e5 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffers.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_buffers.c
@@ -1 +1,132 @@
-../intel/intel_buffers.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "intel_context.h"
+#include "intel_buffers.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+
+/**
+ * Return pointer to current color drawing region, or NULL.
+ */
+struct intel_region *
+intel_drawbuf_region(struct intel_context *intel)
+{
+ struct intel_renderbuffer *irbColor =
+ intel_renderbuffer(intel->ctx.DrawBuffer->_ColorDrawBuffers[0]);
+ if (irbColor && irbColor->mt)
+ return irbColor->mt->region;
+ else
+ return NULL;
+}
+
+/**
+ * Return pointer to current color reading region, or NULL.
+ */
+struct intel_region *
+intel_readbuf_region(struct intel_context *intel)
+{
+ struct intel_renderbuffer *irb
+ = intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
+ if (irb && irb->mt)
+ return irb->mt->region;
+ else
+ return NULL;
+}
+
+/**
+ * Check if we're about to draw into the front color buffer.
+ * If so, set the intel->front_buffer_dirty field to true.
+ */
+void
+intel_check_front_buffer_rendering(struct intel_context *intel)
+{
+ const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
+ if (_mesa_is_winsys_fbo(fb)) {
+ /* drawing to window system buffer */
+ if (fb->_NumColorDrawBuffers > 0) {
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+ intel->front_buffer_dirty = true;
+ }
+ }
+ }
+}
+
+static void
+intelDrawBuffer(struct gl_context * ctx, GLenum mode)
+{
+ if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ struct intel_context *const intel = intel_context(ctx);
+ const bool was_front_buffer_rendering =
+ intel->is_front_buffer_rendering;
+
+ intel->is_front_buffer_rendering = (mode == GL_FRONT_LEFT)
+ || (mode == GL_FRONT) || (mode == GL_FRONT_AND_BACK);
+
+ /* If we weren't front-buffer rendering before but we are now,
+ * invalidate our DRI drawable so we'll ask for new buffers
+ * (including the fake front) before we start rendering again.
+ */
+ if (!was_front_buffer_rendering && intel->is_front_buffer_rendering)
+ dri2InvalidateDrawable(intel->driContext->driDrawablePriv);
+ }
+
+ intel_draw_buffer(ctx);
+}
+
+
+static void
+intelReadBuffer(struct gl_context * ctx, GLenum mode)
+{
+ if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ struct intel_context *const intel = intel_context(ctx);
+ const bool was_front_buffer_reading =
+ intel->is_front_buffer_reading;
+
+ intel->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
+ || (mode == GL_FRONT);
+
+ /* If we weren't front-buffer reading before but we are now,
+ * invalidate our DRI drawable so we'll ask for new buffers
+ * (including the fake front) before we start reading again.
+ */
+ if (!was_front_buffer_reading && intel->is_front_buffer_reading)
+ dri2InvalidateDrawable(intel->driContext->driReadablePriv);
+ }
+}
+
+
+void
+intelInitBufferFuncs(struct dd_function_table *functions)
+{
+ functions->DrawBuffer = intelDrawBuffer;
+ functions->ReadBuffer = intelReadBuffer;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_context.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_context.c
index 27a1cbb255e..25334da33f7 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_context.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_context.c
@@ -1 +1,1030 @@
-../intel/intel_context.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/extensions.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/imports.h"
+#include "main/points.h"
+#include "main/renderbuffer.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "drivers/common/driverfuncs.h"
+#include "drivers/common/meta.h"
+
+#include "intel_chipset.h"
+#include "intel_buffers.h"
+#include "intel_tex.h"
+#include "intel_batchbuffer.h"
+#include "intel_clear.h"
+#include "intel_extensions.h"
+#include "intel_pixel.h"
+#include "intel_regions.h"
+#include "intel_buffer_objects.h"
+#include "intel_fbo.h"
+#include "intel_bufmgr.h"
+#include "intel_screen.h"
+#include "intel_mipmap_tree.h"
+
+#include "utils.h"
+#include "../glsl/ralloc.h"
+
+#ifndef INTEL_DEBUG
+int INTEL_DEBUG = (0);
+#endif
+
+
+static const GLubyte *
+intelGetString(struct gl_context * ctx, GLenum name)
+{
+ const struct intel_context *const intel = intel_context(ctx);
+ const char *chipset;
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) "Intel Open Source Technology Center";
+ break;
+
+ case GL_RENDERER:
+ switch (intel->intelScreen->deviceID) {
+ case PCI_CHIP_845_G:
+ chipset = "Intel(R) 845G";
+ break;
+ case PCI_CHIP_I830_M:
+ chipset = "Intel(R) 830M";
+ break;
+ case PCI_CHIP_I855_GM:
+ chipset = "Intel(R) 852GM/855GM";
+ break;
+ case PCI_CHIP_I865_G:
+ chipset = "Intel(R) 865G";
+ break;
+ case PCI_CHIP_I915_G:
+ chipset = "Intel(R) 915G";
+ break;
+ case PCI_CHIP_E7221_G:
+ chipset = "Intel (R) E7221G (i915)";
+ break;
+ case PCI_CHIP_I915_GM:
+ chipset = "Intel(R) 915GM";
+ break;
+ case PCI_CHIP_I945_G:
+ chipset = "Intel(R) 945G";
+ break;
+ case PCI_CHIP_I945_GM:
+ chipset = "Intel(R) 945GM";
+ break;
+ case PCI_CHIP_I945_GME:
+ chipset = "Intel(R) 945GME";
+ break;
+ case PCI_CHIP_G33_G:
+ chipset = "Intel(R) G33";
+ break;
+ case PCI_CHIP_Q35_G:
+ chipset = "Intel(R) Q35";
+ break;
+ case PCI_CHIP_Q33_G:
+ chipset = "Intel(R) Q33";
+ break;
+ case PCI_CHIP_IGD_GM:
+ case PCI_CHIP_IGD_G:
+ chipset = "Intel(R) IGD";
+ break;
+ case PCI_CHIP_I965_Q:
+ chipset = "Intel(R) 965Q";
+ break;
+ case PCI_CHIP_I965_G:
+ case PCI_CHIP_I965_G_1:
+ chipset = "Intel(R) 965G";
+ break;
+ case PCI_CHIP_I946_GZ:
+ chipset = "Intel(R) 946GZ";
+ break;
+ case PCI_CHIP_I965_GM:
+ chipset = "Intel(R) 965GM";
+ break;
+ case PCI_CHIP_I965_GME:
+ chipset = "Intel(R) 965GME/GLE";
+ break;
+ case PCI_CHIP_GM45_GM:
+ chipset = "Mobile Intel® GM45 Express Chipset";
+ break;
+ case PCI_CHIP_IGD_E_G:
+ chipset = "Intel(R) Integrated Graphics Device";
+ break;
+ case PCI_CHIP_G45_G:
+ chipset = "Intel(R) G45/G43";
+ break;
+ case PCI_CHIP_Q45_G:
+ chipset = "Intel(R) Q45/Q43";
+ break;
+ case PCI_CHIP_G41_G:
+ chipset = "Intel(R) G41";
+ break;
+ case PCI_CHIP_B43_G:
+ case PCI_CHIP_B43_G1:
+ chipset = "Intel(R) B43";
+ break;
+ case PCI_CHIP_ILD_G:
+ chipset = "Intel(R) Ironlake Desktop";
+ break;
+ case PCI_CHIP_ILM_G:
+ chipset = "Intel(R) Ironlake Mobile";
+ break;
+ case PCI_CHIP_SANDYBRIDGE_GT1:
+ case PCI_CHIP_SANDYBRIDGE_GT2:
+ case PCI_CHIP_SANDYBRIDGE_GT2_PLUS:
+ chipset = "Intel(R) Sandybridge Desktop";
+ break;
+ case PCI_CHIP_SANDYBRIDGE_M_GT1:
+ case PCI_CHIP_SANDYBRIDGE_M_GT2:
+ case PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS:
+ chipset = "Intel(R) Sandybridge Mobile";
+ break;
+ case PCI_CHIP_SANDYBRIDGE_S:
+ chipset = "Intel(R) Sandybridge Server";
+ break;
+ case PCI_CHIP_IVYBRIDGE_GT1:
+ case PCI_CHIP_IVYBRIDGE_GT2:
+ chipset = "Intel(R) Ivybridge Desktop";
+ break;
+ case PCI_CHIP_IVYBRIDGE_M_GT1:
+ case PCI_CHIP_IVYBRIDGE_M_GT2:
+ chipset = "Intel(R) Ivybridge Mobile";
+ break;
+ case PCI_CHIP_IVYBRIDGE_S_GT1:
+ case PCI_CHIP_IVYBRIDGE_S_GT2:
+ chipset = "Intel(R) Ivybridge Server";
+ break;
+ case PCI_CHIP_HASWELL_GT1:
+ case PCI_CHIP_HASWELL_GT2:
+ case PCI_CHIP_HASWELL_GT2_PLUS:
+ case PCI_CHIP_HASWELL_SDV_GT1:
+ case PCI_CHIP_HASWELL_SDV_GT2:
+ case PCI_CHIP_HASWELL_SDV_GT2_PLUS:
+ case PCI_CHIP_HASWELL_ULT_GT1:
+ case PCI_CHIP_HASWELL_ULT_GT2:
+ case PCI_CHIP_HASWELL_ULT_GT2_PLUS:
+ case PCI_CHIP_HASWELL_CRW_GT1:
+ case PCI_CHIP_HASWELL_CRW_GT2:
+ case PCI_CHIP_HASWELL_CRW_GT2_PLUS:
+ chipset = "Intel(R) Haswell Desktop";
+ break;
+ case PCI_CHIP_HASWELL_M_GT1:
+ case PCI_CHIP_HASWELL_M_GT2:
+ case PCI_CHIP_HASWELL_M_GT2_PLUS:
+ case PCI_CHIP_HASWELL_SDV_M_GT1:
+ case PCI_CHIP_HASWELL_SDV_M_GT2:
+ case PCI_CHIP_HASWELL_SDV_M_GT2_PLUS:
+ case PCI_CHIP_HASWELL_ULT_M_GT1:
+ case PCI_CHIP_HASWELL_ULT_M_GT2:
+ case PCI_CHIP_HASWELL_ULT_M_GT2_PLUS:
+ case PCI_CHIP_HASWELL_CRW_M_GT1:
+ case PCI_CHIP_HASWELL_CRW_M_GT2:
+ case PCI_CHIP_HASWELL_CRW_M_GT2_PLUS:
+ chipset = "Intel(R) Haswell Mobile";
+ break;
+ case PCI_CHIP_HASWELL_S_GT1:
+ case PCI_CHIP_HASWELL_S_GT2:
+ case PCI_CHIP_HASWELL_S_GT2_PLUS:
+ case PCI_CHIP_HASWELL_SDV_S_GT1:
+ case PCI_CHIP_HASWELL_SDV_S_GT2:
+ case PCI_CHIP_HASWELL_SDV_S_GT2_PLUS:
+ case PCI_CHIP_HASWELL_ULT_S_GT1:
+ case PCI_CHIP_HASWELL_ULT_S_GT2:
+ case PCI_CHIP_HASWELL_ULT_S_GT2_PLUS:
+ case PCI_CHIP_HASWELL_CRW_S_GT1:
+ case PCI_CHIP_HASWELL_CRW_S_GT2:
+ case PCI_CHIP_HASWELL_CRW_S_GT2_PLUS:
+ chipset = "Intel(R) Haswell Server";
+ break;
+ default:
+ chipset = "Unknown Intel Chipset";
+ break;
+ }
+
+ (void) driGetRendererString(buffer, chipset, 0);
+ return (GLubyte *) buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+void
+intel_downsample_for_dri2_flush(struct intel_context *intel,
+ __DRIdrawable *drawable)
+{
+ if (intel->gen < 6) {
+ /* MSAA is not supported, so don't waste time checking for
+ * a multisample buffer.
+ */
+ return;
+ }
+
+ struct gl_framebuffer *fb = drawable->driverPrivate;
+ struct intel_renderbuffer *rb;
+
+ /* Usually, only the back buffer will need to be downsampled. However,
+ * the front buffer will also need it if the user has rendered into it.
+ */
+ static const gl_buffer_index buffers[2] = {
+ BUFFER_BACK_LEFT,
+ BUFFER_FRONT_LEFT,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+ rb = intel_get_renderbuffer(fb, buffers[i]);
+ if (rb == NULL || rb->mt == NULL)
+ continue;
+ intel_miptree_downsample(intel, rb->mt);
+ }
+}
+
+static void
+intel_flush_front(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIcontext *driContext = intel->driContext;
+ __DRIdrawable *driDrawable = driContext->driDrawablePriv;
+ __DRIscreen *const screen = intel->intelScreen->driScrnPriv;
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer) && intel->front_buffer_dirty) {
+ if (screen->dri2.loader->flushFrontBuffer != NULL &&
+ driDrawable &&
+ driDrawable->loaderPrivate) {
+
+ /* Downsample before flushing FAKE_FRONT_LEFT to FRONT_LEFT.
+ *
+ * This potentially downsamples both front and back buffer. It
+ * is unnecessary to downsample the back, but harms nothing except
+ * performance. And no one cares about front-buffer render
+ * performance.
+ */
+ intel_downsample_for_dri2_flush(intel, driDrawable);
+
+ screen->dri2.loader->flushFrontBuffer(driDrawable,
+ driDrawable->loaderPrivate);
+
+ /* We set the dirty bit in intel_prepare_render() if we're
+ * front buffer rendering once we get there.
+ */
+ intel->front_buffer_dirty = false;
+ }
+ }
+}
+
+static unsigned
+intel_bits_per_pixel(const struct intel_renderbuffer *rb)
+{
+ return _mesa_get_format_bytes(intel_rb_format(rb)) * 8;
+}
+
+static void
+intel_query_dri2_buffers(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer **buffers,
+ int *count);
+
+static void
+intel_process_dri2_buffer(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer *buffer,
+ struct intel_renderbuffer *rb,
+ const char *buffer_name);
+
+void
+intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+ struct gl_framebuffer *fb = drawable->driverPrivate;
+ struct intel_renderbuffer *rb;
+ struct intel_context *intel = context->driverPrivate;
+ __DRIbuffer *buffers = NULL;
+ int i, count;
+ const char *region_name;
+
+ /* If we're rendering to the fake front buffer, make sure all the
+ * pending drawing has landed on the real front buffer. Otherwise
+ * when we eventually get to DRI2GetBuffersWithFormat the stale
+ * real front buffer contents will get copied to the new fake front
+ * buffer.
+ */
+ if (intel->is_front_buffer_rendering) {
+ intel_flush(&intel->ctx);
+ intel_flush_front(&intel->ctx);
+ }
+
+ /* Set this up front, so that in case our buffers get invalidated
+ * while we're getting new buffers, we don't clobber the stamp and
+ * thus ignore the invalidate. */
+ drawable->lastStamp = drawable->dri2.stamp;
+
+ if (unlikely(INTEL_DEBUG & DEBUG_DRI))
+ fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+ intel_query_dri2_buffers(intel, drawable, &buffers, &count);
+
+ if (buffers == NULL)
+ return;
+
+ for (i = 0; i < count; i++) {
+ switch (buffers[i].attachment) {
+ case __DRI_BUFFER_FRONT_LEFT:
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ region_name = "dri2 front buffer";
+ break;
+
+ case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ region_name = "dri2 fake front buffer";
+ break;
+
+ case __DRI_BUFFER_BACK_LEFT:
+ rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+ region_name = "dri2 back buffer";
+ break;
+
+ case __DRI_BUFFER_DEPTH:
+ case __DRI_BUFFER_HIZ:
+ case __DRI_BUFFER_DEPTH_STENCIL:
+ case __DRI_BUFFER_STENCIL:
+ case __DRI_BUFFER_ACCUM:
+ default:
+ fprintf(stderr,
+ "unhandled buffer attach event, attachment type %d\n",
+ buffers[i].attachment);
+ return;
+ }
+
+ intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
+ }
+
+ driUpdateFramebufferSize(&intel->ctx, drawable);
+}
+
+/**
+ * intel_prepare_render should be called anywhere that curent read/drawbuffer
+ * state is required.
+ */
+void
+intel_prepare_render(struct intel_context *intel)
+{
+ __DRIcontext *driContext = intel->driContext;
+ __DRIdrawable *drawable;
+
+ drawable = driContext->driDrawablePriv;
+ if (drawable && drawable->dri2.stamp != driContext->dri2.draw_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ intel_update_renderbuffers(driContext, drawable);
+ intel_draw_buffer(&intel->ctx);
+ driContext->dri2.draw_stamp = drawable->dri2.stamp;
+ }
+
+ drawable = driContext->driReadablePriv;
+ if (drawable && drawable->dri2.stamp != driContext->dri2.read_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ intel_update_renderbuffers(driContext, drawable);
+ driContext->dri2.read_stamp = drawable->dri2.stamp;
+ }
+
+ /* If we're currently rendering to the front buffer, the rendering
+ * that will happen next will probably dirty the front buffer. So
+ * mark it as dirty here.
+ */
+ if (intel->is_front_buffer_rendering)
+ intel->front_buffer_dirty = true;
+
+ /* Wait for the swapbuffers before the one we just emitted, so we
+ * don't get too many swaps outstanding for apps that are GPU-heavy
+ * but not CPU-heavy.
+ *
+ * We're using intelDRI2Flush (called from the loader before
+ * swapbuffer) and glFlush (for front buffer rendering) as the
+ * indicator that a frame is done and then throttle when we get
+ * here as we prepare to render the next frame. At this point for
+ * round trips for swap/copy and getting new buffers are done and
+ * we'll spend less time waiting on the GPU.
+ *
+ * Unfortunately, we don't have a handle to the batch containing
+ * the swap, and getting our hands on that doesn't seem worth it,
+ * so we just us the first batch we emitted after the last swap.
+ */
+ if (intel->need_throttle && intel->first_post_swapbuffers_batch) {
+ drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch);
+ drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
+ intel->first_post_swapbuffers_batch = NULL;
+ intel->need_throttle = false;
+ }
+}
+
+static void
+intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIcontext *driContext = intel->driContext;
+
+ if (intel->saved_viewport)
+ intel->saved_viewport(ctx, x, y, w, h);
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ dri2InvalidateDrawable(driContext->driDrawablePriv);
+ dri2InvalidateDrawable(driContext->driReadablePriv);
+ }
+}
+
+static const struct dri_debug_control debug_control[] = {
+ { "tex", DEBUG_TEXTURE},
+ { "state", DEBUG_STATE},
+ { "ioctl", DEBUG_IOCTL},
+ { "blit", DEBUG_BLIT},
+ { "mip", DEBUG_MIPTREE},
+ { "fall", DEBUG_PERF},
+ { "perf", DEBUG_PERF},
+ { "verb", DEBUG_VERBOSE},
+ { "bat", DEBUG_BATCH},
+ { "pix", DEBUG_PIXEL},
+ { "buf", DEBUG_BUFMGR},
+ { "reg", DEBUG_REGION},
+ { "fbo", DEBUG_FBO},
+ { "gs", DEBUG_GS},
+ { "sync", DEBUG_SYNC},
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "dri", DEBUG_DRI },
+ { "sf", DEBUG_SF },
+ { "san", DEBUG_SANITY },
+ { "sleep", DEBUG_SLEEP },
+ { "stats", DEBUG_STATS },
+ { "tile", DEBUG_TILE },
+ { "wm", DEBUG_WM },
+ { "urb", DEBUG_URB },
+ { "vs", DEBUG_VS },
+ { "clip", DEBUG_CLIP },
+ { "aub", DEBUG_AUB },
+ { NULL, 0 }
+};
+
+
+static void
+intelInvalidateState(struct gl_context * ctx, GLuint new_state)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ if (ctx->swrast_context)
+ _swrast_InvalidateState(ctx, new_state);
+ _vbo_InvalidateState(ctx, new_state);
+
+ intel->NewGLState |= new_state;
+
+ if (intel->vtbl.invalidate_state)
+ intel->vtbl.invalidate_state( intel, new_state );
+}
+
+void
+intel_flush_rendering_to_batch(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ if (intel->Fallback)
+ _swrast_flush(ctx);
+
+ if (intel->gen < 4)
+ INTEL_FIREVERTICES(intel);
+}
+
+void
+_intel_flush(struct gl_context *ctx, const char *file, int line)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush_rendering_to_batch(ctx);
+
+ if (intel->batch.used)
+ _intel_batchbuffer_flush(intel, file, line);
+}
+
+static void
+intel_glFlush(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush(ctx);
+ intel_flush_front(ctx);
+ if (intel->is_front_buffer_rendering)
+ intel->need_throttle = true;
+}
+
+void
+intelFinish(struct gl_context * ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush(ctx);
+ intel_flush_front(ctx);
+
+ if (intel->batch.last_bo)
+ drm_intel_bo_wait_rendering(intel->batch.last_bo);
+}
+
+void
+intelInitDriverFunctions(struct dd_function_table *functions)
+{
+ _mesa_init_driver_functions(functions);
+
+ functions->Flush = intel_glFlush;
+ functions->Finish = intelFinish;
+ functions->GetString = intelGetString;
+ functions->UpdateState = intelInvalidateState;
+
+ intelInitTextureFuncs(functions);
+ intelInitTextureImageFuncs(functions);
+ intelInitTextureSubImageFuncs(functions);
+ intelInitTextureCopyImageFuncs(functions);
+ intelInitClearFuncs(functions);
+ intelInitBufferFuncs(functions);
+ intelInitPixelFuncs(functions);
+ intelInitBufferObjectFuncs(functions);
+ intel_init_syncobj_functions(functions);
+}
+
+bool
+intelInitContext(struct intel_context *intel,
+ int api,
+ const struct gl_config * mesaVis,
+ __DRIcontext * driContextPriv,
+ void *sharedContextPrivate,
+ struct dd_function_table *functions)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate;
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+ struct intel_screen *intelScreen = sPriv->driverPrivate;
+ int bo_reuse_mode;
+ struct gl_config visual;
+
+ /* we can't do anything without a connection to the device */
+ if (intelScreen->bufmgr == NULL)
+ return false;
+
+ /* Can't rely on invalidate events, fall back to glViewport hack */
+ if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
+ intel->saved_viewport = functions->Viewport;
+ functions->Viewport = intel_viewport;
+ }
+
+ if (mesaVis == NULL) {
+ memset(&visual, 0, sizeof visual);
+ mesaVis = &visual;
+ }
+
+ if (!_mesa_initialize_context(&intel->ctx, api, mesaVis, shareCtx,
+ functions, (void *) intel)) {
+ printf("%s: failed to init mesa context\n", __FUNCTION__);
+ return false;
+ }
+
+ driContextPriv->driverPrivate = intel;
+ intel->intelScreen = intelScreen;
+ intel->driContext = driContextPriv;
+ intel->driFd = sPriv->fd;
+
+ intel->gen = intelScreen->gen;
+
+ const int devID = intelScreen->deviceID;
+ if (IS_SNB_GT1(devID) || IS_IVB_GT1(devID) || IS_HSW_GT1(devID))
+ intel->gt = 1;
+ else if (IS_SNB_GT2(devID) || IS_IVB_GT2(devID) || IS_HSW_GT2(devID))
+ intel->gt = 2;
+ else
+ intel->gt = 0;
+
+ if (IS_HASWELL(devID)) {
+ intel->is_haswell = true;
+ } else if (IS_G4X(devID)) {
+ intel->is_g4x = true;
+ } else if (IS_945(devID)) {
+ intel->is_945 = true;
+ }
+
+ if (intel->gen >= 5) {
+ intel->needs_ff_sync = true;
+ }
+
+ intel->has_separate_stencil = intel->intelScreen->hw_has_separate_stencil;
+ intel->must_use_separate_stencil = intel->intelScreen->hw_must_use_separate_stencil;
+ intel->has_hiz = intel->gen >= 6 && !intel->is_haswell;
+ intel->has_llc = intel->intelScreen->hw_has_llc;
+ intel->has_swizzling = intel->intelScreen->hw_has_swizzling;
+
+ memset(&ctx->TextureFormatSupported,
+ 0, sizeof(ctx->TextureFormatSupported));
+
+ driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
+ sPriv->myNum, (intel->gen >= 4) ? "i965" : "i915");
+ if (intel->gen < 4)
+ intel->maxBatchSize = 4096;
+ else
+ intel->maxBatchSize = sizeof(intel->batch.map);
+
+ intel->bufmgr = intelScreen->bufmgr;
+
+ bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+ switch (bo_reuse_mode) {
+ case DRI_CONF_BO_REUSE_DISABLED:
+ break;
+ case DRI_CONF_BO_REUSE_ALL:
+ intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+ break;
+ }
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 5.0;
+ ctx->Const.MaxLineWidthAA = 5.0;
+ ctx->Const.LineWidthGranularity = 0.5;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 255.0;
+ ctx->Const.MaxPointSizeAA = 3.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ ctx->Const.MaxSamples = 1.0;
+
+ if (intel->gen >= 6)
+ ctx->Const.MaxClipPlanes = 8;
+
+ ctx->Const.StripTextureBorder = GL_TRUE;
+
+ /* reinitialize the context point state.
+ * It depend on constants in __struct gl_contextRec::Const
+ */
+ _mesa_init_point(ctx);
+
+ if (intel->gen >= 4) {
+ ctx->Const.MaxRenderbufferSize = 8192;
+ } else {
+ ctx->Const.MaxRenderbufferSize = 2048;
+ }
+
+ /* Initialize the software rasterizer and helper modules.
+ *
+ * As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
+ * software fallbacks (which we have to support on legacy GL to do weird
+ * glDrawPixels(), glBitmap(), and other functions).
+ */
+ if (intel->gen <= 3 || api != API_OPENGL_CORE) {
+ _swrast_CreateContext(ctx);
+ }
+
+ _vbo_CreateContext(ctx);
+ if (ctx->swrast_context) {
+ _tnl_CreateContext(ctx);
+ _swsetup_CreateContext(ctx);
+
+ /* Configure swrast to match hardware characteristics: */
+ _swrast_allow_pixel_fog(ctx, false);
+ _swrast_allow_vertex_fog(ctx, true);
+ }
+
+ _mesa_meta_init(ctx);
+
+ intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+ intel->hw_stipple = 1;
+
+ /* XXX FBO: this doesn't seem to be used anywhere */
+ switch (mesaVis->depthBits) {
+ case 0: /* what to do in this case? */
+ case 16:
+ intel->polygon_offset_scale = 1.0;
+ break;
+ case 24:
+ intel->polygon_offset_scale = 2.0; /* req'd to pass glean */
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ if (intel->gen >= 4)
+ intel->polygon_offset_scale /= 0xffff;
+
+ intel->RenderIndex = ~0;
+
+ intelInitExtensions(ctx);
+
+ INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
+ if (INTEL_DEBUG & DEBUG_BUFMGR)
+ dri_bufmgr_set_debug(intel->bufmgr, true);
+
+ if (INTEL_DEBUG & DEBUG_AUB)
+ drm_intel_bufmgr_gem_set_aub_dump(intel->bufmgr, true);
+
+ intel_batchbuffer_init(intel);
+
+ intel_fbo_init(intel);
+
+ intel->use_texture_tiling = driQueryOptionb(&intel->optionCache,
+ "texture_tiling");
+ intel->use_early_z = driQueryOptionb(&intel->optionCache, "early_z");
+
+ if (!driQueryOptionb(&intel->optionCache, "hiz")) {
+ intel->has_hiz = false;
+ /* On gen6, you can only do separate stencil with HIZ. */
+ if (intel->gen == 6)
+ intel->has_separate_stencil = false;
+ }
+
+ intel->prim.primitive = ~0;
+
+ /* Force all software fallbacks */
+#ifdef I915
+ if (driQueryOptionb(&intel->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D rasterization\n");
+ intel->no_rast = 1;
+ }
+#endif
+
+ if (driQueryOptionb(&intel->optionCache, "always_flush_batch")) {
+ fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
+ intel->always_flush_batch = 1;
+ }
+
+ if (driQueryOptionb(&intel->optionCache, "always_flush_cache")) {
+ fprintf(stderr, "flushing GPU caches before/after each draw call\n");
+ intel->always_flush_cache = 1;
+ }
+
+ return true;
+}
+
+void
+intelDestroyContext(__DRIcontext * driContextPriv)
+{
+ struct intel_context *intel =
+ (struct intel_context *) driContextPriv->driverPrivate;
+ struct gl_context *ctx = &intel->ctx;
+
+ assert(intel); /* should never be null */
+ if (intel) {
+ INTEL_FIREVERTICES(intel);
+
+ /* Dump a final BMP in case the application doesn't call SwapBuffers */
+ if (INTEL_DEBUG & DEBUG_AUB) {
+ intel_batchbuffer_flush(intel);
+ aub_dump_bmp(&intel->ctx);
+ }
+
+ _mesa_meta_free(&intel->ctx);
+
+ intel->vtbl.destroy(intel);
+
+ if (ctx->swrast_context) {
+ _swsetup_DestroyContext(&intel->ctx);
+ _tnl_DestroyContext(&intel->ctx);
+ }
+ _vbo_DestroyContext(&intel->ctx);
+
+ if (ctx->swrast_context)
+ _swrast_DestroyContext(&intel->ctx);
+ intel->Fallback = 0x0; /* don't call _swrast_Flush later */
+
+ intel_batchbuffer_free(intel);
+
+ free(intel->prim.vb);
+ intel->prim.vb = NULL;
+ drm_intel_bo_unreference(intel->prim.vb_bo);
+ intel->prim.vb_bo = NULL;
+ drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
+ intel->first_post_swapbuffers_batch = NULL;
+
+ driDestroyOptionCache(&intel->optionCache);
+
+ /* free the Mesa context */
+ _mesa_free_context_data(&intel->ctx);
+
+ _math_matrix_dtr(&intel->ViewportMatrix);
+
+ ralloc_free(intel);
+ driContextPriv->driverPrivate = NULL;
+ }
+}
+
+GLboolean
+intelUnbindContext(__DRIcontext * driContextPriv)
+{
+ /* Unset current context and dispath table */
+ _mesa_make_current(NULL, NULL, NULL);
+
+ return true;
+}
+
+GLboolean
+intelMakeCurrent(__DRIcontext * driContextPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv)
+{
+ struct intel_context *intel;
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if (driContextPriv)
+ intel = (struct intel_context *) driContextPriv->driverPrivate;
+ else
+ intel = NULL;
+
+ /* According to the glXMakeCurrent() man page: "Pending commands to
+ * the previous context, if any, are flushed before it is released."
+ * But only flush if we're actually changing contexts.
+ */
+ if (intel_context(curCtx) && intel_context(curCtx) != intel) {
+ _mesa_flush(curCtx);
+ }
+
+ if (driContextPriv) {
+ struct gl_framebuffer *fb, *readFb;
+
+ if (driDrawPriv == NULL && driReadPriv == NULL) {
+ fb = _mesa_get_incomplete_framebuffer();
+ readFb = _mesa_get_incomplete_framebuffer();
+ } else {
+ fb = driDrawPriv->driverPrivate;
+ readFb = driReadPriv->driverPrivate;
+ driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
+ driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
+ }
+
+ intel_prepare_render(intel);
+ _mesa_make_current(&intel->ctx, fb, readFb);
+
+ /* We do this in intel_prepare_render() too, but intel->ctx.DrawBuffer
+ * is NULL at that point. We can't call _mesa_makecurrent()
+ * first, since we need the buffer size for the initial
+ * viewport. So just call intel_draw_buffer() again here. */
+ intel_draw_buffer(&intel->ctx);
+ }
+ else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return true;
+}
+
+/**
+ * \brief Query DRI2 to obtain a DRIdrawable's buffers.
+ *
+ * To determine which DRI buffers to request, examine the renderbuffers
+ * attached to the drawable's framebuffer. Then request the buffers with
+ * DRI2GetBuffers() or DRI2GetBuffersWithFormat().
+ *
+ * This is called from intel_update_renderbuffers().
+ *
+ * \param drawable Drawable whose buffers are queried.
+ * \param buffers [out] List of buffers returned by DRI2 query.
+ * \param buffer_count [out] Number of buffers returned.
+ *
+ * \see intel_update_renderbuffers()
+ * \see DRI2GetBuffers()
+ * \see DRI2GetBuffersWithFormat()
+ */
+static void
+intel_query_dri2_buffers(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer **buffers,
+ int *buffer_count)
+{
+ __DRIscreen *screen = intel->intelScreen->driScrnPriv;
+ struct gl_framebuffer *fb = drawable->driverPrivate;
+ int i = 0;
+ const int max_attachments = 4;
+ unsigned *attachments = calloc(2 * max_attachments, sizeof(unsigned));
+
+ struct intel_renderbuffer *front_rb;
+ struct intel_renderbuffer *back_rb;
+
+ front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+
+ if ((intel->is_front_buffer_rendering ||
+ intel->is_front_buffer_reading ||
+ !back_rb) && front_rb) {
+ attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ attachments[i++] = intel_bits_per_pixel(front_rb);
+ }
+
+ if (back_rb) {
+ attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ attachments[i++] = intel_bits_per_pixel(back_rb);
+ }
+
+ assert(i <= 2 * max_attachments);
+
+ *buffers = screen->dri2.loader->getBuffersWithFormat(drawable,
+ &drawable->w,
+ &drawable->h,
+ attachments, i / 2,
+ buffer_count,
+ drawable->loaderPrivate);
+ free(attachments);
+}
+
+/**
+ * \brief Assign a DRI buffer's DRM region to a renderbuffer.
+ *
+ * This is called from intel_update_renderbuffers().
+ *
+ * \par Note:
+ * DRI buffers whose attachment point is DRI2BufferStencil or
+ * DRI2BufferDepthStencil are handled as special cases.
+ *
+ * \param buffer_name is a human readable name, such as "dri2 front buffer",
+ * that is passed to intel_region_alloc_for_handle().
+ *
+ * \see intel_update_renderbuffers()
+ * \see intel_region_alloc_for_handle()
+ */
+static void
+intel_process_dri2_buffer(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer *buffer,
+ struct intel_renderbuffer *rb,
+ const char *buffer_name)
+{
+ struct intel_region *region = NULL;
+
+ if (!rb)
+ return;
+
+ unsigned num_samples = rb->Base.Base.NumSamples;
+
+ /* We try to avoid closing and reopening the same BO name, because the first
+ * use of a mapping of the buffer involves a bunch of page faulting which is
+ * moderately expensive.
+ */
+ if (num_samples == 0) {
+ if (rb->mt &&
+ rb->mt->region &&
+ rb->mt->region->name == buffer->name)
+ return;
+ } else {
+ if (rb->mt &&
+ rb->mt->singlesample_mt &&
+ rb->mt->singlesample_mt->region &&
+ rb->mt->singlesample_mt->region->name == buffer->name)
+ return;
+ }
+
+ if (unlikely(INTEL_DEBUG & DEBUG_DRI)) {
+ fprintf(stderr,
+ "attaching buffer %d, at %d, cpp %d, pitch %d\n",
+ buffer->name, buffer->attachment,
+ buffer->cpp, buffer->pitch);
+ }
+
+ intel_miptree_release(&rb->mt);
+ region = intel_region_alloc_for_handle(intel->intelScreen,
+ buffer->cpp,
+ drawable->w,
+ drawable->h,
+ buffer->pitch / buffer->cpp,
+ buffer->name,
+ buffer_name);
+ if (!region)
+ return;
+
+ rb->mt = intel_miptree_create_for_dri2_buffer(intel,
+ buffer->attachment,
+ intel_rb_format(rb),
+ num_samples,
+ region);
+ intel_region_release(&region);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_extensions.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_extensions.c
index a2f3e8cd208..885e8a43e80 120000..100755
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_extensions.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_extensions.c
@@ -1 +1,197 @@
-../intel/intel_extensions.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mfeatures.h"
+#include "main/version.h"
+
+#include "intel_chipset.h"
+#include "intel_context.h"
+#include "intel_extensions.h"
+#include "intel_reg.h"
+#include "utils.h"
+
+/**
+ * Initializes potential list of extensions if ctx == NULL, or actually enables
+ * extensions for a context.
+ */
+void
+intelInitExtensions(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ ctx->Extensions.ARB_draw_elements_base_vertex = true;
+ ctx->Extensions.ARB_explicit_attrib_location = true;
+ if (_mesa_is_desktop_gl(ctx))
+ ctx->Extensions.ARB_framebuffer_object = true;
+ ctx->Extensions.ARB_half_float_pixel = true;
+ ctx->Extensions.ARB_map_buffer_range = true;
+ ctx->Extensions.ARB_point_sprite = true;
+ ctx->Extensions.ARB_shader_objects = true;
+ ctx->Extensions.ARB_shading_language_100 = true;
+ ctx->Extensions.ARB_sync = true;
+ ctx->Extensions.ARB_texture_border_clamp = true;
+ ctx->Extensions.ARB_texture_cube_map = true;
+ ctx->Extensions.ARB_texture_env_combine = true;
+ ctx->Extensions.ARB_texture_env_crossbar = true;
+ ctx->Extensions.ARB_texture_env_dot3 = true;
+ ctx->Extensions.ARB_texture_storage = true;
+ ctx->Extensions.ARB_vertex_program = true;
+ ctx->Extensions.ARB_vertex_shader = true;
+ ctx->Extensions.EXT_blend_color = true;
+ ctx->Extensions.EXT_blend_equation_separate = true;
+ ctx->Extensions.EXT_blend_func_separate = true;
+ ctx->Extensions.EXT_blend_minmax = true;
+ ctx->Extensions.EXT_framebuffer_blit = true;
+ ctx->Extensions.EXT_framebuffer_object = true;
+ ctx->Extensions.EXT_framebuffer_multisample = true;
+ ctx->Extensions.EXT_fog_coord = true;
+ ctx->Extensions.EXT_gpu_program_parameters = true;
+ ctx->Extensions.EXT_packed_depth_stencil = true;
+ ctx->Extensions.EXT_pixel_buffer_object = true;
+ ctx->Extensions.EXT_point_parameters = true;
+ ctx->Extensions.EXT_provoking_vertex = true;
+ ctx->Extensions.EXT_secondary_color = true;
+ ctx->Extensions.EXT_separate_shader_objects = true;
+ ctx->Extensions.EXT_texture_env_dot3 = true;
+ ctx->Extensions.EXT_texture_filter_anisotropic = true;
+ ctx->Extensions.APPLE_object_purgeable = true;
+ ctx->Extensions.MESA_pack_invert = true;
+ ctx->Extensions.MESA_ycbcr_texture = true;
+ ctx->Extensions.NV_blend_square = true;
+ ctx->Extensions.NV_texture_rectangle = true;
+ ctx->Extensions.NV_vertex_program = true;
+ ctx->Extensions.NV_vertex_program1_1 = true;
+ ctx->Extensions.TDFX_texture_compression_FXT1 = true;
+#if FEATURE_OES_EGL_image
+ ctx->Extensions.OES_EGL_image = true;
+#endif
+ ctx->Extensions.OES_draw_texture = true;
+ ctx->Extensions.OES_compressed_ETC1_RGB8_texture = true;
+ ctx->Extensions.ARB_texture_rgb10_a2ui = true;
+
+ if (intel->gen >= 6)
+ if (ctx->API == API_OPENGL_CORE) {
+ ctx->Const.GLSLVersion = 140;
+ } else {
+ ctx->Const.GLSLVersion = 130;
+ }
+ else
+ ctx->Const.GLSLVersion = 120;
+ _mesa_override_glsl_version(ctx);
+
+ if (intel->gen == 6 ||
+ (intel->gen == 7 && intel->intelScreen->kernel_has_gen7_sol_reset))
+ ctx->Extensions.EXT_transform_feedback = true;
+
+ if (intel->gen >= 6) {
+ ctx->Extensions.ARB_blend_func_extended = !driQueryOptionb(&intel->optionCache, "disable_blend_func_extended");
+ ctx->Extensions.ARB_draw_buffers_blend = true;
+ ctx->Extensions.ARB_uniform_buffer_object = true;
+
+ if (ctx->API == API_OPENGL_CORE) {
+ ctx->Extensions.ARB_texture_buffer_object = true;
+ }
+ }
+
+ if (intel->gen >= 5)
+ ctx->Extensions.EXT_timer_query = true;
+
+ if (intel->gen >= 6) {
+ uint64_t dummy;
+ /* Test if the kernel has the ioctl. */
+ if (drm_intel_reg_read(intel->bufmgr, TIMESTAMP, &dummy) == 0)
+ ctx->Extensions.ARB_timer_query = true;
+ }
+
+ if (intel->gen >= 4) {
+ ctx->Extensions.ARB_color_buffer_float = true;
+ ctx->Extensions.ARB_depth_buffer_float = true;
+ ctx->Extensions.ARB_depth_clamp = true;
+ ctx->Extensions.ARB_draw_instanced = true;
+ ctx->Extensions.ARB_instanced_arrays = true;
+ ctx->Extensions.ARB_fragment_coord_conventions = true;
+ ctx->Extensions.ARB_fragment_program_shadow = true;
+ ctx->Extensions.ARB_fragment_shader = true;
+ ctx->Extensions.ARB_half_float_vertex = true;
+ ctx->Extensions.ARB_occlusion_query = true;
+ ctx->Extensions.ARB_occlusion_query2 = true;
+ ctx->Extensions.ARB_point_sprite = true;
+ ctx->Extensions.ARB_seamless_cube_map = true;
+ ctx->Extensions.ARB_shader_bit_encoding = true;
+ ctx->Extensions.ARB_shader_texture_lod = true;
+#ifdef TEXTURE_FLOAT_ENABLED
+ ctx->Extensions.ARB_texture_float = true;
+ ctx->Extensions.EXT_texture_shared_exponent = true;
+ ctx->Extensions.EXT_packed_float = true;
+#endif
+ ctx->Extensions.ARB_texture_compression_rgtc = true;
+ ctx->Extensions.ARB_texture_rg = true;
+ ctx->Extensions.EXT_draw_buffers2 = true;
+ ctx->Extensions.EXT_framebuffer_sRGB = true;
+ ctx->Extensions.EXT_texture_array = true;
+ ctx->Extensions.EXT_texture_integer = true;
+ ctx->Extensions.EXT_texture_snorm = true;
+ ctx->Extensions.EXT_texture_sRGB = true;
+ ctx->Extensions.EXT_texture_sRGB_decode = true;
+ ctx->Extensions.EXT_texture_swizzle = true;
+ ctx->Extensions.EXT_vertex_array_bgra = true;
+ ctx->Extensions.ATI_envmap_bumpmap = true;
+ ctx->Extensions.MESA_texture_array = true;
+ ctx->Extensions.NV_conditional_render = true;
+ }
+
+ if (intel->gen >= 3) {
+ ctx->Extensions.ARB_ES2_compatibility = true;
+ ctx->Extensions.ARB_depth_texture = true;
+ ctx->Extensions.ARB_fragment_program = true;
+ ctx->Extensions.ARB_shadow = true;
+ ctx->Extensions.ARB_texture_non_power_of_two = true;
+ ctx->Extensions.EXT_shadow_funcs = true;
+ ctx->Extensions.EXT_stencil_two_side = true;
+ ctx->Extensions.ATI_separate_stencil = true;
+ ctx->Extensions.ATI_texture_env_combine3 = true;
+ ctx->Extensions.NV_texture_env_combine4 = true;
+
+ if (driQueryOptionb(&intel->optionCache, "fragment_shader"))
+ ctx->Extensions.ARB_fragment_shader = true;
+
+ if (driQueryOptionb(&intel->optionCache, "stub_occlusion_query"))
+ ctx->Extensions.ARB_occlusion_query = true;
+ }
+
+ if (intel->ctx.Mesa_DXTn) {
+ ctx->Extensions.EXT_texture_compression_s3tc = true;
+ ctx->Extensions.S3_s3tc = true;
+ }
+ else if (driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) {
+ ctx->Extensions.EXT_texture_compression_s3tc = true;
+ }
+
+ if (intel->gen >= 4) {
+ ctx->Extensions.NV_primitive_restart = true;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_fbo.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_fbo.c
index a19f86dcc57..65494a2d506 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_fbo.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_fbo.c
@@ -1 +1,964 @@
-../intel/intel_fbo.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/enums.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/context.h"
+#include "main/teximage.h"
+#include "main/image.h"
+
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
+#include "intel_blit.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_tex.h"
+#include "intel_span.h"
+#ifndef I915
+#include "brw_context.h"
+#endif
+
+#define FILE_DEBUG_FLAG DEBUG_FBO
+
+static struct gl_renderbuffer *
+intel_new_renderbuffer(struct gl_context * ctx, GLuint name);
+
+struct intel_region*
+intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
+{
+ struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, attIndex);
+ if (irb && irb->mt) {
+ if (attIndex == BUFFER_STENCIL && irb->mt->stencil_mt)
+ return irb->mt->stencil_mt->region;
+ else
+ return irb->mt->region;
+ } else
+ return NULL;
+}
+
+/**
+ * Create a new framebuffer object.
+ */
+static struct gl_framebuffer *
+intel_new_framebuffer(struct gl_context * ctx, GLuint name)
+{
+ /* Only drawable state in intel_framebuffer at this time, just use Mesa's
+ * class
+ */
+ return _mesa_new_framebuffer(ctx, name);
+}
+
+
+/** Called by gl_renderbuffer::Delete() */
+static void
+intel_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+ ASSERT(irb);
+
+ intel_miptree_release(&irb->mt);
+
+ _mesa_delete_renderbuffer(ctx, rb);
+}
+
+/**
+ * \see dd_function_table::MapRenderbuffer
+ */
+static void
+intel_map_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+ void *map;
+ int stride;
+
+ if (srb->Buffer) {
+ /* this is a malloc'd renderbuffer (accum buffer), not an irb */
+ GLint bpp = _mesa_get_format_bytes(rb->Format);
+ GLint rowStride = srb->RowStride;
+ *out_map = (GLubyte *) srb->Buffer + y * rowStride + x * bpp;
+ *out_stride = rowStride;
+ return;
+ }
+
+ /* We sometimes get called with this by our intel_span.c usage. */
+ if (!irb->mt) {
+ *out_map = NULL;
+ *out_stride = 0;
+ return;
+ }
+
+ /* For a window-system renderbuffer, we need to flip the mapping we receive
+ * upside-down. So we need to ask for a rectangle on flipped vertically, and
+ * we then return a pointer to the bottom of it with a negative stride.
+ */
+ if (rb->Name == 0) {
+ y = rb->Height - y - h;
+ }
+
+ intel_miptree_map(intel, irb->mt, irb->mt_level, irb->mt_layer,
+ x, y, w, h, mode, &map, &stride);
+
+ if (rb->Name == 0) {
+ map += (h - 1) * stride;
+ stride = -stride;
+ }
+
+ DBG("%s: rb %d (%s) mt mapped: (%d, %d) (%dx%d) -> %p/%d\n",
+ __FUNCTION__, rb->Name, _mesa_get_format_name(rb->Format),
+ x, y, w, h, map, stride);
+
+ *out_map = map;
+ *out_stride = stride;
+}
+
+/**
+ * \see dd_function_table::UnmapRenderbuffer
+ */
+static void
+intel_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+ DBG("%s: rb %d (%s)\n", __FUNCTION__,
+ rb->Name, _mesa_get_format_name(rb->Format));
+
+ if (srb->Buffer) {
+ /* this is a malloc'd renderbuffer (accum buffer) */
+ /* nothing to do */
+ return;
+ }
+
+ intel_miptree_unmap(intel, irb->mt, irb->mt_level, irb->mt_layer);
+}
+
+
+/**
+ * Round up the requested multisample count to the next supported sample size.
+ */
+unsigned
+intel_quantize_num_samples(struct intel_screen *intel, unsigned num_samples)
+{
+ switch (intel->gen) {
+ case 6:
+ /* Gen6 supports only 4x multisampling. */
+ if (num_samples > 0)
+ return 4;
+ else
+ return 0;
+ case 7:
+ /* Gen7 supports 4x and 8x multisampling. */
+ if (num_samples > 4)
+ return 8;
+ else if (num_samples > 0)
+ return 4;
+ else
+ return 0;
+ return 0;
+ default:
+ /* MSAA unsupported. However, a careful reading of
+ * EXT_framebuffer_multisample reveals that we need to permit
+ * num_samples to be 1 (since num_samples is permitted to be as high as
+ * GL_MAX_SAMPLES, and GL_MAX_SAMPLES must be at least 1). Since
+ * platforms before Gen6 don't support MSAA, this is safe, because
+ * multisampling won't happen anyhow.
+ */
+ if (num_samples > 0)
+ return 1;
+ return 0;
+ }
+}
+
+
+/**
+ * Called via glRenderbufferStorageEXT() to set the format and allocate
+ * storage for a user-created renderbuffer.
+ */
+GLboolean
+intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width, GLuint height)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_screen *screen = intel->intelScreen;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+ rb->NumSamples = intel_quantize_num_samples(screen, rb->NumSamples);
+
+ switch (internalFormat) {
+ default:
+ /* Use the same format-choice logic as for textures.
+ * Renderbuffers aren't any different from textures for us,
+ * except they're less useful because you can't texture with
+ * them.
+ */
+ rb->Format = intel->ctx.Driver.ChooseTextureFormat(ctx, GL_TEXTURE_2D,
+ internalFormat,
+ GL_NONE, GL_NONE);
+ break;
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ /* These aren't actual texture formats, so force them here. */
+ if (intel->has_separate_stencil) {
+ rb->Format = MESA_FORMAT_S8;
+ } else {
+ assert(!intel->must_use_separate_stencil);
+ rb->Format = MESA_FORMAT_S8_Z24;
+ }
+ break;
+ }
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
+ intel_miptree_release(&irb->mt);
+
+ DBG("%s: %s: %s (%dx%d)\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(internalFormat),
+ _mesa_get_format_name(rb->Format), width, height);
+
+ if (width == 0 || height == 0)
+ return true;
+
+ irb->mt = intel_miptree_create_for_renderbuffer(intel, rb->Format,
+ width, height,
+ rb->NumSamples);
+ if (!irb->mt)
+ return false;
+
+ return true;
+}
+
+
+#if FEATURE_OES_EGL_image
+static void
+intel_image_target_renderbuffer_storage(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ void *image_handle)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_renderbuffer *irb;
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = intel->intelScreen->driScrnPriv;
+ image = screen->dri2.image->lookupEGLImage(screen, image_handle,
+ screen->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ /* __DRIimage is opaque to the core so it has to be checked here */
+ switch (image->format) {
+ case MESA_FORMAT_RGBA8888_REV:
+ _mesa_error(&intel->ctx, GL_INVALID_OPERATION,
+ "glEGLImageTargetRenderbufferStorage(unsupported image format");
+ return;
+ break;
+ default:
+ break;
+ }
+
+ irb = intel_renderbuffer(rb);
+ intel_miptree_release(&irb->mt);
+ irb->mt = intel_miptree_create_for_region(intel,
+ GL_TEXTURE_2D,
+ image->format,
+ image->region);
+ if (!irb->mt)
+ return;
+
+ rb->InternalFormat = image->internal_format;
+ rb->Width = image->region->width;
+ rb->Height = image->region->height;
+ rb->Format = image->format;
+ rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
+ image->internal_format);
+}
+#endif
+
+/**
+ * Called for each hardware renderbuffer when a _window_ is resized.
+ * Just update fields.
+ * Not used for user-created renderbuffers!
+ */
+static GLboolean
+intel_alloc_window_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ ASSERT(rb->Name == 0);
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return true;
+}
+
+
+static void
+intel_resize_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint width, GLuint height)
+{
+ int i;
+
+ _mesa_resize_framebuffer(ctx, fb, width, height);
+
+ fb->Initialized = true; /* XXX remove someday */
+
+ if (_mesa_is_user_fbo(fb)) {
+ return;
+ }
+
+
+ /* Make sure all window system renderbuffers are up to date */
+ for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
+ struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+
+ /* only resize if size is changing */
+ if (rb && (rb->Width != width || rb->Height != height)) {
+ rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
+ }
+ }
+}
+
+
+/** Dummy function for gl_renderbuffer::AllocStorage() */
+static GLboolean
+intel_nop_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ _mesa_problem(ctx, "intel_op_alloc_storage should never be called.");
+ return false;
+}
+
+/**
+ * Create a new intel_renderbuffer which corresponds to an on-screen window,
+ * not a user-created renderbuffer.
+ *
+ * \param num_samples must be quantized.
+ */
+struct intel_renderbuffer *
+intel_create_renderbuffer(gl_format format, unsigned num_samples)
+{
+ struct intel_renderbuffer *irb;
+ struct gl_renderbuffer *rb;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ irb = CALLOC_STRUCT(intel_renderbuffer);
+ if (!irb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+ return NULL;
+ }
+
+ rb = &irb->Base.Base;
+
+ _mesa_init_renderbuffer(rb, 0);
+ rb->ClassID = INTEL_RB_CLASS;
+ rb->_BaseFormat = _mesa_get_format_base_format(format);
+ rb->Format = format;
+ rb->InternalFormat = rb->_BaseFormat;
+ rb->NumSamples = num_samples;
+
+ /* intel-specific methods */
+ rb->Delete = intel_delete_renderbuffer;
+ rb->AllocStorage = intel_alloc_window_storage;
+
+ return irb;
+}
+
+/**
+ * Private window-system buffers (as opposed to ones shared with the display
+ * server created with intel_create_renderbuffer()) are most similar in their
+ * handling to user-created renderbuffers, but they have a resize handler that
+ * may be called at intel_update_renderbuffers() time.
+ *
+ * \param num_samples must be quantized.
+ */
+struct intel_renderbuffer *
+intel_create_private_renderbuffer(gl_format format, unsigned num_samples)
+{
+ struct intel_renderbuffer *irb;
+
+ irb = intel_create_renderbuffer(format, num_samples);
+ irb->Base.Base.AllocStorage = intel_alloc_renderbuffer_storage;
+
+ return irb;
+}
+
+/**
+ * Create a new renderbuffer object.
+ * Typically called via glBindRenderbufferEXT().
+ */
+static struct gl_renderbuffer *
+intel_new_renderbuffer(struct gl_context * ctx, GLuint name)
+{
+ /*struct intel_context *intel = intel_context(ctx); */
+ struct intel_renderbuffer *irb;
+ struct gl_renderbuffer *rb;
+
+ irb = CALLOC_STRUCT(intel_renderbuffer);
+ if (!irb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+ return NULL;
+ }
+
+ rb = &irb->Base.Base;
+
+ _mesa_init_renderbuffer(rb, name);
+ rb->ClassID = INTEL_RB_CLASS;
+
+ /* intel-specific methods */
+ rb->Delete = intel_delete_renderbuffer;
+ rb->AllocStorage = intel_alloc_renderbuffer_storage;
+ /* span routines set in alloc_storage function */
+
+ return rb;
+}
+
+
+/**
+ * Called via glBindFramebufferEXT().
+ */
+static void
+intel_bind_framebuffer(struct gl_context * ctx, GLenum target,
+ struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
+{
+ if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
+ intel_draw_buffer(ctx);
+ }
+ else {
+ /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
+ }
+}
+
+
+/**
+ * Called via glFramebufferRenderbufferEXT().
+ */
+static void
+intel_framebuffer_renderbuffer(struct gl_context * ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment, struct gl_renderbuffer *rb)
+{
+ DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ intel_draw_buffer(ctx);
+}
+
+/**
+ * \par Special case for separate stencil
+ *
+ * When wrapping a depthstencil texture that uses separate stencil, this
+ * function is recursively called twice: once to create \c
+ * irb->wrapped_depth and again to create \c irb->wrapped_stencil. On the
+ * call to create \c irb->wrapped_depth, the \c format and \c
+ * internal_format parameters do not match \c mt->format. In that case, \c
+ * mt->format is MESA_FORMAT_S8_Z24 and \c format is \c
+ * MESA_FORMAT_X8_Z24.
+ *
+ * @return true on success
+ */
+
+static bool
+intel_renderbuffer_update_wrapper(struct intel_context *intel,
+ struct intel_renderbuffer *irb,
+ struct gl_texture_image *image,
+ uint32_t layer)
+{
+ struct gl_renderbuffer *rb = &irb->Base.Base;
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+ int level = image->Level;
+
+ rb->Format = image->TexFormat;
+ rb->InternalFormat = image->InternalFormat;
+ rb->_BaseFormat = image->_BaseFormat;
+ rb->Width = mt->level[level].width;
+ rb->Height = mt->level[level].height;
+
+ rb->Delete = intel_delete_renderbuffer;
+ rb->AllocStorage = intel_nop_alloc_storage;
+
+ intel_miptree_check_level_layer(mt, level, layer);
+ irb->mt_level = level;
+ irb->mt_layer = layer;
+
+ intel_miptree_reference(&irb->mt, mt);
+
+ intel_renderbuffer_set_draw_offset(irb);
+
+ if (mt->hiz_mt == NULL &&
+ intel->vtbl.is_hiz_depth_format(intel, rb->Format)) {
+ intel_miptree_alloc_hiz(intel, mt, 0 /* num_samples */);
+ if (!mt->hiz_mt)
+ return false;
+ }
+
+ return true;
+}
+
+void
+intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb)
+{
+ unsigned int dst_x, dst_y;
+
+ /* compute offset of the particular 2D image within the texture region */
+ intel_miptree_get_image_offset(irb->mt,
+ irb->mt_level,
+ 0, /* face, which we ignore */
+ irb->mt_layer,
+ &dst_x, &dst_y);
+
+ irb->draw_x = dst_x;
+ irb->draw_y = dst_y;
+}
+
+/**
+ * Rendering to tiled buffers requires that the base address of the
+ * buffer be aligned to a page boundary. We generally render to
+ * textures by pointing the surface at the mipmap image level, which
+ * may not be aligned to a tile boundary.
+ *
+ * This function returns an appropriately-aligned base offset
+ * according to the tiling restrictions, plus any required x/y offset
+ * from there.
+ */
+uint32_t
+intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
+ uint32_t *tile_x,
+ uint32_t *tile_y)
+{
+ struct intel_region *region = irb->mt->region;
+ uint32_t mask_x, mask_y;
+
+ intel_region_get_tile_masks(region, &mask_x, &mask_y, false);
+
+ *tile_x = irb->draw_x & mask_x;
+ *tile_y = irb->draw_y & mask_y;
+ return intel_region_get_aligned_offset(region, irb->draw_x & ~mask_x,
+ irb->draw_y & ~mask_y, false);
+}
+
+/**
+ * Called by glFramebufferTexture[123]DEXT() (and other places) to
+ * prepare for rendering into texture memory. This might be called
+ * many times to choose different texture levels, cube faces, etc
+ * before intel_finish_render_texture() is ever called.
+ */
+static void
+intel_render_texture(struct gl_context * ctx,
+ struct gl_framebuffer *fb,
+ struct gl_renderbuffer_attachment *att)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_texture_image *image = _mesa_get_attachment_teximage(att);
+ struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+ int layer;
+
+ (void) fb;
+
+ if (att->CubeMapFace > 0) {
+ assert(att->Zoffset == 0);
+ layer = att->CubeMapFace;
+ } else {
+ layer = att->Zoffset;
+ }
+
+ if (!intel_image->mt) {
+ /* Fallback on drawing to a texture that doesn't have a miptree
+ * (has a border, width/height 0, etc.)
+ */
+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+ else if (!irb) {
+ intel_miptree_check_level_layer(mt, att->TextureLevel, layer);
+
+ irb = (struct intel_renderbuffer *)intel_new_renderbuffer(ctx, ~0);
+
+ if (irb) {
+ /* bind the wrapper to the attachment point */
+ _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base.Base);
+ }
+ else {
+ /* fallback to software rendering */
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+ }
+
+ if (!intel_renderbuffer_update_wrapper(intel, irb, image, layer)) {
+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+
+ irb->tex_image = image;
+
+ DBG("Begin render %s texture tex=%u w=%d h=%d refcount=%d\n",
+ _mesa_get_format_name(image->TexFormat),
+ att->Texture->Name, image->Width, image->Height,
+ irb->Base.Base.RefCount);
+
+ /* update drawing region, etc */
+ intel_draw_buffer(ctx);
+}
+
+
+/**
+ * Called by Mesa when rendering to a texture is done.
+ */
+static void
+intel_finish_render_texture(struct gl_context * ctx,
+ struct gl_renderbuffer_attachment *att)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_texture_object *tex_obj = att->Texture;
+ struct gl_texture_image *image =
+ tex_obj->Image[att->CubeMapFace][att->TextureLevel];
+ struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+
+ DBG("Finish render %s texture tex=%u\n",
+ _mesa_get_format_name(image->TexFormat), att->Texture->Name);
+
+ if (irb)
+ irb->tex_image = NULL;
+
+ /* Since we've (probably) rendered to the texture and will (likely) use
+ * it in the texture domain later on in this batchbuffer, flush the
+ * batch. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer like GEM does in the kernel.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+}
+
+/**
+ * Do additional "completeness" testing of a framebuffer object.
+ */
+static void
+intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ struct intel_context *intel = intel_context(ctx);
+ const struct intel_renderbuffer *depthRb =
+ intel_get_renderbuffer(fb, BUFFER_DEPTH);
+ const struct intel_renderbuffer *stencilRb =
+ intel_get_renderbuffer(fb, BUFFER_STENCIL);
+ struct intel_mipmap_tree *depth_mt = NULL, *stencil_mt = NULL;
+ int i;
+
+ DBG("%s() on fb %p (%s)\n", __FUNCTION__,
+ fb, (fb == ctx->DrawBuffer ? "drawbuffer" :
+ (fb == ctx->ReadBuffer ? "readbuffer" : "other buffer")));
+
+ if (depthRb)
+ depth_mt = depthRb->mt;
+ if (stencilRb) {
+ stencil_mt = stencilRb->mt;
+ if (stencil_mt->stencil_mt)
+ stencil_mt = stencil_mt->stencil_mt;
+ }
+
+ if (depth_mt && stencil_mt) {
+ if (depth_mt == stencil_mt) {
+ /* For true packed depth/stencil (not faked on prefers-separate-stencil
+ * hardware) we need to be sure they're the same level/layer, since
+ * we'll be emitting a single packet describing the packed setup.
+ */
+ if (depthRb->mt_level != stencilRb->mt_level ||
+ depthRb->mt_layer != stencilRb->mt_layer) {
+ DBG("depth image level/layer %d/%d != stencil image %d/%d\n",
+ depthRb->mt_level,
+ depthRb->mt_layer,
+ stencilRb->mt_level,
+ stencilRb->mt_layer);
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ } else {
+ if (!intel->has_separate_stencil) {
+ DBG("separate stencil unsupported\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ if (stencil_mt->format != MESA_FORMAT_S8) {
+ DBG("separate stencil is %s instead of S8\n",
+ _mesa_get_format_name(stencil_mt->format));
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ if (intel->gen < 7 && depth_mt->hiz_mt == NULL) {
+ /* Before Gen7, separate depth and stencil buffers can be used
+ * only if HiZ is enabled. From the Sandybridge PRM, Volume 2,
+ * Part 1, Bit 3DSTATE_DEPTH_BUFFER.SeparateStencilBufferEnable:
+ * [DevSNB]: This field must be set to the same value (enabled
+ * or disabled) as Hierarchical Depth Buffer Enable.
+ */
+ DBG("separate stencil without HiZ\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED;
+ }
+ }
+ }
+
+ for (i = 0; i < Elements(fb->Attachment); i++) {
+ struct gl_renderbuffer *rb;
+ struct intel_renderbuffer *irb;
+
+ if (fb->Attachment[i].Type == GL_NONE)
+ continue;
+
+ /* A supported attachment will have a Renderbuffer set either
+ * from being a Renderbuffer or being a texture that got the
+ * intel_wrap_texture() treatment.
+ */
+ rb = fb->Attachment[i].Renderbuffer;
+ if (rb == NULL) {
+ DBG("attachment without renderbuffer\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ continue;
+ }
+
+ if (fb->Attachment[i].Type == GL_TEXTURE) {
+ const struct gl_texture_image *img =
+ _mesa_get_attachment_teximage_const(&fb->Attachment[i]);
+
+ if (img->Border) {
+ DBG("texture with border\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ continue;
+ }
+ }
+
+ irb = intel_renderbuffer(rb);
+ if (irb == NULL) {
+ DBG("software rendering renderbuffer\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ continue;
+ }
+
+ if (!intel->vtbl.render_target_supported(intel, rb)) {
+ DBG("Unsupported HW texture/renderbuffer format attached: %s\n",
+ _mesa_get_format_name(intel_rb_format(irb)));
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ }
+}
+
+/**
+ * Try to do a glBlitFramebuffer using glCopyTexSubImage2D
+ * We can do this when the dst renderbuffer is actually a texture and
+ * there is no scaling, mirroring or scissoring.
+ *
+ * \return new buffer mask indicating the buffers left to blit using the
+ * normal path.
+ */
+static GLbitfield
+intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,
+ GLint srcX0, GLint srcY0,
+ GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0,
+ GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ const struct gl_framebuffer *drawFb = ctx->DrawBuffer;
+ const struct gl_framebuffer *readFb = ctx->ReadBuffer;
+ const struct gl_renderbuffer_attachment *drawAtt =
+ &drawFb->Attachment[drawFb->_ColorDrawBufferIndexes[0]];
+ struct intel_renderbuffer *srcRb =
+ intel_renderbuffer(readFb->_ColorReadBuffer);
+
+ /* If the source and destination are the same size with no
+ mirroring, the rectangles are within the size of the
+ texture and there is no scissor then we can use
+ glCopyTexSubimage2D to implement the blit. This will end
+ up as a fast hardware blit on some drivers */
+ if (srcRb && drawAtt && drawAtt->Texture &&
+ srcX0 - srcX1 == dstX0 - dstX1 &&
+ srcY0 - srcY1 == dstY0 - dstY1 &&
+ srcX1 >= srcX0 &&
+ srcY1 >= srcY0 &&
+ srcX0 >= 0 && srcX1 <= readFb->Width &&
+ srcY0 >= 0 && srcY1 <= readFb->Height &&
+ dstX0 >= 0 && dstX1 <= drawFb->Width &&
+ dstY0 >= 0 && dstY1 <= drawFb->Height &&
+ !ctx->Scissor.Enabled) {
+ const struct gl_texture_object *texObj = drawAtt->Texture;
+ const GLuint dstLevel = drawAtt->TextureLevel;
+ const GLenum target = texObj->Target;
+
+ struct gl_texture_image *texImage =
+ _mesa_select_tex_image(ctx, texObj, target, dstLevel);
+
+ if (intel_copy_texsubimage(intel_context(ctx),
+ intel_texture_image(texImage),
+ dstX0, dstY0,
+ srcRb,
+ srcX0, srcY0,
+ srcX1 - srcX0, /* width */
+ srcY1 - srcY0))
+ mask &= ~GL_COLOR_BUFFER_BIT;
+ }
+ }
+
+ return mask;
+}
+
+static void
+intel_blit_framebuffer(struct gl_context *ctx,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ /* Try faster, glCopyTexSubImage2D approach first which uses the BLT. */
+ mask = intel_blit_framebuffer_copy_tex_sub_image(ctx,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+ if (mask == 0x0)
+ return;
+
+#ifndef I915
+ mask = brw_blorp_framebuffer(intel_context(ctx),
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+ if (mask == 0x0)
+ return;
+#endif
+
+ _mesa_meta_BlitFramebuffer(ctx,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+}
+
+/**
+ * This is a no-op except on multisample buffers shared with DRI2.
+ */
+void
+intel_renderbuffer_set_needs_downsample(struct intel_renderbuffer *irb)
+{
+ if (irb->mt && irb->mt->singlesample_mt)
+ irb->mt->need_downsample = true;
+}
+
+void
+intel_renderbuffer_set_needs_hiz_resolve(struct intel_renderbuffer *irb)
+{
+ if (irb->mt) {
+ intel_miptree_slice_set_needs_hiz_resolve(irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+ }
+}
+
+void
+intel_renderbuffer_set_needs_depth_resolve(struct intel_renderbuffer *irb)
+{
+ if (irb->mt) {
+ intel_miptree_slice_set_needs_depth_resolve(irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+ }
+}
+
+bool
+intel_renderbuffer_resolve_hiz(struct intel_context *intel,
+ struct intel_renderbuffer *irb)
+{
+ if (irb->mt)
+ return intel_miptree_slice_resolve_hiz(intel,
+ irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+
+ return false;
+}
+
+bool
+intel_renderbuffer_resolve_depth(struct intel_context *intel,
+ struct intel_renderbuffer *irb)
+{
+ if (irb->mt)
+ return intel_miptree_slice_resolve_depth(intel,
+ irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+
+ return false;
+}
+
+/**
+ * Do one-time context initializations related to GL_EXT_framebuffer_object.
+ * Hook in device driver functions.
+ */
+void
+intel_fbo_init(struct intel_context *intel)
+{
+ intel->ctx.Driver.NewFramebuffer = intel_new_framebuffer;
+ intel->ctx.Driver.NewRenderbuffer = intel_new_renderbuffer;
+ intel->ctx.Driver.MapRenderbuffer = intel_map_renderbuffer;
+ intel->ctx.Driver.UnmapRenderbuffer = intel_unmap_renderbuffer;
+ intel->ctx.Driver.BindFramebuffer = intel_bind_framebuffer;
+ intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
+ intel->ctx.Driver.RenderTexture = intel_render_texture;
+ intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
+ intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
+ intel->ctx.Driver.ValidateFramebuffer = intel_validate_framebuffer;
+ intel->ctx.Driver.BlitFramebuffer = intel_blit_framebuffer;
+
+#if FEATURE_OES_EGL_image
+ intel->ctx.Driver.EGLImageTargetRenderbufferStorage =
+ intel_image_target_renderbuffer_storage;
+#endif
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_mipmap_tree.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
index 242fed0b6ae..556a82fc7ff 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
@@ -1 +1,1711 @@
-../intel/intel_mipmap_tree.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <GL/gl.h>
+#include <GL/internal/dri_interface.h>
+
+#include "intel_batchbuffer.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_resolve_map.h"
+#include "intel_span.h"
+#include "intel_tex_layout.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+
+#ifndef I915
+#include "brw_blorp.h"
+#endif
+
+#include "main/enums.h"
+#include "main/formats.h"
+#include "main/glformats.h"
+#include "main/texcompress_etc.h"
+#include "main/teximage.h"
+
+#define FILE_DEBUG_FLAG DEBUG_MIPTREE
+
+static GLenum
+target_to_target(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ return GL_TEXTURE_CUBE_MAP_ARB;
+ default:
+ return target;
+ }
+}
+
+/**
+ * @param for_region Indicates that the caller is
+ * intel_miptree_create_for_region(). If true, then do not create
+ * \c stencil_mt.
+ */
+static struct intel_mipmap_tree *
+intel_miptree_create_internal(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ GLuint first_level,
+ GLuint last_level,
+ GLuint width0,
+ GLuint height0,
+ GLuint depth0,
+ bool for_region,
+ GLuint num_samples,
+ enum intel_msaa_layout msaa_layout)
+{
+ struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+ int compress_byte = 0;
+
+ DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(target),
+ _mesa_get_format_name(format),
+ first_level, last_level, mt);
+
+ if (_mesa_is_format_compressed(format))
+ compress_byte = intel_compressed_num_bytes(format);
+
+ mt->target = target_to_target(target);
+ mt->format = format;
+ mt->first_level = first_level;
+ mt->last_level = last_level;
+ mt->width0 = width0;
+ mt->height0 = height0;
+ mt->cpp = compress_byte ? compress_byte : _mesa_get_format_bytes(mt->format);
+ mt->num_samples = num_samples;
+ mt->compressed = compress_byte ? 1 : 0;
+ mt->msaa_layout = msaa_layout;
+ mt->refcount = 1;
+
+ /* array_spacing_lod0 is only used for non-IMS MSAA surfaces. TODO: can we
+ * use it elsewhere?
+ */
+ switch (msaa_layout) {
+ case INTEL_MSAA_LAYOUT_NONE:
+ case INTEL_MSAA_LAYOUT_IMS:
+ mt->array_spacing_lod0 = false;
+ break;
+ case INTEL_MSAA_LAYOUT_UMS:
+ case INTEL_MSAA_LAYOUT_CMS:
+ mt->array_spacing_lod0 = true;
+ break;
+ }
+
+ if (target == GL_TEXTURE_CUBE_MAP) {
+ assert(depth0 == 1);
+ mt->depth0 = 6;
+ } else {
+ mt->depth0 = depth0;
+ }
+
+ if (!for_region &&
+ _mesa_is_depthstencil_format(_mesa_get_format_base_format(format)) &&
+ (intel->must_use_separate_stencil ||
+ (intel->has_separate_stencil &&
+ intel->vtbl.is_hiz_depth_format(intel, format)))) {
+ /* MSAA stencil surfaces always use IMS layout. */
+ enum intel_msaa_layout msaa_layout =
+ num_samples > 1 ? INTEL_MSAA_LAYOUT_IMS : INTEL_MSAA_LAYOUT_NONE;
+ mt->stencil_mt = intel_miptree_create(intel,
+ mt->target,
+ MESA_FORMAT_S8,
+ mt->first_level,
+ mt->last_level,
+ mt->width0,
+ mt->height0,
+ mt->depth0,
+ true,
+ num_samples,
+ msaa_layout);
+ if (!mt->stencil_mt) {
+ intel_miptree_release(&mt);
+ return NULL;
+ }
+
+ /* Fix up the Z miptree format for how we're splitting out separate
+ * stencil. Gen7 expects there to be no stencil bits in its depth buffer.
+ */
+ if (mt->format == MESA_FORMAT_S8_Z24) {
+ mt->format = MESA_FORMAT_X8_Z24;
+ } else if (mt->format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ mt->format = MESA_FORMAT_Z32_FLOAT;
+ mt->cpp = 4;
+ } else {
+ _mesa_problem(NULL, "Unknown format %s in separate stencil mt\n",
+ _mesa_get_format_name(mt->format));
+ }
+ }
+
+ intel_get_texture_alignment_unit(intel, mt->format,
+ &mt->align_w, &mt->align_h);
+
+#ifdef I915
+ (void) intel;
+ if (intel->is_945)
+ i945_miptree_layout(mt);
+ else
+ i915_miptree_layout(mt);
+#else
+ brw_miptree_layout(intel, mt);
+#endif
+
+ return mt;
+}
+
+
+struct intel_mipmap_tree *
+intel_miptree_create(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ GLuint first_level,
+ GLuint last_level,
+ GLuint width0,
+ GLuint height0,
+ GLuint depth0,
+ bool expect_accelerated_upload,
+ GLuint num_samples,
+ enum intel_msaa_layout msaa_layout)
+{
+ struct intel_mipmap_tree *mt;
+ uint32_t tiling = I915_TILING_NONE;
+ GLenum base_format;
+ bool wraps_etc1 = false;
+ GLuint total_width, total_height;
+
+ if (format == MESA_FORMAT_ETC1_RGB8) {
+ format = MESA_FORMAT_RGBX8888_REV;
+ wraps_etc1 = true;
+ }
+
+ base_format = _mesa_get_format_base_format(format);
+
+ if (intel->use_texture_tiling && !_mesa_is_format_compressed(format)) {
+ if (intel->gen >= 4 &&
+ (base_format == GL_DEPTH_COMPONENT ||
+ base_format == GL_DEPTH_STENCIL_EXT))
+ tiling = I915_TILING_Y;
+ else if (msaa_layout != INTEL_MSAA_LAYOUT_NONE) {
+ /* From p82 of the Sandy Bridge PRM, dw3[1] of SURFACE_STATE ("Tiled
+ * Surface"):
+ *
+ * [DevSNB+]: For multi-sample render targets, this field must be
+ * 1. MSRTs can only be tiled.
+ *
+ * Our usual reason for preferring X tiling (fast blits using the
+ * blitting engine) doesn't apply to MSAA, since we'll generally be
+ * downsampling or upsampling when blitting between the MSAA buffer
+ * and another buffer, and the blitting engine doesn't support that.
+ * So use Y tiling, since it makes better use of the cache.
+ */
+ tiling = I915_TILING_Y;
+ } else if (width0 >= 64)
+ tiling = I915_TILING_X;
+ }
+
+ mt = intel_miptree_create_internal(intel, target, format,
+ first_level, last_level, width0,
+ height0, depth0,
+ false, num_samples, msaa_layout);
+ /*
+ * pitch == 0 || height == 0 indicates the null texture
+ */
+ if (!mt || !mt->total_width || !mt->total_height) {
+ intel_miptree_release(&mt);
+ return NULL;
+ }
+
+ total_width = mt->total_width;
+ total_height = mt->total_height;
+
+ if (format == MESA_FORMAT_S8) {
+ /* The stencil buffer is W tiled. However, we request from the kernel a
+ * non-tiled buffer because the GTT is incapable of W fencing. So round
+ * up the width and height to match the size of W tiles (64x64).
+ */
+ tiling = I915_TILING_NONE;
+ total_width = ALIGN(total_width, 64);
+ total_height = ALIGN(total_height, 64);
+ }
+
+ mt->wraps_etc1 = wraps_etc1;
+ mt->region = intel_region_alloc(intel->intelScreen,
+ tiling,
+ mt->cpp,
+ total_width,
+ total_height,
+ expect_accelerated_upload);
+ mt->offset = 0;
+
+ if (!mt->region) {
+ intel_miptree_release(&mt);
+ return NULL;
+ }
+
+ return mt;
+}
+
+
+struct intel_mipmap_tree *
+intel_miptree_create_for_region(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ struct intel_region *region)
+{
+ struct intel_mipmap_tree *mt;
+
+ mt = intel_miptree_create_internal(intel, target, format,
+ 0, 0,
+ region->width, region->height, 1,
+ true, 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_NONE);
+ if (!mt)
+ return mt;
+
+ intel_region_reference(&mt->region, region);
+
+ return mt;
+}
+
+/**
+ * Determine which MSAA layout should be used by the MSAA surface being
+ * created, based on the chip generation and the surface type.
+ */
+static enum intel_msaa_layout
+compute_msaa_layout(struct intel_context *intel, gl_format format)
+{
+ /* Prior to Gen7, all MSAA surfaces used IMS layout. */
+ if (intel->gen < 7)
+ return INTEL_MSAA_LAYOUT_IMS;
+
+ /* In Gen7, IMS layout is only used for depth and stencil buffers. */
+ switch (_mesa_get_format_base_format(format)) {
+ case GL_DEPTH_COMPONENT:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_STENCIL:
+ return INTEL_MSAA_LAYOUT_IMS;
+ default:
+ /* From the Ivy Bridge PRM, Vol4 Part1 p77 ("MCS Enable"):
+ *
+ * This field must be set to 0 for all SINT MSRTs when all RT channels
+ * are not written
+ *
+ * In practice this means that we have to disable MCS for all signed
+ * integer MSAA buffers. The alternative, to disable MCS only when one
+ * of the render target channels is disabled, is impractical because it
+ * would require converting between CMS and UMS MSAA layouts on the fly,
+ * which is expensive.
+ */
+ if (_mesa_get_format_datatype(format) == GL_INT) {
+ /* TODO: is this workaround needed for future chipsets? */
+ assert(intel->gen == 7);
+ return INTEL_MSAA_LAYOUT_UMS;
+ } else {
+ return INTEL_MSAA_LAYOUT_CMS;
+ }
+ }
+}
+
+/**
+ * For a singlesample DRI2 buffer, this simply wraps the given region with a miptree.
+ *
+ * For a multisample DRI2 buffer, this wraps the given region with
+ * a singlesample miptree, then creates a multisample miptree into which the
+ * singlesample miptree is embedded as a child.
+ */
+struct intel_mipmap_tree*
+intel_miptree_create_for_dri2_buffer(struct intel_context *intel,
+ unsigned dri_attachment,
+ gl_format format,
+ uint32_t num_samples,
+ struct intel_region *region)
+{
+ struct intel_mipmap_tree *singlesample_mt = NULL;
+ struct intel_mipmap_tree *multisample_mt = NULL;
+ GLenum base_format = _mesa_get_format_base_format(format);
+
+ /* Only the front and back buffers, which are color buffers, are shared
+ * through DRI2.
+ */
+ assert(dri_attachment == __DRI_BUFFER_BACK_LEFT ||
+ dri_attachment == __DRI_BUFFER_FRONT_LEFT ||
+ dri_attachment == __DRI_BUFFER_FAKE_FRONT_LEFT);
+ assert(base_format == GL_RGB || base_format == GL_RGBA);
+
+ singlesample_mt = intel_miptree_create_for_region(intel, GL_TEXTURE_2D,
+ format, region);
+ if (!singlesample_mt)
+ return NULL;
+
+ if (num_samples == 0)
+ return singlesample_mt;
+
+ multisample_mt = intel_miptree_create_for_renderbuffer(intel,
+ format,
+ region->width,
+ region->height,
+ num_samples);
+ if (!multisample_mt) {
+ intel_miptree_release(&singlesample_mt);
+ return NULL;
+ }
+
+ multisample_mt->singlesample_mt = singlesample_mt;
+ multisample_mt->need_downsample = false;
+
+ if (intel->is_front_buffer_rendering &&
+ (dri_attachment == __DRI_BUFFER_FRONT_LEFT ||
+ dri_attachment == __DRI_BUFFER_FAKE_FRONT_LEFT)) {
+ intel_miptree_upsample(intel, multisample_mt);
+ }
+
+ return multisample_mt;
+}
+
+struct intel_mipmap_tree*
+intel_miptree_create_for_renderbuffer(struct intel_context *intel,
+ gl_format format,
+ uint32_t width,
+ uint32_t height,
+ uint32_t num_samples)
+{
+ struct intel_mipmap_tree *mt;
+ uint32_t depth = 1;
+ enum intel_msaa_layout msaa_layout = INTEL_MSAA_LAYOUT_NONE;
+ const uint32_t singlesample_width = width;
+ const uint32_t singlesample_height = height;
+ bool ok;
+
+ if (num_samples > 1) {
+ /* Adjust width/height/depth for MSAA */
+ msaa_layout = compute_msaa_layout(intel, format);
+ if (msaa_layout == INTEL_MSAA_LAYOUT_IMS) {
+ /* In the Sandy Bridge PRM, volume 4, part 1, page 31, it says:
+ *
+ * "Any of the other messages (sample*, LOD, load4) used with a
+ * (4x) multisampled surface will in-effect sample a surface with
+ * double the height and width as that indicated in the surface
+ * state. Each pixel position on the original-sized surface is
+ * replaced with a 2x2 of samples with the following arrangement:
+ *
+ * sample 0 sample 2
+ * sample 1 sample 3"
+ *
+ * Thus, when sampling from a multisampled texture, it behaves as
+ * though the layout in memory for (x,y,sample) is:
+ *
+ * (0,0,0) (0,0,2) (1,0,0) (1,0,2)
+ * (0,0,1) (0,0,3) (1,0,1) (1,0,3)
+ *
+ * (0,1,0) (0,1,2) (1,1,0) (1,1,2)
+ * (0,1,1) (0,1,3) (1,1,1) (1,1,3)
+ *
+ * However, the actual layout of multisampled data in memory is:
+ *
+ * (0,0,0) (1,0,0) (0,0,1) (1,0,1)
+ * (0,1,0) (1,1,0) (0,1,1) (1,1,1)
+ *
+ * (0,0,2) (1,0,2) (0,0,3) (1,0,3)
+ * (0,1,2) (1,1,2) (0,1,3) (1,1,3)
+ *
+ * This pattern repeats for each 2x2 pixel block.
+ *
+ * As a result, when calculating the size of our 4-sample buffer for
+ * an odd width or height, we have to align before scaling up because
+ * sample 3 is in that bottom right 2x2 block.
+ */
+ switch (num_samples) {
+ case 4:
+ width = ALIGN(width, 2) * 2;
+ height = ALIGN(height, 2) * 2;
+ break;
+ case 8:
+ width = ALIGN(width, 2) * 4;
+ height = ALIGN(height, 2) * 2;
+ break;
+ default:
+ /* num_samples should already have been quantized to 0, 1, 4, or
+ * 8.
+ */
+ assert(false);
+ }
+ } else {
+ /* Non-interleaved */
+ depth = num_samples;
+ }
+ }
+
+ mt = intel_miptree_create(intel, GL_TEXTURE_2D, format, 0, 0,
+ width, height, depth, true, num_samples,
+ msaa_layout);
+ if (!mt)
+ goto fail;
+
+ if (intel->vtbl.is_hiz_depth_format(intel, format)) {
+ ok = intel_miptree_alloc_hiz(intel, mt, num_samples);
+ if (!ok)
+ goto fail;
+ }
+
+ if (mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
+ ok = intel_miptree_alloc_mcs(intel, mt, num_samples);
+ if (!ok)
+ goto fail;
+ }
+
+ mt->singlesample_width0 = singlesample_width;
+ mt->singlesample_height0 = singlesample_height;
+
+ return mt;
+
+fail:
+ intel_miptree_release(&mt);
+ return NULL;
+}
+
+void
+intel_miptree_reference(struct intel_mipmap_tree **dst,
+ struct intel_mipmap_tree *src)
+{
+ if (*dst == src)
+ return;
+
+ intel_miptree_release(dst);
+
+ if (src) {
+ src->refcount++;
+ DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
+ }
+
+ *dst = src;
+}
+
+
+void
+intel_miptree_release(struct intel_mipmap_tree **mt)
+{
+ if (!*mt)
+ return;
+
+ DBG("%s %p refcount will be %d\n", __FUNCTION__, *mt, (*mt)->refcount - 1);
+ if (--(*mt)->refcount <= 0) {
+ GLuint i;
+
+ DBG("%s deleting %p\n", __FUNCTION__, *mt);
+
+ intel_region_release(&((*mt)->region));
+ intel_miptree_release(&(*mt)->stencil_mt);
+ intel_miptree_release(&(*mt)->hiz_mt);
+ intel_miptree_release(&(*mt)->mcs_mt);
+ intel_miptree_release(&(*mt)->singlesample_mt);
+ intel_resolve_map_clear(&(*mt)->hiz_map);
+
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ free((*mt)->level[i].slice);
+ }
+
+ free(*mt);
+ }
+ *mt = NULL;
+}
+
+void
+intel_miptree_get_dimensions_for_image(struct gl_texture_image *image,
+ int *width, int *height, int *depth)
+{
+ switch (image->TexObject->Target) {
+ case GL_TEXTURE_1D_ARRAY:
+ *width = image->Width;
+ *height = 1;
+ *depth = image->Height;
+ break;
+ default:
+ *width = image->Width;
+ *height = image->Height;
+ *depth = image->Depth;
+ break;
+ }
+}
+
+/**
+ * Can the image be pulled into a unified mipmap tree? This mirrors
+ * the completeness test in a lot of ways.
+ *
+ * Not sure whether I want to pass gl_texture_image here.
+ */
+bool
+intel_miptree_match_image(struct intel_mipmap_tree *mt,
+ struct gl_texture_image *image)
+{
+ struct intel_texture_image *intelImage = intel_texture_image(image);
+ GLuint level = intelImage->base.Base.Level;
+ int width, height, depth;
+
+ if (target_to_target(image->TexObject->Target) != mt->target)
+ return false;
+
+ if (image->TexFormat != mt->format &&
+ !(image->TexFormat == MESA_FORMAT_S8_Z24 &&
+ mt->format == MESA_FORMAT_X8_Z24 &&
+ mt->stencil_mt)) {
+ return false;
+ }
+
+ intel_miptree_get_dimensions_for_image(image, &width, &height, &depth);
+
+ if (mt->target == GL_TEXTURE_CUBE_MAP)
+ depth = 6;
+
+ /* Test image dimensions against the base level image adjusted for
+ * minification. This will also catch images not present in the
+ * tree, changed targets, etc.
+ */
+ if (width != mt->level[level].width ||
+ height != mt->level[level].height ||
+ depth != mt->level[level].depth)
+ return false;
+
+ return true;
+}
+
+
+void
+intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
+ GLuint level,
+ GLuint x, GLuint y,
+ GLuint w, GLuint h, GLuint d)
+{
+ mt->level[level].width = w;
+ mt->level[level].height = h;
+ mt->level[level].depth = d;
+ mt->level[level].level_x = x;
+ mt->level[level].level_y = y;
+
+ DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__,
+ level, w, h, d, x, y);
+
+ assert(mt->level[level].slice == NULL);
+
+ mt->level[level].slice = calloc(d, sizeof(*mt->level[0].slice));
+ mt->level[level].slice[0].x_offset = mt->level[level].level_x;
+ mt->level[level].slice[0].y_offset = mt->level[level].level_y;
+}
+
+
+void
+intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
+ GLuint level, GLuint img,
+ GLuint x, GLuint y)
+{
+ if (img == 0 && level == 0)
+ assert(x == 0 && y == 0);
+
+ assert(img < mt->level[level].depth);
+
+ mt->level[level].slice[img].x_offset = mt->level[level].level_x + x;
+ mt->level[level].slice[img].y_offset = mt->level[level].level_y + y;
+
+ DBG("%s level %d img %d pos %d,%d\n",
+ __FUNCTION__, level, img,
+ mt->level[level].slice[img].x_offset,
+ mt->level[level].slice[img].y_offset);
+}
+
+
+/**
+ * For cube map textures, either the \c face parameter can be used, of course,
+ * or the cube face can be interpreted as a depth layer and the \c layer
+ * parameter used.
+ */
+void
+intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
+ GLuint level, GLuint face, GLuint layer,
+ GLuint *x, GLuint *y)
+{
+ int slice;
+
+ if (face > 0) {
+ assert(mt->target == GL_TEXTURE_CUBE_MAP);
+ assert(face < 6);
+ assert(layer == 0);
+ slice = face;
+ } else {
+ /* This branch may be taken even if the texture target is a cube map. In
+ * that case, the caller chose to interpret each cube face as a layer.
+ */
+ assert(face == 0);
+ slice = layer;
+ }
+
+ *x = mt->level[level].slice[slice].x_offset;
+ *y = mt->level[level].slice[slice].y_offset;
+}
+
+static void
+intel_miptree_copy_slice(struct intel_context *intel,
+ struct intel_mipmap_tree *dst_mt,
+ struct intel_mipmap_tree *src_mt,
+ int level,
+ int face,
+ int depth)
+
+{
+ gl_format format = src_mt->format;
+ uint32_t width = src_mt->level[level].width;
+ uint32_t height = src_mt->level[level].height;
+
+ assert(depth < src_mt->level[level].depth);
+
+ if (dst_mt->compressed) {
+ height = ALIGN(height, dst_mt->align_h) / dst_mt->align_h;
+ width = ALIGN(width, dst_mt->align_w);
+ }
+
+ uint32_t dst_x, dst_y, src_x, src_y;
+ intel_miptree_get_image_offset(dst_mt, level, face, depth,
+ &dst_x, &dst_y);
+ intel_miptree_get_image_offset(src_mt, level, face, depth,
+ &src_x, &src_y);
+
+ DBG("validate blit mt %p %d,%d/%d -> mt %p %d,%d/%d (%dx%d)\n",
+ src_mt, src_x, src_y, src_mt->region->pitch * src_mt->region->cpp,
+ dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp,
+ width, height);
+
+ if (!intelEmitCopyBlit(intel,
+ dst_mt->region->cpp,
+ src_mt->region->pitch, src_mt->region->bo,
+ 0, src_mt->region->tiling,
+ dst_mt->region->pitch, dst_mt->region->bo,
+ 0, dst_mt->region->tiling,
+ src_x, src_y,
+ dst_x, dst_y,
+ width, height,
+ GL_COPY)) {
+
+ fallback_debug("miptree validate blit for %s failed\n",
+ _mesa_get_format_name(format));
+ void *dst = intel_region_map(intel, dst_mt->region, GL_MAP_WRITE_BIT);
+ void *src = intel_region_map(intel, src_mt->region, GL_MAP_READ_BIT);
+
+ _mesa_copy_rect(dst,
+ dst_mt->cpp,
+ dst_mt->region->pitch,
+ dst_x, dst_y,
+ width, height,
+ src, src_mt->region->pitch,
+ src_x, src_y);
+
+ intel_region_unmap(intel, dst_mt->region);
+ intel_region_unmap(intel, src_mt->region);
+ }
+
+ if (src_mt->stencil_mt) {
+ intel_miptree_copy_slice(intel,
+ dst_mt->stencil_mt, src_mt->stencil_mt,
+ level, face, depth);
+ }
+}
+
+/**
+ * Copies the image's current data to the given miptree, and associates that
+ * miptree with the image.
+ */
+void
+intel_miptree_copy_teximage(struct intel_context *intel,
+ struct intel_texture_image *intelImage,
+ struct intel_mipmap_tree *dst_mt)
+{
+ struct intel_mipmap_tree *src_mt = intelImage->mt;
+ int level = intelImage->base.Base.Level;
+ int face = intelImage->base.Base.Face;
+ GLuint depth = intelImage->base.Base.Depth;
+
+ for (int slice = 0; slice < depth; slice++) {
+ intel_miptree_copy_slice(intel, dst_mt, src_mt, level, face, slice);
+ }
+
+ intel_miptree_reference(&intelImage->mt, dst_mt);
+}
+
+bool
+intel_miptree_alloc_mcs(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ GLuint num_samples)
+{
+ assert(mt->mcs_mt == NULL);
+ assert(intel->gen >= 7); /* MCS only used on Gen7+ */
+
+ /* Choose the correct format for the MCS buffer. All that really matters
+ * is that we allocate the right buffer size, since we'll always be
+ * accessing this miptree using MCS-specific hardware mechanisms, which
+ * infer the correct format based on num_samples.
+ */
+ gl_format format;
+ switch (num_samples) {
+ case 4:
+ /* 8 bits/pixel are required for MCS data when using 4x MSAA (2 bits for
+ * each sample).
+ */
+ format = MESA_FORMAT_R8;
+ break;
+ case 8:
+ /* 32 bits/pixel are required for MCS data when using 8x MSAA (3 bits
+ * for each sample, plus 8 padding bits).
+ */
+ format = MESA_FORMAT_R_UINT32;
+ break;
+ default:
+ assert(!"Unrecognized sample count in intel_miptree_alloc_mcs");
+ break;
+ };
+
+ /* From the Ivy Bridge PRM, Vol4 Part1 p76, "MCS Base Address":
+ *
+ * "The MCS surface must be stored as Tile Y."
+ *
+ * We set msaa_format to INTEL_MSAA_LAYOUT_CMS to force
+ * intel_miptree_create() to use Y tiling. msaa_format is otherwise
+ * ignored for the MCS miptree.
+ */
+ mt->mcs_mt = intel_miptree_create(intel,
+ mt->target,
+ format,
+ mt->first_level,
+ mt->last_level,
+ mt->width0,
+ mt->height0,
+ mt->depth0,
+ true,
+ 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_CMS);
+
+ /* From the Ivy Bridge PRM, Vol 2 Part 1 p326:
+ *
+ * When MCS buffer is enabled and bound to MSRT, it is required that it
+ * is cleared prior to any rendering.
+ *
+ * Since we don't use the MCS buffer for any purpose other than rendering,
+ * it makes sense to just clear it immediately upon allocation.
+ *
+ * Note: the clear value for MCS buffers is all 1's, so we memset to 0xff.
+ */
+ void *data = intel_region_map(intel, mt->mcs_mt->region, 0);
+ memset(data, 0xff, mt->mcs_mt->region->bo->size);
+ intel_region_unmap(intel, mt->mcs_mt->region);
+
+ return mt->mcs_mt;
+}
+
+bool
+intel_miptree_alloc_hiz(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ GLuint num_samples)
+{
+ assert(mt->hiz_mt == NULL);
+ /* MSAA HiZ surfaces always use IMS layout. */
+ mt->hiz_mt = intel_miptree_create(intel,
+ mt->target,
+ MESA_FORMAT_X8_Z24,
+ mt->first_level,
+ mt->last_level,
+ mt->width0,
+ mt->height0,
+ mt->depth0,
+ true,
+ num_samples,
+ INTEL_MSAA_LAYOUT_IMS);
+
+ if (!mt->hiz_mt)
+ return false;
+
+ /* Mark that all slices need a HiZ resolve. */
+ struct intel_resolve_map *head = &mt->hiz_map;
+ for (int level = mt->first_level; level <= mt->last_level; ++level) {
+ for (int layer = 0; layer < mt->level[level].depth; ++layer) {
+ head->next = malloc(sizeof(*head->next));
+ head->next->prev = head;
+ head->next->next = NULL;
+ head = head->next;
+
+ head->level = level;
+ head->layer = layer;
+ head->need = GEN6_HIZ_OP_HIZ_RESOLVE;
+ }
+ }
+
+ return true;
+}
+
+void
+intel_miptree_slice_set_needs_hiz_resolve(struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ if (!mt->hiz_mt)
+ return;
+
+ intel_resolve_map_set(&mt->hiz_map,
+ level, layer, GEN6_HIZ_OP_HIZ_RESOLVE);
+}
+
+
+void
+intel_miptree_slice_set_needs_depth_resolve(struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ if (!mt->hiz_mt)
+ return;
+
+ intel_resolve_map_set(&mt->hiz_map,
+ level, layer, GEN6_HIZ_OP_DEPTH_RESOLVE);
+}
+
+static bool
+intel_miptree_slice_resolve(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer,
+ enum gen6_hiz_op need)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ struct intel_resolve_map *item =
+ intel_resolve_map_get(&mt->hiz_map, level, layer);
+
+ if (!item || item->need != need)
+ return false;
+
+ intel_hiz_exec(intel, mt, level, layer, need);
+ intel_resolve_map_remove(item);
+ return true;
+}
+
+bool
+intel_miptree_slice_resolve_hiz(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ return intel_miptree_slice_resolve(intel, mt, level, layer,
+ GEN6_HIZ_OP_HIZ_RESOLVE);
+}
+
+bool
+intel_miptree_slice_resolve_depth(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ return intel_miptree_slice_resolve(intel, mt, level, layer,
+ GEN6_HIZ_OP_DEPTH_RESOLVE);
+}
+
+static bool
+intel_miptree_all_slices_resolve(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ enum gen6_hiz_op need)
+{
+ bool did_resolve = false;
+ struct intel_resolve_map *i, *next;
+
+ for (i = mt->hiz_map.next; i; i = next) {
+ next = i->next;
+ if (i->need != need)
+ continue;
+
+ intel_hiz_exec(intel, mt, i->level, i->layer, need);
+ intel_resolve_map_remove(i);
+ did_resolve = true;
+ }
+
+ return did_resolve;
+}
+
+bool
+intel_miptree_all_slices_resolve_hiz(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ return intel_miptree_all_slices_resolve(intel, mt,
+ GEN6_HIZ_OP_HIZ_RESOLVE);
+}
+
+bool
+intel_miptree_all_slices_resolve_depth(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ return intel_miptree_all_slices_resolve(intel, mt,
+ GEN6_HIZ_OP_DEPTH_RESOLVE);
+}
+
+static void
+intel_miptree_updownsample(struct intel_context *intel,
+ struct intel_mipmap_tree *src,
+ struct intel_mipmap_tree *dst,
+ unsigned width,
+ unsigned height)
+{
+#ifndef I915
+ int src_x0 = 0;
+ int src_y0 = 0;
+ int dst_x0 = 0;
+ int dst_y0 = 0;
+
+ intel_miptree_slice_resolve_depth(intel, src, 0, 0);
+ intel_miptree_slice_resolve_depth(intel, dst, 0, 0);
+
+ brw_blorp_blit_miptrees(intel,
+ src, 0 /* level */, 0 /* layer */,
+ dst, 0 /* level */, 0 /* layer */,
+ src_x0, src_y0,
+ dst_x0, dst_y0,
+ width, height,
+ false, false /*mirror x, y*/);
+
+ if (src->stencil_mt) {
+ brw_blorp_blit_miptrees(intel,
+ src->stencil_mt, 0 /* level */, 0 /* layer */,
+ dst->stencil_mt, 0 /* level */, 0 /* layer */,
+ src_x0, src_y0,
+ dst_x0, dst_y0,
+ width, height,
+ false, false /*mirror x, y*/);
+ }
+#endif /* I915 */
+}
+
+static void
+assert_is_flat(struct intel_mipmap_tree *mt)
+{
+ assert(mt->target == GL_TEXTURE_2D);
+ assert(mt->first_level == 0);
+ assert(mt->last_level == 0);
+}
+
+/**
+ * \brief Downsample from mt to mt->singlesample_mt.
+ *
+ * If the miptree needs no downsample, then skip.
+ */
+void
+intel_miptree_downsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ assert_is_flat(mt);
+
+ if (!mt->need_downsample)
+ return;
+ intel_miptree_updownsample(intel,
+ mt, mt->singlesample_mt,
+ mt->singlesample_mt->width0,
+ mt->singlesample_mt->height0);
+ mt->need_downsample = false;
+
+ /* Strictly speaking, after a downsample on a depth miptree, a hiz
+ * resolve is needed on the singlesample miptree. However, since the
+ * singlesample miptree is never rendered to, the hiz resolve will never
+ * occur. Therefore we do not mark the needed hiz resolve after
+ * downsampling.
+ */
+}
+
+/**
+ * \brief Upsample from mt->singlesample_mt to mt.
+ *
+ * The upsample is done unconditionally.
+ */
+void
+intel_miptree_upsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ assert_is_flat(mt);
+ assert(!mt->need_downsample);
+
+ intel_miptree_updownsample(intel,
+ mt->singlesample_mt, mt,
+ mt->singlesample_mt->width0,
+ mt->singlesample_mt->height0);
+ intel_miptree_slice_set_needs_hiz_resolve(mt, 0, 0);
+}
+
+static void
+intel_miptree_map_gtt(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ unsigned int bw, bh;
+ void *base;
+ unsigned int image_x, image_y;
+ int x = map->x;
+ int y = map->y;
+
+ /* For compressed formats, the stride is the number of bytes per
+ * row of blocks. intel_miptree_get_image_offset() already does
+ * the divide.
+ */
+ _mesa_get_format_block_size(mt->format, &bw, &bh);
+ assert(y % bh == 0);
+ y /= bh;
+
+ base = intel_region_map(intel, mt->region, map->mode);
+
+ if (base == NULL)
+ map->ptr = NULL;
+ else {
+ /* Note that in the case of cube maps, the caller must have passed the
+ * slice number referencing the face.
+ */
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+ x += image_x;
+ y += image_y;
+
+ map->stride = mt->region->pitch * mt->cpp;
+ map->ptr = base + y * map->stride + x * mt->cpp;
+ }
+
+ DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, _mesa_get_format_name(mt->format),
+ x, y, map->ptr, map->stride);
+}
+
+static void
+intel_miptree_unmap_gtt(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ intel_region_unmap(intel, mt->region);
+}
+
+static void
+intel_miptree_map_blit(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ unsigned int image_x, image_y;
+ int x = map->x;
+ int y = map->y;
+ int ret;
+
+ /* The blitter requires the pitch to be aligned to 4. */
+ map->stride = ALIGN(map->w * mt->region->cpp, 4);
+
+ map->bo = drm_intel_bo_alloc(intel->bufmgr, "intel_miptree_map_blit() temp",
+ map->stride * map->h, 4096);
+ if (!map->bo) {
+ fprintf(stderr, "Failed to allocate blit temporary\n");
+ goto fail;
+ }
+
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+ x += image_x;
+ y += image_y;
+
+ if (!intelEmitCopyBlit(intel,
+ mt->region->cpp,
+ mt->region->pitch, mt->region->bo,
+ 0, mt->region->tiling,
+ map->stride / mt->region->cpp, map->bo,
+ 0, I915_TILING_NONE,
+ x, y,
+ 0, 0,
+ map->w, map->h,
+ GL_COPY)) {
+ fprintf(stderr, "Failed to blit\n");
+ goto fail;
+ }
+
+ intel_batchbuffer_flush(intel);
+ ret = drm_intel_bo_map(map->bo, (map->mode & GL_MAP_WRITE_BIT) != 0);
+ if (ret) {
+ fprintf(stderr, "Failed to map blit temporary\n");
+ goto fail;
+ }
+
+ map->ptr = map->bo->virtual;
+
+ DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, _mesa_get_format_name(mt->format),
+ x, y, map->ptr, map->stride);
+
+ return;
+
+fail:
+ drm_intel_bo_unreference(map->bo);
+ map->ptr = NULL;
+ map->stride = 0;
+}
+
+static void
+intel_miptree_unmap_blit(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ assert(!(map->mode & GL_MAP_WRITE_BIT));
+
+ drm_intel_bo_unmap(map->bo);
+ drm_intel_bo_unreference(map->bo);
+}
+
+static void
+intel_miptree_map_s8(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ map->stride = map->w;
+ map->buffer = map->ptr = malloc(map->stride * map->h);
+ if (!map->buffer)
+ return;
+
+ /* One of either READ_BIT or WRITE_BIT or both is set. READ_BIT implies no
+ * INVALIDATE_RANGE_BIT. WRITE_BIT needs the original values read in unless
+ * invalidate is set, since we'll be writing the whole rectangle from our
+ * temporary buffer back out.
+ */
+ if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {
+ uint8_t *untiled_s8_map = map->ptr;
+ uint8_t *tiled_s8_map = intel_region_map(intel, mt->region,
+ GL_MAP_READ_BIT);
+ unsigned int image_x, image_y;
+
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ ptrdiff_t offset = intel_offset_S8(mt->region->pitch,
+ x + image_x + map->x,
+ y + image_y + map->y,
+ intel->has_swizzling);
+ untiled_s8_map[y * map->w + x] = tiled_s8_map[offset];
+ }
+ }
+
+ intel_region_unmap(intel, mt->region);
+
+ DBG("%s: %d,%d %dx%d from mt %p %d,%d = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, map->x + image_x, map->y + image_y, map->ptr, map->stride);
+ } else {
+ DBG("%s: %d,%d %dx%d from mt %p = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, map->ptr, map->stride);
+ }
+}
+
+static void
+intel_miptree_unmap_s8(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ if (map->mode & GL_MAP_WRITE_BIT) {
+ unsigned int image_x, image_y;
+ uint8_t *untiled_s8_map = map->ptr;
+ uint8_t *tiled_s8_map = intel_region_map(intel, mt->region, map->mode);
+
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ ptrdiff_t offset = intel_offset_S8(mt->region->pitch,
+ x + map->x,
+ y + map->y,
+ intel->has_swizzling);
+ tiled_s8_map[offset] = untiled_s8_map[y * map->w + x];
+ }
+ }
+
+ intel_region_unmap(intel, mt->region);
+ }
+
+ free(map->buffer);
+}
+
+static void
+intel_miptree_map_etc1(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ /* For justification of these invariants,
+ * see intel_mipmap_tree:wraps_etc1.
+ */
+ assert(mt->wraps_etc1);
+ assert(mt->format == MESA_FORMAT_RGBX8888_REV);
+
+ /* From the GL_OES_compressed_ETC1_RGB8_texture spec:
+ * INVALID_OPERATION is generated by CompressedTexSubImage2D,
+ * TexSubImage2D, or CopyTexSubImage2D if the texture image <level>
+ * bound to <target> has internal format ETC1_RGB8_OES.
+ *
+ * This implies that intel_miptree_map_etc1() can only be called from
+ * glCompressedTexImage2D, and hence the assertions below hold.
+ */
+ assert(map->mode & GL_MAP_WRITE_BIT);
+ assert(map->mode & GL_MAP_INVALIDATE_RANGE_BIT);
+ assert(map->x == 0);
+ assert(map->y == 0);
+
+ /* Each ETC1 block contains 4x4 pixels in 8 bytes. */
+ map->stride = 2 * map->w;
+ map->buffer = map->ptr = malloc(map->stride * map->h);
+}
+
+static void
+intel_miptree_unmap_etc1(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ uint32_t image_x;
+ uint32_t image_y;
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+
+ uint8_t *xbgr = intel_region_map(intel, mt->region, map->mode)
+ + image_y * mt->region->pitch * mt->region->cpp
+ + image_x * mt->region->cpp;
+
+ _mesa_etc1_unpack_rgba8888(xbgr, mt->region->pitch * mt->region->cpp,
+ map->ptr, map->stride,
+ map->w, map->h);
+
+ intel_region_unmap(intel, mt->region);
+ free(map->buffer);
+}
+
+/**
+ * Mapping function for packed depth/stencil miptrees backed by real separate
+ * miptrees for depth and stencil.
+ *
+ * On gen7, and to support HiZ pre-gen7, we have to have the stencil buffer
+ * separate from the depth buffer. Yet at the GL API level, we have to expose
+ * packed depth/stencil textures and FBO attachments, and Mesa core expects to
+ * be able to map that memory for texture storage and glReadPixels-type
+ * operations. We give Mesa core that access by mallocing a temporary and
+ * copying the data between the actual backing store and the temporary.
+ */
+static void
+intel_miptree_map_depthstencil(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ struct intel_mipmap_tree *z_mt = mt;
+ struct intel_mipmap_tree *s_mt = mt->stencil_mt;
+ bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z32_FLOAT;
+ int packed_bpp = map_z32f_x24s8 ? 8 : 4;
+
+ map->stride = map->w * packed_bpp;
+ map->buffer = map->ptr = malloc(map->stride * map->h);
+ if (!map->buffer)
+ return;
+
+ /* One of either READ_BIT or WRITE_BIT or both is set. READ_BIT implies no
+ * INVALIDATE_RANGE_BIT. WRITE_BIT needs the original values read in unless
+ * invalidate is set, since we'll be writing the whole rectangle from our
+ * temporary buffer back out.
+ */
+ if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {
+ uint32_t *packed_map = map->ptr;
+ uint8_t *s_map = intel_region_map(intel, s_mt->region, GL_MAP_READ_BIT);
+ uint32_t *z_map = intel_region_map(intel, z_mt->region, GL_MAP_READ_BIT);
+ unsigned int s_image_x, s_image_y;
+ unsigned int z_image_x, z_image_y;
+
+ intel_miptree_get_image_offset(s_mt, level, 0, slice,
+ &s_image_x, &s_image_y);
+ intel_miptree_get_image_offset(z_mt, level, 0, slice,
+ &z_image_x, &z_image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ int map_x = map->x + x, map_y = map->y + y;
+ ptrdiff_t s_offset = intel_offset_S8(s_mt->region->pitch,
+ map_x + s_image_x,
+ map_y + s_image_y,
+ intel->has_swizzling);
+ ptrdiff_t z_offset = ((map_y + z_image_y) * z_mt->region->pitch +
+ (map_x + z_image_x));
+ uint8_t s = s_map[s_offset];
+ uint32_t z = z_map[z_offset];
+
+ if (map_z32f_x24s8) {
+ packed_map[(y * map->w + x) * 2 + 0] = z;
+ packed_map[(y * map->w + x) * 2 + 1] = s;
+ } else {
+ packed_map[y * map->w + x] = (s << 24) | (z & 0x00ffffff);
+ }
+ }
+ }
+
+ intel_region_unmap(intel, s_mt->region);
+ intel_region_unmap(intel, z_mt->region);
+
+ DBG("%s: %d,%d %dx%d from z mt %p %d,%d, s mt %p %d,%d = %p/%d\n",
+ __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ z_mt, map->x + z_image_x, map->y + z_image_y,
+ s_mt, map->x + s_image_x, map->y + s_image_y,
+ map->ptr, map->stride);
+ } else {
+ DBG("%s: %d,%d %dx%d from mt %p = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, map->ptr, map->stride);
+ }
+}
+
+static void
+intel_miptree_unmap_depthstencil(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_mipmap_tree *z_mt = mt;
+ struct intel_mipmap_tree *s_mt = mt->stencil_mt;
+ bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z32_FLOAT;
+
+ if (map->mode & GL_MAP_WRITE_BIT) {
+ uint32_t *packed_map = map->ptr;
+ uint8_t *s_map = intel_region_map(intel, s_mt->region, map->mode);
+ uint32_t *z_map = intel_region_map(intel, z_mt->region, map->mode);
+ unsigned int s_image_x, s_image_y;
+ unsigned int z_image_x, z_image_y;
+
+ intel_miptree_get_image_offset(s_mt, level, 0, slice,
+ &s_image_x, &s_image_y);
+ intel_miptree_get_image_offset(z_mt, level, 0, slice,
+ &z_image_x, &z_image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ ptrdiff_t s_offset = intel_offset_S8(s_mt->region->pitch,
+ x + s_image_x + map->x,
+ y + s_image_y + map->y,
+ intel->has_swizzling);
+ ptrdiff_t z_offset = ((y + z_image_y) * z_mt->region->pitch +
+ (x + z_image_x));
+
+ if (map_z32f_x24s8) {
+ z_map[z_offset] = packed_map[(y * map->w + x) * 2 + 0];
+ s_map[s_offset] = packed_map[(y * map->w + x) * 2 + 1];
+ } else {
+ uint32_t packed = packed_map[y * map->w + x];
+ s_map[s_offset] = packed >> 24;
+ z_map[z_offset] = packed;
+ }
+ }
+ }
+
+ intel_region_unmap(intel, s_mt->region);
+ intel_region_unmap(intel, z_mt->region);
+
+ DBG("%s: %d,%d %dx%d from z mt %p (%s) %d,%d, s mt %p %d,%d = %p/%d\n",
+ __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ z_mt, _mesa_get_format_name(z_mt->format),
+ map->x + z_image_x, map->y + z_image_y,
+ s_mt, map->x + s_image_x, map->y + s_image_y,
+ map->ptr, map->stride);
+ }
+
+ free(map->buffer);
+}
+
+/**
+ * Create and attach a map to the miptree at (level, slice). Return the
+ * attached map.
+ */
+static struct intel_miptree_map*
+intel_miptree_attach_map(struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode)
+{
+ struct intel_miptree_map *map = calloc(1, sizeof(*map));
+
+ if (!map)
+ return NULL;
+
+ assert(mt->level[level].slice[slice].map == NULL);
+ mt->level[level].slice[slice].map = map;
+
+ map->mode = mode;
+ map->x = x;
+ map->y = y;
+ map->w = w;
+ map->h = h;
+
+ return map;
+}
+
+/**
+ * Release the map at (level, slice).
+ */
+static void
+intel_miptree_release_map(struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_miptree_map **map;
+
+ map = &mt->level[level].slice[slice].map;
+ free(*map);
+ *map = NULL;
+}
+
+static void
+intel_miptree_map_singlesample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode,
+ void **out_ptr,
+ int *out_stride)
+{
+ struct intel_miptree_map *map;
+
+ assert(mt->num_samples <= 1);
+
+ map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode);
+ if (!map){
+ *out_ptr = NULL;
+ *out_stride = 0;
+ return;
+ }
+
+ intel_miptree_slice_resolve_depth(intel, mt, level, slice);
+ if (map->mode & GL_MAP_WRITE_BIT) {
+ intel_miptree_slice_set_needs_hiz_resolve(mt, level, slice);
+ }
+
+ if (mt->format == MESA_FORMAT_S8) {
+ intel_miptree_map_s8(intel, mt, map, level, slice);
+ } else if (mt->wraps_etc1) {
+ intel_miptree_map_etc1(intel, mt, map, level, slice);
+ } else if (mt->stencil_mt) {
+ intel_miptree_map_depthstencil(intel, mt, map, level, slice);
+ } else if (intel->has_llc &&
+ !(mode & GL_MAP_WRITE_BIT) &&
+ !mt->compressed &&
+ mt->region->tiling == I915_TILING_X) {
+ intel_miptree_map_blit(intel, mt, map, level, slice);
+ } else {
+ intel_miptree_map_gtt(intel, mt, map, level, slice);
+ }
+
+ *out_ptr = map->ptr;
+ *out_stride = map->stride;
+
+ if (map->ptr == NULL)
+ intel_miptree_release_map(mt, level, slice);
+}
+
+static void
+intel_miptree_unmap_singlesample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_miptree_map *map = mt->level[level].slice[slice].map;
+
+ assert(mt->num_samples <= 1);
+
+ if (!map)
+ return;
+
+ DBG("%s: mt %p (%s) level %d slice %d\n", __FUNCTION__,
+ mt, _mesa_get_format_name(mt->format), level, slice);
+
+ if (mt->format == MESA_FORMAT_S8) {
+ intel_miptree_unmap_s8(intel, mt, map, level, slice);
+ } else if (mt->wraps_etc1) {
+ intel_miptree_unmap_etc1(intel, mt, map, level, slice);
+ } else if (mt->stencil_mt) {
+ intel_miptree_unmap_depthstencil(intel, mt, map, level, slice);
+ } else if (map->bo) {
+ intel_miptree_unmap_blit(intel, mt, map, level, slice);
+ } else {
+ intel_miptree_unmap_gtt(intel, mt, map, level, slice);
+ }
+
+ intel_miptree_release_map(mt, level, slice);
+}
+
+static void
+intel_miptree_map_multisample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode,
+ void **out_ptr,
+ int *out_stride)
+{
+ struct intel_miptree_map *map;
+
+ assert(mt->num_samples > 1);
+
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ if (mt->target != GL_TEXTURE_2D ||
+ mt->first_level != 0 ||
+ mt->last_level != 0) {
+ _mesa_problem(&intel->ctx, "attempt to map a multisample miptree for "
+ "which (target, first_level, last_level != "
+ "(GL_TEXTURE_2D, 0, 0)");
+ goto fail;
+ }
+
+ map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode);
+ if (!map)
+ goto fail;
+
+ if (!mt->singlesample_mt) {
+ mt->singlesample_mt =
+ intel_miptree_create_for_renderbuffer(intel,
+ mt->format,
+ mt->singlesample_width0,
+ mt->singlesample_height0,
+ 0 /*num_samples*/);
+ if (!mt->singlesample_mt)
+ goto fail;
+
+ map->singlesample_mt_is_tmp = true;
+ mt->need_downsample = true;
+ }
+
+ intel_miptree_downsample(intel, mt);
+ intel_miptree_map_singlesample(intel, mt->singlesample_mt,
+ level, slice,
+ x, y, w, h,
+ mode,
+ out_ptr, out_stride);
+ return;
+
+fail:
+ intel_miptree_release_map(mt, level, slice);
+ *out_ptr = NULL;
+ *out_stride = 0;
+}
+
+static void
+intel_miptree_unmap_multisample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_miptree_map *map = mt->level[level].slice[slice].map;
+
+ assert(mt->num_samples > 1);
+
+ if (!map)
+ return;
+
+ intel_miptree_unmap_singlesample(intel, mt->singlesample_mt, level, slice);
+
+ mt->need_downsample = false;
+ if (map->mode & GL_MAP_WRITE_BIT)
+ intel_miptree_upsample(intel, mt);
+
+ if (map->singlesample_mt_is_tmp)
+ intel_miptree_release(&mt->singlesample_mt);
+
+ intel_miptree_release_map(mt, level, slice);
+}
+
+void
+intel_miptree_map(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode,
+ void **out_ptr,
+ int *out_stride)
+{
+ if (mt->num_samples <= 1)
+ intel_miptree_map_singlesample(intel, mt,
+ level, slice,
+ x, y, w, h,
+ mode,
+ out_ptr, out_stride);
+ else
+ intel_miptree_map_multisample(intel, mt,
+ level, slice,
+ x, y, w, h,
+ mode,
+ out_ptr, out_stride);
+}
+
+void
+intel_miptree_unmap(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ if (mt->num_samples <= 1)
+ intel_miptree_unmap_singlesample(intel, mt, level, slice);
+ else
+ intel_miptree_unmap_multisample(intel, mt, level, slice);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel.c
index d733c5e8745..bc705105d4d 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel.c
@@ -1 +1,167 @@
-../intel/intel_pixel.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portionsalloc
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/accum.h"
+#include "main/enums.h"
+#include "main/state.h"
+#include "main/bufferobj.h"
+#include "main/context.h"
+#include "swrast/swrast.h"
+
+#include "intel_context.h"
+#include "intel_pixel.h"
+#include "intel_regions.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+static GLenum
+effective_func(GLenum func, bool src_alpha_is_one)
+{
+ if (src_alpha_is_one) {
+ if (func == GL_SRC_ALPHA)
+ return GL_ONE;
+ if (func == GL_ONE_MINUS_SRC_ALPHA)
+ return GL_ZERO;
+ }
+
+ return func;
+}
+
+/**
+ * Check if any fragment operations are in effect which might effect
+ * glDraw/CopyPixels.
+ */
+bool
+intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
+{
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->FragmentProgram._Enabled) {
+ DBG("fallback due to fragment program\n");
+ return false;
+ }
+
+ if (ctx->Color.BlendEnabled &&
+ (effective_func(ctx->Color.Blend[0].SrcRGB, src_alpha_is_one) != GL_ONE ||
+ effective_func(ctx->Color.Blend[0].DstRGB, src_alpha_is_one) != GL_ZERO ||
+ ctx->Color.Blend[0].EquationRGB != GL_FUNC_ADD ||
+ effective_func(ctx->Color.Blend[0].SrcA, src_alpha_is_one) != GL_ONE ||
+ effective_func(ctx->Color.Blend[0].DstA, src_alpha_is_one) != GL_ZERO ||
+ ctx->Color.Blend[0].EquationA != GL_FUNC_ADD)) {
+ DBG("fallback due to blend\n");
+ return false;
+ }
+
+ if (ctx->Texture._EnabledUnits) {
+ DBG("fallback due to texturing\n");
+ return false;
+ }
+
+ if (!(ctx->Color.ColorMask[0][0] &&
+ ctx->Color.ColorMask[0][1] &&
+ ctx->Color.ColorMask[0][2] &&
+ ctx->Color.ColorMask[0][3])) {
+ DBG("fallback due to color masking\n");
+ return false;
+ }
+
+ if (ctx->Color.AlphaEnabled) {
+ DBG("fallback due to alpha\n");
+ return false;
+ }
+
+ if (ctx->Depth.Test) {
+ DBG("fallback due to depth test\n");
+ return false;
+ }
+
+ if (ctx->Fog.Enabled) {
+ DBG("fallback due to fog\n");
+ return false;
+ }
+
+ if (ctx->_ImageTransferState) {
+ DBG("fallback due to image transfer\n");
+ return false;
+ }
+
+ if (ctx->Stencil._Enabled) {
+ DBG("fallback due to image stencil\n");
+ return false;
+ }
+
+ if (ctx->RenderMode != GL_RENDER) {
+ DBG("fallback due to render mode\n");
+ return false;
+ }
+
+ return true;
+}
+
+/* The intel_region struct doesn't really do enough to capture the
+ * format of the pixels in the region. For now this code assumes that
+ * the region is a display surface and hence is either ARGB8888 or
+ * RGB565.
+ * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
+ * know the buffer's pixel format.
+ *
+ * \param format as given to glDraw/ReadPixels
+ * \param type as given to glDraw/ReadPixels
+ */
+bool
+intel_check_blit_format(struct intel_region * region,
+ GLenum format, GLenum type)
+{
+ if (region->cpp == 4 &&
+ (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+ type == GL_UNSIGNED_BYTE) && format == GL_BGRA) {
+ return true;
+ }
+
+ if (region->cpp == 2 &&
+ type == GL_UNSIGNED_SHORT_5_6_5_REV && format == GL_BGR) {
+ return true;
+ }
+
+ DBG("%s: bad format for blit (cpp %d, type %s format %s)\n",
+ __FUNCTION__, region->cpp,
+ _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
+
+ return false;
+}
+
+void
+intelInitPixelFuncs(struct dd_function_table *functions)
+{
+ functions->Accum = _mesa_accum;
+ functions->Bitmap = intelBitmap;
+ functions->CopyPixels = intelCopyPixels;
+ functions->DrawPixels = intelDrawPixels;
+ functions->ReadPixels = intelReadPixels;
+}
+
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c
index 9085c7b0397..954dfc50b14 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c
@@ -1 +1,340 @@
-../intel/intel_pixel_bitmap.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portionsalloc
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/colormac.h"
+#include "main/condrender.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/pbo.h"
+#include "main/bufferobj.h"
+#include "main/state.h"
+#include "main/texobj.h"
+#include "main/context.h"
+#include "main/fbobject.h"
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
+#include "intel_regions.h"
+#include "intel_buffers.h"
+#include "intel_pixel.h"
+#include "intel_reg.h"
+
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+
+/* Unlike the other intel_pixel_* functions, the expectation here is
+ * that the incoming data is not in a PBO. With the XY_TEXT blit
+ * method, there's no benefit haveing it in a PBO, but we could
+ * implement a path based on XY_MONO_SRC_COPY_BLIT which might benefit
+ * PBO bitmaps. I think they are probably pretty rare though - I
+ * wonder if Xgl uses them?
+ */
+static const GLubyte *map_pbo( struct gl_context *ctx,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ GLubyte *buf;
+
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+ GL_COLOR_INDEX, GL_BITMAP,
+ INT_MAX, (const GLvoid *) bitmap)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)");
+ return NULL;
+ }
+
+ buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+ GL_MAP_READ_BIT,
+ unpack->BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
+ return NULL;
+ }
+
+ return ADD_POINTERS(buf, bitmap);
+}
+
+static bool test_bit( const GLubyte *src, GLuint bit )
+{
+ return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
+}
+
+static void set_bit( GLubyte *dest, GLuint bit )
+{
+ dest[bit/8] |= 1 << (bit % 8);
+}
+
+/* Extract a rectangle's worth of data from the bitmap. Called
+ * per chunk of HW-sized bitmap.
+ */
+static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap,
+ GLuint x, GLuint y,
+ GLuint w, GLuint h,
+ GLubyte *dest,
+ GLuint row_align,
+ bool invert)
+{
+ GLuint src_offset = (x + unpack->SkipPixels) & 0x7;
+ GLuint mask = unpack->LsbFirst ? 0 : 7;
+ GLuint bit = 0;
+ GLint row, col;
+ GLint first, last;
+ GLint incr;
+ GLuint count = 0;
+
+ DBG("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n",
+ __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask);
+
+ if (invert) {
+ first = h-1;
+ last = 0;
+ incr = -1;
+ }
+ else {
+ first = 0;
+ last = h-1;
+ incr = 1;
+ }
+
+ /* Require that dest be pre-zero'd.
+ */
+ for (row = first; row != (last+incr); row += incr) {
+ const GLubyte *rowsrc = _mesa_image_address2d(unpack, bitmap,
+ width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ y + row, x);
+
+ for (col = 0; col < w; col++, bit++) {
+ if (test_bit(rowsrc, (col + src_offset) ^ mask)) {
+ set_bit(dest, bit ^ 7);
+ count++;
+ }
+ }
+
+ if (row_align)
+ bit = ALIGN(bit, row_align);
+ }
+
+ return count;
+}
+
+/**
+ * Returns the low Y value of the vertical range given, flipped according to
+ * whether the framebuffer is or not.
+ */
+static INLINE int
+y_flip(struct gl_framebuffer *fb, int y, int height)
+{
+ if (_mesa_is_user_fbo(fb))
+ return y;
+ else
+ return fb->Height - y - height;
+}
+
+/*
+ * Render a bitmap.
+ */
+static bool
+do_blit_bitmap( struct gl_context *ctx,
+ GLint dstx, GLint dsty,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_region *dst;
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ GLfloat tmpColor[4];
+ GLubyte ubcolor[4];
+ GLuint color;
+ GLsizei bitmap_width = width;
+ GLsizei bitmap_height = height;
+ GLint px, py;
+ GLuint stipple[32];
+ GLint orig_dstx = dstx;
+ GLint orig_dsty = dsty;
+
+ /* Update draw buffer bounds */
+ _mesa_update_state(ctx);
+
+ if (ctx->Depth.Test) {
+ /* The blit path produces incorrect results when depth testing is on.
+ * It seems the blit Z coord is always 1.0 (the far plane) so fragments
+ * will likely be obscured by other, closer geometry.
+ */
+ return false;
+ }
+
+ intel_prepare_render(intel);
+ dst = intel_drawbuf_region(intel);
+
+ if (!dst)
+ return false;
+
+ if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ bitmap = map_pbo(ctx, width, height, unpack, bitmap);
+ if (bitmap == NULL)
+ return true; /* even though this is an error, we're done */
+ }
+
+ COPY_4V(tmpColor, ctx->Current.RasterColor);
+
+ if (_mesa_need_secondary_color(ctx)) {
+ ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor);
+ }
+
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[0], tmpColor[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[1], tmpColor[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[2], tmpColor[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[3], tmpColor[3]);
+
+ if (dst->cpp == 2)
+ color = PACK_COLOR_565(ubcolor[0], ubcolor[1], ubcolor[2]);
+ else
+ color = PACK_COLOR_8888(ubcolor[3], ubcolor[0], ubcolor[1], ubcolor[2]);
+
+ if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
+ return false;
+
+ /* Clip to buffer bounds and scissor. */
+ if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
+ fb->_Xmax, fb->_Ymax,
+ &dstx, &dsty, &width, &height))
+ goto out;
+
+ dsty = y_flip(fb, dsty, height);
+
+#define DY 32
+#define DX 32
+
+ /* Chop it all into chunks that can be digested by hardware: */
+ for (py = 0; py < height; py += DY) {
+ for (px = 0; px < width; px += DX) {
+ int h = MIN2(DY, height - py);
+ int w = MIN2(DX, width - px);
+ GLuint sz = ALIGN(ALIGN(w,8) * h, 64)/8;
+ GLenum logic_op = ctx->Color.ColorLogicOpEnabled ?
+ ctx->Color.LogicOp : GL_COPY;
+
+ assert(sz <= sizeof(stipple));
+ memset(stipple, 0, sz);
+
+ /* May need to adjust this when padding has been introduced in
+ * sz above:
+ *
+ * Have to translate destination coordinates back into source
+ * coordinates.
+ */
+ if (get_bitmap_rect(bitmap_width, bitmap_height, unpack,
+ bitmap,
+ -orig_dstx + (dstx + px),
+ -orig_dsty + y_flip(fb, dsty + py, h),
+ w, h,
+ (GLubyte *)stipple,
+ 8,
+ _mesa_is_winsys_fbo(fb)) == 0)
+ continue;
+
+ if (!intelEmitImmediateColorExpandBlit(intel,
+ dst->cpp,
+ (GLubyte *)stipple,
+ sz,
+ color,
+ dst->pitch,
+ dst->bo,
+ 0,
+ dst->tiling,
+ dstx + px,
+ dsty + py,
+ w, h,
+ logic_op)) {
+ return false;
+ }
+ }
+ }
+out:
+
+ if (unlikely(INTEL_DEBUG & DEBUG_SYNC))
+ intel_batchbuffer_flush(intel);
+
+ if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ /* done with PBO so unmap it now */
+ ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj);
+ }
+
+ intel_check_front_buffer_rendering(intel);
+
+ return true;
+}
+
+
+/* There are a large number of possible ways to implement bitmap on
+ * this hardware, most of them have some sort of drawback. Here are a
+ * few that spring to mind:
+ *
+ * Blit:
+ * - XY_MONO_SRC_BLT_CMD
+ * - use XY_SETUP_CLIP_BLT for cliprect clipping.
+ * - XY_TEXT_BLT
+ * - XY_TEXT_IMMEDIATE_BLT
+ * - blit per cliprect, subject to maximum immediate data size.
+ * - XY_COLOR_BLT
+ * - per pixel or run of pixels
+ * - XY_PIXEL_BLT
+ * - good for sparse bitmaps
+ *
+ * 3D engine:
+ * - Point per pixel
+ * - Translate bitmap to an alpha texture and render as a quad
+ * - Chop bitmap up into 32x32 squares and render w/polygon stipple.
+ */
+void
+intelBitmap(struct gl_context * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * pixels)
+{
+ if (!_mesa_check_conditional_render(ctx))
+ return;
+
+ if (do_blit_bitmap(ctx, x, y, width, height,
+ unpack, pixels))
+ return;
+
+ _mesa_meta_Bitmap(ctx, x, y, width, height, unpack, pixels);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_copy.c
index ee433605904..682a52d97d2 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_copy.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_copy.c
@@ -1 +1,230 @@
-../intel/intel_pixel_copy.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/image.h"
+#include "main/state.h"
+#include "main/mtypes.h"
+#include "main/condrender.h"
+#include "main/fbobject.h"
+#include "drivers/common/meta.h"
+
+#include "intel_context.h"
+#include "intel_buffers.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+#include "intel_fbo.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+/**
+ * Check if any fragment operations are in effect which might effect
+ * glCopyPixels. Differs from intel_check_blit_fragment_ops in that
+ * we allow Scissor.
+ */
+static bool
+intel_check_copypixel_blit_fragment_ops(struct gl_context * ctx)
+{
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ /* Could do logicop with the blitter:
+ */
+ return !(ctx->_ImageTransferState ||
+ ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Stencil._Enabled ||
+ !ctx->Color.ColorMask[0][0] ||
+ !ctx->Color.ColorMask[0][1] ||
+ !ctx->Color.ColorMask[0][2] ||
+ !ctx->Color.ColorMask[0][3] ||
+ ctx->Texture._EnabledUnits ||
+ ctx->FragmentProgram._Enabled ||
+ ctx->Color.BlendEnabled);
+}
+
+
+/**
+ * CopyPixels with the blitter. Don't support zooming, pixel transfer, etc.
+ */
+static bool
+do_blit_copypixels(struct gl_context * ctx,
+ GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint dstx, GLint dsty, GLenum type)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_framebuffer *read_fb = ctx->ReadBuffer;
+ GLint orig_dstx;
+ GLint orig_dsty;
+ GLint orig_srcx;
+ GLint orig_srcy;
+ bool flip = false;
+ struct intel_renderbuffer *draw_irb = NULL;
+ struct intel_renderbuffer *read_irb = NULL;
+ gl_format read_format, draw_format;
+
+ /* Update draw buffer bounds */
+ _mesa_update_state(ctx);
+
+ switch (type) {
+ case GL_COLOR:
+ if (fb->_NumColorDrawBuffers != 1) {
+ fallback_debug("glCopyPixels() fallback: MRT\n");
+ return false;
+ }
+
+ draw_irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
+ read_irb = intel_renderbuffer(read_fb->_ColorReadBuffer);
+ break;
+ case GL_DEPTH_STENCIL_EXT:
+ draw_irb = intel_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ read_irb =
+ intel_renderbuffer(read_fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ break;
+ case GL_DEPTH:
+ fallback_debug("glCopyPixels() fallback: GL_DEPTH\n");
+ return false;
+ case GL_STENCIL:
+ fallback_debug("glCopyPixels() fallback: GL_STENCIL\n");
+ return false;
+ default:
+ fallback_debug("glCopyPixels(): Unknown type\n");
+ return false;
+ }
+
+ if (!draw_irb) {
+ fallback_debug("glCopyPixels() fallback: missing draw buffer\n");
+ return false;
+ }
+
+ if (!read_irb) {
+ fallback_debug("glCopyPixels() fallback: missing read buffer\n");
+ return false;
+ }
+
+ read_format = intel_rb_format(read_irb);
+ draw_format = intel_rb_format(draw_irb);
+
+ if (draw_format != read_format &&
+ !(draw_format == MESA_FORMAT_XRGB8888 &&
+ read_format == MESA_FORMAT_ARGB8888)) {
+ fallback_debug("glCopyPixels() fallback: mismatched formats (%s -> %s\n",
+ _mesa_get_format_name(read_format),
+ _mesa_get_format_name(draw_format));
+ return false;
+ }
+
+ /* Copypixels can be more than a straight copy. Ensure all the
+ * extra operations are disabled:
+ */
+ if (!intel_check_copypixel_blit_fragment_ops(ctx) ||
+ ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F)
+ return false;
+
+ intel_prepare_render(intel);
+
+ intel_flush(&intel->ctx);
+
+ /* Clip to destination buffer. */
+ orig_dstx = dstx;
+ orig_dsty = dsty;
+ if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
+ fb->_Xmax, fb->_Ymax,
+ &dstx, &dsty, &width, &height))
+ goto out;
+ /* Adjust src coords for our post-clipped destination origin */
+ srcx += dstx - orig_dstx;
+ srcy += dsty - orig_dsty;
+
+ /* Clip to source buffer. */
+ orig_srcx = srcx;
+ orig_srcy = srcy;
+ if (!_mesa_clip_to_region(0, 0,
+ read_fb->Width, read_fb->Height,
+ &srcx, &srcy, &width, &height))
+ goto out;
+ /* Adjust dst coords for our post-clipped source origin */
+ dstx += srcx - orig_srcx;
+ dsty += srcy - orig_srcy;
+
+ /* Flip dest Y if it's a window system framebuffer. */
+ if (_mesa_is_winsys_fbo(fb)) {
+ /* copypixels to a window system framebuffer */
+ dsty = fb->Height - dsty - height;
+ flip = !flip;
+ }
+
+ /* Flip source Y if it's a window system framebuffer. */
+ if (_mesa_is_winsys_fbo(read_fb)) {
+ srcy = read_fb->Height - srcy - height;
+ flip = !flip;
+ }
+
+ srcx += read_irb->draw_x;
+ srcy += read_irb->draw_y;
+ dstx += draw_irb->draw_x;
+ dsty += draw_irb->draw_y;
+
+ if (!intel_region_copy(intel,
+ draw_irb->mt->region, 0, dstx, dsty,
+ read_irb->mt->region, 0, srcx, srcy,
+ width, height, flip,
+ ctx->Color.ColorLogicOpEnabled ?
+ ctx->Color.LogicOp : GL_COPY)) {
+ DBG("%s: blit failure\n", __FUNCTION__);
+ return false;
+ }
+
+out:
+ intel_check_front_buffer_rendering(intel);
+
+ DBG("%s: success\n", __FUNCTION__);
+ return true;
+}
+
+
+void
+intelCopyPixels(struct gl_context * ctx,
+ GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint destx, GLint desty, GLenum type)
+{
+ DBG("%s\n", __FUNCTION__);
+
+ if (!_mesa_check_conditional_render(ctx))
+ return;
+
+ if (do_blit_copypixels(ctx, srcx, srcy, width, height, destx, desty, type))
+ return;
+
+ /* this will use swrast if needed */
+ _mesa_meta_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_draw.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_draw.c
index 8431a24edfc..2ec7ed8e269 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_draw.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_draw.c
@@ -1 +1,58 @@
-../intel/intel_pixel_draw.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portionsalloc
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/mtypes.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
+#include "main/texstate.h"
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "intel_context.h"
+#include "intel_pixel.h"
+
+void
+intelDrawPixels(struct gl_context * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ if (format == GL_STENCIL_INDEX) {
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type,
+ unpack, pixels);
+ return;
+ }
+
+ _mesa_meta_DrawPixels(ctx, x, y, width, height, format, type,
+ unpack, pixels);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_read.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_read.c
index cc4589f4d42..ab4e581c400 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_read.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_pixel_read.c
@@ -1 +1,205 @@
-../intel/intel_pixel_read.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/fbobject.h"
+#include "main/image.h"
+#include "main/bufferobj.h"
+#include "main/readpix.h"
+#include "main/state.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+#include "intel_buffer_objects.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+/* For many applications, the new ability to pull the source buffers
+ * back out of the GTT and then do the packing/conversion operations
+ * in software will be as much of an improvement as trying to get the
+ * blitter and/or texture engine to do the work.
+ *
+ * This step is gated on private backbuffers.
+ *
+ * Obviously the frontbuffer can't be pulled back, so that is either
+ * an argument for blit/texture readpixels, or for blitting to a
+ * temporary and then pulling that back.
+ *
+ * When the destination is a pbo, however, it's not clear if it is
+ * ever going to be pulled to main memory (though the access param
+ * will be a good hint). So it sounds like we do want to be able to
+ * choose between blit/texture implementation on the gpu and pullback
+ * and cpu-based copying.
+ *
+ * Unless you can magically turn client memory into a PBO for the
+ * duration of this call, there will be a cpu-based copying step in
+ * any case.
+ */
+
+static bool
+do_blit_readpixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_region *src = intel_readbuf_region(intel);
+ struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj);
+ GLuint dst_offset;
+ GLuint rowLength;
+ drm_intel_bo *dst_buffer;
+ bool all;
+ GLint dst_x, dst_y;
+ GLuint dirty;
+
+ DBG("%s\n", __FUNCTION__);
+
+ if (!src)
+ return false;
+
+ if (!_mesa_is_bufferobj(pack->BufferObj)) {
+ /* PBO only for now:
+ */
+ DBG("%s - not PBO\n", __FUNCTION__);
+ return false;
+ }
+
+
+ if (ctx->_ImageTransferState ||
+ !intel_check_blit_format(src, format, type)) {
+ DBG("%s - bad format for blit\n", __FUNCTION__);
+ return false;
+ }
+
+ if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) {
+ DBG("%s: bad packing params\n", __FUNCTION__);
+ return false;
+ }
+
+ if (pack->RowLength > 0)
+ rowLength = pack->RowLength;
+ else
+ rowLength = width;
+
+ if (pack->Invert) {
+ DBG("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
+ return false;
+ }
+ else {
+ if (_mesa_is_winsys_fbo(ctx->ReadBuffer))
+ rowLength = -rowLength;
+ }
+
+ dst_offset = (GLintptr)pixels;
+ dst_offset += _mesa_image_offset(2, pack, width, height,
+ format, type, 0, 0, 0);
+
+ if (!_mesa_clip_copytexsubimage(ctx,
+ &dst_x, &dst_y,
+ &x, &y,
+ &width, &height)) {
+ return true;
+ }
+
+ dirty = intel->front_buffer_dirty;
+ intel_prepare_render(intel);
+ intel->front_buffer_dirty = dirty;
+
+ all = (width * height * src->cpp == dst->Base.Size &&
+ x == 0 && dst_offset == 0);
+
+ dst_x = 0;
+ dst_y = 0;
+
+ dst_buffer = intel_bufferobj_buffer(intel, dst,
+ all ? INTEL_WRITE_FULL :
+ INTEL_WRITE_PART);
+
+ if (_mesa_is_winsys_fbo(ctx->ReadBuffer))
+ y = ctx->ReadBuffer->Height - (y + height);
+
+ if (!intelEmitCopyBlit(intel,
+ src->cpp,
+ src->pitch, src->bo, 0, src->tiling,
+ rowLength, dst_buffer, dst_offset, false,
+ x, y,
+ dst_x, dst_y,
+ width, height,
+ GL_COPY)) {
+ return false;
+ }
+
+ DBG("%s - DONE\n", __FUNCTION__);
+
+ return true;
+}
+
+void
+intelReadPixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+ struct intel_context *intel = intel_context(ctx);
+ bool dirty;
+
+ intel_flush_rendering_to_batch(ctx);
+
+ DBG("%s\n", __FUNCTION__);
+
+ if (do_blit_readpixels
+ (ctx, x, y, width, height, format, type, pack, pixels))
+ return;
+
+ /* glReadPixels() wont dirty the front buffer, so reset the dirty
+ * flag after calling intel_prepare_render(). */
+ dirty = intel->front_buffer_dirty;
+ intel_prepare_render(intel);
+ intel->front_buffer_dirty = dirty;
+
+ fallback_debug("%s: fallback to swrast\n", __FUNCTION__);
+
+ /* Update Mesa state before calling _mesa_readpixels().
+ * XXX this may not be needed since ReadPixels no longer uses the
+ * span code.
+ */
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ _mesa_readpixels(ctx, x, y, width, height, format, type, pack, pixels);
+
+ /* There's an intel_prepare_render() call in intelSpanRenderStart(). */
+ intel->front_buffer_dirty = dirty;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_regions.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_regions.c
index 89b2f15c10f..7cb008c2f71 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_regions.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_regions.c
@@ -1 +1,473 @@
-../intel/intel_regions.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/* Provide additional functionality on top of bufmgr buffers:
+ * - 2d semantics and blit operations
+ * - refcounting of buffers for multiple images in a buffer.
+ * - refcounting of buffer mappings.
+ * - some logic for moving the buffers to the best memory pools for
+ * given operations.
+ *
+ * Most of this is to make it easier to implement the fixed-layout
+ * mipmap tree required by intel hardware in the face of GL's
+ * programming interface where each image can be specifed in random
+ * order and it isn't clear what layout the tree should have until the
+ * last moment.
+ */
+
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "main/hash.h"
+#include "intel_context.h"
+#include "intel_regions.h"
+#include "intel_blit.h"
+#include "intel_buffer_objects.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+
+#define FILE_DEBUG_FLAG DEBUG_REGION
+
+/* This should be set to the maximum backtrace size desired.
+ * Set it to 0 to disable backtrace debugging.
+ */
+#define DEBUG_BACKTRACE_SIZE 0
+
+#if DEBUG_BACKTRACE_SIZE == 0
+/* Use the standard debug output */
+#define _DBG(...) DBG(__VA_ARGS__)
+#else
+/* Use backtracing debug output */
+#define _DBG(...) {debug_backtrace(); DBG(__VA_ARGS__);}
+
+/* Backtracing debug support */
+#include <execinfo.h>
+
+static void
+debug_backtrace(void)
+{
+ void *trace[DEBUG_BACKTRACE_SIZE];
+ char **strings = NULL;
+ int traceSize;
+ register int i;
+
+ traceSize = backtrace(trace, DEBUG_BACKTRACE_SIZE);
+ strings = backtrace_symbols(trace, traceSize);
+ if (strings == NULL) {
+ DBG("no backtrace:");
+ return;
+ }
+
+ /* Spit out all the strings with a colon separator. Ignore
+ * the first, since we don't really care about the call
+ * to debug_backtrace() itself. Skip until the final "/" in
+ * the trace to avoid really long lines.
+ */
+ for (i = 1; i < traceSize; i++) {
+ char *p = strings[i], *slash = strings[i];
+ while (*p) {
+ if (*p++ == '/') {
+ slash = p;
+ }
+ }
+
+ DBG("%s:", slash);
+ }
+
+ /* Free up the memory, and we're done */
+ free(strings);
+}
+
+#endif
+
+
+
+/* XXX: Thread safety?
+ */
+void *
+intel_region_map(struct intel_context *intel, struct intel_region *region,
+ GLbitfield mode)
+{
+ /* We have the region->map_refcount controlling mapping of the BO because
+ * in software fallbacks we may end up mapping the same buffer multiple
+ * times on Mesa's behalf, so we refcount our mappings to make sure that
+ * the pointer stays valid until the end of the unmap chain. However, we
+ * must not emit any batchbuffers between the start of mapping and the end
+ * of unmapping, or further use of the map will be incoherent with the GPU
+ * rendering done by that batchbuffer. Hence we assert in
+ * intel_batchbuffer_flush() that that doesn't happen, which means that the
+ * flush is only needed on first map of the buffer.
+ */
+
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (drm_intel_bo_busy(region->bo)) {
+ perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
+ }
+ }
+
+ _DBG("%s %p\n", __FUNCTION__, region);
+ if (!region->map_refcount) {
+ intel_flush(&intel->ctx);
+
+ if (region->tiling != I915_TILING_NONE)
+ drm_intel_gem_bo_map_gtt(region->bo);
+ else
+ drm_intel_bo_map(region->bo, true);
+
+ region->map = region->bo->virtual;
+ }
+ if (region->map) {
+ intel->num_mapped_regions++;
+ region->map_refcount++;
+ }
+
+ return region->map;
+}
+
+void
+intel_region_unmap(struct intel_context *intel, struct intel_region *region)
+{
+ _DBG("%s %p\n", __FUNCTION__, region);
+ if (!--region->map_refcount) {
+ if (region->tiling != I915_TILING_NONE)
+ drm_intel_gem_bo_unmap_gtt(region->bo);
+ else
+ drm_intel_bo_unmap(region->bo);
+
+ region->map = NULL;
+ --intel->num_mapped_regions;
+ assert(intel->num_mapped_regions >= 0);
+ }
+}
+
+static struct intel_region *
+intel_region_alloc_internal(struct intel_screen *screen,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
+ uint32_t tiling, drm_intel_bo *buffer)
+{
+ struct intel_region *region;
+
+ region = calloc(sizeof(*region), 1);
+ if (region == NULL)
+ return region;
+
+ region->cpp = cpp;
+ region->width = width;
+ region->height = height;
+ region->pitch = pitch;
+ region->refcount = 1;
+ region->bo = buffer;
+ region->tiling = tiling;
+ region->screen = screen;
+
+ _DBG("%s <-- %p\n", __FUNCTION__, region);
+ return region;
+}
+
+struct intel_region *
+intel_region_alloc(struct intel_screen *screen,
+ uint32_t tiling,
+ GLuint cpp, GLuint width, GLuint height,
+ bool expect_accelerated_upload)
+{
+ drm_intel_bo *buffer;
+ unsigned long flags = 0;
+ unsigned long aligned_pitch;
+ struct intel_region *region;
+
+ if (expect_accelerated_upload)
+ flags |= BO_ALLOC_FOR_RENDER;
+
+ buffer = drm_intel_bo_alloc_tiled(screen->bufmgr, "region",
+ width, height, cpp,
+ &tiling, &aligned_pitch, flags);
+ if (buffer == NULL)
+ return NULL;
+
+ region = intel_region_alloc_internal(screen, cpp, width, height,
+ aligned_pitch / cpp, tiling, buffer);
+ if (region == NULL) {
+ drm_intel_bo_unreference(buffer);
+ return NULL;
+ }
+
+ return region;
+}
+
+bool
+intel_region_flink(struct intel_region *region, uint32_t *name)
+{
+ if (region->name == 0) {
+ if (drm_intel_bo_flink(region->bo, &region->name))
+ return false;
+
+ _mesa_HashInsert(region->screen->named_regions,
+ region->name, region);
+ }
+
+ *name = region->name;
+
+ return true;
+}
+
+struct intel_region *
+intel_region_alloc_for_handle(struct intel_screen *screen,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
+ GLuint handle, const char *name)
+{
+ struct intel_region *region, *dummy;
+ drm_intel_bo *buffer;
+ int ret;
+ uint32_t bit_6_swizzle, tiling;
+
+ region = _mesa_HashLookup(screen->named_regions, handle);
+ if (region != NULL) {
+ dummy = NULL;
+ if (region->width != width || region->height != height ||
+ region->cpp != cpp || region->pitch != pitch) {
+ fprintf(stderr,
+ "Region for name %d already exists but is not compatible\n",
+ handle);
+ return NULL;
+ }
+ intel_region_reference(&dummy, region);
+ return dummy;
+ }
+
+ buffer = intel_bo_gem_create_from_name(screen->bufmgr, name, handle);
+ if (buffer == NULL)
+ return NULL;
+ ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle);
+ if (ret != 0) {
+ fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n",
+ handle, name, strerror(-ret));
+ drm_intel_bo_unreference(buffer);
+ return NULL;
+ }
+
+ region = intel_region_alloc_internal(screen, cpp,
+ width, height, pitch, tiling, buffer);
+ if (region == NULL) {
+ drm_intel_bo_unreference(buffer);
+ return NULL;
+ }
+
+ region->name = handle;
+ _mesa_HashInsert(screen->named_regions, handle, region);
+
+ return region;
+}
+
+void
+intel_region_reference(struct intel_region **dst, struct intel_region *src)
+{
+ _DBG("%s: %p(%d) -> %p(%d)\n", __FUNCTION__,
+ *dst, *dst ? (*dst)->refcount : 0, src, src ? src->refcount : 0);
+
+ if (src != *dst) {
+ if (*dst)
+ intel_region_release(dst);
+
+ if (src)
+ src->refcount++;
+ *dst = src;
+ }
+}
+
+void
+intel_region_release(struct intel_region **region_handle)
+{
+ struct intel_region *region = *region_handle;
+
+ if (region == NULL) {
+ _DBG("%s NULL\n", __FUNCTION__);
+ return;
+ }
+
+ _DBG("%s %p %d\n", __FUNCTION__, region, region->refcount - 1);
+
+ ASSERT(region->refcount > 0);
+ region->refcount--;
+
+ if (region->refcount == 0) {
+ assert(region->map_refcount == 0);
+
+ drm_intel_bo_unreference(region->bo);
+
+ if (region->name > 0)
+ _mesa_HashRemove(region->screen->named_regions, region->name);
+
+ free(region);
+ }
+ *region_handle = NULL;
+}
+
+/*
+ * XXX Move this into core Mesa?
+ */
+void
+_mesa_copy_rect(GLubyte * dst,
+ GLuint cpp,
+ GLuint dst_pitch,
+ GLuint dst_x,
+ GLuint dst_y,
+ GLuint width,
+ GLuint height,
+ const GLubyte * src,
+ GLuint src_pitch, GLuint src_x, GLuint src_y)
+{
+ GLuint i;
+
+ dst_pitch *= cpp;
+ src_pitch *= cpp;
+ dst += dst_x * cpp;
+ src += src_x * cpp;
+ dst += dst_y * dst_pitch;
+ src += src_y * src_pitch;
+ width *= cpp;
+
+ if (width == dst_pitch && width == src_pitch)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+ }
+}
+
+/* Copy rectangular sub-regions. Need better logic about when to
+ * push buffers into AGP - will currently do so whenever possible.
+ */
+bool
+intel_region_copy(struct intel_context *intel,
+ struct intel_region *dst,
+ GLuint dst_offset,
+ GLuint dstx, GLuint dsty,
+ struct intel_region *src,
+ GLuint src_offset,
+ GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+ bool flip,
+ GLenum logicop)
+{
+ uint32_t src_pitch = src->pitch;
+
+ _DBG("%s\n", __FUNCTION__);
+
+ if (intel == NULL)
+ return false;
+
+ assert(src->cpp == dst->cpp);
+
+ if (flip)
+ src_pitch = -src_pitch;
+
+ return intelEmitCopyBlit(intel,
+ dst->cpp,
+ src_pitch, src->bo, src_offset, src->tiling,
+ dst->pitch, dst->bo, dst_offset, dst->tiling,
+ srcx, srcy, dstx, dsty, width, height,
+ logicop);
+}
+
+/**
+ * This function computes masks that may be used to select the bits of the X
+ * and Y coordinates that indicate the offset within a tile. If the region is
+ * untiled, the masks are set to 0.
+ */
+void
+intel_region_get_tile_masks(struct intel_region *region,
+ uint32_t *mask_x, uint32_t *mask_y,
+ bool map_stencil_as_y_tiled)
+{
+ int cpp = region->cpp;
+ uint32_t tiling = region->tiling;
+
+ if (map_stencil_as_y_tiled)
+ tiling = I915_TILING_Y;
+
+ switch (tiling) {
+ default:
+ assert(false);
+ case I915_TILING_NONE:
+ *mask_x = *mask_y = 0;
+ break;
+ case I915_TILING_X:
+ *mask_x = 512 / cpp - 1;
+ *mask_y = 7;
+ break;
+ case I915_TILING_Y:
+ *mask_x = 128 / cpp - 1;
+ *mask_y = 31;
+ break;
+ }
+}
+
+/**
+ * Compute the offset (in bytes) from the start of the region to the given x
+ * and y coordinate. For tiled regions, caller must ensure that x and y are
+ * multiples of the tile size.
+ */
+uint32_t
+intel_region_get_aligned_offset(struct intel_region *region, uint32_t x,
+ uint32_t y, bool map_stencil_as_y_tiled)
+{
+ int cpp = region->cpp;
+ uint32_t pitch = region->pitch * cpp;
+ uint32_t tiling = region->tiling;
+
+ if (map_stencil_as_y_tiled) {
+ tiling = I915_TILING_Y;
+
+ /* When mapping a W-tiled stencil buffer as Y-tiled, each 64-high W-tile
+ * gets transformed into a 32-high Y-tile. Accordingly, the pitch of
+ * the resulting region is twice the pitch of the original region, since
+ * each row in the Y-tiled view corresponds to two rows in the actual
+ * W-tiled surface. So we need to correct the pitch before computing
+ * the offsets.
+ */
+ pitch *= 2;
+ }
+
+ switch (tiling) {
+ default:
+ assert(false);
+ case I915_TILING_NONE:
+ return y * pitch + x * cpp;
+ case I915_TILING_X:
+ assert((x % (512 / cpp)) == 0);
+ assert((y % 8) == 0);
+ return y * pitch + x / (512 / cpp) * 4096;
+ case I915_TILING_Y:
+ assert((x % (128 / cpp)) == 0);
+ assert((y % 32) == 0);
+ return y * pitch + x / (128 / cpp) * 4096;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_resolve_map.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_resolve_map.c
index 77e50fbaea4..04b5c942432 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_resolve_map.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_resolve_map.c
@@ -1 +1,111 @@
-../intel/intel_resolve_map.c \ No newline at end of file
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "intel_resolve_map.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+/**
+ * \brief Set that the miptree slice at (level, layer) needs a resolve.
+ *
+ * If a map element already exists with the given key, then the value is
+ * changed to the given value of \c need.
+ */
+void
+intel_resolve_map_set(struct intel_resolve_map *head,
+ uint32_t level,
+ uint32_t layer,
+ enum gen6_hiz_op need)
+{
+ struct intel_resolve_map **tail = &head->next;
+ struct intel_resolve_map *prev = head;
+
+ while (*tail) {
+ if ((*tail)->level == level && (*tail)->layer == layer) {
+ (*tail)->need = need;
+ return;
+ }
+ prev = *tail;
+ tail = &(*tail)->next;
+ }
+
+ *tail = malloc(sizeof(**tail));
+ (*tail)->prev = prev;
+ (*tail)->next = NULL;
+ (*tail)->level = level;
+ (*tail)->layer = layer;
+ (*tail)->need = need;
+}
+
+/**
+ * \brief Get an element from the map.
+ * \return null if element is not contained in map.
+ */
+struct intel_resolve_map*
+intel_resolve_map_get(struct intel_resolve_map *head,
+ uint32_t level,
+ uint32_t layer)
+{
+ struct intel_resolve_map *item = head->next;
+
+ while (item) {
+ if (item->level == level && item->layer == layer)
+ break;
+ else
+ item = item->next;
+ }
+
+ return item;
+}
+
+/**
+ * \brief Remove and free an element from the map.
+ */
+void
+intel_resolve_map_remove(struct intel_resolve_map *elem)
+{
+ if (elem->prev)
+ elem->prev->next = elem->next;
+ if (elem->next)
+ elem->next->prev = elem->prev;
+ free(elem);
+}
+
+/**
+ * \brief Remove and free all elements of the map.
+ */
+void
+intel_resolve_map_clear(struct intel_resolve_map *head)
+{
+ struct intel_resolve_map *next = head->next;
+ struct intel_resolve_map *trash;
+
+ while (next) {
+ trash = next;
+ next = next->next;
+ free(trash);
+ }
+
+ head->next = NULL;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_screen.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_screen.c
index f2db48272b9..00a1b0122ec 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_screen.c
@@ -1 +1,1204 @@
-../intel/intel_screen.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <errno.h>
+#include <time.h>
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/hash.h"
+#include "main/fbobject.h"
+#include "main/mfeatures.h"
+#include "main/version.h"
+#include "swrast/s_renderbuffer.h"
+
+#include "utils.h"
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+ DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
+ /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
+ * DRI_CONF_BO_REUSE_ALL
+ */
+ DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 1, "0:1")
+ DRI_CONF_DESC_BEGIN(en, "Buffer object reuse")
+ DRI_CONF_ENUM(0, "Disable buffer object reuse")
+ DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
+ DRI_CONF_DESC_END
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(texture_tiling, bool, true)
+ DRI_CONF_DESC(en, "Enable texture tiling")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(hiz, bool, true)
+ DRI_CONF_DESC(en, "Enable Hierarchical Z on gen6+")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(early_z, bool, false)
+ DRI_CONF_DESC(en, "Enable early Z in classic mode (unstable, 945-only).")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(fragment_shader, bool, true)
+ DRI_CONF_DESC(en, "Enable limited ARB_fragment_shader support on 915/945.")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_ALLOW_LARGE_TEXTURES(2)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_ALWAYS_FLUSH_BATCH(false)
+ DRI_CONF_ALWAYS_FLUSH_CACHE(false)
+ DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN(false)
+ DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED(false)
+
+ DRI_CONF_OPT_BEGIN(stub_occlusion_query, bool, false)
+ DRI_CONF_DESC(en, "Enable stub ARB_occlusion_query support on 915/945.")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(shader_precompile, bool, true)
+ DRI_CONF_DESC(en, "Perform code generation at shader link time.")
+ DRI_CONF_OPT_END
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+
+const GLuint __driNConfigOptions = 15;
+
+#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
+#include "intel_bufmgr.h"
+#include "intel_chipset.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_screen.h"
+#include "intel_tex.h"
+#include "intel_regions.h"
+
+#include "i915_drm.h"
+
+#ifdef USE_NEW_INTERFACE
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+#endif /*USE_NEW_INTERFACE */
+
+/**
+ * For debugging purposes, this returns a time in seconds.
+ */
+double
+get_time(void)
+{
+ struct timespec tp;
+
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+
+ return tp.tv_sec + tp.tv_nsec / 1000000000.0;
+}
+
+void
+aub_dump_bmp(struct gl_context *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ for (int i = 0; i < fb->_NumColorDrawBuffers; i++) {
+ struct intel_renderbuffer *irb =
+ intel_renderbuffer(fb->_ColorDrawBuffers[i]);
+
+ if (irb && irb->mt) {
+ enum aub_dump_bmp_format format;
+
+ switch (irb->Base.Base.Format) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ format = AUB_DUMP_BMP_FORMAT_ARGB_8888;
+ break;
+ default:
+ continue;
+ }
+
+ drm_intel_gem_bo_aub_dump_bmp(irb->mt->region->bo,
+ irb->draw_x,
+ irb->draw_y,
+ irb->Base.Base.Width,
+ irb->Base.Base.Height,
+ format,
+ irb->mt->region->pitch *
+ irb->mt->region->cpp,
+ 0);
+ }
+ }
+}
+
+static const __DRItexBufferExtension intelTexBufferExtension = {
+ { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+ intelSetTexBuffer,
+ intelSetTexBuffer2,
+};
+
+static void
+intelDRI2Flush(__DRIdrawable *drawable)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct intel_context *intel = intel_context(ctx);
+ if (intel == NULL)
+ return;
+
+ if (intel->gen < 4)
+ INTEL_FIREVERTICES(intel);
+
+ intel_downsample_for_dri2_flush(intel, drawable);
+ intel->need_throttle = true;
+
+ if (intel->batch.used)
+ intel_batchbuffer_flush(intel);
+
+ if (INTEL_DEBUG & DEBUG_AUB) {
+ aub_dump_bmp(ctx);
+ }
+}
+
+static const struct __DRI2flushExtensionRec intelFlushExtension = {
+ { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
+ intelDRI2Flush,
+ dri2InvalidateDrawable,
+};
+
+struct intel_image_format intel_image_formats[] = {
+ { __DRI_IMAGE_FOURCC_ARGB8888, __DRI_IMAGE_COMPONENTS_RGBA, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
+
+ { __DRI_IMAGE_FOURCC_XRGB8888, __DRI_IMAGE_COMPONENTS_RGB, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB8888, 4 }, } },
+
+ { __DRI_IMAGE_FOURCC_YUV410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV411, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV444, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_NV12, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 1, __DRI_IMAGE_FORMAT_GR88, 2 } } },
+
+ { __DRI_IMAGE_FOURCC_NV16, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
+
+ /* For YUYV buffers, we set up two overlapping DRI images and treat
+ * them as planar buffers in the compositors. Plane 0 is GR88 and
+ * samples YU or YV pairs and places Y into the R component, while
+ * plane 1 is ARGB and samples YUYV clusters and places pairs and
+ * places U into the G component and V into A. This lets the
+ * texture sampler interpolate the Y components correctly when
+ * sampling from plane 0, and interpolate U and V correctly when
+ * sampling from plane 1. */
+ { __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
+ { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
+};
+
+static __DRIimage *
+intel_allocate_image(int dri_format, void *loaderPrivate)
+{
+ __DRIimage *image;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->dri_format = dri_format;
+ image->offset = 0;
+
+ switch (dri_format) {
+ case __DRI_IMAGE_FORMAT_RGB565:
+ image->format = MESA_FORMAT_RGB565;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ image->format = MESA_FORMAT_XRGB8888;
+ break;
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ image->format = MESA_FORMAT_ARGB8888;
+ break;
+ case __DRI_IMAGE_FORMAT_ABGR8888:
+ image->format = MESA_FORMAT_RGBA8888_REV;
+ break;
+ case __DRI_IMAGE_FORMAT_XBGR8888:
+ image->format = MESA_FORMAT_RGBX8888_REV;
+ break;
+ case __DRI_IMAGE_FORMAT_R8:
+ image->format = MESA_FORMAT_R8;
+ break;
+ case __DRI_IMAGE_FORMAT_GR88:
+ image->format = MESA_FORMAT_GR88;
+ break;
+ case __DRI_IMAGE_FORMAT_NONE:
+ image->format = MESA_FORMAT_NONE;
+ break;
+ default:
+ free(image);
+ return NULL;
+ }
+
+ image->internal_format = _mesa_get_format_base_format(image->format);
+ image->data = loaderPrivate;
+
+ return image;
+}
+
+static __DRIimage *
+intel_create_image_from_name(__DRIscreen *screen,
+ int width, int height, int format,
+ int name, int pitch, void *loaderPrivate)
+{
+ struct intel_screen *intelScreen = screen->driverPrivate;
+ __DRIimage *image;
+ int cpp;
+
+ image = intel_allocate_image(format, loaderPrivate);
+ if (image->format == MESA_FORMAT_NONE)
+ cpp = 1;
+ else
+ cpp = _mesa_get_format_bytes(image->format);
+ image->region = intel_region_alloc_for_handle(intelScreen,
+ cpp, width, height,
+ pitch, name, "image");
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static __DRIimage *
+intel_create_image_from_renderbuffer(__DRIcontext *context,
+ int renderbuffer, void *loaderPrivate)
+{
+ __DRIimage *image;
+ struct intel_context *intel = context->driverPrivate;
+ struct gl_renderbuffer *rb;
+ struct intel_renderbuffer *irb;
+
+ rb = _mesa_lookup_renderbuffer(&intel->ctx, renderbuffer);
+ if (!rb) {
+ _mesa_error(&intel->ctx,
+ GL_INVALID_OPERATION, "glRenderbufferExternalMESA");
+ return NULL;
+ }
+
+ irb = intel_renderbuffer(rb);
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->internal_format = rb->InternalFormat;
+ image->format = rb->Format;
+ image->offset = 0;
+ image->data = loaderPrivate;
+ intel_region_reference(&image->region, irb->mt->region);
+
+ switch (image->format) {
+ case MESA_FORMAT_RGB565:
+ image->dri_format = __DRI_IMAGE_FORMAT_RGB565;
+ break;
+ case MESA_FORMAT_XRGB8888:
+ image->dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
+ break;
+ case MESA_FORMAT_ARGB8888:
+ image->dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
+ break;
+ case MESA_FORMAT_RGBA8888_REV:
+ image->dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
+ break;
+ case MESA_FORMAT_R8:
+ image->dri_format = __DRI_IMAGE_FORMAT_R8;
+ break;
+ case MESA_FORMAT_RG88:
+ image->dri_format = __DRI_IMAGE_FORMAT_GR88;
+ break;
+ }
+
+ return image;
+}
+
+static void
+intel_destroy_image(__DRIimage *image)
+{
+ intel_region_release(&image->region);
+ FREE(image);
+}
+
+static __DRIimage *
+intel_create_image(__DRIscreen *screen,
+ int width, int height, int format,
+ unsigned int use,
+ void *loaderPrivate)
+{
+ __DRIimage *image;
+ struct intel_screen *intelScreen = screen->driverPrivate;
+ uint32_t tiling;
+ int cpp;
+
+ tiling = I915_TILING_X;
+ if (use & __DRI_IMAGE_USE_CURSOR) {
+ if (width != 64 || height != 64)
+ return NULL;
+ tiling = I915_TILING_NONE;
+ }
+
+ image = intel_allocate_image(format, loaderPrivate);
+ cpp = _mesa_get_format_bytes(image->format);
+ image->region =
+ intel_region_alloc(intelScreen, tiling, cpp, width, height, true);
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static GLboolean
+intel_query_image(__DRIimage *image, int attrib, int *value)
+{
+ switch (attrib) {
+ case __DRI_IMAGE_ATTRIB_STRIDE:
+ *value = image->region->pitch * image->region->cpp;
+ return true;
+ case __DRI_IMAGE_ATTRIB_HANDLE:
+ *value = image->region->bo->handle;
+ return true;
+ case __DRI_IMAGE_ATTRIB_NAME:
+ return intel_region_flink(image->region, (uint32_t *) value);
+ case __DRI_IMAGE_ATTRIB_FORMAT:
+ *value = image->dri_format;
+ return true;
+ case __DRI_IMAGE_ATTRIB_WIDTH:
+ *value = image->region->width;
+ return true;
+ case __DRI_IMAGE_ATTRIB_HEIGHT:
+ *value = image->region->height;
+ return true;
+ case __DRI_IMAGE_ATTRIB_COMPONENTS:
+ if (image->planar_format == NULL)
+ return false;
+ *value = image->planar_format->components;
+ return true;
+ default:
+ return false;
+ }
+}
+
+static __DRIimage *
+intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
+{
+ __DRIimage *image;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ intel_region_reference(&image->region, orig_image->region);
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ image->internal_format = orig_image->internal_format;
+ image->planar_format = orig_image->planar_format;
+ image->dri_format = orig_image->dri_format;
+ image->format = orig_image->format;
+ image->offset = orig_image->offset;
+ image->data = loaderPrivate;
+
+ memcpy(image->strides, orig_image->strides, sizeof(image->strides));
+ memcpy(image->offsets, orig_image->offsets, sizeof(image->offsets));
+
+ return image;
+}
+
+static GLboolean
+intel_validate_usage(__DRIimage *image, unsigned int use)
+{
+ if (use & __DRI_IMAGE_USE_CURSOR) {
+ if (image->region->width != 64 || image->region->height != 64)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static __DRIimage *
+intel_create_image_from_names(__DRIscreen *screen,
+ int width, int height, int fourcc,
+ int *names, int num_names,
+ int *strides, int *offsets,
+ void *loaderPrivate)
+{
+ struct intel_image_format *f = NULL;
+ __DRIimage *image;
+ int i, index;
+
+ if (screen == NULL || names == NULL || num_names != 1)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
+ if (intel_image_formats[i].fourcc == fourcc) {
+ f = &intel_image_formats[i];
+ }
+ }
+
+ if (f == NULL)
+ return NULL;
+
+ image = intel_create_image_from_name(screen, width, height,
+ __DRI_IMAGE_FORMAT_NONE,
+ names[0], strides[0],
+ loaderPrivate);
+
+ if (image == NULL)
+ return NULL;
+
+ image->planar_format = f;
+ for (i = 0; i < f->nplanes; i++) {
+ index = f->planes[i].buffer_index;
+ image->offsets[index] = offsets[index];
+ image->strides[index] = strides[index];
+ }
+
+ return image;
+}
+
+static __DRIimage *
+intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
+{
+ int width, height, offset, stride, dri_format, cpp, index, pitch;
+ struct intel_image_format *f;
+ uint32_t mask_x, mask_y;
+ __DRIimage *image;
+
+ if (parent == NULL || parent->planar_format == NULL)
+ return NULL;
+
+ f = parent->planar_format;
+
+ if (plane >= f->nplanes)
+ return NULL;
+
+ width = parent->region->width >> f->planes[plane].width_shift;
+ height = parent->region->height >> f->planes[plane].height_shift;
+ dri_format = f->planes[plane].dri_format;
+ index = f->planes[plane].buffer_index;
+ offset = parent->offsets[index];
+ stride = parent->strides[index];
+
+ image = intel_allocate_image(dri_format, loaderPrivate);
+ cpp = _mesa_get_format_bytes(image->format); /* safe since no none format */
+ pitch = stride / cpp;
+ if (offset + height * cpp * pitch > parent->region->bo->size) {
+ _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
+ FREE(image);
+ return NULL;
+ }
+
+ image->region = calloc(sizeof(*image->region), 1);
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ image->region->cpp = _mesa_get_format_bytes(image->format);
+ image->region->width = width;
+ image->region->height = height;
+ image->region->pitch = pitch;
+ image->region->refcount = 1;
+ image->region->bo = parent->region->bo;
+ drm_intel_bo_reference(image->region->bo);
+ image->region->tiling = parent->region->tiling;
+ image->region->screen = parent->region->screen;
+ image->offset = offset;
+
+ intel_region_get_tile_masks(image->region, &mask_x, &mask_y, false);
+ if (offset & mask_x)
+ _mesa_warning(NULL,
+ "intel_create_sub_image: offset not on tile boundary");
+
+ return image;
+}
+
+static struct __DRIimageExtensionRec intelImageExtension = {
+ { __DRI_IMAGE, 5 },
+ intel_create_image_from_name,
+ intel_create_image_from_renderbuffer,
+ intel_destroy_image,
+ intel_create_image,
+ intel_query_image,
+ intel_dup_image,
+ intel_validate_usage,
+ intel_create_image_from_names,
+ intel_from_planar
+};
+
+static const __DRIextension *intelScreenExtensions[] = {
+ &intelTexBufferExtension.base,
+ &intelFlushExtension.base,
+ &intelImageExtension.base,
+ &dri2ConfigQueryExtension.base,
+ NULL
+};
+
+static bool
+intel_get_param(__DRIscreen *psp, int param, int *value)
+{
+ int ret;
+ struct drm_i915_getparam gp;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = param;
+ gp.value = value;
+
+ ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+ if (ret) {
+ if (ret != -EINVAL)
+ _mesa_warning(NULL, "drm_i915_getparam: %d", ret);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+intel_get_boolean(__DRIscreen *psp, int param)
+{
+ int value = 0;
+ return intel_get_param(psp, param, &value) && value;
+}
+
+static void
+nop_callback(GLuint key, void *data, void *userData)
+{
+}
+
+static void
+intelDestroyScreen(__DRIscreen * sPriv)
+{
+ struct intel_screen *intelScreen = sPriv->driverPrivate;
+
+ dri_bufmgr_destroy(intelScreen->bufmgr);
+ driDestroyOptionInfo(&intelScreen->optionCache);
+
+ /* Some regions may still have references to them at this point, so
+ * flush the hash table to prevent _mesa_DeleteHashTable() from
+ * complaining about the hash not being empty; */
+ _mesa_HashDeleteAll(intelScreen->named_regions, nop_callback, NULL);
+ _mesa_DeleteHashTable(intelScreen->named_regions);
+
+ FREE(intelScreen);
+ sPriv->driverPrivate = NULL;
+}
+
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+static GLboolean
+intelCreateBuffer(__DRIscreen * driScrnPriv,
+ __DRIdrawable * driDrawPriv,
+ const struct gl_config * mesaVis, GLboolean isPixmap)
+{
+ struct intel_renderbuffer *rb;
+ struct intel_screen *screen = (struct intel_screen*) driScrnPriv->driverPrivate;
+ gl_format rgbFormat;
+ unsigned num_samples = intel_quantize_num_samples(screen, mesaVis->samples);
+ struct gl_framebuffer *fb;
+
+ if (isPixmap)
+ return false;
+
+ fb = CALLOC_STRUCT(gl_framebuffer);
+ if (!fb)
+ return false;
+
+ _mesa_initialize_window_framebuffer(fb, mesaVis);
+
+ if (mesaVis->redBits == 5)
+ rgbFormat = MESA_FORMAT_RGB565;
+ else if (mesaVis->alphaBits == 0)
+ rgbFormat = MESA_FORMAT_XRGB8888;
+ else
+ rgbFormat = MESA_FORMAT_ARGB8888;
+
+ /* setup the hardware-based renderbuffers */
+ rb = intel_create_renderbuffer(rgbFormat, num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base.Base);
+
+ if (mesaVis->doubleBufferMode) {
+ rb = intel_create_renderbuffer(rgbFormat, num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base.Base);
+ }
+
+ /*
+ * Assert here that the gl_config has an expected depth/stencil bit
+ * combination: one of d24/s8, d16/s0, d0/s0. (See intelInitScreen2(),
+ * which constructs the advertised configs.)
+ */
+ if (mesaVis->depthBits == 24) {
+ assert(mesaVis->stencilBits == 8);
+
+ if (screen->hw_has_separate_stencil) {
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_X8_Z24,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base.Base);
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_S8,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base.Base);
+ } else {
+ /*
+ * Use combined depth/stencil. Note that the renderbuffer is
+ * attached to two attachment points.
+ */
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_S8_Z24,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base.Base);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base.Base);
+ }
+ }
+ else if (mesaVis->depthBits == 16) {
+ assert(mesaVis->stencilBits == 0);
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_Z16,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base.Base);
+ }
+ else {
+ assert(mesaVis->depthBits == 0);
+ assert(mesaVis->stencilBits == 0);
+ }
+
+ /* now add any/all software-based renderbuffers we may need */
+ _swrast_add_soft_renderbuffers(fb,
+ false, /* never sw color */
+ false, /* never sw depth */
+ false, /* never sw stencil */
+ mesaVis->accumRedBits > 0,
+ false, /* never sw alpha */
+ false /* never sw aux */ );
+ driDrawPriv->driverPrivate = fb;
+
+ return true;
+}
+
+static void
+intelDestroyBuffer(__DRIdrawable * driDrawPriv)
+{
+ struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+
+ _mesa_reference_framebuffer(&fb, NULL);
+}
+
+/* There are probably better ways to do this, such as an
+ * init-designated function to register chipids and createcontext
+ * functions.
+ */
+extern bool
+i830CreateContext(const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ void *sharedContextPrivate);
+
+extern bool
+i915CreateContext(int api,
+ const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ unsigned *error,
+ void *sharedContextPrivate);
+extern bool
+brwCreateContext(int api,
+ const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate);
+
+static GLboolean
+intelCreateContext(gl_api api,
+ const struct gl_config * mesaVis,
+ __DRIcontext * driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate)
+{
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+ struct intel_screen *intelScreen = sPriv->driverPrivate;
+ bool success = false;
+
+#ifdef I915
+ if (IS_9XX(intelScreen->deviceID)) {
+ success = i915CreateContext(api, mesaVis, driContextPriv,
+ major_version, minor_version, error,
+ sharedContextPrivate);
+ } else {
+ switch (api) {
+ case API_OPENGL:
+ if (major_version > 1 || minor_version > 3) {
+ *error = __DRI_CTX_ERROR_BAD_VERSION;
+ success = false;
+ }
+ break;
+ case API_OPENGLES:
+ break;
+ default:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ success = false;
+ }
+
+ if (success) {
+ intelScreen->no_vbo = true;
+ success = i830CreateContext(mesaVis, driContextPriv,
+ sharedContextPrivate);
+ if (!success)
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
+ }
+ }
+#else
+ success = brwCreateContext(api, mesaVis,
+ driContextPriv,
+ major_version, minor_version, flags,
+ error, sharedContextPrivate);
+#endif
+
+ if (success)
+ return true;
+
+ if (driContextPriv->driverPrivate != NULL)
+ intelDestroyContext(driContextPriv);
+
+ return false;
+}
+
+static bool
+intel_init_bufmgr(struct intel_screen *intelScreen)
+{
+ __DRIscreen *spriv = intelScreen->driScrnPriv;
+ int num_fences = 0;
+
+ intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
+
+ intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
+ if (intelScreen->bufmgr == NULL) {
+ fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+ __func__, __LINE__);
+ return false;
+ }
+
+ if (!intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences) ||
+ num_fences == 0) {
+ fprintf(stderr, "[%s: %u] Kernel 2.6.29 required.\n", __func__, __LINE__);
+ return false;
+ }
+
+ drm_intel_bufmgr_gem_enable_fenced_relocs(intelScreen->bufmgr);
+
+ intelScreen->named_regions = _mesa_NewHashTable();
+
+ intelScreen->relaxed_relocations = 0;
+ intelScreen->relaxed_relocations |=
+ intel_get_boolean(spriv, I915_PARAM_HAS_RELAXED_DELTA) << 0;
+
+ return true;
+}
+
+/**
+ * Override intel_screen.hw_has_separate_stencil with environment variable
+ * INTEL_SEPARATE_STENCIL.
+ *
+ * Valid values for INTEL_SEPARATE_STENCIL are "0" and "1". If an invalid
+ * valid value is encountered, a warning is emitted and INTEL_SEPARATE_STENCIL
+ * is ignored.
+ */
+static void
+intel_override_separate_stencil(struct intel_screen *screen)
+{
+ const char *s = getenv("INTEL_SEPARATE_STENCIL");
+ if (!s) {
+ return;
+ } else if (!strncmp("0", s, 2)) {
+ screen->hw_has_separate_stencil = false;
+ } else if (!strncmp("1", s, 2)) {
+ screen->hw_has_separate_stencil = true;
+ } else {
+ fprintf(stderr,
+ "warning: env variable INTEL_SEPARATE_STENCIL=\"%s\" has "
+ "invalid value and is ignored", s);
+ }
+}
+
+static bool
+intel_detect_swizzling(struct intel_screen *screen)
+{
+ drm_intel_bo *buffer;
+ unsigned long flags = 0;
+ unsigned long aligned_pitch;
+ uint32_t tiling = I915_TILING_X;
+ uint32_t swizzle_mode = 0;
+
+ buffer = drm_intel_bo_alloc_tiled(screen->bufmgr, "swizzle test",
+ 64, 64, 4,
+ &tiling, &aligned_pitch, flags);
+ if (buffer == NULL)
+ return false;
+
+ drm_intel_bo_get_tiling(buffer, &tiling, &swizzle_mode);
+ drm_intel_bo_unreference(buffer);
+
+ if (swizzle_mode == I915_BIT_6_SWIZZLE_NONE)
+ return false;
+ else
+ return true;
+}
+
+static __DRIconfig**
+intel_screen_make_configs(__DRIscreen *dri_screen)
+{
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ static const uint8_t singlesample_samples[1] = {0};
+ static const uint8_t multisample_samples[2] = {4, 8};
+
+ struct intel_screen *screen = dri_screen->driverPrivate;
+ GLenum fb_format[3];
+ GLenum fb_type[3];
+ uint8_t depth_bits[4], stencil_bits[4];
+ __DRIconfig **configs = NULL;
+
+ fb_format[0] = GL_RGB;
+ fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
+
+ fb_format[1] = GL_BGR;
+ fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+ fb_format[2] = GL_BGRA;
+ fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+ /* Generate singlesample configs without accumulation buffer. */
+ for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ __DRIconfig **new_configs;
+ const int num_depth_stencil_bits = 2;
+
+ /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil
+ * buffer that has a different number of bits per pixel than the color
+ * buffer. This isn't yet supported here.
+ */
+ depth_bits[0] = 0;
+ stencil_bits[0] = 0;
+
+ if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ depth_bits[1] = 16;
+ stencil_bits[1] = 0;
+ } else {
+ depth_bits[1] = 24;
+ stencil_bits[1] = 8;
+ }
+
+ new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ depth_bits,
+ stencil_bits,
+ num_depth_stencil_bits,
+ back_buffer_modes,
+ ARRAY_SIZE(back_buffer_modes),
+ singlesample_samples, 1,
+ false);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ /* Generate the minimum possible set of configs that include an
+ * accumulation buffer.
+ */
+ for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ __DRIconfig **new_configs;
+
+ if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ depth_bits[0] = 16;
+ stencil_bits[0] = 0;
+ } else {
+ depth_bits[0] = 24;
+ stencil_bits[0] = 8;
+ }
+
+ new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ depth_bits, stencil_bits, 1,
+ back_buffer_modes + 1, 1,
+ singlesample_samples, 1,
+ true);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ /* Generate multisample configs.
+ *
+ * This loop breaks early, and hence is a no-op, on gen < 6.
+ *
+ * Multisample configs must follow the singlesample configs in order to
+ * work around an X server bug present in 1.12. The X server chooses to
+ * associate the first listed RGBA888-Z24S8 config, regardless of its
+ * sample count, with the 32-bit depth visual used for compositing.
+ *
+ * Only doublebuffer configs with GLX_SWAP_UNDEFINED_OML behavior are
+ * supported. Singlebuffer configs are not supported because no one wants
+ * them. GLX_SWAP_COPY_OML is not supported due to page flipping.
+ */
+ for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ if (screen->gen < 6)
+ break;
+
+ __DRIconfig **new_configs;
+ const int num_depth_stencil_bits = 2;
+ int num_msaa_modes = 0;
+
+ depth_bits[0] = 0;
+ stencil_bits[0] = 0;
+
+ if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ depth_bits[1] = 16;
+ stencil_bits[1] = 0;
+ } else {
+ depth_bits[1] = 24;
+ stencil_bits[1] = 8;
+ }
+
+ if (screen->gen >= 7)
+ num_msaa_modes = 2;
+ else if (screen->gen == 6)
+ num_msaa_modes = 1;
+
+ new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ depth_bits,
+ stencil_bits,
+ num_depth_stencil_bits,
+ back_buffer_modes + 1, 1,
+ multisample_samples,
+ num_msaa_modes,
+ false);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ if (configs == NULL) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ __LINE__);
+ return NULL;
+ }
+
+ return configs;
+}
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * Called when using DRI2.
+ *
+ * \return the struct gl_config supported by this driver
+ */
+static const
+__DRIconfig **intelInitScreen2(__DRIscreen *psp)
+{
+ struct intel_screen *intelScreen;
+ unsigned int api_mask;
+
+ if (psp->dri2.loader->base.version <= 2 ||
+ psp->dri2.loader->getBuffersWithFormat == NULL) {
+ fprintf(stderr,
+ "\nERROR! DRI2 loader with getBuffersWithFormat() "
+ "support required\n");
+ return false;
+ }
+
+ /* Allocate the private area */
+ intelScreen = CALLOC(sizeof *intelScreen);
+ if (!intelScreen) {
+ fprintf(stderr, "\nERROR! Allocating private area failed\n");
+ return false;
+ }
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo(&intelScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ intelScreen->driScrnPriv = psp;
+ psp->driverPrivate = (void *) intelScreen;
+
+ if (!intel_init_bufmgr(intelScreen))
+ return false;
+
+ intelScreen->deviceID = drm_intel_bufmgr_gem_get_devid(intelScreen->bufmgr);
+
+ intelScreen->kernel_has_gen7_sol_reset =
+ intel_get_boolean(intelScreen->driScrnPriv,
+ I915_PARAM_HAS_GEN7_SOL_RESET);
+
+ if (IS_GEN7(intelScreen->deviceID)) {
+ intelScreen->gen = 7;
+ } else if (IS_GEN6(intelScreen->deviceID)) {
+ intelScreen->gen = 6;
+ } else if (IS_GEN5(intelScreen->deviceID)) {
+ intelScreen->gen = 5;
+ } else if (IS_965(intelScreen->deviceID)) {
+ intelScreen->gen = 4;
+ } else if (IS_9XX(intelScreen->deviceID)) {
+ intelScreen->gen = 3;
+ } else {
+ intelScreen->gen = 2;
+ }
+
+ intelScreen->hw_has_separate_stencil = intelScreen->gen >= 6;
+ intelScreen->hw_must_use_separate_stencil = intelScreen->gen >= 7;
+
+ int has_llc = 0;
+ bool success = intel_get_param(intelScreen->driScrnPriv, I915_PARAM_HAS_LLC,
+ &has_llc);
+ if (success && has_llc)
+ intelScreen->hw_has_llc = true;
+ else if (!success && intelScreen->gen >= 6)
+ intelScreen->hw_has_llc = true;
+
+ intel_override_separate_stencil(intelScreen);
+
+ api_mask = (1 << __DRI_API_OPENGL);
+#if FEATURE_ES1
+ api_mask |= (1 << __DRI_API_GLES);
+#endif
+#if FEATURE_ES2
+ api_mask |= (1 << __DRI_API_GLES2);
+#endif
+
+ if (IS_9XX(intelScreen->deviceID) || IS_965(intelScreen->deviceID))
+ psp->api_mask = api_mask;
+
+ intelScreen->hw_has_swizzling = intel_detect_swizzling(intelScreen);
+
+ psp->extensions = intelScreenExtensions;
+
+ return (const __DRIconfig**) intel_screen_make_configs(psp);
+}
+
+struct intel_buffer {
+ __DRIbuffer base;
+ struct intel_region *region;
+};
+
+static __DRIbuffer *
+intelAllocateBuffer(__DRIscreen *screen,
+ unsigned attachment, unsigned format,
+ int width, int height)
+{
+ struct intel_buffer *intelBuffer;
+ struct intel_screen *intelScreen = screen->driverPrivate;
+
+ assert(attachment == __DRI_BUFFER_FRONT_LEFT ||
+ attachment == __DRI_BUFFER_BACK_LEFT);
+
+ intelBuffer = CALLOC(sizeof *intelBuffer);
+ if (intelBuffer == NULL)
+ return NULL;
+
+ /* The front and back buffers are color buffers, which are X tiled. */
+ intelBuffer->region = intel_region_alloc(intelScreen,
+ I915_TILING_X,
+ format / 8,
+ width,
+ height,
+ true);
+
+ if (intelBuffer->region == NULL) {
+ FREE(intelBuffer);
+ return NULL;
+ }
+
+ intel_region_flink(intelBuffer->region, &intelBuffer->base.name);
+
+ intelBuffer->base.attachment = attachment;
+ intelBuffer->base.cpp = intelBuffer->region->cpp;
+ intelBuffer->base.pitch =
+ intelBuffer->region->pitch * intelBuffer->region->cpp;
+
+ return &intelBuffer->base;
+}
+
+static void
+intelReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
+{
+ struct intel_buffer *intelBuffer = (struct intel_buffer *) buffer;
+
+ intel_region_release(&intelBuffer->region);
+ free(intelBuffer);
+}
+
+
+const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = intelInitScreen2,
+ .DestroyScreen = intelDestroyScreen,
+ .CreateContext = intelCreateContext,
+ .DestroyContext = intelDestroyContext,
+ .CreateBuffer = intelCreateBuffer,
+ .DestroyBuffer = intelDestroyBuffer,
+ .MakeCurrent = intelMakeCurrent,
+ .UnbindContext = intelUnbindContext,
+ .AllocateBuffer = intelAllocateBuffer,
+ .ReleaseBuffer = intelReleaseBuffer
+};
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+ &driCoreExtension.base,
+ &driDRI2Extension.base,
+ NULL
+};
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_span.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_span.c
index 05e5e8e5833..d7eaa41241e 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_span.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_span.c
@@ -1 +1,215 @@
-../intel/intel_span.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2011 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chad Versace <chad@chad-versace.us>
+ *
+ **************************************************************************/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/colormac.h"
+#include "main/renderbuffer.h"
+
+#include "intel_buffers.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_screen.h"
+#include "intel_span.h"
+#include "intel_regions.h"
+#include "intel_tex.h"
+
+#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
+
+/**
+ * \brief Get pointer offset into stencil buffer.
+ *
+ * The stencil buffer is W tiled. Since the GTT is incapable of W fencing, we
+ * must decode the tile's layout in software.
+ *
+ * See
+ * - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Tile
+ * Format.
+ * - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.3 Tiling Algorithm
+ *
+ * Even though the returned offset is always positive, the return type is
+ * signed due to
+ * commit e8b1c6d6f55f5be3bef25084fdd8b6127517e137
+ * mesa: Fix return type of _mesa_get_format_bytes() (#37351)
+ */
+intptr_t
+intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y, bool swizzled)
+{
+ uint32_t tile_size = 4096;
+ uint32_t tile_width = 64;
+ uint32_t tile_height = 64;
+ uint32_t row_size = 64 * stride;
+
+ uint32_t tile_x = x / tile_width;
+ uint32_t tile_y = y / tile_height;
+
+ /* The byte's address relative to the tile's base addres. */
+ uint32_t byte_x = x % tile_width;
+ uint32_t byte_y = y % tile_height;
+
+ uintptr_t u = tile_y * row_size
+ + tile_x * tile_size
+ + 512 * (byte_x / 8)
+ + 64 * (byte_y / 8)
+ + 32 * ((byte_y / 4) % 2)
+ + 16 * ((byte_x / 4) % 2)
+ + 8 * ((byte_y / 2) % 2)
+ + 4 * ((byte_x / 2) % 2)
+ + 2 * (byte_y % 2)
+ + 1 * (byte_x % 2);
+
+ if (swizzled) {
+ /* adjust for bit6 swizzling */
+ if (((byte_x / 8) % 2) == 1) {
+ if (((byte_y / 8) % 2) == 0) {
+ u += 64;
+ } else {
+ u -= 64;
+ }
+ }
+ }
+
+ return u;
+}
+
+/**
+ * Map the regions needed by intelSpanRenderStart().
+ */
+static void
+intel_span_map_buffers(struct intel_context *intel)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct intel_texture_object *tex_obj;
+
+ for (int i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ continue;
+ tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
+ intel_finalize_mipmap_tree(intel, i);
+ intel_tex_map_images(intel, tex_obj,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+ }
+
+ _swrast_map_renderbuffers(ctx);
+}
+
+/**
+ * Prepare for software rendering. Map current read/draw framebuffers'
+ * renderbuffes and all currently bound texture objects.
+ *
+ * Old note: Moved locking out to get reasonable span performance.
+ */
+void
+intelSpanRenderStart(struct gl_context * ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush(ctx);
+ intel_prepare_render(intel);
+ intel_flush(ctx);
+ intel_span_map_buffers(intel);
+}
+
+/**
+ * Called when done software rendering. Unmap the buffers we mapped in
+ * the above function.
+ */
+void
+intelSpanRenderFinish(struct gl_context * ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ GLuint i;
+
+ _swrast_flush(ctx);
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+ intel_tex_unmap_images(intel, intel_texture_object(texObj));
+ }
+ }
+
+ _swrast_unmap_renderbuffers(ctx);
+}
+
+
+void
+intelInitSpanFuncs(struct gl_context * ctx)
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+ if (swdd) {
+ swdd->SpanRenderStart = intelSpanRenderStart;
+ swdd->SpanRenderFinish = intelSpanRenderFinish;
+ }
+}
+
+void
+intel_map_vertex_shader_textures(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ int i;
+
+ if (ctx->VertexProgram._Current == NULL)
+ return;
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled &&
+ ctx->VertexProgram._Current->Base.TexturesUsed[i] != 0) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+
+ intel_tex_map_images(intel, intel_texture_object(texObj),
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+ }
+ }
+}
+
+void
+intel_unmap_vertex_shader_textures(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ int i;
+
+ if (ctx->VertexProgram._Current == NULL)
+ return;
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled &&
+ ctx->VertexProgram._Current->Base.TexturesUsed[i] != 0) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+
+ intel_tex_unmap_images(intel, intel_texture_object(texObj));
+ }
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_state.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_state.c
index 519672fc359..6a817cdf3f6 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_state.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_state.c
@@ -1 +1,195 @@
-../intel/intel_state.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/enums.h"
+#include "main/colormac.h"
+#include "main/dd.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+
+int
+intel_translate_shadow_compare_func(GLenum func)
+{
+ switch (func) {
+ case GL_NEVER:
+ return COMPAREFUNC_ALWAYS;
+ case GL_LESS:
+ return COMPAREFUNC_LEQUAL;
+ case GL_LEQUAL:
+ return COMPAREFUNC_LESS;
+ case GL_GREATER:
+ return COMPAREFUNC_GEQUAL;
+ case GL_GEQUAL:
+ return COMPAREFUNC_GREATER;
+ case GL_NOTEQUAL:
+ return COMPAREFUNC_EQUAL;
+ case GL_EQUAL:
+ return COMPAREFUNC_NOTEQUAL;
+ case GL_ALWAYS:
+ return COMPAREFUNC_NEVER;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+ return COMPAREFUNC_NEVER;
+}
+
+int
+intel_translate_compare_func(GLenum func)
+{
+ switch (func) {
+ case GL_NEVER:
+ return COMPAREFUNC_NEVER;
+ case GL_LESS:
+ return COMPAREFUNC_LESS;
+ case GL_LEQUAL:
+ return COMPAREFUNC_LEQUAL;
+ case GL_GREATER:
+ return COMPAREFUNC_GREATER;
+ case GL_GEQUAL:
+ return COMPAREFUNC_GEQUAL;
+ case GL_NOTEQUAL:
+ return COMPAREFUNC_NOTEQUAL;
+ case GL_EQUAL:
+ return COMPAREFUNC_EQUAL;
+ case GL_ALWAYS:
+ return COMPAREFUNC_ALWAYS;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+ return COMPAREFUNC_ALWAYS;
+}
+
+int
+intel_translate_stencil_op(GLenum op)
+{
+ switch (op) {
+ case GL_KEEP:
+ return STENCILOP_KEEP;
+ case GL_ZERO:
+ return STENCILOP_ZERO;
+ case GL_REPLACE:
+ return STENCILOP_REPLACE;
+ case GL_INCR:
+ return STENCILOP_INCRSAT;
+ case GL_DECR:
+ return STENCILOP_DECRSAT;
+ case GL_INCR_WRAP:
+ return STENCILOP_INCR;
+ case GL_DECR_WRAP:
+ return STENCILOP_DECR;
+ case GL_INVERT:
+ return STENCILOP_INVERT;
+ default:
+ return STENCILOP_ZERO;
+ }
+}
+
+int
+intel_translate_blend_factor(GLenum factor)
+{
+ switch (factor) {
+ case GL_ZERO:
+ return BLENDFACT_ZERO;
+ case GL_SRC_ALPHA:
+ return BLENDFACT_SRC_ALPHA;
+ case GL_ONE:
+ return BLENDFACT_ONE;
+ case GL_SRC_COLOR:
+ return BLENDFACT_SRC_COLR;
+ case GL_ONE_MINUS_SRC_COLOR:
+ return BLENDFACT_INV_SRC_COLR;
+ case GL_DST_COLOR:
+ return BLENDFACT_DST_COLR;
+ case GL_ONE_MINUS_DST_COLOR:
+ return BLENDFACT_INV_DST_COLR;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ return BLENDFACT_INV_SRC_ALPHA;
+ case GL_DST_ALPHA:
+ return BLENDFACT_DST_ALPHA;
+ case GL_ONE_MINUS_DST_ALPHA:
+ return BLENDFACT_INV_DST_ALPHA;
+ case GL_SRC_ALPHA_SATURATE:
+ return BLENDFACT_SRC_ALPHA_SATURATE;
+ case GL_CONSTANT_COLOR:
+ return BLENDFACT_CONST_COLOR;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ return BLENDFACT_INV_CONST_COLOR;
+ case GL_CONSTANT_ALPHA:
+ return BLENDFACT_CONST_ALPHA;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ return BLENDFACT_INV_CONST_ALPHA;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, factor);
+ return BLENDFACT_ZERO;
+}
+
+int
+intel_translate_logic_op(GLenum opcode)
+{
+ switch (opcode) {
+ case GL_CLEAR:
+ return LOGICOP_CLEAR;
+ case GL_AND:
+ return LOGICOP_AND;
+ case GL_AND_REVERSE:
+ return LOGICOP_AND_RVRSE;
+ case GL_COPY:
+ return LOGICOP_COPY;
+ case GL_COPY_INVERTED:
+ return LOGICOP_COPY_INV;
+ case GL_AND_INVERTED:
+ return LOGICOP_AND_INV;
+ case GL_NOOP:
+ return LOGICOP_NOOP;
+ case GL_XOR:
+ return LOGICOP_XOR;
+ case GL_OR:
+ return LOGICOP_OR;
+ case GL_OR_INVERTED:
+ return LOGICOP_OR_INV;
+ case GL_NOR:
+ return LOGICOP_NOR;
+ case GL_EQUIV:
+ return LOGICOP_EQUIV;
+ case GL_INVERT:
+ return LOGICOP_INV;
+ case GL_OR_REVERSE:
+ return LOGICOP_OR_RVRSE;
+ case GL_NAND:
+ return LOGICOP_NAND;
+ case GL_SET:
+ return LOGICOP_SET;
+ default:
+ return LOGICOP_SET;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_syncobj.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_syncobj.c
index 0b2e56ab246..e965896df60 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_syncobj.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_syncobj.c
@@ -1 +1,132 @@
-../intel/intel_syncobj.c \ No newline at end of file
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file intel_syncobj.c
+ *
+ * Support for ARB_sync
+ *
+ * ARB_sync is implemented by flushing the current batchbuffer and keeping a
+ * reference on it. We can then check for completion or wait for completion
+ * using the normal buffer object mechanisms. This does mean that if an
+ * application is using many sync objects, it will emit small batchbuffers
+ * which may end up being a significant overhead. In other tests of removing
+ * gratuitous batchbuffer syncs in Mesa, it hasn't appeared to be a significant
+ * performance bottleneck, though.
+ */
+
+#include "main/simple_list.h"
+#include "main/imports.h"
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_reg.h"
+
+static struct gl_sync_object *
+intel_new_sync_object(struct gl_context *ctx, GLuint id)
+{
+ struct intel_sync_object *sync;
+
+ sync = calloc(1, sizeof(struct intel_sync_object));
+
+ return &sync->Base;
+}
+
+static void
+intel_delete_sync_object(struct gl_context *ctx, struct gl_sync_object *s)
+{
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ drm_intel_bo_unreference(sync->bo);
+ free(sync);
+}
+
+static void
+intel_fence_sync(struct gl_context *ctx, struct gl_sync_object *s,
+ GLenum condition, GLbitfield flags)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ assert(condition == GL_SYNC_GPU_COMMANDS_COMPLETE);
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ sync->bo = intel->batch.bo;
+ drm_intel_bo_reference(sync->bo);
+
+ intel_flush(ctx);
+}
+
+/* We ignore the user-supplied timeout. This is weaselly -- we're allowed to
+ * round to an implementation-dependent accuracy, and right now our
+ * implementation "rounds" to the wait-forever value.
+ *
+ * The fix would be a new kernel function to do the GTT transition with a
+ * timeout.
+ */
+static void intel_client_wait_sync(struct gl_context *ctx, struct gl_sync_object *s,
+ GLbitfield flags, GLuint64 timeout)
+{
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ if (sync->bo) {
+ drm_intel_bo_wait_rendering(sync->bo);
+ s->StatusFlag = 1;
+ drm_intel_bo_unreference(sync->bo);
+ sync->bo = NULL;
+ }
+}
+
+/* We have nothing to do for WaitSync. Our GL command stream is sequential,
+ * so given that the sync object has already flushed the batchbuffer,
+ * any batchbuffers coming after this waitsync will naturally not occur until
+ * the previous one is done.
+ */
+static void intel_server_wait_sync(struct gl_context *ctx, struct gl_sync_object *s,
+ GLbitfield flags, GLuint64 timeout)
+{
+}
+
+static void intel_check_sync(struct gl_context *ctx, struct gl_sync_object *s)
+{
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ if (sync->bo && !drm_intel_bo_busy(sync->bo)) {
+ drm_intel_bo_unreference(sync->bo);
+ sync->bo = NULL;
+ s->StatusFlag = 1;
+ }
+}
+
+void intel_init_syncobj_functions(struct dd_function_table *functions)
+{
+ functions->NewSyncObject = intel_new_sync_object;
+ functions->DeleteSyncObject = intel_delete_sync_object;
+ functions->FenceSync = intel_fence_sync;
+ functions->CheckSync = intel_check_sync;
+ functions->ClientWaitSync = intel_client_wait_sync;
+ functions->ServerWaitSync = intel_server_wait_sync;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex.c
index d77ce749a3e..5d938798d9f 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex.c
@@ -1 +1,222 @@
-../intel/intel_tex.c \ No newline at end of file
+#include "swrast/swrast.h"
+#include "main/renderbuffer.h"
+#include "main/texobj.h"
+#include "main/teximage.h"
+#include "main/mipmap.h"
+#include "drivers/common/meta.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_tex.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static struct gl_texture_image *
+intelNewTextureImage(struct gl_context * ctx)
+{
+ DBG("%s\n", __FUNCTION__);
+ (void) ctx;
+ return (struct gl_texture_image *) CALLOC_STRUCT(intel_texture_image);
+}
+
+static void
+intelDeleteTextureImage(struct gl_context * ctx, struct gl_texture_image *img)
+{
+ /* nothing special (yet) for intel_texture_image */
+ _mesa_delete_texture_image(ctx, img);
+}
+
+
+static struct gl_texture_object *
+intelNewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
+{
+ struct intel_texture_object *obj = CALLOC_STRUCT(intel_texture_object);
+
+ (void) ctx;
+
+ DBG("%s\n", __FUNCTION__);
+ _mesa_initialize_texture_object(&obj->base, name, target);
+
+ return &obj->base;
+}
+
+static void
+intelDeleteTextureObject(struct gl_context *ctx,
+ struct gl_texture_object *texObj)
+{
+ struct intel_texture_object *intelObj = intel_texture_object(texObj);
+
+ intel_miptree_release(&intelObj->mt);
+ _mesa_delete_texture_object(ctx, texObj);
+}
+
+static GLboolean
+intel_alloc_texture_image_buffer(struct gl_context *ctx,
+ struct gl_texture_image *image)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct gl_texture_object *texobj = image->TexObject;
+ struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
+ GLuint slices;
+
+ assert(image->Border == 0);
+
+ /* Because the driver uses AllocTextureImageBuffer() internally, it may end
+ * up mismatched with FreeTextureImageBuffer(), but that is safe to call
+ * multiple times.
+ */
+ ctx->Driver.FreeTextureImageBuffer(ctx, image);
+
+ /* Allocate the swrast_texture_image::ImageOffsets array now */
+ switch (texobj->Target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ slices = image->Depth;
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ slices = image->Height;
+ break;
+ default:
+ slices = 1;
+ }
+ assert(!intel_image->base.ImageOffsets);
+ intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint));
+
+ _swrast_init_texture_image(image);
+
+ if (intel_texobj->mt &&
+ intel_miptree_match_image(intel_texobj->mt, image)) {
+ intel_miptree_reference(&intel_image->mt, intel_texobj->mt);
+ DBG("%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n",
+ __FUNCTION__, texobj, image->Level,
+ image->Width, image->Height, image->Depth, intel_texobj->mt);
+ } else {
+ intel_image->mt = intel_miptree_create_for_teximage(intel, intel_texobj,
+ intel_image,
+ false);
+
+ /* Even if the object currently has a mipmap tree associated
+ * with it, this one is a more likely candidate to represent the
+ * whole object since our level didn't fit what was there
+ * before, and any lower levels would fit into our miptree.
+ */
+ intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
+
+ DBG("%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n",
+ __FUNCTION__, texobj, image->Level,
+ image->Width, image->Height, image->Depth, intel_image->mt);
+ }
+
+ return true;
+}
+
+/**
+ * Called via ctx->Driver.AllocTextureStorage()
+ * Just have to allocate memory for the texture images.
+ */
+static GLboolean
+intel_alloc_texture_storage(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLsizei levels, GLsizei width,
+ GLsizei height, GLsizei depth)
+{
+ const int numFaces = _mesa_num_tex_faces(texObj->Target);
+ int face;
+ int level;
+
+ for (face = 0; face < numFaces; face++) {
+ for (level = 0; level < levels; level++) {
+ struct gl_texture_image *const texImage = texObj->Image[face][level];
+ if (!intel_alloc_texture_image_buffer(ctx, texImage))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void
+intel_free_texture_image_buffer(struct gl_context * ctx,
+ struct gl_texture_image *texImage)
+{
+ struct intel_texture_image *intelImage = intel_texture_image(texImage);
+
+ DBG("%s\n", __FUNCTION__);
+
+ intel_miptree_release(&intelImage->mt);
+
+ if (intelImage->base.Buffer) {
+ _mesa_align_free(intelImage->base.Buffer);
+ intelImage->base.Buffer = NULL;
+ }
+
+ if (intelImage->base.ImageOffsets) {
+ free(intelImage->base.ImageOffsets);
+ intelImage->base.ImageOffsets = NULL;
+ }
+}
+
+/**
+ * Map texture memory/buffer into user space.
+ * Note: the region of interest parameters are ignored here.
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ * \param mapOut returns start of mapping of region of interest
+ * \param rowStrideOut returns row stride in bytes
+ */
+static void
+intel_map_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *tex_image,
+ GLuint slice,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **map,
+ GLint *stride)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(tex_image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+
+ /* Our texture data is always stored in a miptree. */
+ assert(mt);
+
+ /* Check that our caller wasn't confused about how to map a 1D texture. */
+ assert(tex_image->TexObject->Target != GL_TEXTURE_1D_ARRAY ||
+ h == 1);
+
+ /* intel_miptree_map operates on a unified "slice" number that references the
+ * cube face, since it's all just slices to the miptree code.
+ */
+ if (tex_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
+ slice = tex_image->Face;
+
+ intel_miptree_map(intel, mt, tex_image->Level, slice, x, y, w, h, mode,
+ (void **)map, stride);
+}
+
+static void
+intel_unmap_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *tex_image, GLuint slice)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(tex_image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+
+ if (tex_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
+ slice = tex_image->Face;
+
+ intel_miptree_unmap(intel, mt, tex_image->Level, slice);
+}
+
+void
+intelInitTextureFuncs(struct dd_function_table *functions)
+{
+ functions->NewTextureObject = intelNewTextureObject;
+ functions->NewTextureImage = intelNewTextureImage;
+ functions->DeleteTextureImage = intelDeleteTextureImage;
+ functions->DeleteTexture = intelDeleteTextureObject;
+ functions->AllocTextureImageBuffer = intel_alloc_texture_image_buffer;
+ functions->FreeTextureImageBuffer = intel_free_texture_image_buffer;
+ functions->AllocTextureStorage = intel_alloc_texture_storage;
+ functions->MapTextureImage = intel_map_texture_image;
+ functions->UnmapTextureImage = intel_unmap_texture_image;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_copy.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_copy.c
index 87196c5d1ed..f4366330f88 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_copy.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_copy.c
@@ -1 +1,171 @@
-../intel/intel_tex_copy.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "main/fbobject.h"
+
+#include "drivers/common/meta.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_fbo.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+
+bool
+intel_copy_texsubimage(struct intel_context *intel,
+ struct intel_texture_image *intelImage,
+ GLint dstx, GLint dsty,
+ struct intel_renderbuffer *irb,
+ GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct intel_region *region;
+ const GLenum internalFormat = intelImage->base.Base.InternalFormat;
+ bool copy_supported = false;
+ bool copy_supported_with_alpha_override = false;
+
+ intel_prepare_render(intel);
+
+ if (!intelImage->mt || !irb || !irb->mt) {
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF))
+ fprintf(stderr, "%s fail %p %p (0x%08x)\n",
+ __FUNCTION__, intelImage->mt, irb, internalFormat);
+ return false;
+ } else {
+ region = irb->mt->region;
+ assert(region);
+ }
+
+ copy_supported = intelImage->base.Base.TexFormat == intel_rb_format(irb);
+
+ /* Converting ARGB8888 to XRGB8888 is trivial: ignore the alpha bits */
+ if (intel_rb_format(irb) == MESA_FORMAT_ARGB8888 &&
+ intelImage->base.Base.TexFormat == MESA_FORMAT_XRGB8888) {
+ copy_supported = true;
+ }
+
+ /* Converting XRGB8888 to ARGB8888 requires setting the alpha bits to 1.0 */
+ if (intel_rb_format(irb) == MESA_FORMAT_XRGB8888 &&
+ intelImage->base.Base.TexFormat == MESA_FORMAT_ARGB8888) {
+ copy_supported_with_alpha_override = true;
+ }
+
+ if (!copy_supported && !copy_supported_with_alpha_override) {
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF))
+ fprintf(stderr, "%s mismatched formats %s, %s\n",
+ __FUNCTION__,
+ _mesa_get_format_name(intelImage->base.Base.TexFormat),
+ _mesa_get_format_name(intel_rb_format(irb)));
+ return false;
+ }
+
+ {
+ GLuint image_x, image_y;
+ GLshort src_pitch;
+
+ /* get dest x/y in destination texture */
+ intel_miptree_get_image_offset(intelImage->mt,
+ intelImage->base.Base.Level,
+ intelImage->base.Base.Face,
+ 0,
+ &image_x, &image_y);
+
+ /* The blitter can't handle Y-tiled buffers. */
+ if (intelImage->mt->region->tiling == I915_TILING_Y) {
+ return false;
+ }
+
+ if (_mesa_is_winsys_fbo(ctx->ReadBuffer)) {
+ /* Flip vertical orientation for system framebuffers */
+ y = ctx->ReadBuffer->Height - (y + height);
+ src_pitch = -region->pitch;
+ } else {
+ /* reading from a FBO, y is already oriented the way we like */
+ src_pitch = region->pitch;
+ }
+
+ /* blit from src buffer to texture */
+ if (!intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ src_pitch,
+ region->bo,
+ 0,
+ region->tiling,
+ intelImage->mt->region->pitch,
+ intelImage->mt->region->bo,
+ 0,
+ intelImage->mt->region->tiling,
+ irb->draw_x + x, irb->draw_y + y,
+ image_x + dstx, image_y + dsty,
+ width, height,
+ GL_COPY)) {
+ return false;
+ }
+ }
+
+ if (copy_supported_with_alpha_override)
+ intel_set_teximage_alpha_to_one(ctx, intelImage);
+
+ return true;
+}
+
+
+static void
+intelCopyTexSubImage(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ if (dims == 3 || !intel_copy_texsubimage(intel_context(ctx),
+ intel_texture_image(texImage),
+ xoffset, yoffset,
+ intel_renderbuffer(rb), x, y, width, height)) {
+ fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
+ _mesa_meta_CopyTexSubImage(ctx, dims, texImage,
+ xoffset, yoffset, zoffset,
+ rb, x, y, width, height);
+ }
+}
+
+
+void
+intelInitTextureCopyImageFuncs(struct dd_function_table *functions)
+{
+ functions->CopyTexSubImage = intelCopyTexSubImage;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_format.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_format.c
index 3415f754705..f53054d55d3 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_format.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_format.c
@@ -1 +1,65 @@
-../intel/intel_tex_format.c \ No newline at end of file
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "main/enums.h"
+#include "main/formats.h"
+
+/**
+ * Returns the renderbuffer DataType for a MESA_FORMAT.
+ */
+GLenum
+intel_mesa_format_to_rb_datatype(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ case MESA_FORMAT_SARGB8:
+ case MESA_FORMAT_R8:
+ case MESA_FORMAT_GR88:
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_RGB565:
+ case MESA_FORMAT_ARGB1555:
+ case MESA_FORMAT_ARGB4444:
+ case MESA_FORMAT_S8:
+ return GL_UNSIGNED_BYTE;
+ case MESA_FORMAT_R16:
+ case MESA_FORMAT_RG1616:
+ case MESA_FORMAT_Z16:
+ return GL_UNSIGNED_SHORT;
+ case MESA_FORMAT_X8_Z24:
+ return GL_UNSIGNED_INT;
+ case MESA_FORMAT_S8_Z24:
+ return GL_UNSIGNED_INT_24_8_EXT;
+ case MESA_FORMAT_RGBA_FLOAT32:
+ case MESA_FORMAT_RG_FLOAT32:
+ case MESA_FORMAT_R_FLOAT32:
+ case MESA_FORMAT_INTENSITY_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+ return GL_FLOAT;
+
+ /* The core depthstencil wrappers demand this. */
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+
+ default:
+ /* Unsupported format. We may hit this when people ask for FBO-incomplete
+ * formats.
+ */
+ return GL_NONE;
+ }
+}
+
+int intel_compressed_num_bytes(GLuint mesaFormat)
+{
+ GLuint bw, bh;
+ GLuint block_size;
+
+ block_size = _mesa_get_format_bytes(mesaFormat);
+ _mesa_get_format_block_size(mesaFormat, &bw, &bh);
+
+ return block_size / bw;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_image.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_image.c
index 567abe4974e..fe9040cf1b6 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_image.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_image.c
@@ -1 +1,360 @@
-../intel/intel_tex_image.c \ No newline at end of file
+
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/bufferobj.h"
+#include "main/context.h"
+#include "main/formats.h"
+#include "main/pbo.h"
+#include "main/renderbuffer.h"
+#include "main/texcompress.h"
+#include "main/texgetimage.h"
+#include "main/texobj.h"
+#include "main/teximage.h"
+#include "main/texstore.h"
+
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_buffer_objects.h"
+#include "intel_batchbuffer.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+#include "intel_fbo.h"
+#include "intel_span.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/* Work back from the specified level of the image to the baselevel and create a
+ * miptree of that size.
+ */
+struct intel_mipmap_tree *
+intel_miptree_create_for_teximage(struct intel_context *intel,
+ struct intel_texture_object *intelObj,
+ struct intel_texture_image *intelImage,
+ bool expect_accelerated_upload)
+{
+ GLuint firstLevel;
+ GLuint lastLevel;
+ int width, height, depth;
+ GLuint i;
+
+ intel_miptree_get_dimensions_for_image(&intelImage->base.Base,
+ &width, &height, &depth);
+
+ DBG("%s\n", __FUNCTION__);
+
+ if (intelImage->base.Base.Level > intelObj->base.BaseLevel &&
+ (width == 1 ||
+ (intelObj->base.Target != GL_TEXTURE_1D && height == 1) ||
+ (intelObj->base.Target == GL_TEXTURE_3D && depth == 1))) {
+ /* For this combination, we're at some lower mipmap level and
+ * some important dimension is 1. We can't extrapolate up to a
+ * likely base level width/height/depth for a full mipmap stack
+ * from this info, so just allocate this one level.
+ */
+ firstLevel = intelImage->base.Base.Level;
+ lastLevel = intelImage->base.Base.Level;
+ } else {
+ /* If this image disrespects BaseLevel, allocate from level zero.
+ * Usually BaseLevel == 0, so it's unlikely to happen.
+ */
+ if (intelImage->base.Base.Level < intelObj->base.BaseLevel)
+ firstLevel = 0;
+ else
+ firstLevel = intelObj->base.BaseLevel;
+
+ /* Figure out image dimensions at start level. */
+ for (i = intelImage->base.Base.Level; i > firstLevel; i--) {
+ width <<= 1;
+ if (height != 1)
+ height <<= 1;
+ if (depth != 1)
+ depth <<= 1;
+ }
+
+ /* Guess a reasonable value for lastLevel. This is probably going
+ * to be wrong fairly often and might mean that we have to look at
+ * resizable buffers, or require that buffers implement lazy
+ * pagetable arrangements.
+ */
+ if ((intelObj->base.Sampler.MinFilter == GL_NEAREST ||
+ intelObj->base.Sampler.MinFilter == GL_LINEAR) &&
+ intelImage->base.Base.Level == firstLevel &&
+ (intel->gen < 4 || firstLevel == 0)) {
+ lastLevel = firstLevel;
+ } else if (intelObj->base.Target == GL_TEXTURE_EXTERNAL_OES) {
+ lastLevel = firstLevel;
+ } else {
+ lastLevel = firstLevel + _mesa_logbase2(MAX2(MAX2(width, height), depth));
+ }
+ }
+
+ return intel_miptree_create(intel,
+ intelObj->base.Target,
+ intelImage->base.Base.TexFormat,
+ firstLevel,
+ lastLevel,
+ width,
+ height,
+ depth,
+ expect_accelerated_upload,
+ 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_NONE);
+}
+
+/* There are actually quite a few combinations this will work for,
+ * more than what I've listed here.
+ */
+static bool
+check_pbo_format(GLenum format, GLenum type,
+ gl_format mesa_format)
+{
+ switch (mesa_format) {
+ case MESA_FORMAT_ARGB8888:
+ return (format == GL_BGRA && (type == GL_UNSIGNED_BYTE ||
+ type == GL_UNSIGNED_INT_8_8_8_8_REV));
+ case MESA_FORMAT_RGB565:
+ return (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5);
+ case MESA_FORMAT_L8:
+ return (format == GL_LUMINANCE && type == GL_UNSIGNED_BYTE);
+ case MESA_FORMAT_YCBCR:
+ return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE);
+ default:
+ return false;
+ }
+}
+
+
+/* XXX: Do this for TexSubImage also:
+ */
+static bool
+try_pbo_upload(struct gl_context *ctx,
+ struct gl_texture_image *image,
+ const struct gl_pixelstore_attrib *unpack,
+ GLenum format, GLenum type, const void *pixels)
+{
+ struct intel_texture_image *intelImage = intel_texture_image(image);
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
+ GLuint src_offset, src_stride;
+ GLuint dst_x, dst_y, dst_stride;
+ drm_intel_bo *dst_buffer, *src_buffer;
+
+ if (!_mesa_is_bufferobj(unpack->BufferObj))
+ return false;
+
+ DBG("trying pbo upload\n");
+
+ if (intel->ctx._ImageTransferState ||
+ unpack->SkipPixels || unpack->SkipRows) {
+ DBG("%s: image transfer\n", __FUNCTION__);
+ return false;
+ }
+
+ if (!check_pbo_format(format, type, intelImage->base.Base.TexFormat)) {
+ DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
+ __FUNCTION__, _mesa_get_format_name(intelImage->base.Base.TexFormat),
+ format, type);
+ return false;
+ }
+
+ ctx->Driver.AllocTextureImageBuffer(ctx, image);
+
+ if (!intelImage->mt) {
+ DBG("%s: no miptree\n", __FUNCTION__);
+ return false;
+ }
+
+ dst_buffer = intelImage->mt->region->bo;
+ src_buffer = intel_bufferobj_source(intel, pbo, 64, &src_offset);
+ /* note: potential 64-bit ptr to 32-bit int cast */
+ src_offset += (GLuint) (unsigned long) pixels;
+
+ if (unpack->RowLength > 0)
+ src_stride = unpack->RowLength;
+ else
+ src_stride = image->Width;
+
+ intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level,
+ intelImage->base.Base.Face, 0,
+ &dst_x, &dst_y);
+
+ dst_stride = intelImage->mt->region->pitch;
+
+ if (!intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ src_stride, src_buffer,
+ src_offset, false,
+ dst_stride, dst_buffer, 0,
+ intelImage->mt->region->tiling,
+ 0, 0, dst_x, dst_y, image->Width, image->Height,
+ GL_COPY)) {
+ DBG("%s: blit failed\n", __FUNCTION__);
+ return false;
+ }
+
+ DBG("%s: success\n", __FUNCTION__);
+ return true;
+}
+
+static void
+intelTexImage(struct gl_context * ctx,
+ GLuint dims,
+ struct gl_texture_image *texImage,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *unpack)
+{
+ DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+ texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
+
+ /* Attempt to use the blitter for PBO image uploads.
+ */
+ if (dims <= 2 &&
+ try_pbo_upload(ctx, texImage, unpack, format, type, pixels)) {
+ return;
+ }
+
+ DBG("%s: upload image %dx%dx%d pixels %p\n",
+ __FUNCTION__, texImage->Width, texImage->Height, texImage->Depth,
+ pixels);
+
+ _mesa_store_teximage(ctx, dims, texImage,
+ format, type, pixels, unpack);
+}
+
+
+/**
+ * Binds a region to a texture image, like it was uploaded by glTexImage2D().
+ *
+ * Used for GLX_EXT_texture_from_pixmap and EGL image extensions,
+ */
+static void
+intel_set_texture_image_region(struct gl_context *ctx,
+ struct gl_texture_image *image,
+ struct intel_region *region,
+ GLenum target,
+ GLenum internalFormat,
+ gl_format format,
+ uint32_t offset)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct gl_texture_object *texobj = image->TexObject;
+ struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
+
+ _mesa_init_teximage_fields(&intel->ctx, image,
+ region->width, region->height, 1,
+ 0, internalFormat, format);
+
+ ctx->Driver.FreeTextureImageBuffer(ctx, image);
+
+ intel_image->mt = intel_miptree_create_for_region(intel, target,
+ image->TexFormat,
+ region);
+ if (intel_image->mt == NULL)
+ return;
+
+ intel_image->mt->offset = offset;
+ intel_image->base.RowStride = region->pitch;
+
+ /* Immediately validate the image to the object. */
+ intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
+}
+
+void
+intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
+ GLint texture_format,
+ __DRIdrawable *dPriv)
+{
+ struct gl_framebuffer *fb = dPriv->driverPrivate;
+ struct intel_context *intel = pDRICtx->driverPrivate;
+ struct gl_context *ctx = &intel->ctx;
+ struct intel_texture_object *intelObj;
+ struct intel_renderbuffer *rb;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ int level = 0, internalFormat = 0;
+ gl_format texFormat = MESA_FORMAT_NONE;
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ intelObj = intel_texture_object(texObj);
+
+ if (!intelObj)
+ return;
+
+ if (dPriv->lastStamp != dPriv->dri2.stamp ||
+ !pDRICtx->driScreenPriv->dri2.useInvalidate)
+ intel_update_renderbuffers(pDRICtx, dPriv);
+
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ /* If the region isn't set, then intel_update_renderbuffers was unable
+ * to get the buffers for the drawable.
+ */
+ if (!rb || !rb->mt)
+ return;
+
+ if (rb->mt->cpp == 4) {
+ if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
+ internalFormat = GL_RGB;
+ texFormat = MESA_FORMAT_XRGB8888;
+ }
+ else {
+ internalFormat = GL_RGBA;
+ texFormat = MESA_FORMAT_ARGB8888;
+ }
+ } else if (rb->mt->cpp == 2) {
+ internalFormat = GL_RGB;
+ texFormat = MESA_FORMAT_RGB565;
+ }
+
+ _mesa_lock_texture(&intel->ctx, texObj);
+ texImage = _mesa_get_tex_image(ctx, texObj, target, level);
+ intel_set_texture_image_region(ctx, texImage, rb->mt->region, target,
+ internalFormat, texFormat, 0);
+ _mesa_unlock_texture(&intel->ctx, texObj);
+}
+
+void
+intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
+{
+ /* The old interface didn't have the format argument, so copy our
+ * implementation's behavior at the time.
+ */
+ intelSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
+}
+
+#if FEATURE_OES_EGL_image
+static void
+intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = intel->intelScreen->driScrnPriv;
+ image = screen->dri2.image->lookupEGLImage(screen, image_handle,
+ screen->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ intel_set_texture_image_region(ctx, texImage, image->region,
+ target, image->internal_format,
+ image->format, image->offset);
+}
+#endif
+
+void
+intelInitTextureImageFuncs(struct dd_function_table *functions)
+{
+ functions->TexImage = intelTexImage;
+
+#if FEATURE_OES_EGL_image
+ functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
+#endif
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_layout.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_layout.c
index fe61b441945..65645bc46a4 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_layout.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_layout.c
@@ -1 +1,206 @@
-../intel/intel_tex_layout.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Michel Dänzer <michel@tungstengraphics.com>
+ */
+
+#include "intel_mipmap_tree.h"
+#include "intel_tex_layout.h"
+#include "intel_context.h"
+
+#include "main/image.h"
+#include "main/macros.h"
+
+static unsigned int
+intel_horizontal_texture_alignment_unit(struct intel_context *intel,
+ gl_format format)
+{
+ /**
+ * From the "Alignment Unit Size" section of various specs, namely:
+ * - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4
+ * - i965 and G45 PRMs: Volume 1, Section 6.17.3.4.
+ * - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4
+ * - BSpec (for Ivybridge and slight variations in separate stencil)
+ *
+ * +----------------------------------------------------------------------+
+ * | | alignment unit width ("i") |
+ * | Surface Property |-----------------------------|
+ * | | 915 | 965 | ILK | SNB | IVB |
+ * +----------------------------------------------------------------------+
+ * | YUV 4:2:2 format | 8 | 4 | 4 | 4 | 4 |
+ * | BC1-5 compressed format (DXTn/S3TC) | 4 | 4 | 4 | 4 | 4 |
+ * | FXT1 compressed format | 8 | 8 | 8 | 8 | 8 |
+ * | Depth Buffer (16-bit) | 4 | 4 | 4 | 4 | 8 |
+ * | Depth Buffer (other) | 4 | 4 | 4 | 4 | 4 |
+ * | Separate Stencil Buffer | N/A | N/A | 8 | 8 | 8 |
+ * | All Others | 4 | 4 | 4 | 4 | 4 |
+ * +----------------------------------------------------------------------+
+ *
+ * On IVB+, non-special cases can be overridden by setting the SURFACE_STATE
+ * "Surface Horizontal Alignment" field to HALIGN_4 or HALIGN_8.
+ */
+ if (_mesa_is_format_compressed(format)) {
+ /* The hardware alignment requirements for compressed textures
+ * happen to match the block boundaries.
+ */
+ unsigned int i, j;
+ _mesa_get_format_block_size(format, &i, &j);
+ return i;
+ }
+
+ if (format == MESA_FORMAT_S8)
+ return 8;
+
+ if (intel->gen >= 7 && format == MESA_FORMAT_Z16)
+ return 8;
+
+ return 4;
+}
+
+static unsigned int
+intel_vertical_texture_alignment_unit(struct intel_context *intel,
+ gl_format format)
+{
+ /**
+ * From the "Alignment Unit Size" section of various specs, namely:
+ * - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4
+ * - i965 and G45 PRMs: Volume 1, Section 6.17.3.4.
+ * - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4
+ * - BSpec (for Ivybridge and slight variations in separate stencil)
+ *
+ * +----------------------------------------------------------------------+
+ * | | alignment unit height ("j") |
+ * | Surface Property |-----------------------------|
+ * | | 915 | 965 | ILK | SNB | IVB |
+ * +----------------------------------------------------------------------+
+ * | BC1-5 compressed format (DXTn/S3TC) | 4 | 4 | 4 | 4 | 4 |
+ * | FXT1 compressed format | 4 | 4 | 4 | 4 | 4 |
+ * | Depth Buffer | 2 | 2 | 2 | 4 | 4 |
+ * | Separate Stencil Buffer | N/A | N/A | N/A | 4 | 8 |
+ * | Multisampled (4x or 8x) render target | N/A | N/A | N/A | 4 | 4 |
+ * | All Others | 2 | 2 | 2 | 2 | 2 |
+ * +----------------------------------------------------------------------+
+ *
+ * On SNB+, non-special cases can be overridden by setting the SURFACE_STATE
+ * "Surface Vertical Alignment" field to VALIGN_2 or VALIGN_4.
+ *
+ * We currently don't support multisampling.
+ */
+ if (_mesa_is_format_compressed(format))
+ return 4;
+
+ if (format == MESA_FORMAT_S8)
+ return intel->gen >= 7 ? 8 : 4;
+
+ GLenum base_format = _mesa_get_format_base_format(format);
+
+ if (intel->gen >= 6 &&
+ (base_format == GL_DEPTH_COMPONENT ||
+ base_format == GL_DEPTH_STENCIL)) {
+ return 4;
+ }
+
+ return 2;
+}
+
+void
+intel_get_texture_alignment_unit(struct intel_context *intel,
+ gl_format format,
+ unsigned int *w, unsigned int *h)
+{
+ *w = intel_horizontal_texture_alignment_unit(intel, format);
+ *h = intel_vertical_texture_alignment_unit(intel, format);
+}
+
+void i945_miptree_layout_2d(struct intel_mipmap_tree *mt)
+{
+ GLuint level;
+ GLuint x = 0;
+ GLuint y = 0;
+ GLuint width = mt->width0;
+ GLuint height = mt->height0;
+ GLuint depth = mt->depth0; /* number of array layers. */
+
+ mt->total_width = mt->width0;
+
+ if (mt->compressed) {
+ mt->total_width = ALIGN(mt->width0, mt->align_w);
+ }
+
+ /* May need to adjust width to accomodate the placement of
+ * the 2nd mipmap. This occurs when the alignment
+ * constraints of mipmap placement push the right edge of the
+ * 2nd mipmap out past the width of its parent.
+ */
+ if (mt->first_level != mt->last_level) {
+ GLuint mip1_width;
+
+ if (mt->compressed) {
+ mip1_width = ALIGN(minify(mt->width0), mt->align_w)
+ + ALIGN(minify(minify(mt->width0)), mt->align_w);
+ } else {
+ mip1_width = ALIGN(minify(mt->width0), mt->align_w)
+ + minify(minify(mt->width0));
+ }
+
+ if (mip1_width > mt->total_width) {
+ mt->total_width = mip1_width;
+ }
+ }
+
+ mt->total_height = 0;
+
+ for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
+ GLuint img_height;
+
+ intel_miptree_set_level_info(mt, level, x, y, width,
+ height, depth);
+
+ img_height = ALIGN(height, mt->align_h);
+ if (mt->compressed)
+ img_height /= mt->align_h;
+
+ /* Because the images are packed better, the final offset
+ * might not be the maximal one:
+ */
+ mt->total_height = MAX2(mt->total_height, y + img_height);
+
+ /* Layout_below: step right after second mipmap.
+ */
+ if (level == mt->first_level + 1) {
+ x += ALIGN(width, mt->align_w);
+ }
+ else {
+ y += img_height;
+ }
+
+ width = minify(width);
+ height = minify(height);
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_subimage.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_subimage.c
index b3a8a3d7ca7..ae4b3bca305 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_subimage.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_subimage.c
@@ -1 +1,177 @@
-../intel/intel_tex_subimage.c \ No newline at end of file
+
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mtypes.h"
+#include "main/pbo.h"
+#include "main/texobj.h"
+#include "main/texstore.h"
+#include "main/texcompress.h"
+#include "main/enums.h"
+
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "intel_mipmap_tree.h"
+#include "intel_blit.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static bool
+intel_blit_texsubimage(struct gl_context * ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intelImage = intel_texture_image(texImage);
+ GLuint dstRowStride = 0;
+ drm_intel_bo *temp_bo = NULL;
+ unsigned int blit_x = 0, blit_y = 0;
+ unsigned long pitch;
+ uint32_t tiling_mode = I915_TILING_NONE;
+ GLubyte *dstMap;
+
+ /* Try to do a blit upload of the subimage if the texture is
+ * currently busy.
+ */
+ if (!intelImage->mt)
+ return false;
+
+ /* The blitter can't handle Y tiling */
+ if (intelImage->mt->region->tiling == I915_TILING_Y)
+ return false;
+
+ if (texImage->TexObject->Target != GL_TEXTURE_2D)
+ return false;
+
+ /* On gen6, it's probably not worth swapping to the blit ring to do
+ * this because of all the overhead involved.
+ */
+ if (intel->gen >= 6)
+ return false;
+
+ if (!drm_intel_bo_busy(intelImage->mt->region->bo))
+ return false;
+
+ DBG("BLT subimage %s target %s level %d offset %d,%d %dx%d\n",
+ __FUNCTION__,
+ _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+ texImage->Level, xoffset, yoffset, width, height);
+
+ pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1,
+ format, type, pixels, packing,
+ "glTexSubImage");
+ if (!pixels)
+ return false;
+
+ temp_bo = drm_intel_bo_alloc_tiled(intel->bufmgr,
+ "subimage blit bo",
+ width, height,
+ intelImage->mt->cpp,
+ &tiling_mode,
+ &pitch,
+ 0);
+ if (temp_bo == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+ return false;
+ }
+
+ if (drm_intel_gem_bo_map_gtt(temp_bo)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+ return false;
+ }
+
+ dstMap = temp_bo->virtual;
+ dstRowStride = pitch;
+
+ intel_miptree_get_image_offset(intelImage->mt, texImage->Level,
+ intelImage->base.Base.Face, 0,
+ &blit_x, &blit_y);
+ blit_x += xoffset;
+ blit_y += yoffset;
+
+ if (!_mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ dstRowStride,
+ &dstMap,
+ width, height, 1,
+ format, type, pixels, packing)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+ }
+
+ bool ret;
+ unsigned int dst_pitch = intelImage->mt->region->pitch *
+ intelImage->mt->cpp;
+
+ drm_intel_gem_bo_unmap_gtt(temp_bo);
+
+ ret = intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ dstRowStride / intelImage->mt->cpp,
+ temp_bo, 0, false,
+ dst_pitch / intelImage->mt->cpp,
+ intelImage->mt->region->bo, 0,
+ intelImage->mt->region->tiling,
+ 0, 0, blit_x, blit_y, width, height,
+ GL_COPY);
+ assert(ret);
+
+ drm_intel_bo_unreference(temp_bo);
+ _mesa_unmap_teximage_pbo(ctx, packing);
+
+ return true;
+}
+
+static void
+intelTexSubImage(struct gl_context * ctx,
+ GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing)
+{
+ /* The intel_blit_texsubimage() function only handles 2D images */
+ if (dims != 2 || !intel_blit_texsubimage(ctx, texImage,
+ xoffset, yoffset,
+ width, height,
+ format, type, pixels, packing)) {
+ _mesa_store_texsubimage(ctx, dims, texImage,
+ xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels, packing);
+ }
+}
+
+void
+intelInitTextureSubImageFuncs(struct dd_function_table *functions)
+{
+ functions->TexSubImage = intelTexSubImage;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_validate.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_validate.c
index 41a75674c27..578b4173512 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_validate.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i915/intel_tex_validate.c
@@ -1 +1,218 @@
-../intel/intel_tex_validate.c \ No newline at end of file
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/samplerobj.h"
+#include "main/texobj.h"
+
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_blit.h"
+#include "intel_tex.h"
+#include "intel_tex_layout.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/**
+ * When validating, we only care about the texture images that could
+ * be seen, so for non-mipmapped modes we want to ignore everything
+ * but BaseLevel.
+ */
+static void
+intel_update_max_level(struct intel_texture_object *intelObj,
+ struct gl_sampler_object *sampler)
+{
+ struct gl_texture_object *tObj = &intelObj->base;
+
+ if (sampler->MinFilter == GL_NEAREST ||
+ sampler->MinFilter == GL_LINEAR) {
+ intelObj->_MaxLevel = tObj->BaseLevel;
+ } else {
+ intelObj->_MaxLevel = tObj->_MaxLevel;
+ }
+}
+
+/*
+ */
+GLuint
+intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
+ struct intel_texture_object *intelObj = intel_texture_object(tObj);
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
+ GLuint face, i;
+ GLuint nr_faces = 0;
+ struct intel_texture_image *firstImage;
+ int width, height, depth;
+
+ /* TBOs require no validation -- they always just point to their BO. */
+ if (tObj->Target == GL_TEXTURE_BUFFER)
+ return true;
+
+ /* We know/require this is true by now:
+ */
+ assert(intelObj->base._BaseComplete);
+
+ /* What levels must the tree include at a minimum?
+ */
+ intel_update_max_level(intelObj, sampler);
+ firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]);
+
+ /* Check tree can hold all active levels. Check tree matches
+ * target, imageFormat, etc.
+ *
+ * For pre-gen4, we have to match first_level == tObj->BaseLevel,
+ * because we don't have the control that gen4 does to make min/mag
+ * determination happen at a nonzero (hardware) baselevel. Because
+ * of that, we just always relayout on baselevel change.
+ */
+ if (intelObj->mt &&
+ (!intel_miptree_match_image(intelObj->mt, &firstImage->base.Base) ||
+ intelObj->mt->first_level != tObj->BaseLevel ||
+ intelObj->mt->last_level < intelObj->_MaxLevel)) {
+ intel_miptree_release(&intelObj->mt);
+ }
+
+
+ /* May need to create a new tree:
+ */
+ if (!intelObj->mt) {
+ intel_miptree_get_dimensions_for_image(&firstImage->base.Base,
+ &width, &height, &depth);
+
+ intelObj->mt = intel_miptree_create(intel,
+ intelObj->base.Target,
+ firstImage->base.Base.TexFormat,
+ tObj->BaseLevel,
+ intelObj->_MaxLevel,
+ width,
+ height,
+ depth,
+ true,
+ 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_NONE);
+ if (!intelObj->mt)
+ return false;
+ }
+
+ /* Pull in any images not in the object's tree:
+ */
+ nr_faces = _mesa_num_tex_faces(intelObj->base.Target);
+ for (face = 0; face < nr_faces; face++) {
+ for (i = tObj->BaseLevel; i <= intelObj->_MaxLevel; i++) {
+ struct intel_texture_image *intelImage =
+ intel_texture_image(intelObj->base.Image[face][i]);
+ /* skip too small size mipmap */
+ if (intelImage == NULL)
+ break;
+
+ if (intelObj->mt != intelImage->mt) {
+ intel_miptree_copy_teximage(intel, intelImage, intelObj->mt);
+ }
+ }
+ }
+
+ return true;
+}
+
+/**
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ */
+static void
+intel_tex_map_image_for_swrast(struct intel_context *intel,
+ struct intel_texture_image *intel_image,
+ GLbitfield mode)
+{
+ int level;
+ int face;
+ struct intel_mipmap_tree *mt;
+ unsigned int x, y;
+
+ if (!intel_image || !intel_image->mt)
+ return;
+
+ level = intel_image->base.Base.Level;
+ face = intel_image->base.Base.Face;
+ mt = intel_image->mt;
+
+ for (int i = 0; i < mt->level[level].depth; i++)
+ intel_miptree_slice_resolve_depth(intel, mt, level, i);
+
+ if (mt->target == GL_TEXTURE_3D ||
+ mt->target == GL_TEXTURE_2D_ARRAY ||
+ mt->target == GL_TEXTURE_1D_ARRAY) {
+ int i;
+
+ /* ImageOffsets[] is only used for swrast's fetch_texel_3d, so we can't
+ * share code with the normal path.
+ */
+ for (i = 0; i < mt->level[level].depth; i++) {
+ intel_miptree_get_image_offset(mt, level, face, i, &x, &y);
+ intel_image->base.ImageOffsets[i] = x + y * mt->region->pitch;
+ }
+
+ DBG("%s \n", __FUNCTION__);
+
+ intel_image->base.Map = intel_region_map(intel, mt->region, mode);
+ } else {
+ assert(intel_image->base.Base.Depth == 1);
+ intel_miptree_get_image_offset(mt, level, face, 0, &x, &y);
+
+ DBG("%s: (%d,%d) -> (%d, %d)/%d\n",
+ __FUNCTION__, face, level, x, y, mt->region->pitch * mt->cpp);
+
+ intel_image->base.Map = intel_region_map(intel, mt->region, mode) +
+ (x + y * mt->region->pitch) * mt->cpp;
+ }
+
+ intel_image->base.RowStride = mt->region->pitch;
+}
+
+static void
+intel_tex_unmap_image_for_swrast(struct intel_context *intel,
+ struct intel_texture_image *intel_image)
+{
+ if (intel_image && intel_image->mt) {
+ intel_region_unmap(intel, intel_image->mt->region);
+ intel_image->base.Map = NULL;
+ }
+}
+
+/**
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ */
+void
+intel_tex_map_images(struct intel_context *intel,
+ struct intel_texture_object *intelObj,
+ GLbitfield mode)
+{
+ GLuint nr_faces = _mesa_num_tex_faces(intelObj->base.Target);
+ int i, face;
+
+ DBG("%s\n", __FUNCTION__);
+
+ for (i = intelObj->base.BaseLevel; i <= intelObj->_MaxLevel; i++) {
+ for (face = 0; face < nr_faces; face++) {
+ struct intel_texture_image *intel_image =
+ intel_texture_image(intelObj->base.Image[face][i]);
+
+ intel_tex_map_image_for_swrast(intel, intel_image, mode);
+ }
+ }
+}
+
+void
+intel_tex_unmap_images(struct intel_context *intel,
+ struct intel_texture_object *intelObj)
+{
+ GLuint nr_faces = _mesa_num_tex_faces(intelObj->base.Target);
+ int i, face;
+
+ for (i = intelObj->base.BaseLevel; i <= intelObj->_MaxLevel; i++) {
+ for (face = 0; face < nr_faces; face++) {
+ struct intel_texture_image *intel_image =
+ intel_texture_image(intelObj->base.Image[face][i]);
+
+ intel_tex_unmap_image_for_swrast(intel, intel_image);
+ }
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index d38cdf31cc6..06cbaecc74d 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -1 +1,543 @@
-../intel/intel_batchbuffer.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_buffer_objects.h"
+#include "intel_reg.h"
+#include "intel_bufmgr.h"
+#include "intel_buffers.h"
+
+struct cached_batch_item {
+ struct cached_batch_item *next;
+ uint16_t header;
+ uint16_t size;
+};
+
+static void clear_cache( struct intel_context *intel )
+{
+ struct cached_batch_item *item = intel->batch.cached_items;
+
+ while (item) {
+ struct cached_batch_item *next = item->next;
+ free(item);
+ item = next;
+ }
+
+ intel->batch.cached_items = NULL;
+}
+
+void
+intel_batchbuffer_init(struct intel_context *intel)
+{
+ intel_batchbuffer_reset(intel);
+
+ if (intel->gen >= 6) {
+ /* We can't just use brw_state_batch to get a chunk of space for
+ * the gen6 workaround because it involves actually writing to
+ * the buffer, and the kernel doesn't let us write to the batch.
+ */
+ intel->batch.workaround_bo = drm_intel_bo_alloc(intel->bufmgr,
+ "pipe_control workaround",
+ 4096, 4096);
+ }
+}
+
+void
+intel_batchbuffer_reset(struct intel_context *intel)
+{
+ if (intel->batch.last_bo != NULL) {
+ drm_intel_bo_unreference(intel->batch.last_bo);
+ intel->batch.last_bo = NULL;
+ }
+ intel->batch.last_bo = intel->batch.bo;
+
+ clear_cache(intel);
+
+ intel->batch.bo = drm_intel_bo_alloc(intel->bufmgr, "batchbuffer",
+ intel->maxBatchSize, 4096);
+
+ intel->batch.reserved_space = BATCH_RESERVED;
+ intel->batch.state_batch_offset = intel->batch.bo->size;
+ intel->batch.used = 0;
+ intel->batch.needs_sol_reset = false;
+}
+
+void
+intel_batchbuffer_save_state(struct intel_context *intel)
+{
+ intel->batch.saved.used = intel->batch.used;
+ intel->batch.saved.reloc_count =
+ drm_intel_gem_bo_get_reloc_count(intel->batch.bo);
+}
+
+void
+intel_batchbuffer_reset_to_saved(struct intel_context *intel)
+{
+ drm_intel_gem_bo_clear_relocs(intel->batch.bo, intel->batch.saved.reloc_count);
+
+ intel->batch.used = intel->batch.saved.used;
+
+ /* Cached batch state is dead, since we just cleared some unknown part of the
+ * batchbuffer. Assume that the caller resets any other state necessary.
+ */
+ clear_cache(intel);
+}
+
+void
+intel_batchbuffer_free(struct intel_context *intel)
+{
+ drm_intel_bo_unreference(intel->batch.last_bo);
+ drm_intel_bo_unreference(intel->batch.bo);
+ drm_intel_bo_unreference(intel->batch.workaround_bo);
+ clear_cache(intel);
+}
+
+static void
+do_batch_dump(struct intel_context *intel)
+{
+ struct drm_intel_decode *decode;
+ struct intel_batchbuffer *batch = &intel->batch;
+ int ret;
+
+ decode = drm_intel_decode_context_alloc(intel->intelScreen->deviceID);
+ if (!decode)
+ return;
+
+ ret = drm_intel_bo_map(batch->bo, false);
+ if (ret == 0) {
+ drm_intel_decode_set_batch_pointer(decode,
+ batch->bo->virtual,
+ batch->bo->offset,
+ batch->used);
+ } else {
+ fprintf(stderr,
+ "WARNING: failed to map batchbuffer (%s), "
+ "dumping uploaded data instead.\n", strerror(ret));
+
+ drm_intel_decode_set_batch_pointer(decode,
+ batch->map,
+ batch->bo->offset,
+ batch->used);
+ }
+
+ drm_intel_decode(decode);
+
+ drm_intel_decode_context_free(decode);
+
+ if (ret == 0) {
+ drm_intel_bo_unmap(batch->bo);
+
+ if (intel->vtbl.debug_batch != NULL)
+ intel->vtbl.debug_batch(intel);
+ }
+}
+
+/* TODO: Push this whole function into bufmgr.
+ */
+static int
+do_flush_locked(struct intel_context *intel)
+{
+ struct intel_batchbuffer *batch = &intel->batch;
+ int ret = 0;
+
+ ret = drm_intel_bo_subdata(batch->bo, 0, 4*batch->used, batch->map);
+ if (ret == 0 && batch->state_batch_offset != batch->bo->size) {
+ ret = drm_intel_bo_subdata(batch->bo,
+ batch->state_batch_offset,
+ batch->bo->size - batch->state_batch_offset,
+ (char *)batch->map + batch->state_batch_offset);
+ }
+
+ if (!intel->intelScreen->no_hw) {
+ int flags;
+
+ if (intel->gen < 6 || !batch->is_blit) {
+ flags = I915_EXEC_RENDER;
+ } else {
+ flags = I915_EXEC_BLT;
+ }
+
+ if (batch->needs_sol_reset)
+ flags |= I915_EXEC_GEN7_SOL_RESET;
+
+ if (ret == 0) {
+ if (unlikely(INTEL_DEBUG & DEBUG_AUB) && intel->vtbl.annotate_aub)
+ intel->vtbl.annotate_aub(intel);
+ if (intel->hw_ctx == NULL || batch->is_blit) {
+ ret = drm_intel_bo_mrb_exec(batch->bo, 4 * batch->used, NULL, 0, 0,
+ flags);
+ } else {
+ ret = drm_intel_gem_bo_context_exec(batch->bo, intel->hw_ctx,
+ 4 * batch->used, flags);
+ }
+ }
+ }
+
+ if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+ do_batch_dump(intel);
+
+ if (ret != 0) {
+ fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret));
+ exit(1);
+ }
+ intel->vtbl.new_batch(intel);
+
+ return ret;
+}
+
+int
+_intel_batchbuffer_flush(struct intel_context *intel,
+ const char *file, int line)
+{
+ int ret;
+
+ if (intel->batch.used == 0)
+ return 0;
+
+ if (intel->first_post_swapbuffers_batch == NULL) {
+ intel->first_post_swapbuffers_batch = intel->batch.bo;
+ drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
+ }
+
+ if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+ fprintf(stderr, "%s:%d: Batchbuffer flush with %db used\n", file, line,
+ 4*intel->batch.used);
+
+ intel->batch.reserved_space = 0;
+
+ if (intel->vtbl.finish_batch)
+ intel->vtbl.finish_batch(intel);
+
+ /* Mark the end of the buffer. */
+ intel_batchbuffer_emit_dword(intel, MI_BATCH_BUFFER_END);
+ if (intel->batch.used & 1) {
+ /* Round batchbuffer usage to 2 DWORDs. */
+ intel_batchbuffer_emit_dword(intel, MI_NOOP);
+ }
+
+ intel_upload_finish(intel);
+
+ /* Check that we didn't just wrap our batchbuffer at a bad time. */
+ assert(!intel->no_batch_wrap);
+
+ ret = do_flush_locked(intel);
+
+ if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
+ fprintf(stderr, "waiting for idle\n");
+ drm_intel_bo_wait_rendering(intel->batch.bo);
+ }
+
+ /* Reset the buffer:
+ */
+ intel_batchbuffer_reset(intel);
+
+ return ret;
+}
+
+
+/* This is the only way buffers get added to the validate list.
+ */
+bool
+intel_batchbuffer_emit_reloc(struct intel_context *intel,
+ drm_intel_bo *buffer,
+ uint32_t read_domains, uint32_t write_domain,
+ uint32_t delta)
+{
+ int ret;
+
+ ret = drm_intel_bo_emit_reloc(intel->batch.bo, 4*intel->batch.used,
+ buffer, delta,
+ read_domains, write_domain);
+ assert(ret == 0);
+ (void)ret;
+
+ /*
+ * Using the old buffer offset, write in what the right data would be, in case
+ * the buffer doesn't move and we can short-circuit the relocation processing
+ * in the kernel
+ */
+ intel_batchbuffer_emit_dword(intel, buffer->offset + delta);
+
+ return true;
+}
+
+bool
+intel_batchbuffer_emit_reloc_fenced(struct intel_context *intel,
+ drm_intel_bo *buffer,
+ uint32_t read_domains,
+ uint32_t write_domain,
+ uint32_t delta)
+{
+ int ret;
+
+ ret = drm_intel_bo_emit_reloc_fence(intel->batch.bo, 4*intel->batch.used,
+ buffer, delta,
+ read_domains, write_domain);
+ assert(ret == 0);
+ (void)ret;
+
+ /*
+ * Using the old buffer offset, write in what the right data would
+ * be, in case the buffer doesn't move and we can short-circuit the
+ * relocation processing in the kernel
+ */
+ intel_batchbuffer_emit_dword(intel, buffer->offset + delta);
+
+ return true;
+}
+
+void
+intel_batchbuffer_data(struct intel_context *intel,
+ const void *data, GLuint bytes, bool is_blit)
+{
+ assert((bytes & 3) == 0);
+ intel_batchbuffer_require_space(intel, bytes, is_blit);
+ __memcpy(intel->batch.map + intel->batch.used, data, bytes);
+ intel->batch.used += bytes >> 2;
+}
+
+void
+intel_batchbuffer_cached_advance(struct intel_context *intel)
+{
+ struct cached_batch_item **prev = &intel->batch.cached_items, *item;
+ uint32_t sz = (intel->batch.used - intel->batch.emit) * sizeof(uint32_t);
+ uint32_t *start = intel->batch.map + intel->batch.emit;
+ uint16_t op = *start >> 16;
+
+ while (*prev) {
+ uint32_t *old;
+
+ item = *prev;
+ old = intel->batch.map + item->header;
+ if (op == *old >> 16) {
+ if (item->size == sz && memcmp(old, start, sz) == 0) {
+ if (prev != &intel->batch.cached_items) {
+ *prev = item->next;
+ item->next = intel->batch.cached_items;
+ intel->batch.cached_items = item;
+ }
+ intel->batch.used = intel->batch.emit;
+ return;
+ }
+
+ goto emit;
+ }
+ prev = &item->next;
+ }
+
+ item = malloc(sizeof(struct cached_batch_item));
+ if (item == NULL)
+ return;
+
+ item->next = intel->batch.cached_items;
+ intel->batch.cached_items = item;
+
+emit:
+ item->size = sz;
+ item->header = intel->batch.emit;
+}
+
+/**
+ * Restriction [DevSNB, DevIVB]:
+ *
+ * Prior to changing Depth/Stencil Buffer state (i.e. any combination of
+ * 3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS, 3DSTATE_STENCIL_BUFFER,
+ * 3DSTATE_HIER_DEPTH_BUFFER) SW must first issue a pipelined depth stall
+ * (PIPE_CONTROL with Depth Stall bit set), followed by a pipelined depth
+ * cache flush (PIPE_CONTROL with Depth Flush Bit set), followed by
+ * another pipelined depth stall (PIPE_CONTROL with Depth Stall bit set),
+ * unless SW can otherwise guarantee that the pipeline from WM onwards is
+ * already flushed (e.g., via a preceding MI_FLUSH).
+ */
+void
+intel_emit_depth_stall_flushes(struct intel_context *intel)
+{
+ assert(intel->gen >= 6 && intel->gen <= 7);
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH()
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_CACHE_FLUSH);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+}
+
+/**
+ * From the BSpec, volume 2a.03: VS Stage Input / State:
+ * "[DevIVB] A PIPE_CONTROL with Post-Sync Operation set to 1h and a depth
+ * stall needs to be sent just prior to any 3DSTATE_VS, 3DSTATE_URB_VS,
+ * 3DSTATE_CONSTANT_VS, 3DSTATE_BINDING_TABLE_POINTER_VS,
+ * 3DSTATE_SAMPLER_STATE_POINTER_VS command. Only one PIPE_CONTROL needs
+ * to be sent before any combination of VS associated 3DSTATE."
+ */
+void
+gen7_emit_vs_workaround_flush(struct intel_context *intel)
+{
+ assert(intel->gen == 7);
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_DEPTH_STALL | PIPE_CONTROL_WRITE_IMMEDIATE);
+ OUT_RELOC(intel->batch.workaround_bo,
+ I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0);
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+}
+
+/**
+ * Emits a PIPE_CONTROL with a non-zero post-sync operation, for
+ * implementing two workarounds on gen6. From section 1.4.7.1
+ * "PIPE_CONTROL" of the Sandy Bridge PRM volume 2 part 1:
+ *
+ * [DevSNB-C+{W/A}] Before any depth stall flush (including those
+ * produced by non-pipelined state commands), software needs to first
+ * send a PIPE_CONTROL with no bits set except Post-Sync Operation !=
+ * 0.
+ *
+ * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache Flush Enable
+ * =1, a PIPE_CONTROL with any non-zero post-sync-op is required.
+ *
+ * And the workaround for these two requires this workaround first:
+ *
+ * [Dev-SNB{W/A}]: Pipe-control with CS-stall bit set must be sent
+ * BEFORE the pipe-control with a post-sync op and no write-cache
+ * flushes.
+ *
+ * And this last workaround is tricky because of the requirements on
+ * that bit. From section 1.4.7.2.3 "Stall" of the Sandy Bridge PRM
+ * volume 2 part 1:
+ *
+ * "1 of the following must also be set:
+ * - Render Target Cache Flush Enable ([12] of DW1)
+ * - Depth Cache Flush Enable ([0] of DW1)
+ * - Stall at Pixel Scoreboard ([1] of DW1)
+ * - Depth Stall ([13] of DW1)
+ * - Post-Sync Operation ([13] of DW1)
+ * - Notify Enable ([8] of DW1)"
+ *
+ * The cache flushes require the workaround flush that triggered this
+ * one, so we can't use it. Depth stall would trigger the same.
+ * Post-sync nonzero is what triggered this second workaround, so we
+ * can't use that one either. Notify enable is IRQs, which aren't
+ * really our business. That leaves only stall at scoreboard.
+ */
+void
+intel_emit_post_sync_nonzero_flush(struct intel_context *intel)
+{
+ if (!intel->batch.need_workaround_flush)
+ return;
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_CS_STALL |
+ PIPE_CONTROL_STALL_AT_SCOREBOARD);
+ OUT_BATCH(0); /* address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_WRITE_IMMEDIATE);
+ OUT_RELOC(intel->batch.workaround_bo,
+ I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0);
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+
+ intel->batch.need_workaround_flush = false;
+}
+
+/* Emit a pipelined flush to either flush render and texture cache for
+ * reading from a FBO-drawn texture, or flush so that frontbuffer
+ * render appears on the screen in DRI1.
+ *
+ * This is also used for the always_flush_cache driconf debug option.
+ */
+void
+intel_batchbuffer_emit_mi_flush(struct intel_context *intel)
+{
+ if (intel->gen >= 6) {
+ if (intel->batch.is_blit) {
+ BEGIN_BATCH_BLT(4);
+ OUT_BATCH(MI_FLUSH_DW);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+ ADVANCE_BATCH();
+ } else {
+ if (intel->gen == 6) {
+ /* Hardware workaround: SNB B-Spec says:
+ *
+ * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache
+ * Flush Enable =1, a PIPE_CONTROL with any non-zero
+ * post-sync-op is required.
+ */
+ intel_emit_post_sync_nonzero_flush(intel);
+ }
+
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
+ OUT_BATCH(PIPE_CONTROL_INSTRUCTION_FLUSH |
+ PIPE_CONTROL_WRITE_FLUSH |
+ PIPE_CONTROL_DEPTH_CACHE_FLUSH |
+ PIPE_CONTROL_VF_CACHE_INVALIDATE |
+ PIPE_CONTROL_TC_FLUSH |
+ PIPE_CONTROL_NO_WRITE |
+ PIPE_CONTROL_CS_STALL);
+ OUT_BATCH(0); /* write address */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+ }
+ } else if (intel->gen >= 4) {
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2) |
+ PIPE_CONTROL_WRITE_FLUSH |
+ PIPE_CONTROL_NO_WRITE);
+ OUT_BATCH(0); /* write address */
+ OUT_BATCH(0); /* write data */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+ } else {
+ BEGIN_BATCH(1);
+ OUT_BATCH(MI_FLUSH);
+ ADVANCE_BATCH();
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_blit.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_blit.c
index dd6c8d17c28..36a2c6aadac 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_blit.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_blit.c
@@ -1 +1,604 @@
-../intel/intel_blit.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/mtypes.h"
+#include "main/context.h"
+#include "main/enums.h"
+#include "main/colormac.h"
+#include "main/fbobject.h"
+
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_reg.h"
+#include "intel_regions.h"
+#include "intel_batchbuffer.h"
+#include "intel_mipmap_tree.h"
+
+#define FILE_DEBUG_FLAG DEBUG_BLIT
+
+static GLuint translate_raster_op(GLenum logicop)
+{
+ switch(logicop) {
+ case GL_CLEAR: return 0x00;
+ case GL_AND: return 0x88;
+ case GL_AND_REVERSE: return 0x44;
+ case GL_COPY: return 0xCC;
+ case GL_AND_INVERTED: return 0x22;
+ case GL_NOOP: return 0xAA;
+ case GL_XOR: return 0x66;
+ case GL_OR: return 0xEE;
+ case GL_NOR: return 0x11;
+ case GL_EQUIV: return 0x99;
+ case GL_INVERT: return 0x55;
+ case GL_OR_REVERSE: return 0xDD;
+ case GL_COPY_INVERTED: return 0x33;
+ case GL_OR_INVERTED: return 0xBB;
+ case GL_NAND: return 0x77;
+ case GL_SET: return 0xFF;
+ default: return 0;
+ }
+}
+
+static uint32_t
+br13_for_cpp(int cpp)
+{
+ switch (cpp) {
+ case 4:
+ return BR13_8888;
+ break;
+ case 2:
+ return BR13_565;
+ break;
+ case 1:
+ return BR13_8;
+ break;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+/* Copy BitBlt
+ */
+bool
+intelEmitCopyBlit(struct intel_context *intel,
+ GLuint cpp,
+ GLshort src_pitch,
+ drm_intel_bo *src_buffer,
+ GLuint src_offset,
+ uint32_t src_tiling,
+ GLshort dst_pitch,
+ drm_intel_bo *dst_buffer,
+ GLuint dst_offset,
+ uint32_t dst_tiling,
+ GLshort src_x, GLshort src_y,
+ GLshort dst_x, GLshort dst_y,
+ GLshort w, GLshort h,
+ GLenum logic_op)
+{
+ GLuint CMD, BR13, pass = 0;
+ int dst_y2 = dst_y + h;
+ int dst_x2 = dst_x + w;
+ drm_intel_bo *aper_array[3];
+ BATCH_LOCALS;
+
+ if (dst_tiling != I915_TILING_NONE) {
+ if (dst_offset & 4095)
+ return false;
+ if (dst_tiling == I915_TILING_Y)
+ return false;
+ }
+ if (src_tiling != I915_TILING_NONE) {
+ if (src_offset & 4095)
+ return false;
+ if (src_tiling == I915_TILING_Y)
+ return false;
+ }
+
+ /* do space check before going any further */
+ do {
+ aper_array[0] = intel->batch.bo;
+ aper_array[1] = dst_buffer;
+ aper_array[2] = src_buffer;
+
+ if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
+ intel_batchbuffer_flush(intel);
+ pass++;
+ } else
+ break;
+ } while (pass < 2);
+
+ if (pass >= 2)
+ return false;
+
+ intel_batchbuffer_require_space(intel, 8 * 4, true);
+ DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+ __FUNCTION__,
+ src_buffer, src_pitch, src_offset, src_x, src_y,
+ dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h);
+
+ src_pitch *= cpp;
+ dst_pitch *= cpp;
+
+ /* Blit pitch must be dword-aligned. Otherwise, the hardware appears to drop
+ * the low bits.
+ */
+ assert(src_pitch % 4 == 0);
+ assert(dst_pitch % 4 == 0);
+
+ /* For big formats (such as floating point), do the copy using 32bpp and
+ * multiply the coordinates.
+ */
+ if (cpp > 4) {
+ assert(cpp % 4 == 0);
+ dst_x *= cpp / 4;
+ dst_x2 *= cpp / 4;
+ src_x *= cpp / 4;
+ cpp = 4;
+ }
+
+ BR13 = br13_for_cpp(cpp) | translate_raster_op(logic_op) << 16;
+
+ switch (cpp) {
+ case 1:
+ case 2:
+ CMD = XY_SRC_COPY_BLT_CMD;
+ break;
+ case 4:
+ CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+ break;
+ default:
+ return false;
+ }
+
+#ifndef I915
+ if (dst_tiling != I915_TILING_NONE) {
+ CMD |= XY_DST_TILED;
+ dst_pitch /= 4;
+ }
+ if (src_tiling != I915_TILING_NONE) {
+ CMD |= XY_SRC_TILED;
+ src_pitch /= 4;
+ }
+#endif
+
+ if (dst_y2 <= dst_y || dst_x2 <= dst_x) {
+ return true;
+ }
+
+ assert(dst_x < dst_x2);
+ assert(dst_y < dst_y2);
+
+ BEGIN_BATCH_BLT(8);
+ OUT_BATCH(CMD);
+ OUT_BATCH(BR13 | (uint16_t)dst_pitch);
+ OUT_BATCH((dst_y << 16) | dst_x);
+ OUT_BATCH((dst_y2 << 16) | dst_x2);
+ OUT_RELOC_FENCED(dst_buffer,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ dst_offset);
+ OUT_BATCH((src_y << 16) | src_x);
+ OUT_BATCH((uint16_t)src_pitch);
+ OUT_RELOC_FENCED(src_buffer,
+ I915_GEM_DOMAIN_RENDER, 0,
+ src_offset);
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ return true;
+}
+
+
+/**
+ * Use blitting to clear the renderbuffers named by 'flags'.
+ * Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferIndexes field
+ * since that might include software renderbuffers or renderbuffers
+ * which we're clearing with triangles.
+ * \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear
+ */
+GLbitfield
+intelClearWithBlit(struct gl_context *ctx, GLbitfield mask)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ GLuint clear_depth_value, clear_depth_mask;
+ GLint cx, cy, cw, ch;
+ GLbitfield fail_mask = 0;
+ BATCH_LOCALS;
+
+ /*
+ * Compute values for clearing the buffers.
+ */
+ clear_depth_value = 0;
+ clear_depth_mask = 0;
+ if (mask & BUFFER_BIT_DEPTH) {
+ clear_depth_value = (GLuint) (fb->_DepthMax * ctx->Depth.Clear);
+ clear_depth_mask = XY_BLT_WRITE_RGB;
+ }
+ if (mask & BUFFER_BIT_STENCIL) {
+ clear_depth_value |= (ctx->Stencil.Clear & 0xff) << 24;
+ clear_depth_mask |= XY_BLT_WRITE_ALPHA;
+ }
+
+ cx = fb->_Xmin;
+ if (_mesa_is_winsys_fbo(fb))
+ cy = ctx->DrawBuffer->Height - fb->_Ymax;
+ else
+ cy = fb->_Ymin;
+ cw = fb->_Xmax - fb->_Xmin;
+ ch = fb->_Ymax - fb->_Ymin;
+
+ if (cw == 0 || ch == 0)
+ return 0;
+
+ /* Loop over all renderbuffers */
+ mask &= (1 << BUFFER_COUNT) - 1;
+ while (mask) {
+ GLuint buf = ffs(mask) - 1;
+ bool is_depth_stencil = buf == BUFFER_DEPTH || buf == BUFFER_STENCIL;
+ struct intel_renderbuffer *irb;
+ int x1, y1, x2, y2;
+ uint32_t clear_val;
+ uint32_t BR13, CMD;
+ struct intel_region *region;
+ int pitch, cpp;
+ drm_intel_bo *aper_array[2];
+
+ mask &= ~(1 << buf);
+
+ irb = intel_get_renderbuffer(fb, buf);
+ if (irb && irb->mt) {
+ region = irb->mt->region;
+ assert(region);
+ assert(region->bo);
+ } else {
+ fail_mask |= 1 << buf;
+ continue;
+ }
+
+ /* OK, clear this renderbuffer */
+ x1 = cx + irb->draw_x;
+ y1 = cy + irb->draw_y;
+ x2 = cx + cw + irb->draw_x;
+ y2 = cy + ch + irb->draw_y;
+
+ pitch = region->pitch;
+ cpp = region->cpp;
+
+ DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
+ __FUNCTION__,
+ region->bo, (pitch * cpp),
+ x1, y1, x2 - x1, y2 - y1);
+
+ BR13 = 0xf0 << 16;
+ CMD = XY_COLOR_BLT_CMD;
+
+ /* Setup the blit command */
+ if (cpp == 4) {
+ if (is_depth_stencil) {
+ CMD |= clear_depth_mask;
+ } else {
+ /* clearing RGBA */
+ CMD |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+ }
+ }
+
+ assert(region->tiling != I915_TILING_Y);
+
+#ifndef I915
+ if (region->tiling != I915_TILING_NONE) {
+ CMD |= XY_DST_TILED;
+ pitch /= 4;
+ }
+#endif
+ BR13 |= (pitch * cpp);
+
+ if (is_depth_stencil) {
+ clear_val = clear_depth_value;
+ } else {
+ uint8_t clear[4];
+ GLfloat *color = ctx->Color.ClearColor.f;
+
+ _mesa_unclamped_float_rgba_to_ubyte(clear, color);
+
+ switch (intel_rb_format(irb)) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ clear_val = PACK_COLOR_8888(clear[3], clear[0],
+ clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_RGB565:
+ clear_val = PACK_COLOR_565(clear[0], clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_ARGB4444:
+ clear_val = PACK_COLOR_4444(clear[3], clear[0],
+ clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_ARGB1555:
+ clear_val = PACK_COLOR_1555(clear[3], clear[0],
+ clear[1], clear[2]);
+ break;
+ case MESA_FORMAT_A8:
+ clear_val = PACK_COLOR_8888(clear[3], clear[3],
+ clear[3], clear[3]);
+ break;
+ default:
+ fail_mask |= 1 << buf;
+ continue;
+ }
+ }
+
+ BR13 |= br13_for_cpp(cpp);
+
+ assert(x1 < x2);
+ assert(y1 < y2);
+
+ /* do space check before going any further */
+ aper_array[0] = intel->batch.bo;
+ aper_array[1] = region->bo;
+
+ if (drm_intel_bufmgr_check_aperture_space(aper_array,
+ ARRAY_SIZE(aper_array)) != 0) {
+ intel_batchbuffer_flush(intel);
+ }
+
+ BEGIN_BATCH_BLT(6);
+ OUT_BATCH(CMD);
+ OUT_BATCH(BR13);
+ OUT_BATCH((y1 << 16) | x1);
+ OUT_BATCH((y2 << 16) | x2);
+ OUT_RELOC_FENCED(region->bo,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ 0);
+ OUT_BATCH(clear_val);
+ ADVANCE_BATCH();
+
+ if (intel->always_flush_cache)
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL)
+ mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
+ }
+
+ return fail_mask;
+}
+
+bool
+intelEmitImmediateColorExpandBlit(struct intel_context *intel,
+ GLuint cpp,
+ GLubyte *src_bits, GLuint src_size,
+ GLuint fg_color,
+ GLshort dst_pitch,
+ drm_intel_bo *dst_buffer,
+ GLuint dst_offset,
+ uint32_t dst_tiling,
+ GLshort x, GLshort y,
+ GLshort w, GLshort h,
+ GLenum logic_op)
+{
+ int dwords = ALIGN(src_size, 8) / 4;
+ uint32_t opcode, br13, blit_cmd;
+
+ if (dst_tiling != I915_TILING_NONE) {
+ if (dst_offset & 4095)
+ return false;
+ if (dst_tiling == I915_TILING_Y)
+ return false;
+ }
+
+ assert( logic_op - GL_CLEAR >= 0 );
+ assert( logic_op - GL_CLEAR < 0x10 );
+ assert(dst_pitch > 0);
+
+ if (w < 0 || h < 0)
+ return true;
+
+ dst_pitch *= cpp;
+
+ DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d, %d bytes %d dwords\n",
+ __FUNCTION__,
+ dst_buffer, dst_pitch, dst_offset, x, y, w, h, src_size, dwords);
+
+ intel_batchbuffer_require_space(intel,
+ (8 * 4) +
+ (3 * 4) +
+ dwords * 4, true);
+
+ opcode = XY_SETUP_BLT_CMD;
+ if (cpp == 4)
+ opcode |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+#ifndef I915
+ if (dst_tiling != I915_TILING_NONE) {
+ opcode |= XY_DST_TILED;
+ dst_pitch /= 4;
+ }
+#endif
+
+ br13 = dst_pitch | (translate_raster_op(logic_op) << 16) | (1 << 29);
+ br13 |= br13_for_cpp(cpp);
+
+ blit_cmd = XY_TEXT_IMMEDIATE_BLIT_CMD | XY_TEXT_BYTE_PACKED; /* packing? */
+ if (dst_tiling != I915_TILING_NONE)
+ blit_cmd |= XY_DST_TILED;
+
+ BEGIN_BATCH_BLT(8 + 3);
+ OUT_BATCH(opcode);
+ OUT_BATCH(br13);
+ OUT_BATCH((0 << 16) | 0); /* clip x1, y1 */
+ OUT_BATCH((100 << 16) | 100); /* clip x2, y2 */
+ OUT_RELOC_FENCED(dst_buffer,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ dst_offset);
+ OUT_BATCH(0); /* bg */
+ OUT_BATCH(fg_color); /* fg */
+ OUT_BATCH(0); /* pattern base addr */
+
+ OUT_BATCH(blit_cmd | ((3 - 2) + dwords));
+ OUT_BATCH((y << 16) | x);
+ OUT_BATCH(((y + h) << 16) | (x + w));
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_data(intel, src_bits, dwords * 4, true);
+
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ return true;
+}
+
+/* We don't have a memmove-type blit like some other hardware, so we'll do a
+ * rectangular blit covering a large space, then emit 1-scanline blit at the
+ * end to cover the last if we need.
+ */
+void
+intel_emit_linear_blit(struct intel_context *intel,
+ drm_intel_bo *dst_bo,
+ unsigned int dst_offset,
+ drm_intel_bo *src_bo,
+ unsigned int src_offset,
+ unsigned int size)
+{
+ GLuint pitch, height;
+ bool ok;
+
+ /* The pitch given to the GPU must be DWORD aligned, and
+ * we want width to match pitch. Max width is (1 << 15 - 1),
+ * rounding that down to the nearest DWORD is 1 << 15 - 4
+ */
+ pitch = ROUND_DOWN_TO(MIN2(size, (1 << 15) - 1), 4);
+ height = (pitch == 0) ? 1 : size / pitch;
+ ok = intelEmitCopyBlit(intel, 1,
+ pitch, src_bo, src_offset, I915_TILING_NONE,
+ pitch, dst_bo, dst_offset, I915_TILING_NONE,
+ 0, 0, /* src x/y */
+ 0, 0, /* dst x/y */
+ pitch, height, /* w, h */
+ GL_COPY);
+ assert(ok);
+
+ src_offset += pitch * height;
+ dst_offset += pitch * height;
+ size -= pitch * height;
+ assert (size < (1 << 15));
+ pitch = ALIGN(size, 4);
+ if (size != 0) {
+ ok = intelEmitCopyBlit(intel, 1,
+ pitch, src_bo, src_offset, I915_TILING_NONE,
+ pitch, dst_bo, dst_offset, I915_TILING_NONE,
+ 0, 0, /* src x/y */
+ 0, 0, /* dst x/y */
+ size, 1, /* w, h */
+ GL_COPY);
+ assert(ok);
+ }
+}
+
+/**
+ * Used to initialize the alpha value of an ARGB8888 teximage after
+ * loading it from an XRGB8888 source.
+ *
+ * This is very common with glCopyTexImage2D().
+ */
+void
+intel_set_teximage_alpha_to_one(struct gl_context *ctx,
+ struct intel_texture_image *intel_image)
+{
+ struct intel_context *intel = intel_context(ctx);
+ unsigned int image_x, image_y;
+ uint32_t x1, y1, x2, y2;
+ uint32_t BR13, CMD;
+ int pitch, cpp;
+ drm_intel_bo *aper_array[2];
+ struct intel_region *region = intel_image->mt->region;
+ int width, height, depth;
+ BATCH_LOCALS;
+
+ intel_miptree_get_dimensions_for_image(&intel_image->base.Base,
+ &width, &height, &depth);
+ assert(depth == 1);
+
+ assert(intel_image->base.Base.TexFormat == MESA_FORMAT_ARGB8888);
+
+ /* get dest x/y in destination texture */
+ intel_miptree_get_image_offset(intel_image->mt,
+ intel_image->base.Base.Level,
+ intel_image->base.Base.Face,
+ 0,
+ &image_x, &image_y);
+
+ x1 = image_x;
+ y1 = image_y;
+ x2 = image_x + width;
+ y2 = image_y + height;
+
+ pitch = region->pitch;
+ cpp = region->cpp;
+
+ DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
+ __FUNCTION__,
+ intel_image->mt->region->bo, (pitch * cpp),
+ x1, y1, x2 - x1, y2 - y1);
+
+ BR13 = br13_for_cpp(cpp) | 0xf0 << 16;
+ CMD = XY_COLOR_BLT_CMD;
+ CMD |= XY_BLT_WRITE_ALPHA;
+
+ assert(region->tiling != I915_TILING_Y);
+
+#ifndef I915
+ if (region->tiling != I915_TILING_NONE) {
+ CMD |= XY_DST_TILED;
+ pitch /= 4;
+ }
+#endif
+ BR13 |= (pitch * cpp);
+
+ /* do space check before going any further */
+ aper_array[0] = intel->batch.bo;
+ aper_array[1] = region->bo;
+
+ if (drm_intel_bufmgr_check_aperture_space(aper_array,
+ ARRAY_SIZE(aper_array)) != 0) {
+ intel_batchbuffer_flush(intel);
+ }
+
+ BEGIN_BATCH_BLT(6);
+ OUT_BATCH(CMD);
+ OUT_BATCH(BR13);
+ OUT_BATCH((y1 << 16) | x1);
+ OUT_BATCH((y2 << 16) | x2);
+ OUT_RELOC_FENCED(region->bo,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ 0);
+ OUT_BATCH(0xffffffff); /* white, but only alpha gets written */
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_emit_mi_flush(intel);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffer_objects.c
index e06dd3c8d3c..df8ac7fb301 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffer_objects.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffer_objects.c
@@ -1 +1,849 @@
-../intel/intel_buffer_objects.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/imports.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/bufferobj.h"
+
+#include "intel_blit.h"
+#include "intel_buffer_objects.h"
+#include "intel_batchbuffer.h"
+#include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+
+static GLboolean
+intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj);
+
+/** Allocates a new drm_intel_bo to store the data for the buffer object. */
+static void
+intel_bufferobj_alloc_buffer(struct intel_context *intel,
+ struct intel_buffer_object *intel_obj)
+{
+ intel_obj->buffer = drm_intel_bo_alloc(intel->bufmgr, "bufferobj",
+ intel_obj->Base.Size, 64);
+}
+
+static void
+release_buffer(struct intel_buffer_object *intel_obj)
+{
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_obj->buffer = NULL;
+ intel_obj->offset = 0;
+ intel_obj->source = 0;
+}
+
+/**
+ * There is some duplication between mesa's bufferobjects and our
+ * bufmgr buffers. Both have an integer handle and a hashtable to
+ * lookup an opaque structure. It would be nice if the handles and
+ * internal structure where somehow shared.
+ */
+static struct gl_buffer_object *
+intel_bufferobj_alloc(struct gl_context * ctx, GLuint name, GLenum target)
+{
+ struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object);
+
+ _mesa_initialize_buffer_object(ctx, &obj->Base, name, target);
+
+ obj->buffer = NULL;
+
+ return &obj->Base;
+}
+
+/**
+ * Deallocate/free a vertex/pixel buffer object.
+ * Called via glDeleteBuffersARB().
+ */
+static void
+intel_bufferobj_free(struct gl_context * ctx, struct gl_buffer_object *obj)
+{
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ assert(intel_obj);
+
+ /* Buffer objects are automatically unmapped when deleting according
+ * to the spec, but Mesa doesn't do UnmapBuffer for us at context destroy
+ * (though it does if you call glDeleteBuffers)
+ */
+ if (obj->Pointer)
+ intel_bufferobj_unmap(ctx, obj);
+
+ free(intel_obj->sys_buffer);
+
+ drm_intel_bo_unreference(intel_obj->buffer);
+ free(intel_obj);
+}
+
+
+
+/**
+ * Allocate space for and store data in a buffer object. Any data that was
+ * previously stored in the buffer object is lost. If data is NULL,
+ * memory will be allocated, but no copy will occur.
+ * Called via ctx->Driver.BufferData().
+ * \return true for success, false if out of memory
+ */
+static GLboolean
+intel_bufferobj_data(struct gl_context * ctx,
+ GLenum target,
+ GLsizeiptrARB size,
+ const GLvoid * data,
+ GLenum usage, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ /* Part of the ABI, but this function doesn't use it.
+ */
+#ifndef I915
+ (void) target;
+#endif
+
+ intel_obj->Base.Size = size;
+ intel_obj->Base.Usage = usage;
+
+ assert(!obj->Pointer); /* Mesa should have unmapped it */
+
+ if (intel_obj->buffer != NULL)
+ release_buffer(intel_obj);
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+
+ if (size != 0) {
+#ifdef I915
+ /* On pre-965, stick VBOs in system memory, as we're always doing
+ * swtnl with their contents anyway.
+ */
+ if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
+ intel_obj->sys_buffer = malloc(size);
+ if (intel_obj->sys_buffer != NULL) {
+ if (data != NULL)
+ memcpy(intel_obj->sys_buffer, data, size);
+ return true;
+ }
+ }
+#endif
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ if (!intel_obj->buffer)
+ return false;
+
+ if (data != NULL)
+ drm_intel_bo_subdata(intel_obj->buffer, 0, size, data);
+ }
+
+ return true;
+}
+
+
+/**
+ * Replace data in a subrange of buffer object. If the data range
+ * specified by size + offset extends beyond the end of the buffer or
+ * if data is NULL, no copy is performed.
+ * Called via glBufferSubDataARB().
+ */
+static void
+intel_bufferobj_subdata(struct gl_context * ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ const GLvoid * data, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+ bool busy;
+
+ if (size == 0)
+ return;
+
+ assert(intel_obj);
+
+ /* If we have a single copy in system memory, update that */
+ if (intel_obj->sys_buffer) {
+ if (intel_obj->source)
+ release_buffer(intel_obj);
+
+ if (intel_obj->buffer == NULL) {
+ memcpy((char *)intel_obj->sys_buffer + offset, data, size);
+ return;
+ }
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
+ /* Otherwise we need to update the copy in video memory. */
+ busy =
+ drm_intel_bo_busy(intel_obj->buffer) ||
+ drm_intel_bo_references(intel->batch.bo, intel_obj->buffer);
+
+ if (busy) {
+ if (size == intel_obj->Base.Size) {
+ /* Replace the current busy bo with fresh data. */
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ drm_intel_bo_subdata(intel_obj->buffer, 0, size, data);
+ } else {
+ perf_debug("Using a blit copy to avoid stalling on glBufferSubData() "
+ "to a busy buffer object.\n");
+ drm_intel_bo *temp_bo =
+ drm_intel_bo_alloc(intel->bufmgr, "subdata temp", size, 64);
+
+ drm_intel_bo_subdata(temp_bo, 0, size, data);
+
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, offset,
+ temp_bo, 0,
+ size);
+
+ drm_intel_bo_unreference(temp_bo);
+ }
+ } else {
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (drm_intel_bo_busy(intel_obj->buffer)) {
+ perf_debug("Stalling on the GPU in glBufferSubData().\n");
+ }
+ }
+ drm_intel_bo_subdata(intel_obj->buffer, offset, size, data);
+ }
+}
+
+
+/**
+ * Called via glGetBufferSubDataARB().
+ */
+static void
+intel_bufferobj_get_subdata(struct gl_context * ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ GLvoid * data, struct gl_buffer_object *obj)
+{
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+ struct intel_context *intel = intel_context(ctx);
+
+ assert(intel_obj);
+ if (intel_obj->sys_buffer)
+ memcpy(data, (char *)intel_obj->sys_buffer + offset, size);
+ else {
+ if (drm_intel_bo_references(intel->batch.bo, intel_obj->buffer)) {
+ intel_batchbuffer_flush(intel);
+ }
+ drm_intel_bo_get_subdata(intel_obj->buffer, offset, size, data);
+ }
+}
+
+
+
+/**
+ * Called via glMapBufferRange and glMapBuffer
+ *
+ * The goal of this extension is to allow apps to accumulate their rendering
+ * at the same time as they accumulate their buffer object. Without it,
+ * you'd end up blocking on execution of rendering every time you mapped
+ * the buffer to put new data in.
+ *
+ * We support it in 3 ways: If unsynchronized, then don't bother
+ * flushing the batchbuffer before mapping the buffer, which can save blocking
+ * in many cases. If we would still block, and they allow the whole buffer
+ * to be invalidated, then just allocate a new buffer to replace the old one.
+ * If not, and we'd block, and they allow the subrange of the buffer to be
+ * invalidated, then we can make a new little BO, let them write into that,
+ * and blit it into the real BO at unmap time.
+ */
+static void *
+intel_bufferobj_map_range(struct gl_context * ctx,
+ GLintptr offset, GLsizeiptr length,
+ GLbitfield access, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ assert(intel_obj);
+
+ /* _mesa_MapBufferRange (GL entrypoint) sets these, but the vbo module also
+ * internally uses our functions directly.
+ */
+ obj->Offset = offset;
+ obj->Length = length;
+ obj->AccessFlags = access;
+
+ if (intel_obj->sys_buffer) {
+ const bool read_only =
+ (access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == GL_MAP_READ_BIT;
+
+ if (!read_only && intel_obj->source)
+ release_buffer(intel_obj);
+
+ if (!intel_obj->buffer || intel_obj->source) {
+ obj->Pointer = intel_obj->sys_buffer + offset;
+ return obj->Pointer;
+ }
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
+ if (intel_obj->buffer == NULL) {
+ obj->Pointer = NULL;
+ return NULL;
+ }
+
+ /* If the access is synchronized (like a normal buffer mapping), then get
+ * things flushed out so the later mapping syncs appropriately through GEM.
+ * If the user doesn't care about existing buffer contents and mapping would
+ * cause us to block, then throw out the old buffer.
+ *
+ * If they set INVALIDATE_BUFFER, we can pitch the current contents to
+ * achieve the required synchronization.
+ */
+ if (!(access & GL_MAP_UNSYNCHRONIZED_BIT)) {
+ if (drm_intel_bo_references(intel->batch.bo, intel_obj->buffer)) {
+ if (access & GL_MAP_INVALIDATE_BUFFER_BIT) {
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ } else {
+ intel_flush(ctx);
+ }
+ } else if (drm_intel_bo_busy(intel_obj->buffer) &&
+ (access & GL_MAP_INVALIDATE_BUFFER_BIT)) {
+ drm_intel_bo_unreference(intel_obj->buffer);
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ }
+ }
+
+ /* If the user is mapping a range of an active buffer object but
+ * doesn't require the current contents of that range, make a new
+ * BO, and we'll copy what they put in there out at unmap or
+ * FlushRange time.
+ */
+ if ((access & GL_MAP_INVALIDATE_RANGE_BIT) &&
+ drm_intel_bo_busy(intel_obj->buffer)) {
+ if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
+ intel_obj->range_map_buffer = malloc(length);
+ obj->Pointer = intel_obj->range_map_buffer;
+ } else {
+ intel_obj->range_map_bo = drm_intel_bo_alloc(intel->bufmgr,
+ "range map",
+ length, 64);
+ if (!(access & GL_MAP_READ_BIT)) {
+ drm_intel_gem_bo_map_gtt(intel_obj->range_map_bo);
+ } else {
+ drm_intel_bo_map(intel_obj->range_map_bo,
+ (access & GL_MAP_WRITE_BIT) != 0);
+ }
+ obj->Pointer = intel_obj->range_map_bo->virtual;
+ }
+ return obj->Pointer;
+ }
+
+ if (access & GL_MAP_UNSYNCHRONIZED_BIT)
+ drm_intel_gem_bo_map_unsynchronized(intel_obj->buffer);
+ else if (!(access & GL_MAP_READ_BIT)) {
+ drm_intel_gem_bo_map_gtt(intel_obj->buffer);
+ } else {
+ drm_intel_bo_map(intel_obj->buffer, (access & GL_MAP_WRITE_BIT) != 0);
+ }
+
+ obj->Pointer = intel_obj->buffer->virtual + offset;
+ return obj->Pointer;
+}
+
+/* Ideally we'd use a BO to avoid taking up cache space for the temporary
+ * data, but FlushMappedBufferRange may be followed by further writes to
+ * the pointer, so we would have to re-map after emitting our blit, which
+ * would defeat the point.
+ */
+static void
+intel_bufferobj_flush_mapped_range(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length,
+ struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+ drm_intel_bo *temp_bo;
+
+ /* Unless we're in the range map using a temporary system buffer,
+ * there's no work to do.
+ */
+ if (intel_obj->range_map_buffer == NULL)
+ return;
+
+ if (length == 0)
+ return;
+
+ temp_bo = drm_intel_bo_alloc(intel->bufmgr, "range map flush", length, 64);
+
+ drm_intel_bo_subdata(temp_bo, 0, length, intel_obj->range_map_buffer);
+
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, obj->Offset + offset,
+ temp_bo, 0,
+ length);
+
+ drm_intel_bo_unreference(temp_bo);
+}
+
+
+/**
+ * Called via glUnmapBuffer().
+ */
+static GLboolean
+intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+ assert(intel_obj);
+ assert(obj->Pointer);
+ if (intel_obj->sys_buffer != NULL) {
+ /* always keep the mapping around. */
+ } else if (intel_obj->range_map_buffer != NULL) {
+ /* Since we've emitted some blits to buffers that will (likely) be used
+ * in rendering operations in other cache domains in this batch, emit a
+ * flush. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+ free(intel_obj->range_map_buffer);
+ intel_obj->range_map_buffer = NULL;
+ } else if (intel_obj->range_map_bo != NULL) {
+ drm_intel_bo_unmap(intel_obj->range_map_bo);
+
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, obj->Offset,
+ intel_obj->range_map_bo, 0,
+ obj->Length);
+
+ /* Since we've emitted some blits to buffers that will (likely) be used
+ * in rendering operations in other cache domains in this batch, emit a
+ * flush. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ drm_intel_bo_unreference(intel_obj->range_map_bo);
+ intel_obj->range_map_bo = NULL;
+ } else if (intel_obj->buffer != NULL) {
+ drm_intel_bo_unmap(intel_obj->buffer);
+ }
+ obj->Pointer = NULL;
+ obj->Offset = 0;
+ obj->Length = 0;
+
+ return true;
+}
+
+drm_intel_bo *
+intel_bufferobj_buffer(struct intel_context *intel,
+ struct intel_buffer_object *intel_obj,
+ GLuint flag)
+{
+ if (intel_obj->source)
+ release_buffer(intel_obj);
+
+ if (intel_obj->buffer == NULL) {
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ drm_intel_bo_subdata(intel_obj->buffer,
+ 0, intel_obj->Base.Size,
+ intel_obj->sys_buffer);
+
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ intel_obj->offset = 0;
+ }
+
+ return intel_obj->buffer;
+}
+
+#define INTEL_UPLOAD_SIZE (64*1024)
+
+void
+intel_upload_finish(struct intel_context *intel)
+{
+ if (!intel->upload.bo)
+ return;
+
+ if (intel->upload.buffer_len) {
+ drm_intel_bo_subdata(intel->upload.bo,
+ intel->upload.buffer_offset,
+ intel->upload.buffer_len,
+ intel->upload.buffer);
+ intel->upload.buffer_len = 0;
+ }
+
+ drm_intel_bo_unreference(intel->upload.bo);
+ intel->upload.bo = NULL;
+}
+
+static void wrap_buffers(struct intel_context *intel, GLuint size)
+{
+ intel_upload_finish(intel);
+
+ if (size < INTEL_UPLOAD_SIZE)
+ size = INTEL_UPLOAD_SIZE;
+
+ intel->upload.bo = drm_intel_bo_alloc(intel->bufmgr, "upload", size, 0);
+ intel->upload.offset = 0;
+}
+
+void intel_upload_data(struct intel_context *intel,
+ const void *ptr, GLuint size, GLuint align,
+ drm_intel_bo **return_bo,
+ GLuint *return_offset)
+{
+ GLuint base, delta;
+
+ base = (intel->upload.offset + align - 1) / align * align;
+ if (intel->upload.bo == NULL || base + size > intel->upload.bo->size) {
+ wrap_buffers(intel, size);
+ base = 0;
+ }
+
+ drm_intel_bo_reference(intel->upload.bo);
+ *return_bo = intel->upload.bo;
+ *return_offset = base;
+
+ delta = base - intel->upload.offset;
+ if (intel->upload.buffer_len &&
+ intel->upload.buffer_len + delta + size > sizeof(intel->upload.buffer))
+ {
+ drm_intel_bo_subdata(intel->upload.bo,
+ intel->upload.buffer_offset,
+ intel->upload.buffer_len,
+ intel->upload.buffer);
+ intel->upload.buffer_len = 0;
+ }
+
+ if (size < sizeof(intel->upload.buffer))
+ {
+ if (intel->upload.buffer_len == 0)
+ intel->upload.buffer_offset = base;
+ else
+ intel->upload.buffer_len += delta;
+
+ memcpy(intel->upload.buffer + intel->upload.buffer_len, ptr, size);
+ intel->upload.buffer_len += size;
+ }
+ else
+ {
+ drm_intel_bo_subdata(intel->upload.bo, base, size, ptr);
+ }
+
+ intel->upload.offset = base + size;
+}
+
+void *intel_upload_map(struct intel_context *intel, GLuint size, GLuint align)
+{
+ GLuint base, delta;
+ char *ptr;
+
+ base = (intel->upload.offset + align - 1) / align * align;
+ if (intel->upload.bo == NULL || base + size > intel->upload.bo->size) {
+ wrap_buffers(intel, size);
+ base = 0;
+ }
+
+ delta = base - intel->upload.offset;
+ if (intel->upload.buffer_len &&
+ intel->upload.buffer_len + delta + size > sizeof(intel->upload.buffer))
+ {
+ drm_intel_bo_subdata(intel->upload.bo,
+ intel->upload.buffer_offset,
+ intel->upload.buffer_len,
+ intel->upload.buffer);
+ intel->upload.buffer_len = 0;
+ }
+
+ if (size <= sizeof(intel->upload.buffer)) {
+ if (intel->upload.buffer_len == 0)
+ intel->upload.buffer_offset = base;
+ else
+ intel->upload.buffer_len += delta;
+
+ ptr = intel->upload.buffer + intel->upload.buffer_len;
+ intel->upload.buffer_len += size;
+ } else
+ ptr = malloc(size);
+
+ return ptr;
+}
+
+void intel_upload_unmap(struct intel_context *intel,
+ const void *ptr, GLuint size, GLuint align,
+ drm_intel_bo **return_bo,
+ GLuint *return_offset)
+{
+ GLuint base;
+
+ base = (intel->upload.offset + align - 1) / align * align;
+ if (size > sizeof(intel->upload.buffer)) {
+ drm_intel_bo_subdata(intel->upload.bo, base, size, ptr);
+ free((void*)ptr);
+ }
+
+ drm_intel_bo_reference(intel->upload.bo);
+ *return_bo = intel->upload.bo;
+ *return_offset = base;
+
+ intel->upload.offset = base + size;
+}
+
+drm_intel_bo *
+intel_bufferobj_source(struct intel_context *intel,
+ struct intel_buffer_object *intel_obj,
+ GLuint align, GLuint *offset)
+{
+ if (intel_obj->buffer == NULL) {
+ intel_upload_data(intel,
+ intel_obj->sys_buffer, intel_obj->Base.Size, align,
+ &intel_obj->buffer, &intel_obj->offset);
+ intel_obj->source = 1;
+ }
+
+ *offset = intel_obj->offset;
+ return intel_obj->buffer;
+}
+
+static void
+intel_bufferobj_copy_subdata(struct gl_context *ctx,
+ struct gl_buffer_object *src,
+ struct gl_buffer_object *dst,
+ GLintptr read_offset, GLintptr write_offset,
+ GLsizeiptr size)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *intel_src = intel_buffer_object(src);
+ struct intel_buffer_object *intel_dst = intel_buffer_object(dst);
+ drm_intel_bo *src_bo, *dst_bo;
+ GLuint src_offset;
+
+ if (size == 0)
+ return;
+
+ /* If we're in system memory, just map and memcpy. */
+ if (intel_src->sys_buffer || intel_dst->sys_buffer) {
+ /* The same buffer may be used, but note that regions copied may
+ * not overlap.
+ */
+ if (src == dst) {
+ char *ptr = intel_bufferobj_map_range(ctx, 0, dst->Size,
+ GL_MAP_READ_BIT |
+ GL_MAP_WRITE_BIT,
+ dst);
+ memmove(ptr + write_offset, ptr + read_offset, size);
+ intel_bufferobj_unmap(ctx, dst);
+ } else {
+ const char *src_ptr;
+ char *dst_ptr;
+
+ src_ptr = intel_bufferobj_map_range(ctx, 0, src->Size,
+ GL_MAP_READ_BIT, src);
+ dst_ptr = intel_bufferobj_map_range(ctx, 0, dst->Size,
+ GL_MAP_WRITE_BIT, dst);
+
+ memcpy(dst_ptr + write_offset, src_ptr + read_offset, size);
+
+ intel_bufferobj_unmap(ctx, src);
+ intel_bufferobj_unmap(ctx, dst);
+ }
+ return;
+ }
+
+ /* Otherwise, we have real BOs, so blit them. */
+
+ dst_bo = intel_bufferobj_buffer(intel, intel_dst, INTEL_WRITE_PART);
+ src_bo = intel_bufferobj_source(intel, intel_src, 64, &src_offset);
+
+ intel_emit_linear_blit(intel,
+ dst_bo, write_offset,
+ src_bo, read_offset + src_offset, size);
+
+ /* Since we've emitted some blits to buffers that will (likely) be used
+ * in rendering operations in other cache domains in this batch, emit a
+ * flush. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+}
+
+#if FEATURE_APPLE_object_purgeable
+static GLenum
+intel_buffer_purgeable(drm_intel_bo *buffer)
+{
+ int retained = 0;
+
+ if (buffer != NULL)
+ retained = drm_intel_bo_madvise (buffer, I915_MADV_DONTNEED);
+
+ return retained ? GL_VOLATILE_APPLE : GL_RELEASED_APPLE;
+}
+
+static GLenum
+intel_buffer_object_purgeable(struct gl_context * ctx,
+ struct gl_buffer_object *obj,
+ GLenum option)
+{
+ struct intel_buffer_object *intel_obj = intel_buffer_object (obj);
+
+ if (intel_obj->buffer != NULL)
+ return intel_buffer_purgeable(intel_obj->buffer);
+
+ if (option == GL_RELEASED_APPLE) {
+ if (intel_obj->sys_buffer != NULL) {
+ free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
+ return GL_RELEASED_APPLE;
+ } else {
+ /* XXX Create the buffer and madvise(MADV_DONTNEED)? */
+ struct intel_context *intel = intel_context(ctx);
+ drm_intel_bo *bo = intel_bufferobj_buffer(intel, intel_obj, INTEL_READ);
+
+ return intel_buffer_purgeable(bo);
+ }
+}
+
+static GLenum
+intel_texture_object_purgeable(struct gl_context * ctx,
+ struct gl_texture_object *obj,
+ GLenum option)
+{
+ struct intel_texture_object *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_texture_object(obj);
+ if (intel->mt == NULL || intel->mt->region == NULL)
+ return GL_RELEASED_APPLE;
+
+ return intel_buffer_purgeable(intel->mt->region->bo);
+}
+
+static GLenum
+intel_render_object_purgeable(struct gl_context * ctx,
+ struct gl_renderbuffer *obj,
+ GLenum option)
+{
+ struct intel_renderbuffer *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_renderbuffer(obj);
+ if (intel->mt == NULL)
+ return GL_RELEASED_APPLE;
+
+ return intel_buffer_purgeable(intel->mt->region->bo);
+}
+
+static GLenum
+intel_buffer_unpurgeable(drm_intel_bo *buffer)
+{
+ int retained;
+
+ retained = 0;
+ if (buffer != NULL)
+ retained = drm_intel_bo_madvise (buffer, I915_MADV_WILLNEED);
+
+ return retained ? GL_RETAINED_APPLE : GL_UNDEFINED_APPLE;
+}
+
+static GLenum
+intel_buffer_object_unpurgeable(struct gl_context * ctx,
+ struct gl_buffer_object *obj,
+ GLenum option)
+{
+ (void) ctx;
+ (void) option;
+
+ return intel_buffer_unpurgeable(intel_buffer_object (obj)->buffer);
+}
+
+static GLenum
+intel_texture_object_unpurgeable(struct gl_context * ctx,
+ struct gl_texture_object *obj,
+ GLenum option)
+{
+ struct intel_texture_object *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_texture_object(obj);
+ if (intel->mt == NULL || intel->mt->region == NULL)
+ return GL_UNDEFINED_APPLE;
+
+ return intel_buffer_unpurgeable(intel->mt->region->bo);
+}
+
+static GLenum
+intel_render_object_unpurgeable(struct gl_context * ctx,
+ struct gl_renderbuffer *obj,
+ GLenum option)
+{
+ struct intel_renderbuffer *intel;
+
+ (void) ctx;
+ (void) option;
+
+ intel = intel_renderbuffer(obj);
+ if (intel->mt == NULL)
+ return GL_UNDEFINED_APPLE;
+
+ return intel_buffer_unpurgeable(intel->mt->region->bo);
+}
+#endif
+
+void
+intelInitBufferObjectFuncs(struct dd_function_table *functions)
+{
+ functions->NewBufferObject = intel_bufferobj_alloc;
+ functions->DeleteBuffer = intel_bufferobj_free;
+ functions->BufferData = intel_bufferobj_data;
+ functions->BufferSubData = intel_bufferobj_subdata;
+ functions->GetBufferSubData = intel_bufferobj_get_subdata;
+ functions->MapBufferRange = intel_bufferobj_map_range;
+ functions->FlushMappedBufferRange = intel_bufferobj_flush_mapped_range;
+ functions->UnmapBuffer = intel_bufferobj_unmap;
+ functions->CopyBufferSubData = intel_bufferobj_copy_subdata;
+
+#if FEATURE_APPLE_object_purgeable
+ functions->BufferObjectPurgeable = intel_buffer_object_purgeable;
+ functions->TextureObjectPurgeable = intel_texture_object_purgeable;
+ functions->RenderObjectPurgeable = intel_render_object_purgeable;
+
+ functions->BufferObjectUnpurgeable = intel_buffer_object_unpurgeable;
+ functions->TextureObjectUnpurgeable = intel_texture_object_unpurgeable;
+ functions->RenderObjectUnpurgeable = intel_render_object_unpurgeable;
+#endif
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffers.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffers.c
index c86daa49f47..9a9a259c9e5 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffers.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_buffers.c
@@ -1 +1,132 @@
-../intel/intel_buffers.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "intel_context.h"
+#include "intel_buffers.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+
+/**
+ * Return pointer to current color drawing region, or NULL.
+ */
+struct intel_region *
+intel_drawbuf_region(struct intel_context *intel)
+{
+ struct intel_renderbuffer *irbColor =
+ intel_renderbuffer(intel->ctx.DrawBuffer->_ColorDrawBuffers[0]);
+ if (irbColor && irbColor->mt)
+ return irbColor->mt->region;
+ else
+ return NULL;
+}
+
+/**
+ * Return pointer to current color reading region, or NULL.
+ */
+struct intel_region *
+intel_readbuf_region(struct intel_context *intel)
+{
+ struct intel_renderbuffer *irb
+ = intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
+ if (irb && irb->mt)
+ return irb->mt->region;
+ else
+ return NULL;
+}
+
+/**
+ * Check if we're about to draw into the front color buffer.
+ * If so, set the intel->front_buffer_dirty field to true.
+ */
+void
+intel_check_front_buffer_rendering(struct intel_context *intel)
+{
+ const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
+ if (_mesa_is_winsys_fbo(fb)) {
+ /* drawing to window system buffer */
+ if (fb->_NumColorDrawBuffers > 0) {
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+ intel->front_buffer_dirty = true;
+ }
+ }
+ }
+}
+
+static void
+intelDrawBuffer(struct gl_context * ctx, GLenum mode)
+{
+ if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ struct intel_context *const intel = intel_context(ctx);
+ const bool was_front_buffer_rendering =
+ intel->is_front_buffer_rendering;
+
+ intel->is_front_buffer_rendering = (mode == GL_FRONT_LEFT)
+ || (mode == GL_FRONT) || (mode == GL_FRONT_AND_BACK);
+
+ /* If we weren't front-buffer rendering before but we are now,
+ * invalidate our DRI drawable so we'll ask for new buffers
+ * (including the fake front) before we start rendering again.
+ */
+ if (!was_front_buffer_rendering && intel->is_front_buffer_rendering)
+ dri2InvalidateDrawable(intel->driContext->driDrawablePriv);
+ }
+
+ intel_draw_buffer(ctx);
+}
+
+
+static void
+intelReadBuffer(struct gl_context * ctx, GLenum mode)
+{
+ if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ struct intel_context *const intel = intel_context(ctx);
+ const bool was_front_buffer_reading =
+ intel->is_front_buffer_reading;
+
+ intel->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
+ || (mode == GL_FRONT);
+
+ /* If we weren't front-buffer reading before but we are now,
+ * invalidate our DRI drawable so we'll ask for new buffers
+ * (including the fake front) before we start reading again.
+ */
+ if (!was_front_buffer_reading && intel->is_front_buffer_reading)
+ dri2InvalidateDrawable(intel->driContext->driReadablePriv);
+ }
+}
+
+
+void
+intelInitBufferFuncs(struct dd_function_table *functions)
+{
+ functions->DrawBuffer = intelDrawBuffer;
+ functions->ReadBuffer = intelReadBuffer;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_context.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_context.c
index 27a1cbb255e..25334da33f7 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_context.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_context.c
@@ -1 +1,1030 @@
-../intel/intel_context.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/extensions.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/imports.h"
+#include "main/points.h"
+#include "main/renderbuffer.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "drivers/common/driverfuncs.h"
+#include "drivers/common/meta.h"
+
+#include "intel_chipset.h"
+#include "intel_buffers.h"
+#include "intel_tex.h"
+#include "intel_batchbuffer.h"
+#include "intel_clear.h"
+#include "intel_extensions.h"
+#include "intel_pixel.h"
+#include "intel_regions.h"
+#include "intel_buffer_objects.h"
+#include "intel_fbo.h"
+#include "intel_bufmgr.h"
+#include "intel_screen.h"
+#include "intel_mipmap_tree.h"
+
+#include "utils.h"
+#include "../glsl/ralloc.h"
+
+#ifndef INTEL_DEBUG
+int INTEL_DEBUG = (0);
+#endif
+
+
+static const GLubyte *
+intelGetString(struct gl_context * ctx, GLenum name)
+{
+ const struct intel_context *const intel = intel_context(ctx);
+ const char *chipset;
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) "Intel Open Source Technology Center";
+ break;
+
+ case GL_RENDERER:
+ switch (intel->intelScreen->deviceID) {
+ case PCI_CHIP_845_G:
+ chipset = "Intel(R) 845G";
+ break;
+ case PCI_CHIP_I830_M:
+ chipset = "Intel(R) 830M";
+ break;
+ case PCI_CHIP_I855_GM:
+ chipset = "Intel(R) 852GM/855GM";
+ break;
+ case PCI_CHIP_I865_G:
+ chipset = "Intel(R) 865G";
+ break;
+ case PCI_CHIP_I915_G:
+ chipset = "Intel(R) 915G";
+ break;
+ case PCI_CHIP_E7221_G:
+ chipset = "Intel (R) E7221G (i915)";
+ break;
+ case PCI_CHIP_I915_GM:
+ chipset = "Intel(R) 915GM";
+ break;
+ case PCI_CHIP_I945_G:
+ chipset = "Intel(R) 945G";
+ break;
+ case PCI_CHIP_I945_GM:
+ chipset = "Intel(R) 945GM";
+ break;
+ case PCI_CHIP_I945_GME:
+ chipset = "Intel(R) 945GME";
+ break;
+ case PCI_CHIP_G33_G:
+ chipset = "Intel(R) G33";
+ break;
+ case PCI_CHIP_Q35_G:
+ chipset = "Intel(R) Q35";
+ break;
+ case PCI_CHIP_Q33_G:
+ chipset = "Intel(R) Q33";
+ break;
+ case PCI_CHIP_IGD_GM:
+ case PCI_CHIP_IGD_G:
+ chipset = "Intel(R) IGD";
+ break;
+ case PCI_CHIP_I965_Q:
+ chipset = "Intel(R) 965Q";
+ break;
+ case PCI_CHIP_I965_G:
+ case PCI_CHIP_I965_G_1:
+ chipset = "Intel(R) 965G";
+ break;
+ case PCI_CHIP_I946_GZ:
+ chipset = "Intel(R) 946GZ";
+ break;
+ case PCI_CHIP_I965_GM:
+ chipset = "Intel(R) 965GM";
+ break;
+ case PCI_CHIP_I965_GME:
+ chipset = "Intel(R) 965GME/GLE";
+ break;
+ case PCI_CHIP_GM45_GM:
+ chipset = "Mobile Intel® GM45 Express Chipset";
+ break;
+ case PCI_CHIP_IGD_E_G:
+ chipset = "Intel(R) Integrated Graphics Device";
+ break;
+ case PCI_CHIP_G45_G:
+ chipset = "Intel(R) G45/G43";
+ break;
+ case PCI_CHIP_Q45_G:
+ chipset = "Intel(R) Q45/Q43";
+ break;
+ case PCI_CHIP_G41_G:
+ chipset = "Intel(R) G41";
+ break;
+ case PCI_CHIP_B43_G:
+ case PCI_CHIP_B43_G1:
+ chipset = "Intel(R) B43";
+ break;
+ case PCI_CHIP_ILD_G:
+ chipset = "Intel(R) Ironlake Desktop";
+ break;
+ case PCI_CHIP_ILM_G:
+ chipset = "Intel(R) Ironlake Mobile";
+ break;
+ case PCI_CHIP_SANDYBRIDGE_GT1:
+ case PCI_CHIP_SANDYBRIDGE_GT2:
+ case PCI_CHIP_SANDYBRIDGE_GT2_PLUS:
+ chipset = "Intel(R) Sandybridge Desktop";
+ break;
+ case PCI_CHIP_SANDYBRIDGE_M_GT1:
+ case PCI_CHIP_SANDYBRIDGE_M_GT2:
+ case PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS:
+ chipset = "Intel(R) Sandybridge Mobile";
+ break;
+ case PCI_CHIP_SANDYBRIDGE_S:
+ chipset = "Intel(R) Sandybridge Server";
+ break;
+ case PCI_CHIP_IVYBRIDGE_GT1:
+ case PCI_CHIP_IVYBRIDGE_GT2:
+ chipset = "Intel(R) Ivybridge Desktop";
+ break;
+ case PCI_CHIP_IVYBRIDGE_M_GT1:
+ case PCI_CHIP_IVYBRIDGE_M_GT2:
+ chipset = "Intel(R) Ivybridge Mobile";
+ break;
+ case PCI_CHIP_IVYBRIDGE_S_GT1:
+ case PCI_CHIP_IVYBRIDGE_S_GT2:
+ chipset = "Intel(R) Ivybridge Server";
+ break;
+ case PCI_CHIP_HASWELL_GT1:
+ case PCI_CHIP_HASWELL_GT2:
+ case PCI_CHIP_HASWELL_GT2_PLUS:
+ case PCI_CHIP_HASWELL_SDV_GT1:
+ case PCI_CHIP_HASWELL_SDV_GT2:
+ case PCI_CHIP_HASWELL_SDV_GT2_PLUS:
+ case PCI_CHIP_HASWELL_ULT_GT1:
+ case PCI_CHIP_HASWELL_ULT_GT2:
+ case PCI_CHIP_HASWELL_ULT_GT2_PLUS:
+ case PCI_CHIP_HASWELL_CRW_GT1:
+ case PCI_CHIP_HASWELL_CRW_GT2:
+ case PCI_CHIP_HASWELL_CRW_GT2_PLUS:
+ chipset = "Intel(R) Haswell Desktop";
+ break;
+ case PCI_CHIP_HASWELL_M_GT1:
+ case PCI_CHIP_HASWELL_M_GT2:
+ case PCI_CHIP_HASWELL_M_GT2_PLUS:
+ case PCI_CHIP_HASWELL_SDV_M_GT1:
+ case PCI_CHIP_HASWELL_SDV_M_GT2:
+ case PCI_CHIP_HASWELL_SDV_M_GT2_PLUS:
+ case PCI_CHIP_HASWELL_ULT_M_GT1:
+ case PCI_CHIP_HASWELL_ULT_M_GT2:
+ case PCI_CHIP_HASWELL_ULT_M_GT2_PLUS:
+ case PCI_CHIP_HASWELL_CRW_M_GT1:
+ case PCI_CHIP_HASWELL_CRW_M_GT2:
+ case PCI_CHIP_HASWELL_CRW_M_GT2_PLUS:
+ chipset = "Intel(R) Haswell Mobile";
+ break;
+ case PCI_CHIP_HASWELL_S_GT1:
+ case PCI_CHIP_HASWELL_S_GT2:
+ case PCI_CHIP_HASWELL_S_GT2_PLUS:
+ case PCI_CHIP_HASWELL_SDV_S_GT1:
+ case PCI_CHIP_HASWELL_SDV_S_GT2:
+ case PCI_CHIP_HASWELL_SDV_S_GT2_PLUS:
+ case PCI_CHIP_HASWELL_ULT_S_GT1:
+ case PCI_CHIP_HASWELL_ULT_S_GT2:
+ case PCI_CHIP_HASWELL_ULT_S_GT2_PLUS:
+ case PCI_CHIP_HASWELL_CRW_S_GT1:
+ case PCI_CHIP_HASWELL_CRW_S_GT2:
+ case PCI_CHIP_HASWELL_CRW_S_GT2_PLUS:
+ chipset = "Intel(R) Haswell Server";
+ break;
+ default:
+ chipset = "Unknown Intel Chipset";
+ break;
+ }
+
+ (void) driGetRendererString(buffer, chipset, 0);
+ return (GLubyte *) buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+void
+intel_downsample_for_dri2_flush(struct intel_context *intel,
+ __DRIdrawable *drawable)
+{
+ if (intel->gen < 6) {
+ /* MSAA is not supported, so don't waste time checking for
+ * a multisample buffer.
+ */
+ return;
+ }
+
+ struct gl_framebuffer *fb = drawable->driverPrivate;
+ struct intel_renderbuffer *rb;
+
+ /* Usually, only the back buffer will need to be downsampled. However,
+ * the front buffer will also need it if the user has rendered into it.
+ */
+ static const gl_buffer_index buffers[2] = {
+ BUFFER_BACK_LEFT,
+ BUFFER_FRONT_LEFT,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+ rb = intel_get_renderbuffer(fb, buffers[i]);
+ if (rb == NULL || rb->mt == NULL)
+ continue;
+ intel_miptree_downsample(intel, rb->mt);
+ }
+}
+
+static void
+intel_flush_front(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIcontext *driContext = intel->driContext;
+ __DRIdrawable *driDrawable = driContext->driDrawablePriv;
+ __DRIscreen *const screen = intel->intelScreen->driScrnPriv;
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer) && intel->front_buffer_dirty) {
+ if (screen->dri2.loader->flushFrontBuffer != NULL &&
+ driDrawable &&
+ driDrawable->loaderPrivate) {
+
+ /* Downsample before flushing FAKE_FRONT_LEFT to FRONT_LEFT.
+ *
+ * This potentially downsamples both front and back buffer. It
+ * is unnecessary to downsample the back, but harms nothing except
+ * performance. And no one cares about front-buffer render
+ * performance.
+ */
+ intel_downsample_for_dri2_flush(intel, driDrawable);
+
+ screen->dri2.loader->flushFrontBuffer(driDrawable,
+ driDrawable->loaderPrivate);
+
+ /* We set the dirty bit in intel_prepare_render() if we're
+ * front buffer rendering once we get there.
+ */
+ intel->front_buffer_dirty = false;
+ }
+ }
+}
+
+static unsigned
+intel_bits_per_pixel(const struct intel_renderbuffer *rb)
+{
+ return _mesa_get_format_bytes(intel_rb_format(rb)) * 8;
+}
+
+static void
+intel_query_dri2_buffers(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer **buffers,
+ int *count);
+
+static void
+intel_process_dri2_buffer(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer *buffer,
+ struct intel_renderbuffer *rb,
+ const char *buffer_name);
+
+void
+intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+ struct gl_framebuffer *fb = drawable->driverPrivate;
+ struct intel_renderbuffer *rb;
+ struct intel_context *intel = context->driverPrivate;
+ __DRIbuffer *buffers = NULL;
+ int i, count;
+ const char *region_name;
+
+ /* If we're rendering to the fake front buffer, make sure all the
+ * pending drawing has landed on the real front buffer. Otherwise
+ * when we eventually get to DRI2GetBuffersWithFormat the stale
+ * real front buffer contents will get copied to the new fake front
+ * buffer.
+ */
+ if (intel->is_front_buffer_rendering) {
+ intel_flush(&intel->ctx);
+ intel_flush_front(&intel->ctx);
+ }
+
+ /* Set this up front, so that in case our buffers get invalidated
+ * while we're getting new buffers, we don't clobber the stamp and
+ * thus ignore the invalidate. */
+ drawable->lastStamp = drawable->dri2.stamp;
+
+ if (unlikely(INTEL_DEBUG & DEBUG_DRI))
+ fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+ intel_query_dri2_buffers(intel, drawable, &buffers, &count);
+
+ if (buffers == NULL)
+ return;
+
+ for (i = 0; i < count; i++) {
+ switch (buffers[i].attachment) {
+ case __DRI_BUFFER_FRONT_LEFT:
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ region_name = "dri2 front buffer";
+ break;
+
+ case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ region_name = "dri2 fake front buffer";
+ break;
+
+ case __DRI_BUFFER_BACK_LEFT:
+ rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+ region_name = "dri2 back buffer";
+ break;
+
+ case __DRI_BUFFER_DEPTH:
+ case __DRI_BUFFER_HIZ:
+ case __DRI_BUFFER_DEPTH_STENCIL:
+ case __DRI_BUFFER_STENCIL:
+ case __DRI_BUFFER_ACCUM:
+ default:
+ fprintf(stderr,
+ "unhandled buffer attach event, attachment type %d\n",
+ buffers[i].attachment);
+ return;
+ }
+
+ intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
+ }
+
+ driUpdateFramebufferSize(&intel->ctx, drawable);
+}
+
+/**
+ * intel_prepare_render should be called anywhere that curent read/drawbuffer
+ * state is required.
+ */
+void
+intel_prepare_render(struct intel_context *intel)
+{
+ __DRIcontext *driContext = intel->driContext;
+ __DRIdrawable *drawable;
+
+ drawable = driContext->driDrawablePriv;
+ if (drawable && drawable->dri2.stamp != driContext->dri2.draw_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ intel_update_renderbuffers(driContext, drawable);
+ intel_draw_buffer(&intel->ctx);
+ driContext->dri2.draw_stamp = drawable->dri2.stamp;
+ }
+
+ drawable = driContext->driReadablePriv;
+ if (drawable && drawable->dri2.stamp != driContext->dri2.read_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ intel_update_renderbuffers(driContext, drawable);
+ driContext->dri2.read_stamp = drawable->dri2.stamp;
+ }
+
+ /* If we're currently rendering to the front buffer, the rendering
+ * that will happen next will probably dirty the front buffer. So
+ * mark it as dirty here.
+ */
+ if (intel->is_front_buffer_rendering)
+ intel->front_buffer_dirty = true;
+
+ /* Wait for the swapbuffers before the one we just emitted, so we
+ * don't get too many swaps outstanding for apps that are GPU-heavy
+ * but not CPU-heavy.
+ *
+ * We're using intelDRI2Flush (called from the loader before
+ * swapbuffer) and glFlush (for front buffer rendering) as the
+ * indicator that a frame is done and then throttle when we get
+ * here as we prepare to render the next frame. At this point for
+ * round trips for swap/copy and getting new buffers are done and
+ * we'll spend less time waiting on the GPU.
+ *
+ * Unfortunately, we don't have a handle to the batch containing
+ * the swap, and getting our hands on that doesn't seem worth it,
+ * so we just us the first batch we emitted after the last swap.
+ */
+ if (intel->need_throttle && intel->first_post_swapbuffers_batch) {
+ drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch);
+ drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
+ intel->first_post_swapbuffers_batch = NULL;
+ intel->need_throttle = false;
+ }
+}
+
+static void
+intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIcontext *driContext = intel->driContext;
+
+ if (intel->saved_viewport)
+ intel->saved_viewport(ctx, x, y, w, h);
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ dri2InvalidateDrawable(driContext->driDrawablePriv);
+ dri2InvalidateDrawable(driContext->driReadablePriv);
+ }
+}
+
+static const struct dri_debug_control debug_control[] = {
+ { "tex", DEBUG_TEXTURE},
+ { "state", DEBUG_STATE},
+ { "ioctl", DEBUG_IOCTL},
+ { "blit", DEBUG_BLIT},
+ { "mip", DEBUG_MIPTREE},
+ { "fall", DEBUG_PERF},
+ { "perf", DEBUG_PERF},
+ { "verb", DEBUG_VERBOSE},
+ { "bat", DEBUG_BATCH},
+ { "pix", DEBUG_PIXEL},
+ { "buf", DEBUG_BUFMGR},
+ { "reg", DEBUG_REGION},
+ { "fbo", DEBUG_FBO},
+ { "gs", DEBUG_GS},
+ { "sync", DEBUG_SYNC},
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "dri", DEBUG_DRI },
+ { "sf", DEBUG_SF },
+ { "san", DEBUG_SANITY },
+ { "sleep", DEBUG_SLEEP },
+ { "stats", DEBUG_STATS },
+ { "tile", DEBUG_TILE },
+ { "wm", DEBUG_WM },
+ { "urb", DEBUG_URB },
+ { "vs", DEBUG_VS },
+ { "clip", DEBUG_CLIP },
+ { "aub", DEBUG_AUB },
+ { NULL, 0 }
+};
+
+
+static void
+intelInvalidateState(struct gl_context * ctx, GLuint new_state)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ if (ctx->swrast_context)
+ _swrast_InvalidateState(ctx, new_state);
+ _vbo_InvalidateState(ctx, new_state);
+
+ intel->NewGLState |= new_state;
+
+ if (intel->vtbl.invalidate_state)
+ intel->vtbl.invalidate_state( intel, new_state );
+}
+
+void
+intel_flush_rendering_to_batch(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ if (intel->Fallback)
+ _swrast_flush(ctx);
+
+ if (intel->gen < 4)
+ INTEL_FIREVERTICES(intel);
+}
+
+void
+_intel_flush(struct gl_context *ctx, const char *file, int line)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush_rendering_to_batch(ctx);
+
+ if (intel->batch.used)
+ _intel_batchbuffer_flush(intel, file, line);
+}
+
+static void
+intel_glFlush(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush(ctx);
+ intel_flush_front(ctx);
+ if (intel->is_front_buffer_rendering)
+ intel->need_throttle = true;
+}
+
+void
+intelFinish(struct gl_context * ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush(ctx);
+ intel_flush_front(ctx);
+
+ if (intel->batch.last_bo)
+ drm_intel_bo_wait_rendering(intel->batch.last_bo);
+}
+
+void
+intelInitDriverFunctions(struct dd_function_table *functions)
+{
+ _mesa_init_driver_functions(functions);
+
+ functions->Flush = intel_glFlush;
+ functions->Finish = intelFinish;
+ functions->GetString = intelGetString;
+ functions->UpdateState = intelInvalidateState;
+
+ intelInitTextureFuncs(functions);
+ intelInitTextureImageFuncs(functions);
+ intelInitTextureSubImageFuncs(functions);
+ intelInitTextureCopyImageFuncs(functions);
+ intelInitClearFuncs(functions);
+ intelInitBufferFuncs(functions);
+ intelInitPixelFuncs(functions);
+ intelInitBufferObjectFuncs(functions);
+ intel_init_syncobj_functions(functions);
+}
+
+bool
+intelInitContext(struct intel_context *intel,
+ int api,
+ const struct gl_config * mesaVis,
+ __DRIcontext * driContextPriv,
+ void *sharedContextPrivate,
+ struct dd_function_table *functions)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate;
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+ struct intel_screen *intelScreen = sPriv->driverPrivate;
+ int bo_reuse_mode;
+ struct gl_config visual;
+
+ /* we can't do anything without a connection to the device */
+ if (intelScreen->bufmgr == NULL)
+ return false;
+
+ /* Can't rely on invalidate events, fall back to glViewport hack */
+ if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
+ intel->saved_viewport = functions->Viewport;
+ functions->Viewport = intel_viewport;
+ }
+
+ if (mesaVis == NULL) {
+ memset(&visual, 0, sizeof visual);
+ mesaVis = &visual;
+ }
+
+ if (!_mesa_initialize_context(&intel->ctx, api, mesaVis, shareCtx,
+ functions, (void *) intel)) {
+ printf("%s: failed to init mesa context\n", __FUNCTION__);
+ return false;
+ }
+
+ driContextPriv->driverPrivate = intel;
+ intel->intelScreen = intelScreen;
+ intel->driContext = driContextPriv;
+ intel->driFd = sPriv->fd;
+
+ intel->gen = intelScreen->gen;
+
+ const int devID = intelScreen->deviceID;
+ if (IS_SNB_GT1(devID) || IS_IVB_GT1(devID) || IS_HSW_GT1(devID))
+ intel->gt = 1;
+ else if (IS_SNB_GT2(devID) || IS_IVB_GT2(devID) || IS_HSW_GT2(devID))
+ intel->gt = 2;
+ else
+ intel->gt = 0;
+
+ if (IS_HASWELL(devID)) {
+ intel->is_haswell = true;
+ } else if (IS_G4X(devID)) {
+ intel->is_g4x = true;
+ } else if (IS_945(devID)) {
+ intel->is_945 = true;
+ }
+
+ if (intel->gen >= 5) {
+ intel->needs_ff_sync = true;
+ }
+
+ intel->has_separate_stencil = intel->intelScreen->hw_has_separate_stencil;
+ intel->must_use_separate_stencil = intel->intelScreen->hw_must_use_separate_stencil;
+ intel->has_hiz = intel->gen >= 6 && !intel->is_haswell;
+ intel->has_llc = intel->intelScreen->hw_has_llc;
+ intel->has_swizzling = intel->intelScreen->hw_has_swizzling;
+
+ memset(&ctx->TextureFormatSupported,
+ 0, sizeof(ctx->TextureFormatSupported));
+
+ driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
+ sPriv->myNum, (intel->gen >= 4) ? "i965" : "i915");
+ if (intel->gen < 4)
+ intel->maxBatchSize = 4096;
+ else
+ intel->maxBatchSize = sizeof(intel->batch.map);
+
+ intel->bufmgr = intelScreen->bufmgr;
+
+ bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+ switch (bo_reuse_mode) {
+ case DRI_CONF_BO_REUSE_DISABLED:
+ break;
+ case DRI_CONF_BO_REUSE_ALL:
+ intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+ break;
+ }
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 5.0;
+ ctx->Const.MaxLineWidthAA = 5.0;
+ ctx->Const.LineWidthGranularity = 0.5;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 255.0;
+ ctx->Const.MaxPointSizeAA = 3.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ ctx->Const.MaxSamples = 1.0;
+
+ if (intel->gen >= 6)
+ ctx->Const.MaxClipPlanes = 8;
+
+ ctx->Const.StripTextureBorder = GL_TRUE;
+
+ /* reinitialize the context point state.
+ * It depend on constants in __struct gl_contextRec::Const
+ */
+ _mesa_init_point(ctx);
+
+ if (intel->gen >= 4) {
+ ctx->Const.MaxRenderbufferSize = 8192;
+ } else {
+ ctx->Const.MaxRenderbufferSize = 2048;
+ }
+
+ /* Initialize the software rasterizer and helper modules.
+ *
+ * As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
+ * software fallbacks (which we have to support on legacy GL to do weird
+ * glDrawPixels(), glBitmap(), and other functions).
+ */
+ if (intel->gen <= 3 || api != API_OPENGL_CORE) {
+ _swrast_CreateContext(ctx);
+ }
+
+ _vbo_CreateContext(ctx);
+ if (ctx->swrast_context) {
+ _tnl_CreateContext(ctx);
+ _swsetup_CreateContext(ctx);
+
+ /* Configure swrast to match hardware characteristics: */
+ _swrast_allow_pixel_fog(ctx, false);
+ _swrast_allow_vertex_fog(ctx, true);
+ }
+
+ _mesa_meta_init(ctx);
+
+ intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+ intel->hw_stipple = 1;
+
+ /* XXX FBO: this doesn't seem to be used anywhere */
+ switch (mesaVis->depthBits) {
+ case 0: /* what to do in this case? */
+ case 16:
+ intel->polygon_offset_scale = 1.0;
+ break;
+ case 24:
+ intel->polygon_offset_scale = 2.0; /* req'd to pass glean */
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ if (intel->gen >= 4)
+ intel->polygon_offset_scale /= 0xffff;
+
+ intel->RenderIndex = ~0;
+
+ intelInitExtensions(ctx);
+
+ INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
+ if (INTEL_DEBUG & DEBUG_BUFMGR)
+ dri_bufmgr_set_debug(intel->bufmgr, true);
+
+ if (INTEL_DEBUG & DEBUG_AUB)
+ drm_intel_bufmgr_gem_set_aub_dump(intel->bufmgr, true);
+
+ intel_batchbuffer_init(intel);
+
+ intel_fbo_init(intel);
+
+ intel->use_texture_tiling = driQueryOptionb(&intel->optionCache,
+ "texture_tiling");
+ intel->use_early_z = driQueryOptionb(&intel->optionCache, "early_z");
+
+ if (!driQueryOptionb(&intel->optionCache, "hiz")) {
+ intel->has_hiz = false;
+ /* On gen6, you can only do separate stencil with HIZ. */
+ if (intel->gen == 6)
+ intel->has_separate_stencil = false;
+ }
+
+ intel->prim.primitive = ~0;
+
+ /* Force all software fallbacks */
+#ifdef I915
+ if (driQueryOptionb(&intel->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D rasterization\n");
+ intel->no_rast = 1;
+ }
+#endif
+
+ if (driQueryOptionb(&intel->optionCache, "always_flush_batch")) {
+ fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
+ intel->always_flush_batch = 1;
+ }
+
+ if (driQueryOptionb(&intel->optionCache, "always_flush_cache")) {
+ fprintf(stderr, "flushing GPU caches before/after each draw call\n");
+ intel->always_flush_cache = 1;
+ }
+
+ return true;
+}
+
+void
+intelDestroyContext(__DRIcontext * driContextPriv)
+{
+ struct intel_context *intel =
+ (struct intel_context *) driContextPriv->driverPrivate;
+ struct gl_context *ctx = &intel->ctx;
+
+ assert(intel); /* should never be null */
+ if (intel) {
+ INTEL_FIREVERTICES(intel);
+
+ /* Dump a final BMP in case the application doesn't call SwapBuffers */
+ if (INTEL_DEBUG & DEBUG_AUB) {
+ intel_batchbuffer_flush(intel);
+ aub_dump_bmp(&intel->ctx);
+ }
+
+ _mesa_meta_free(&intel->ctx);
+
+ intel->vtbl.destroy(intel);
+
+ if (ctx->swrast_context) {
+ _swsetup_DestroyContext(&intel->ctx);
+ _tnl_DestroyContext(&intel->ctx);
+ }
+ _vbo_DestroyContext(&intel->ctx);
+
+ if (ctx->swrast_context)
+ _swrast_DestroyContext(&intel->ctx);
+ intel->Fallback = 0x0; /* don't call _swrast_Flush later */
+
+ intel_batchbuffer_free(intel);
+
+ free(intel->prim.vb);
+ intel->prim.vb = NULL;
+ drm_intel_bo_unreference(intel->prim.vb_bo);
+ intel->prim.vb_bo = NULL;
+ drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
+ intel->first_post_swapbuffers_batch = NULL;
+
+ driDestroyOptionCache(&intel->optionCache);
+
+ /* free the Mesa context */
+ _mesa_free_context_data(&intel->ctx);
+
+ _math_matrix_dtr(&intel->ViewportMatrix);
+
+ ralloc_free(intel);
+ driContextPriv->driverPrivate = NULL;
+ }
+}
+
+GLboolean
+intelUnbindContext(__DRIcontext * driContextPriv)
+{
+ /* Unset current context and dispath table */
+ _mesa_make_current(NULL, NULL, NULL);
+
+ return true;
+}
+
+GLboolean
+intelMakeCurrent(__DRIcontext * driContextPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv)
+{
+ struct intel_context *intel;
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if (driContextPriv)
+ intel = (struct intel_context *) driContextPriv->driverPrivate;
+ else
+ intel = NULL;
+
+ /* According to the glXMakeCurrent() man page: "Pending commands to
+ * the previous context, if any, are flushed before it is released."
+ * But only flush if we're actually changing contexts.
+ */
+ if (intel_context(curCtx) && intel_context(curCtx) != intel) {
+ _mesa_flush(curCtx);
+ }
+
+ if (driContextPriv) {
+ struct gl_framebuffer *fb, *readFb;
+
+ if (driDrawPriv == NULL && driReadPriv == NULL) {
+ fb = _mesa_get_incomplete_framebuffer();
+ readFb = _mesa_get_incomplete_framebuffer();
+ } else {
+ fb = driDrawPriv->driverPrivate;
+ readFb = driReadPriv->driverPrivate;
+ driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
+ driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
+ }
+
+ intel_prepare_render(intel);
+ _mesa_make_current(&intel->ctx, fb, readFb);
+
+ /* We do this in intel_prepare_render() too, but intel->ctx.DrawBuffer
+ * is NULL at that point. We can't call _mesa_makecurrent()
+ * first, since we need the buffer size for the initial
+ * viewport. So just call intel_draw_buffer() again here. */
+ intel_draw_buffer(&intel->ctx);
+ }
+ else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return true;
+}
+
+/**
+ * \brief Query DRI2 to obtain a DRIdrawable's buffers.
+ *
+ * To determine which DRI buffers to request, examine the renderbuffers
+ * attached to the drawable's framebuffer. Then request the buffers with
+ * DRI2GetBuffers() or DRI2GetBuffersWithFormat().
+ *
+ * This is called from intel_update_renderbuffers().
+ *
+ * \param drawable Drawable whose buffers are queried.
+ * \param buffers [out] List of buffers returned by DRI2 query.
+ * \param buffer_count [out] Number of buffers returned.
+ *
+ * \see intel_update_renderbuffers()
+ * \see DRI2GetBuffers()
+ * \see DRI2GetBuffersWithFormat()
+ */
+static void
+intel_query_dri2_buffers(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer **buffers,
+ int *buffer_count)
+{
+ __DRIscreen *screen = intel->intelScreen->driScrnPriv;
+ struct gl_framebuffer *fb = drawable->driverPrivate;
+ int i = 0;
+ const int max_attachments = 4;
+ unsigned *attachments = calloc(2 * max_attachments, sizeof(unsigned));
+
+ struct intel_renderbuffer *front_rb;
+ struct intel_renderbuffer *back_rb;
+
+ front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+
+ if ((intel->is_front_buffer_rendering ||
+ intel->is_front_buffer_reading ||
+ !back_rb) && front_rb) {
+ attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ attachments[i++] = intel_bits_per_pixel(front_rb);
+ }
+
+ if (back_rb) {
+ attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ attachments[i++] = intel_bits_per_pixel(back_rb);
+ }
+
+ assert(i <= 2 * max_attachments);
+
+ *buffers = screen->dri2.loader->getBuffersWithFormat(drawable,
+ &drawable->w,
+ &drawable->h,
+ attachments, i / 2,
+ buffer_count,
+ drawable->loaderPrivate);
+ free(attachments);
+}
+
+/**
+ * \brief Assign a DRI buffer's DRM region to a renderbuffer.
+ *
+ * This is called from intel_update_renderbuffers().
+ *
+ * \par Note:
+ * DRI buffers whose attachment point is DRI2BufferStencil or
+ * DRI2BufferDepthStencil are handled as special cases.
+ *
+ * \param buffer_name is a human readable name, such as "dri2 front buffer",
+ * that is passed to intel_region_alloc_for_handle().
+ *
+ * \see intel_update_renderbuffers()
+ * \see intel_region_alloc_for_handle()
+ */
+static void
+intel_process_dri2_buffer(struct intel_context *intel,
+ __DRIdrawable *drawable,
+ __DRIbuffer *buffer,
+ struct intel_renderbuffer *rb,
+ const char *buffer_name)
+{
+ struct intel_region *region = NULL;
+
+ if (!rb)
+ return;
+
+ unsigned num_samples = rb->Base.Base.NumSamples;
+
+ /* We try to avoid closing and reopening the same BO name, because the first
+ * use of a mapping of the buffer involves a bunch of page faulting which is
+ * moderately expensive.
+ */
+ if (num_samples == 0) {
+ if (rb->mt &&
+ rb->mt->region &&
+ rb->mt->region->name == buffer->name)
+ return;
+ } else {
+ if (rb->mt &&
+ rb->mt->singlesample_mt &&
+ rb->mt->singlesample_mt->region &&
+ rb->mt->singlesample_mt->region->name == buffer->name)
+ return;
+ }
+
+ if (unlikely(INTEL_DEBUG & DEBUG_DRI)) {
+ fprintf(stderr,
+ "attaching buffer %d, at %d, cpp %d, pitch %d\n",
+ buffer->name, buffer->attachment,
+ buffer->cpp, buffer->pitch);
+ }
+
+ intel_miptree_release(&rb->mt);
+ region = intel_region_alloc_for_handle(intel->intelScreen,
+ buffer->cpp,
+ drawable->w,
+ drawable->h,
+ buffer->pitch / buffer->cpp,
+ buffer->name,
+ buffer_name);
+ if (!region)
+ return;
+
+ rb->mt = intel_miptree_create_for_dri2_buffer(intel,
+ buffer->attachment,
+ intel_rb_format(rb),
+ num_samples,
+ region);
+ intel_region_release(&region);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_extensions.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_extensions.c
index a2f3e8cd208..885e8a43e80 120000..100755
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -1 +1,197 @@
-../intel/intel_extensions.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mfeatures.h"
+#include "main/version.h"
+
+#include "intel_chipset.h"
+#include "intel_context.h"
+#include "intel_extensions.h"
+#include "intel_reg.h"
+#include "utils.h"
+
+/**
+ * Initializes potential list of extensions if ctx == NULL, or actually enables
+ * extensions for a context.
+ */
+void
+intelInitExtensions(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ ctx->Extensions.ARB_draw_elements_base_vertex = true;
+ ctx->Extensions.ARB_explicit_attrib_location = true;
+ if (_mesa_is_desktop_gl(ctx))
+ ctx->Extensions.ARB_framebuffer_object = true;
+ ctx->Extensions.ARB_half_float_pixel = true;
+ ctx->Extensions.ARB_map_buffer_range = true;
+ ctx->Extensions.ARB_point_sprite = true;
+ ctx->Extensions.ARB_shader_objects = true;
+ ctx->Extensions.ARB_shading_language_100 = true;
+ ctx->Extensions.ARB_sync = true;
+ ctx->Extensions.ARB_texture_border_clamp = true;
+ ctx->Extensions.ARB_texture_cube_map = true;
+ ctx->Extensions.ARB_texture_env_combine = true;
+ ctx->Extensions.ARB_texture_env_crossbar = true;
+ ctx->Extensions.ARB_texture_env_dot3 = true;
+ ctx->Extensions.ARB_texture_storage = true;
+ ctx->Extensions.ARB_vertex_program = true;
+ ctx->Extensions.ARB_vertex_shader = true;
+ ctx->Extensions.EXT_blend_color = true;
+ ctx->Extensions.EXT_blend_equation_separate = true;
+ ctx->Extensions.EXT_blend_func_separate = true;
+ ctx->Extensions.EXT_blend_minmax = true;
+ ctx->Extensions.EXT_framebuffer_blit = true;
+ ctx->Extensions.EXT_framebuffer_object = true;
+ ctx->Extensions.EXT_framebuffer_multisample = true;
+ ctx->Extensions.EXT_fog_coord = true;
+ ctx->Extensions.EXT_gpu_program_parameters = true;
+ ctx->Extensions.EXT_packed_depth_stencil = true;
+ ctx->Extensions.EXT_pixel_buffer_object = true;
+ ctx->Extensions.EXT_point_parameters = true;
+ ctx->Extensions.EXT_provoking_vertex = true;
+ ctx->Extensions.EXT_secondary_color = true;
+ ctx->Extensions.EXT_separate_shader_objects = true;
+ ctx->Extensions.EXT_texture_env_dot3 = true;
+ ctx->Extensions.EXT_texture_filter_anisotropic = true;
+ ctx->Extensions.APPLE_object_purgeable = true;
+ ctx->Extensions.MESA_pack_invert = true;
+ ctx->Extensions.MESA_ycbcr_texture = true;
+ ctx->Extensions.NV_blend_square = true;
+ ctx->Extensions.NV_texture_rectangle = true;
+ ctx->Extensions.NV_vertex_program = true;
+ ctx->Extensions.NV_vertex_program1_1 = true;
+ ctx->Extensions.TDFX_texture_compression_FXT1 = true;
+#if FEATURE_OES_EGL_image
+ ctx->Extensions.OES_EGL_image = true;
+#endif
+ ctx->Extensions.OES_draw_texture = true;
+ ctx->Extensions.OES_compressed_ETC1_RGB8_texture = true;
+ ctx->Extensions.ARB_texture_rgb10_a2ui = true;
+
+ if (intel->gen >= 6)
+ if (ctx->API == API_OPENGL_CORE) {
+ ctx->Const.GLSLVersion = 140;
+ } else {
+ ctx->Const.GLSLVersion = 130;
+ }
+ else
+ ctx->Const.GLSLVersion = 120;
+ _mesa_override_glsl_version(ctx);
+
+ if (intel->gen == 6 ||
+ (intel->gen == 7 && intel->intelScreen->kernel_has_gen7_sol_reset))
+ ctx->Extensions.EXT_transform_feedback = true;
+
+ if (intel->gen >= 6) {
+ ctx->Extensions.ARB_blend_func_extended = !driQueryOptionb(&intel->optionCache, "disable_blend_func_extended");
+ ctx->Extensions.ARB_draw_buffers_blend = true;
+ ctx->Extensions.ARB_uniform_buffer_object = true;
+
+ if (ctx->API == API_OPENGL_CORE) {
+ ctx->Extensions.ARB_texture_buffer_object = true;
+ }
+ }
+
+ if (intel->gen >= 5)
+ ctx->Extensions.EXT_timer_query = true;
+
+ if (intel->gen >= 6) {
+ uint64_t dummy;
+ /* Test if the kernel has the ioctl. */
+ if (drm_intel_reg_read(intel->bufmgr, TIMESTAMP, &dummy) == 0)
+ ctx->Extensions.ARB_timer_query = true;
+ }
+
+ if (intel->gen >= 4) {
+ ctx->Extensions.ARB_color_buffer_float = true;
+ ctx->Extensions.ARB_depth_buffer_float = true;
+ ctx->Extensions.ARB_depth_clamp = true;
+ ctx->Extensions.ARB_draw_instanced = true;
+ ctx->Extensions.ARB_instanced_arrays = true;
+ ctx->Extensions.ARB_fragment_coord_conventions = true;
+ ctx->Extensions.ARB_fragment_program_shadow = true;
+ ctx->Extensions.ARB_fragment_shader = true;
+ ctx->Extensions.ARB_half_float_vertex = true;
+ ctx->Extensions.ARB_occlusion_query = true;
+ ctx->Extensions.ARB_occlusion_query2 = true;
+ ctx->Extensions.ARB_point_sprite = true;
+ ctx->Extensions.ARB_seamless_cube_map = true;
+ ctx->Extensions.ARB_shader_bit_encoding = true;
+ ctx->Extensions.ARB_shader_texture_lod = true;
+#ifdef TEXTURE_FLOAT_ENABLED
+ ctx->Extensions.ARB_texture_float = true;
+ ctx->Extensions.EXT_texture_shared_exponent = true;
+ ctx->Extensions.EXT_packed_float = true;
+#endif
+ ctx->Extensions.ARB_texture_compression_rgtc = true;
+ ctx->Extensions.ARB_texture_rg = true;
+ ctx->Extensions.EXT_draw_buffers2 = true;
+ ctx->Extensions.EXT_framebuffer_sRGB = true;
+ ctx->Extensions.EXT_texture_array = true;
+ ctx->Extensions.EXT_texture_integer = true;
+ ctx->Extensions.EXT_texture_snorm = true;
+ ctx->Extensions.EXT_texture_sRGB = true;
+ ctx->Extensions.EXT_texture_sRGB_decode = true;
+ ctx->Extensions.EXT_texture_swizzle = true;
+ ctx->Extensions.EXT_vertex_array_bgra = true;
+ ctx->Extensions.ATI_envmap_bumpmap = true;
+ ctx->Extensions.MESA_texture_array = true;
+ ctx->Extensions.NV_conditional_render = true;
+ }
+
+ if (intel->gen >= 3) {
+ ctx->Extensions.ARB_ES2_compatibility = true;
+ ctx->Extensions.ARB_depth_texture = true;
+ ctx->Extensions.ARB_fragment_program = true;
+ ctx->Extensions.ARB_shadow = true;
+ ctx->Extensions.ARB_texture_non_power_of_two = true;
+ ctx->Extensions.EXT_shadow_funcs = true;
+ ctx->Extensions.EXT_stencil_two_side = true;
+ ctx->Extensions.ATI_separate_stencil = true;
+ ctx->Extensions.ATI_texture_env_combine3 = true;
+ ctx->Extensions.NV_texture_env_combine4 = true;
+
+ if (driQueryOptionb(&intel->optionCache, "fragment_shader"))
+ ctx->Extensions.ARB_fragment_shader = true;
+
+ if (driQueryOptionb(&intel->optionCache, "stub_occlusion_query"))
+ ctx->Extensions.ARB_occlusion_query = true;
+ }
+
+ if (intel->ctx.Mesa_DXTn) {
+ ctx->Extensions.EXT_texture_compression_s3tc = true;
+ ctx->Extensions.S3_s3tc = true;
+ }
+ else if (driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) {
+ ctx->Extensions.EXT_texture_compression_s3tc = true;
+ }
+
+ if (intel->gen >= 4) {
+ ctx->Extensions.NV_primitive_restart = true;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_fbo.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_fbo.c
index a19f86dcc57..65494a2d506 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_fbo.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_fbo.c
@@ -1 +1,964 @@
-../intel/intel_fbo.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/enums.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/context.h"
+#include "main/teximage.h"
+#include "main/image.h"
+
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
+#include "intel_blit.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_tex.h"
+#include "intel_span.h"
+#ifndef I915
+#include "brw_context.h"
+#endif
+
+#define FILE_DEBUG_FLAG DEBUG_FBO
+
+static struct gl_renderbuffer *
+intel_new_renderbuffer(struct gl_context * ctx, GLuint name);
+
+struct intel_region*
+intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
+{
+ struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, attIndex);
+ if (irb && irb->mt) {
+ if (attIndex == BUFFER_STENCIL && irb->mt->stencil_mt)
+ return irb->mt->stencil_mt->region;
+ else
+ return irb->mt->region;
+ } else
+ return NULL;
+}
+
+/**
+ * Create a new framebuffer object.
+ */
+static struct gl_framebuffer *
+intel_new_framebuffer(struct gl_context * ctx, GLuint name)
+{
+ /* Only drawable state in intel_framebuffer at this time, just use Mesa's
+ * class
+ */
+ return _mesa_new_framebuffer(ctx, name);
+}
+
+
+/** Called by gl_renderbuffer::Delete() */
+static void
+intel_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+ ASSERT(irb);
+
+ intel_miptree_release(&irb->mt);
+
+ _mesa_delete_renderbuffer(ctx, rb);
+}
+
+/**
+ * \see dd_function_table::MapRenderbuffer
+ */
+static void
+intel_map_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+ void *map;
+ int stride;
+
+ if (srb->Buffer) {
+ /* this is a malloc'd renderbuffer (accum buffer), not an irb */
+ GLint bpp = _mesa_get_format_bytes(rb->Format);
+ GLint rowStride = srb->RowStride;
+ *out_map = (GLubyte *) srb->Buffer + y * rowStride + x * bpp;
+ *out_stride = rowStride;
+ return;
+ }
+
+ /* We sometimes get called with this by our intel_span.c usage. */
+ if (!irb->mt) {
+ *out_map = NULL;
+ *out_stride = 0;
+ return;
+ }
+
+ /* For a window-system renderbuffer, we need to flip the mapping we receive
+ * upside-down. So we need to ask for a rectangle on flipped vertically, and
+ * we then return a pointer to the bottom of it with a negative stride.
+ */
+ if (rb->Name == 0) {
+ y = rb->Height - y - h;
+ }
+
+ intel_miptree_map(intel, irb->mt, irb->mt_level, irb->mt_layer,
+ x, y, w, h, mode, &map, &stride);
+
+ if (rb->Name == 0) {
+ map += (h - 1) * stride;
+ stride = -stride;
+ }
+
+ DBG("%s: rb %d (%s) mt mapped: (%d, %d) (%dx%d) -> %p/%d\n",
+ __FUNCTION__, rb->Name, _mesa_get_format_name(rb->Format),
+ x, y, w, h, map, stride);
+
+ *out_map = map;
+ *out_stride = stride;
+}
+
+/**
+ * \see dd_function_table::UnmapRenderbuffer
+ */
+static void
+intel_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+ DBG("%s: rb %d (%s)\n", __FUNCTION__,
+ rb->Name, _mesa_get_format_name(rb->Format));
+
+ if (srb->Buffer) {
+ /* this is a malloc'd renderbuffer (accum buffer) */
+ /* nothing to do */
+ return;
+ }
+
+ intel_miptree_unmap(intel, irb->mt, irb->mt_level, irb->mt_layer);
+}
+
+
+/**
+ * Round up the requested multisample count to the next supported sample size.
+ */
+unsigned
+intel_quantize_num_samples(struct intel_screen *intel, unsigned num_samples)
+{
+ switch (intel->gen) {
+ case 6:
+ /* Gen6 supports only 4x multisampling. */
+ if (num_samples > 0)
+ return 4;
+ else
+ return 0;
+ case 7:
+ /* Gen7 supports 4x and 8x multisampling. */
+ if (num_samples > 4)
+ return 8;
+ else if (num_samples > 0)
+ return 4;
+ else
+ return 0;
+ return 0;
+ default:
+ /* MSAA unsupported. However, a careful reading of
+ * EXT_framebuffer_multisample reveals that we need to permit
+ * num_samples to be 1 (since num_samples is permitted to be as high as
+ * GL_MAX_SAMPLES, and GL_MAX_SAMPLES must be at least 1). Since
+ * platforms before Gen6 don't support MSAA, this is safe, because
+ * multisampling won't happen anyhow.
+ */
+ if (num_samples > 0)
+ return 1;
+ return 0;
+ }
+}
+
+
+/**
+ * Called via glRenderbufferStorageEXT() to set the format and allocate
+ * storage for a user-created renderbuffer.
+ */
+GLboolean
+intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width, GLuint height)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_screen *screen = intel->intelScreen;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+ rb->NumSamples = intel_quantize_num_samples(screen, rb->NumSamples);
+
+ switch (internalFormat) {
+ default:
+ /* Use the same format-choice logic as for textures.
+ * Renderbuffers aren't any different from textures for us,
+ * except they're less useful because you can't texture with
+ * them.
+ */
+ rb->Format = intel->ctx.Driver.ChooseTextureFormat(ctx, GL_TEXTURE_2D,
+ internalFormat,
+ GL_NONE, GL_NONE);
+ break;
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ /* These aren't actual texture formats, so force them here. */
+ if (intel->has_separate_stencil) {
+ rb->Format = MESA_FORMAT_S8;
+ } else {
+ assert(!intel->must_use_separate_stencil);
+ rb->Format = MESA_FORMAT_S8_Z24;
+ }
+ break;
+ }
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
+ intel_miptree_release(&irb->mt);
+
+ DBG("%s: %s: %s (%dx%d)\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(internalFormat),
+ _mesa_get_format_name(rb->Format), width, height);
+
+ if (width == 0 || height == 0)
+ return true;
+
+ irb->mt = intel_miptree_create_for_renderbuffer(intel, rb->Format,
+ width, height,
+ rb->NumSamples);
+ if (!irb->mt)
+ return false;
+
+ return true;
+}
+
+
+#if FEATURE_OES_EGL_image
+static void
+intel_image_target_renderbuffer_storage(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ void *image_handle)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_renderbuffer *irb;
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = intel->intelScreen->driScrnPriv;
+ image = screen->dri2.image->lookupEGLImage(screen, image_handle,
+ screen->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ /* __DRIimage is opaque to the core so it has to be checked here */
+ switch (image->format) {
+ case MESA_FORMAT_RGBA8888_REV:
+ _mesa_error(&intel->ctx, GL_INVALID_OPERATION,
+ "glEGLImageTargetRenderbufferStorage(unsupported image format");
+ return;
+ break;
+ default:
+ break;
+ }
+
+ irb = intel_renderbuffer(rb);
+ intel_miptree_release(&irb->mt);
+ irb->mt = intel_miptree_create_for_region(intel,
+ GL_TEXTURE_2D,
+ image->format,
+ image->region);
+ if (!irb->mt)
+ return;
+
+ rb->InternalFormat = image->internal_format;
+ rb->Width = image->region->width;
+ rb->Height = image->region->height;
+ rb->Format = image->format;
+ rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
+ image->internal_format);
+}
+#endif
+
+/**
+ * Called for each hardware renderbuffer when a _window_ is resized.
+ * Just update fields.
+ * Not used for user-created renderbuffers!
+ */
+static GLboolean
+intel_alloc_window_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ ASSERT(rb->Name == 0);
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return true;
+}
+
+
+static void
+intel_resize_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint width, GLuint height)
+{
+ int i;
+
+ _mesa_resize_framebuffer(ctx, fb, width, height);
+
+ fb->Initialized = true; /* XXX remove someday */
+
+ if (_mesa_is_user_fbo(fb)) {
+ return;
+ }
+
+
+ /* Make sure all window system renderbuffers are up to date */
+ for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
+ struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+
+ /* only resize if size is changing */
+ if (rb && (rb->Width != width || rb->Height != height)) {
+ rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
+ }
+ }
+}
+
+
+/** Dummy function for gl_renderbuffer::AllocStorage() */
+static GLboolean
+intel_nop_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ _mesa_problem(ctx, "intel_op_alloc_storage should never be called.");
+ return false;
+}
+
+/**
+ * Create a new intel_renderbuffer which corresponds to an on-screen window,
+ * not a user-created renderbuffer.
+ *
+ * \param num_samples must be quantized.
+ */
+struct intel_renderbuffer *
+intel_create_renderbuffer(gl_format format, unsigned num_samples)
+{
+ struct intel_renderbuffer *irb;
+ struct gl_renderbuffer *rb;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ irb = CALLOC_STRUCT(intel_renderbuffer);
+ if (!irb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+ return NULL;
+ }
+
+ rb = &irb->Base.Base;
+
+ _mesa_init_renderbuffer(rb, 0);
+ rb->ClassID = INTEL_RB_CLASS;
+ rb->_BaseFormat = _mesa_get_format_base_format(format);
+ rb->Format = format;
+ rb->InternalFormat = rb->_BaseFormat;
+ rb->NumSamples = num_samples;
+
+ /* intel-specific methods */
+ rb->Delete = intel_delete_renderbuffer;
+ rb->AllocStorage = intel_alloc_window_storage;
+
+ return irb;
+}
+
+/**
+ * Private window-system buffers (as opposed to ones shared with the display
+ * server created with intel_create_renderbuffer()) are most similar in their
+ * handling to user-created renderbuffers, but they have a resize handler that
+ * may be called at intel_update_renderbuffers() time.
+ *
+ * \param num_samples must be quantized.
+ */
+struct intel_renderbuffer *
+intel_create_private_renderbuffer(gl_format format, unsigned num_samples)
+{
+ struct intel_renderbuffer *irb;
+
+ irb = intel_create_renderbuffer(format, num_samples);
+ irb->Base.Base.AllocStorage = intel_alloc_renderbuffer_storage;
+
+ return irb;
+}
+
+/**
+ * Create a new renderbuffer object.
+ * Typically called via glBindRenderbufferEXT().
+ */
+static struct gl_renderbuffer *
+intel_new_renderbuffer(struct gl_context * ctx, GLuint name)
+{
+ /*struct intel_context *intel = intel_context(ctx); */
+ struct intel_renderbuffer *irb;
+ struct gl_renderbuffer *rb;
+
+ irb = CALLOC_STRUCT(intel_renderbuffer);
+ if (!irb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+ return NULL;
+ }
+
+ rb = &irb->Base.Base;
+
+ _mesa_init_renderbuffer(rb, name);
+ rb->ClassID = INTEL_RB_CLASS;
+
+ /* intel-specific methods */
+ rb->Delete = intel_delete_renderbuffer;
+ rb->AllocStorage = intel_alloc_renderbuffer_storage;
+ /* span routines set in alloc_storage function */
+
+ return rb;
+}
+
+
+/**
+ * Called via glBindFramebufferEXT().
+ */
+static void
+intel_bind_framebuffer(struct gl_context * ctx, GLenum target,
+ struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
+{
+ if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
+ intel_draw_buffer(ctx);
+ }
+ else {
+ /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
+ }
+}
+
+
+/**
+ * Called via glFramebufferRenderbufferEXT().
+ */
+static void
+intel_framebuffer_renderbuffer(struct gl_context * ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment, struct gl_renderbuffer *rb)
+{
+ DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ intel_draw_buffer(ctx);
+}
+
+/**
+ * \par Special case for separate stencil
+ *
+ * When wrapping a depthstencil texture that uses separate stencil, this
+ * function is recursively called twice: once to create \c
+ * irb->wrapped_depth and again to create \c irb->wrapped_stencil. On the
+ * call to create \c irb->wrapped_depth, the \c format and \c
+ * internal_format parameters do not match \c mt->format. In that case, \c
+ * mt->format is MESA_FORMAT_S8_Z24 and \c format is \c
+ * MESA_FORMAT_X8_Z24.
+ *
+ * @return true on success
+ */
+
+static bool
+intel_renderbuffer_update_wrapper(struct intel_context *intel,
+ struct intel_renderbuffer *irb,
+ struct gl_texture_image *image,
+ uint32_t layer)
+{
+ struct gl_renderbuffer *rb = &irb->Base.Base;
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+ int level = image->Level;
+
+ rb->Format = image->TexFormat;
+ rb->InternalFormat = image->InternalFormat;
+ rb->_BaseFormat = image->_BaseFormat;
+ rb->Width = mt->level[level].width;
+ rb->Height = mt->level[level].height;
+
+ rb->Delete = intel_delete_renderbuffer;
+ rb->AllocStorage = intel_nop_alloc_storage;
+
+ intel_miptree_check_level_layer(mt, level, layer);
+ irb->mt_level = level;
+ irb->mt_layer = layer;
+
+ intel_miptree_reference(&irb->mt, mt);
+
+ intel_renderbuffer_set_draw_offset(irb);
+
+ if (mt->hiz_mt == NULL &&
+ intel->vtbl.is_hiz_depth_format(intel, rb->Format)) {
+ intel_miptree_alloc_hiz(intel, mt, 0 /* num_samples */);
+ if (!mt->hiz_mt)
+ return false;
+ }
+
+ return true;
+}
+
+void
+intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb)
+{
+ unsigned int dst_x, dst_y;
+
+ /* compute offset of the particular 2D image within the texture region */
+ intel_miptree_get_image_offset(irb->mt,
+ irb->mt_level,
+ 0, /* face, which we ignore */
+ irb->mt_layer,
+ &dst_x, &dst_y);
+
+ irb->draw_x = dst_x;
+ irb->draw_y = dst_y;
+}
+
+/**
+ * Rendering to tiled buffers requires that the base address of the
+ * buffer be aligned to a page boundary. We generally render to
+ * textures by pointing the surface at the mipmap image level, which
+ * may not be aligned to a tile boundary.
+ *
+ * This function returns an appropriately-aligned base offset
+ * according to the tiling restrictions, plus any required x/y offset
+ * from there.
+ */
+uint32_t
+intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
+ uint32_t *tile_x,
+ uint32_t *tile_y)
+{
+ struct intel_region *region = irb->mt->region;
+ uint32_t mask_x, mask_y;
+
+ intel_region_get_tile_masks(region, &mask_x, &mask_y, false);
+
+ *tile_x = irb->draw_x & mask_x;
+ *tile_y = irb->draw_y & mask_y;
+ return intel_region_get_aligned_offset(region, irb->draw_x & ~mask_x,
+ irb->draw_y & ~mask_y, false);
+}
+
+/**
+ * Called by glFramebufferTexture[123]DEXT() (and other places) to
+ * prepare for rendering into texture memory. This might be called
+ * many times to choose different texture levels, cube faces, etc
+ * before intel_finish_render_texture() is ever called.
+ */
+static void
+intel_render_texture(struct gl_context * ctx,
+ struct gl_framebuffer *fb,
+ struct gl_renderbuffer_attachment *att)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_texture_image *image = _mesa_get_attachment_teximage(att);
+ struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+ int layer;
+
+ (void) fb;
+
+ if (att->CubeMapFace > 0) {
+ assert(att->Zoffset == 0);
+ layer = att->CubeMapFace;
+ } else {
+ layer = att->Zoffset;
+ }
+
+ if (!intel_image->mt) {
+ /* Fallback on drawing to a texture that doesn't have a miptree
+ * (has a border, width/height 0, etc.)
+ */
+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+ else if (!irb) {
+ intel_miptree_check_level_layer(mt, att->TextureLevel, layer);
+
+ irb = (struct intel_renderbuffer *)intel_new_renderbuffer(ctx, ~0);
+
+ if (irb) {
+ /* bind the wrapper to the attachment point */
+ _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base.Base);
+ }
+ else {
+ /* fallback to software rendering */
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+ }
+
+ if (!intel_renderbuffer_update_wrapper(intel, irb, image, layer)) {
+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+
+ irb->tex_image = image;
+
+ DBG("Begin render %s texture tex=%u w=%d h=%d refcount=%d\n",
+ _mesa_get_format_name(image->TexFormat),
+ att->Texture->Name, image->Width, image->Height,
+ irb->Base.Base.RefCount);
+
+ /* update drawing region, etc */
+ intel_draw_buffer(ctx);
+}
+
+
+/**
+ * Called by Mesa when rendering to a texture is done.
+ */
+static void
+intel_finish_render_texture(struct gl_context * ctx,
+ struct gl_renderbuffer_attachment *att)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_texture_object *tex_obj = att->Texture;
+ struct gl_texture_image *image =
+ tex_obj->Image[att->CubeMapFace][att->TextureLevel];
+ struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+
+ DBG("Finish render %s texture tex=%u\n",
+ _mesa_get_format_name(image->TexFormat), att->Texture->Name);
+
+ if (irb)
+ irb->tex_image = NULL;
+
+ /* Since we've (probably) rendered to the texture and will (likely) use
+ * it in the texture domain later on in this batchbuffer, flush the
+ * batch. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer like GEM does in the kernel.
+ */
+ intel_batchbuffer_emit_mi_flush(intel);
+}
+
+/**
+ * Do additional "completeness" testing of a framebuffer object.
+ */
+static void
+intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ struct intel_context *intel = intel_context(ctx);
+ const struct intel_renderbuffer *depthRb =
+ intel_get_renderbuffer(fb, BUFFER_DEPTH);
+ const struct intel_renderbuffer *stencilRb =
+ intel_get_renderbuffer(fb, BUFFER_STENCIL);
+ struct intel_mipmap_tree *depth_mt = NULL, *stencil_mt = NULL;
+ int i;
+
+ DBG("%s() on fb %p (%s)\n", __FUNCTION__,
+ fb, (fb == ctx->DrawBuffer ? "drawbuffer" :
+ (fb == ctx->ReadBuffer ? "readbuffer" : "other buffer")));
+
+ if (depthRb)
+ depth_mt = depthRb->mt;
+ if (stencilRb) {
+ stencil_mt = stencilRb->mt;
+ if (stencil_mt->stencil_mt)
+ stencil_mt = stencil_mt->stencil_mt;
+ }
+
+ if (depth_mt && stencil_mt) {
+ if (depth_mt == stencil_mt) {
+ /* For true packed depth/stencil (not faked on prefers-separate-stencil
+ * hardware) we need to be sure they're the same level/layer, since
+ * we'll be emitting a single packet describing the packed setup.
+ */
+ if (depthRb->mt_level != stencilRb->mt_level ||
+ depthRb->mt_layer != stencilRb->mt_layer) {
+ DBG("depth image level/layer %d/%d != stencil image %d/%d\n",
+ depthRb->mt_level,
+ depthRb->mt_layer,
+ stencilRb->mt_level,
+ stencilRb->mt_layer);
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ } else {
+ if (!intel->has_separate_stencil) {
+ DBG("separate stencil unsupported\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ if (stencil_mt->format != MESA_FORMAT_S8) {
+ DBG("separate stencil is %s instead of S8\n",
+ _mesa_get_format_name(stencil_mt->format));
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ if (intel->gen < 7 && depth_mt->hiz_mt == NULL) {
+ /* Before Gen7, separate depth and stencil buffers can be used
+ * only if HiZ is enabled. From the Sandybridge PRM, Volume 2,
+ * Part 1, Bit 3DSTATE_DEPTH_BUFFER.SeparateStencilBufferEnable:
+ * [DevSNB]: This field must be set to the same value (enabled
+ * or disabled) as Hierarchical Depth Buffer Enable.
+ */
+ DBG("separate stencil without HiZ\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED;
+ }
+ }
+ }
+
+ for (i = 0; i < Elements(fb->Attachment); i++) {
+ struct gl_renderbuffer *rb;
+ struct intel_renderbuffer *irb;
+
+ if (fb->Attachment[i].Type == GL_NONE)
+ continue;
+
+ /* A supported attachment will have a Renderbuffer set either
+ * from being a Renderbuffer or being a texture that got the
+ * intel_wrap_texture() treatment.
+ */
+ rb = fb->Attachment[i].Renderbuffer;
+ if (rb == NULL) {
+ DBG("attachment without renderbuffer\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ continue;
+ }
+
+ if (fb->Attachment[i].Type == GL_TEXTURE) {
+ const struct gl_texture_image *img =
+ _mesa_get_attachment_teximage_const(&fb->Attachment[i]);
+
+ if (img->Border) {
+ DBG("texture with border\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ continue;
+ }
+ }
+
+ irb = intel_renderbuffer(rb);
+ if (irb == NULL) {
+ DBG("software rendering renderbuffer\n");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ continue;
+ }
+
+ if (!intel->vtbl.render_target_supported(intel, rb)) {
+ DBG("Unsupported HW texture/renderbuffer format attached: %s\n",
+ _mesa_get_format_name(intel_rb_format(irb)));
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
+ }
+}
+
+/**
+ * Try to do a glBlitFramebuffer using glCopyTexSubImage2D
+ * We can do this when the dst renderbuffer is actually a texture and
+ * there is no scaling, mirroring or scissoring.
+ *
+ * \return new buffer mask indicating the buffers left to blit using the
+ * normal path.
+ */
+static GLbitfield
+intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,
+ GLint srcX0, GLint srcY0,
+ GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0,
+ GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ const struct gl_framebuffer *drawFb = ctx->DrawBuffer;
+ const struct gl_framebuffer *readFb = ctx->ReadBuffer;
+ const struct gl_renderbuffer_attachment *drawAtt =
+ &drawFb->Attachment[drawFb->_ColorDrawBufferIndexes[0]];
+ struct intel_renderbuffer *srcRb =
+ intel_renderbuffer(readFb->_ColorReadBuffer);
+
+ /* If the source and destination are the same size with no
+ mirroring, the rectangles are within the size of the
+ texture and there is no scissor then we can use
+ glCopyTexSubimage2D to implement the blit. This will end
+ up as a fast hardware blit on some drivers */
+ if (srcRb && drawAtt && drawAtt->Texture &&
+ srcX0 - srcX1 == dstX0 - dstX1 &&
+ srcY0 - srcY1 == dstY0 - dstY1 &&
+ srcX1 >= srcX0 &&
+ srcY1 >= srcY0 &&
+ srcX0 >= 0 && srcX1 <= readFb->Width &&
+ srcY0 >= 0 && srcY1 <= readFb->Height &&
+ dstX0 >= 0 && dstX1 <= drawFb->Width &&
+ dstY0 >= 0 && dstY1 <= drawFb->Height &&
+ !ctx->Scissor.Enabled) {
+ const struct gl_texture_object *texObj = drawAtt->Texture;
+ const GLuint dstLevel = drawAtt->TextureLevel;
+ const GLenum target = texObj->Target;
+
+ struct gl_texture_image *texImage =
+ _mesa_select_tex_image(ctx, texObj, target, dstLevel);
+
+ if (intel_copy_texsubimage(intel_context(ctx),
+ intel_texture_image(texImage),
+ dstX0, dstY0,
+ srcRb,
+ srcX0, srcY0,
+ srcX1 - srcX0, /* width */
+ srcY1 - srcY0))
+ mask &= ~GL_COLOR_BUFFER_BIT;
+ }
+ }
+
+ return mask;
+}
+
+static void
+intel_blit_framebuffer(struct gl_context *ctx,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ /* Try faster, glCopyTexSubImage2D approach first which uses the BLT. */
+ mask = intel_blit_framebuffer_copy_tex_sub_image(ctx,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+ if (mask == 0x0)
+ return;
+
+#ifndef I915
+ mask = brw_blorp_framebuffer(intel_context(ctx),
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+ if (mask == 0x0)
+ return;
+#endif
+
+ _mesa_meta_BlitFramebuffer(ctx,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+}
+
+/**
+ * This is a no-op except on multisample buffers shared with DRI2.
+ */
+void
+intel_renderbuffer_set_needs_downsample(struct intel_renderbuffer *irb)
+{
+ if (irb->mt && irb->mt->singlesample_mt)
+ irb->mt->need_downsample = true;
+}
+
+void
+intel_renderbuffer_set_needs_hiz_resolve(struct intel_renderbuffer *irb)
+{
+ if (irb->mt) {
+ intel_miptree_slice_set_needs_hiz_resolve(irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+ }
+}
+
+void
+intel_renderbuffer_set_needs_depth_resolve(struct intel_renderbuffer *irb)
+{
+ if (irb->mt) {
+ intel_miptree_slice_set_needs_depth_resolve(irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+ }
+}
+
+bool
+intel_renderbuffer_resolve_hiz(struct intel_context *intel,
+ struct intel_renderbuffer *irb)
+{
+ if (irb->mt)
+ return intel_miptree_slice_resolve_hiz(intel,
+ irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+
+ return false;
+}
+
+bool
+intel_renderbuffer_resolve_depth(struct intel_context *intel,
+ struct intel_renderbuffer *irb)
+{
+ if (irb->mt)
+ return intel_miptree_slice_resolve_depth(intel,
+ irb->mt,
+ irb->mt_level,
+ irb->mt_layer);
+
+ return false;
+}
+
+/**
+ * Do one-time context initializations related to GL_EXT_framebuffer_object.
+ * Hook in device driver functions.
+ */
+void
+intel_fbo_init(struct intel_context *intel)
+{
+ intel->ctx.Driver.NewFramebuffer = intel_new_framebuffer;
+ intel->ctx.Driver.NewRenderbuffer = intel_new_renderbuffer;
+ intel->ctx.Driver.MapRenderbuffer = intel_map_renderbuffer;
+ intel->ctx.Driver.UnmapRenderbuffer = intel_unmap_renderbuffer;
+ intel->ctx.Driver.BindFramebuffer = intel_bind_framebuffer;
+ intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
+ intel->ctx.Driver.RenderTexture = intel_render_texture;
+ intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
+ intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
+ intel->ctx.Driver.ValidateFramebuffer = intel_validate_framebuffer;
+ intel->ctx.Driver.BlitFramebuffer = intel_blit_framebuffer;
+
+#if FEATURE_OES_EGL_image
+ intel->ctx.Driver.EGLImageTargetRenderbufferStorage =
+ intel_image_target_renderbuffer_storage;
+#endif
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 242fed0b6ae..556a82fc7ff 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1 +1,1711 @@
-../intel/intel_mipmap_tree.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <GL/gl.h>
+#include <GL/internal/dri_interface.h>
+
+#include "intel_batchbuffer.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_resolve_map.h"
+#include "intel_span.h"
+#include "intel_tex_layout.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+
+#ifndef I915
+#include "brw_blorp.h"
+#endif
+
+#include "main/enums.h"
+#include "main/formats.h"
+#include "main/glformats.h"
+#include "main/texcompress_etc.h"
+#include "main/teximage.h"
+
+#define FILE_DEBUG_FLAG DEBUG_MIPTREE
+
+static GLenum
+target_to_target(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ return GL_TEXTURE_CUBE_MAP_ARB;
+ default:
+ return target;
+ }
+}
+
+/**
+ * @param for_region Indicates that the caller is
+ * intel_miptree_create_for_region(). If true, then do not create
+ * \c stencil_mt.
+ */
+static struct intel_mipmap_tree *
+intel_miptree_create_internal(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ GLuint first_level,
+ GLuint last_level,
+ GLuint width0,
+ GLuint height0,
+ GLuint depth0,
+ bool for_region,
+ GLuint num_samples,
+ enum intel_msaa_layout msaa_layout)
+{
+ struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+ int compress_byte = 0;
+
+ DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(target),
+ _mesa_get_format_name(format),
+ first_level, last_level, mt);
+
+ if (_mesa_is_format_compressed(format))
+ compress_byte = intel_compressed_num_bytes(format);
+
+ mt->target = target_to_target(target);
+ mt->format = format;
+ mt->first_level = first_level;
+ mt->last_level = last_level;
+ mt->width0 = width0;
+ mt->height0 = height0;
+ mt->cpp = compress_byte ? compress_byte : _mesa_get_format_bytes(mt->format);
+ mt->num_samples = num_samples;
+ mt->compressed = compress_byte ? 1 : 0;
+ mt->msaa_layout = msaa_layout;
+ mt->refcount = 1;
+
+ /* array_spacing_lod0 is only used for non-IMS MSAA surfaces. TODO: can we
+ * use it elsewhere?
+ */
+ switch (msaa_layout) {
+ case INTEL_MSAA_LAYOUT_NONE:
+ case INTEL_MSAA_LAYOUT_IMS:
+ mt->array_spacing_lod0 = false;
+ break;
+ case INTEL_MSAA_LAYOUT_UMS:
+ case INTEL_MSAA_LAYOUT_CMS:
+ mt->array_spacing_lod0 = true;
+ break;
+ }
+
+ if (target == GL_TEXTURE_CUBE_MAP) {
+ assert(depth0 == 1);
+ mt->depth0 = 6;
+ } else {
+ mt->depth0 = depth0;
+ }
+
+ if (!for_region &&
+ _mesa_is_depthstencil_format(_mesa_get_format_base_format(format)) &&
+ (intel->must_use_separate_stencil ||
+ (intel->has_separate_stencil &&
+ intel->vtbl.is_hiz_depth_format(intel, format)))) {
+ /* MSAA stencil surfaces always use IMS layout. */
+ enum intel_msaa_layout msaa_layout =
+ num_samples > 1 ? INTEL_MSAA_LAYOUT_IMS : INTEL_MSAA_LAYOUT_NONE;
+ mt->stencil_mt = intel_miptree_create(intel,
+ mt->target,
+ MESA_FORMAT_S8,
+ mt->first_level,
+ mt->last_level,
+ mt->width0,
+ mt->height0,
+ mt->depth0,
+ true,
+ num_samples,
+ msaa_layout);
+ if (!mt->stencil_mt) {
+ intel_miptree_release(&mt);
+ return NULL;
+ }
+
+ /* Fix up the Z miptree format for how we're splitting out separate
+ * stencil. Gen7 expects there to be no stencil bits in its depth buffer.
+ */
+ if (mt->format == MESA_FORMAT_S8_Z24) {
+ mt->format = MESA_FORMAT_X8_Z24;
+ } else if (mt->format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ mt->format = MESA_FORMAT_Z32_FLOAT;
+ mt->cpp = 4;
+ } else {
+ _mesa_problem(NULL, "Unknown format %s in separate stencil mt\n",
+ _mesa_get_format_name(mt->format));
+ }
+ }
+
+ intel_get_texture_alignment_unit(intel, mt->format,
+ &mt->align_w, &mt->align_h);
+
+#ifdef I915
+ (void) intel;
+ if (intel->is_945)
+ i945_miptree_layout(mt);
+ else
+ i915_miptree_layout(mt);
+#else
+ brw_miptree_layout(intel, mt);
+#endif
+
+ return mt;
+}
+
+
+struct intel_mipmap_tree *
+intel_miptree_create(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ GLuint first_level,
+ GLuint last_level,
+ GLuint width0,
+ GLuint height0,
+ GLuint depth0,
+ bool expect_accelerated_upload,
+ GLuint num_samples,
+ enum intel_msaa_layout msaa_layout)
+{
+ struct intel_mipmap_tree *mt;
+ uint32_t tiling = I915_TILING_NONE;
+ GLenum base_format;
+ bool wraps_etc1 = false;
+ GLuint total_width, total_height;
+
+ if (format == MESA_FORMAT_ETC1_RGB8) {
+ format = MESA_FORMAT_RGBX8888_REV;
+ wraps_etc1 = true;
+ }
+
+ base_format = _mesa_get_format_base_format(format);
+
+ if (intel->use_texture_tiling && !_mesa_is_format_compressed(format)) {
+ if (intel->gen >= 4 &&
+ (base_format == GL_DEPTH_COMPONENT ||
+ base_format == GL_DEPTH_STENCIL_EXT))
+ tiling = I915_TILING_Y;
+ else if (msaa_layout != INTEL_MSAA_LAYOUT_NONE) {
+ /* From p82 of the Sandy Bridge PRM, dw3[1] of SURFACE_STATE ("Tiled
+ * Surface"):
+ *
+ * [DevSNB+]: For multi-sample render targets, this field must be
+ * 1. MSRTs can only be tiled.
+ *
+ * Our usual reason for preferring X tiling (fast blits using the
+ * blitting engine) doesn't apply to MSAA, since we'll generally be
+ * downsampling or upsampling when blitting between the MSAA buffer
+ * and another buffer, and the blitting engine doesn't support that.
+ * So use Y tiling, since it makes better use of the cache.
+ */
+ tiling = I915_TILING_Y;
+ } else if (width0 >= 64)
+ tiling = I915_TILING_X;
+ }
+
+ mt = intel_miptree_create_internal(intel, target, format,
+ first_level, last_level, width0,
+ height0, depth0,
+ false, num_samples, msaa_layout);
+ /*
+ * pitch == 0 || height == 0 indicates the null texture
+ */
+ if (!mt || !mt->total_width || !mt->total_height) {
+ intel_miptree_release(&mt);
+ return NULL;
+ }
+
+ total_width = mt->total_width;
+ total_height = mt->total_height;
+
+ if (format == MESA_FORMAT_S8) {
+ /* The stencil buffer is W tiled. However, we request from the kernel a
+ * non-tiled buffer because the GTT is incapable of W fencing. So round
+ * up the width and height to match the size of W tiles (64x64).
+ */
+ tiling = I915_TILING_NONE;
+ total_width = ALIGN(total_width, 64);
+ total_height = ALIGN(total_height, 64);
+ }
+
+ mt->wraps_etc1 = wraps_etc1;
+ mt->region = intel_region_alloc(intel->intelScreen,
+ tiling,
+ mt->cpp,
+ total_width,
+ total_height,
+ expect_accelerated_upload);
+ mt->offset = 0;
+
+ if (!mt->region) {
+ intel_miptree_release(&mt);
+ return NULL;
+ }
+
+ return mt;
+}
+
+
+struct intel_mipmap_tree *
+intel_miptree_create_for_region(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ struct intel_region *region)
+{
+ struct intel_mipmap_tree *mt;
+
+ mt = intel_miptree_create_internal(intel, target, format,
+ 0, 0,
+ region->width, region->height, 1,
+ true, 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_NONE);
+ if (!mt)
+ return mt;
+
+ intel_region_reference(&mt->region, region);
+
+ return mt;
+}
+
+/**
+ * Determine which MSAA layout should be used by the MSAA surface being
+ * created, based on the chip generation and the surface type.
+ */
+static enum intel_msaa_layout
+compute_msaa_layout(struct intel_context *intel, gl_format format)
+{
+ /* Prior to Gen7, all MSAA surfaces used IMS layout. */
+ if (intel->gen < 7)
+ return INTEL_MSAA_LAYOUT_IMS;
+
+ /* In Gen7, IMS layout is only used for depth and stencil buffers. */
+ switch (_mesa_get_format_base_format(format)) {
+ case GL_DEPTH_COMPONENT:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_STENCIL:
+ return INTEL_MSAA_LAYOUT_IMS;
+ default:
+ /* From the Ivy Bridge PRM, Vol4 Part1 p77 ("MCS Enable"):
+ *
+ * This field must be set to 0 for all SINT MSRTs when all RT channels
+ * are not written
+ *
+ * In practice this means that we have to disable MCS for all signed
+ * integer MSAA buffers. The alternative, to disable MCS only when one
+ * of the render target channels is disabled, is impractical because it
+ * would require converting between CMS and UMS MSAA layouts on the fly,
+ * which is expensive.
+ */
+ if (_mesa_get_format_datatype(format) == GL_INT) {
+ /* TODO: is this workaround needed for future chipsets? */
+ assert(intel->gen == 7);
+ return INTEL_MSAA_LAYOUT_UMS;
+ } else {
+ return INTEL_MSAA_LAYOUT_CMS;
+ }
+ }
+}
+
+/**
+ * For a singlesample DRI2 buffer, this simply wraps the given region with a miptree.
+ *
+ * For a multisample DRI2 buffer, this wraps the given region with
+ * a singlesample miptree, then creates a multisample miptree into which the
+ * singlesample miptree is embedded as a child.
+ */
+struct intel_mipmap_tree*
+intel_miptree_create_for_dri2_buffer(struct intel_context *intel,
+ unsigned dri_attachment,
+ gl_format format,
+ uint32_t num_samples,
+ struct intel_region *region)
+{
+ struct intel_mipmap_tree *singlesample_mt = NULL;
+ struct intel_mipmap_tree *multisample_mt = NULL;
+ GLenum base_format = _mesa_get_format_base_format(format);
+
+ /* Only the front and back buffers, which are color buffers, are shared
+ * through DRI2.
+ */
+ assert(dri_attachment == __DRI_BUFFER_BACK_LEFT ||
+ dri_attachment == __DRI_BUFFER_FRONT_LEFT ||
+ dri_attachment == __DRI_BUFFER_FAKE_FRONT_LEFT);
+ assert(base_format == GL_RGB || base_format == GL_RGBA);
+
+ singlesample_mt = intel_miptree_create_for_region(intel, GL_TEXTURE_2D,
+ format, region);
+ if (!singlesample_mt)
+ return NULL;
+
+ if (num_samples == 0)
+ return singlesample_mt;
+
+ multisample_mt = intel_miptree_create_for_renderbuffer(intel,
+ format,
+ region->width,
+ region->height,
+ num_samples);
+ if (!multisample_mt) {
+ intel_miptree_release(&singlesample_mt);
+ return NULL;
+ }
+
+ multisample_mt->singlesample_mt = singlesample_mt;
+ multisample_mt->need_downsample = false;
+
+ if (intel->is_front_buffer_rendering &&
+ (dri_attachment == __DRI_BUFFER_FRONT_LEFT ||
+ dri_attachment == __DRI_BUFFER_FAKE_FRONT_LEFT)) {
+ intel_miptree_upsample(intel, multisample_mt);
+ }
+
+ return multisample_mt;
+}
+
+struct intel_mipmap_tree*
+intel_miptree_create_for_renderbuffer(struct intel_context *intel,
+ gl_format format,
+ uint32_t width,
+ uint32_t height,
+ uint32_t num_samples)
+{
+ struct intel_mipmap_tree *mt;
+ uint32_t depth = 1;
+ enum intel_msaa_layout msaa_layout = INTEL_MSAA_LAYOUT_NONE;
+ const uint32_t singlesample_width = width;
+ const uint32_t singlesample_height = height;
+ bool ok;
+
+ if (num_samples > 1) {
+ /* Adjust width/height/depth for MSAA */
+ msaa_layout = compute_msaa_layout(intel, format);
+ if (msaa_layout == INTEL_MSAA_LAYOUT_IMS) {
+ /* In the Sandy Bridge PRM, volume 4, part 1, page 31, it says:
+ *
+ * "Any of the other messages (sample*, LOD, load4) used with a
+ * (4x) multisampled surface will in-effect sample a surface with
+ * double the height and width as that indicated in the surface
+ * state. Each pixel position on the original-sized surface is
+ * replaced with a 2x2 of samples with the following arrangement:
+ *
+ * sample 0 sample 2
+ * sample 1 sample 3"
+ *
+ * Thus, when sampling from a multisampled texture, it behaves as
+ * though the layout in memory for (x,y,sample) is:
+ *
+ * (0,0,0) (0,0,2) (1,0,0) (1,0,2)
+ * (0,0,1) (0,0,3) (1,0,1) (1,0,3)
+ *
+ * (0,1,0) (0,1,2) (1,1,0) (1,1,2)
+ * (0,1,1) (0,1,3) (1,1,1) (1,1,3)
+ *
+ * However, the actual layout of multisampled data in memory is:
+ *
+ * (0,0,0) (1,0,0) (0,0,1) (1,0,1)
+ * (0,1,0) (1,1,0) (0,1,1) (1,1,1)
+ *
+ * (0,0,2) (1,0,2) (0,0,3) (1,0,3)
+ * (0,1,2) (1,1,2) (0,1,3) (1,1,3)
+ *
+ * This pattern repeats for each 2x2 pixel block.
+ *
+ * As a result, when calculating the size of our 4-sample buffer for
+ * an odd width or height, we have to align before scaling up because
+ * sample 3 is in that bottom right 2x2 block.
+ */
+ switch (num_samples) {
+ case 4:
+ width = ALIGN(width, 2) * 2;
+ height = ALIGN(height, 2) * 2;
+ break;
+ case 8:
+ width = ALIGN(width, 2) * 4;
+ height = ALIGN(height, 2) * 2;
+ break;
+ default:
+ /* num_samples should already have been quantized to 0, 1, 4, or
+ * 8.
+ */
+ assert(false);
+ }
+ } else {
+ /* Non-interleaved */
+ depth = num_samples;
+ }
+ }
+
+ mt = intel_miptree_create(intel, GL_TEXTURE_2D, format, 0, 0,
+ width, height, depth, true, num_samples,
+ msaa_layout);
+ if (!mt)
+ goto fail;
+
+ if (intel->vtbl.is_hiz_depth_format(intel, format)) {
+ ok = intel_miptree_alloc_hiz(intel, mt, num_samples);
+ if (!ok)
+ goto fail;
+ }
+
+ if (mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
+ ok = intel_miptree_alloc_mcs(intel, mt, num_samples);
+ if (!ok)
+ goto fail;
+ }
+
+ mt->singlesample_width0 = singlesample_width;
+ mt->singlesample_height0 = singlesample_height;
+
+ return mt;
+
+fail:
+ intel_miptree_release(&mt);
+ return NULL;
+}
+
+void
+intel_miptree_reference(struct intel_mipmap_tree **dst,
+ struct intel_mipmap_tree *src)
+{
+ if (*dst == src)
+ return;
+
+ intel_miptree_release(dst);
+
+ if (src) {
+ src->refcount++;
+ DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
+ }
+
+ *dst = src;
+}
+
+
+void
+intel_miptree_release(struct intel_mipmap_tree **mt)
+{
+ if (!*mt)
+ return;
+
+ DBG("%s %p refcount will be %d\n", __FUNCTION__, *mt, (*mt)->refcount - 1);
+ if (--(*mt)->refcount <= 0) {
+ GLuint i;
+
+ DBG("%s deleting %p\n", __FUNCTION__, *mt);
+
+ intel_region_release(&((*mt)->region));
+ intel_miptree_release(&(*mt)->stencil_mt);
+ intel_miptree_release(&(*mt)->hiz_mt);
+ intel_miptree_release(&(*mt)->mcs_mt);
+ intel_miptree_release(&(*mt)->singlesample_mt);
+ intel_resolve_map_clear(&(*mt)->hiz_map);
+
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ free((*mt)->level[i].slice);
+ }
+
+ free(*mt);
+ }
+ *mt = NULL;
+}
+
+void
+intel_miptree_get_dimensions_for_image(struct gl_texture_image *image,
+ int *width, int *height, int *depth)
+{
+ switch (image->TexObject->Target) {
+ case GL_TEXTURE_1D_ARRAY:
+ *width = image->Width;
+ *height = 1;
+ *depth = image->Height;
+ break;
+ default:
+ *width = image->Width;
+ *height = image->Height;
+ *depth = image->Depth;
+ break;
+ }
+}
+
+/**
+ * Can the image be pulled into a unified mipmap tree? This mirrors
+ * the completeness test in a lot of ways.
+ *
+ * Not sure whether I want to pass gl_texture_image here.
+ */
+bool
+intel_miptree_match_image(struct intel_mipmap_tree *mt,
+ struct gl_texture_image *image)
+{
+ struct intel_texture_image *intelImage = intel_texture_image(image);
+ GLuint level = intelImage->base.Base.Level;
+ int width, height, depth;
+
+ if (target_to_target(image->TexObject->Target) != mt->target)
+ return false;
+
+ if (image->TexFormat != mt->format &&
+ !(image->TexFormat == MESA_FORMAT_S8_Z24 &&
+ mt->format == MESA_FORMAT_X8_Z24 &&
+ mt->stencil_mt)) {
+ return false;
+ }
+
+ intel_miptree_get_dimensions_for_image(image, &width, &height, &depth);
+
+ if (mt->target == GL_TEXTURE_CUBE_MAP)
+ depth = 6;
+
+ /* Test image dimensions against the base level image adjusted for
+ * minification. This will also catch images not present in the
+ * tree, changed targets, etc.
+ */
+ if (width != mt->level[level].width ||
+ height != mt->level[level].height ||
+ depth != mt->level[level].depth)
+ return false;
+
+ return true;
+}
+
+
+void
+intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
+ GLuint level,
+ GLuint x, GLuint y,
+ GLuint w, GLuint h, GLuint d)
+{
+ mt->level[level].width = w;
+ mt->level[level].height = h;
+ mt->level[level].depth = d;
+ mt->level[level].level_x = x;
+ mt->level[level].level_y = y;
+
+ DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__,
+ level, w, h, d, x, y);
+
+ assert(mt->level[level].slice == NULL);
+
+ mt->level[level].slice = calloc(d, sizeof(*mt->level[0].slice));
+ mt->level[level].slice[0].x_offset = mt->level[level].level_x;
+ mt->level[level].slice[0].y_offset = mt->level[level].level_y;
+}
+
+
+void
+intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
+ GLuint level, GLuint img,
+ GLuint x, GLuint y)
+{
+ if (img == 0 && level == 0)
+ assert(x == 0 && y == 0);
+
+ assert(img < mt->level[level].depth);
+
+ mt->level[level].slice[img].x_offset = mt->level[level].level_x + x;
+ mt->level[level].slice[img].y_offset = mt->level[level].level_y + y;
+
+ DBG("%s level %d img %d pos %d,%d\n",
+ __FUNCTION__, level, img,
+ mt->level[level].slice[img].x_offset,
+ mt->level[level].slice[img].y_offset);
+}
+
+
+/**
+ * For cube map textures, either the \c face parameter can be used, of course,
+ * or the cube face can be interpreted as a depth layer and the \c layer
+ * parameter used.
+ */
+void
+intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
+ GLuint level, GLuint face, GLuint layer,
+ GLuint *x, GLuint *y)
+{
+ int slice;
+
+ if (face > 0) {
+ assert(mt->target == GL_TEXTURE_CUBE_MAP);
+ assert(face < 6);
+ assert(layer == 0);
+ slice = face;
+ } else {
+ /* This branch may be taken even if the texture target is a cube map. In
+ * that case, the caller chose to interpret each cube face as a layer.
+ */
+ assert(face == 0);
+ slice = layer;
+ }
+
+ *x = mt->level[level].slice[slice].x_offset;
+ *y = mt->level[level].slice[slice].y_offset;
+}
+
+static void
+intel_miptree_copy_slice(struct intel_context *intel,
+ struct intel_mipmap_tree *dst_mt,
+ struct intel_mipmap_tree *src_mt,
+ int level,
+ int face,
+ int depth)
+
+{
+ gl_format format = src_mt->format;
+ uint32_t width = src_mt->level[level].width;
+ uint32_t height = src_mt->level[level].height;
+
+ assert(depth < src_mt->level[level].depth);
+
+ if (dst_mt->compressed) {
+ height = ALIGN(height, dst_mt->align_h) / dst_mt->align_h;
+ width = ALIGN(width, dst_mt->align_w);
+ }
+
+ uint32_t dst_x, dst_y, src_x, src_y;
+ intel_miptree_get_image_offset(dst_mt, level, face, depth,
+ &dst_x, &dst_y);
+ intel_miptree_get_image_offset(src_mt, level, face, depth,
+ &src_x, &src_y);
+
+ DBG("validate blit mt %p %d,%d/%d -> mt %p %d,%d/%d (%dx%d)\n",
+ src_mt, src_x, src_y, src_mt->region->pitch * src_mt->region->cpp,
+ dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp,
+ width, height);
+
+ if (!intelEmitCopyBlit(intel,
+ dst_mt->region->cpp,
+ src_mt->region->pitch, src_mt->region->bo,
+ 0, src_mt->region->tiling,
+ dst_mt->region->pitch, dst_mt->region->bo,
+ 0, dst_mt->region->tiling,
+ src_x, src_y,
+ dst_x, dst_y,
+ width, height,
+ GL_COPY)) {
+
+ fallback_debug("miptree validate blit for %s failed\n",
+ _mesa_get_format_name(format));
+ void *dst = intel_region_map(intel, dst_mt->region, GL_MAP_WRITE_BIT);
+ void *src = intel_region_map(intel, src_mt->region, GL_MAP_READ_BIT);
+
+ _mesa_copy_rect(dst,
+ dst_mt->cpp,
+ dst_mt->region->pitch,
+ dst_x, dst_y,
+ width, height,
+ src, src_mt->region->pitch,
+ src_x, src_y);
+
+ intel_region_unmap(intel, dst_mt->region);
+ intel_region_unmap(intel, src_mt->region);
+ }
+
+ if (src_mt->stencil_mt) {
+ intel_miptree_copy_slice(intel,
+ dst_mt->stencil_mt, src_mt->stencil_mt,
+ level, face, depth);
+ }
+}
+
+/**
+ * Copies the image's current data to the given miptree, and associates that
+ * miptree with the image.
+ */
+void
+intel_miptree_copy_teximage(struct intel_context *intel,
+ struct intel_texture_image *intelImage,
+ struct intel_mipmap_tree *dst_mt)
+{
+ struct intel_mipmap_tree *src_mt = intelImage->mt;
+ int level = intelImage->base.Base.Level;
+ int face = intelImage->base.Base.Face;
+ GLuint depth = intelImage->base.Base.Depth;
+
+ for (int slice = 0; slice < depth; slice++) {
+ intel_miptree_copy_slice(intel, dst_mt, src_mt, level, face, slice);
+ }
+
+ intel_miptree_reference(&intelImage->mt, dst_mt);
+}
+
+bool
+intel_miptree_alloc_mcs(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ GLuint num_samples)
+{
+ assert(mt->mcs_mt == NULL);
+ assert(intel->gen >= 7); /* MCS only used on Gen7+ */
+
+ /* Choose the correct format for the MCS buffer. All that really matters
+ * is that we allocate the right buffer size, since we'll always be
+ * accessing this miptree using MCS-specific hardware mechanisms, which
+ * infer the correct format based on num_samples.
+ */
+ gl_format format;
+ switch (num_samples) {
+ case 4:
+ /* 8 bits/pixel are required for MCS data when using 4x MSAA (2 bits for
+ * each sample).
+ */
+ format = MESA_FORMAT_R8;
+ break;
+ case 8:
+ /* 32 bits/pixel are required for MCS data when using 8x MSAA (3 bits
+ * for each sample, plus 8 padding bits).
+ */
+ format = MESA_FORMAT_R_UINT32;
+ break;
+ default:
+ assert(!"Unrecognized sample count in intel_miptree_alloc_mcs");
+ break;
+ };
+
+ /* From the Ivy Bridge PRM, Vol4 Part1 p76, "MCS Base Address":
+ *
+ * "The MCS surface must be stored as Tile Y."
+ *
+ * We set msaa_format to INTEL_MSAA_LAYOUT_CMS to force
+ * intel_miptree_create() to use Y tiling. msaa_format is otherwise
+ * ignored for the MCS miptree.
+ */
+ mt->mcs_mt = intel_miptree_create(intel,
+ mt->target,
+ format,
+ mt->first_level,
+ mt->last_level,
+ mt->width0,
+ mt->height0,
+ mt->depth0,
+ true,
+ 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_CMS);
+
+ /* From the Ivy Bridge PRM, Vol 2 Part 1 p326:
+ *
+ * When MCS buffer is enabled and bound to MSRT, it is required that it
+ * is cleared prior to any rendering.
+ *
+ * Since we don't use the MCS buffer for any purpose other than rendering,
+ * it makes sense to just clear it immediately upon allocation.
+ *
+ * Note: the clear value for MCS buffers is all 1's, so we memset to 0xff.
+ */
+ void *data = intel_region_map(intel, mt->mcs_mt->region, 0);
+ memset(data, 0xff, mt->mcs_mt->region->bo->size);
+ intel_region_unmap(intel, mt->mcs_mt->region);
+
+ return mt->mcs_mt;
+}
+
+bool
+intel_miptree_alloc_hiz(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ GLuint num_samples)
+{
+ assert(mt->hiz_mt == NULL);
+ /* MSAA HiZ surfaces always use IMS layout. */
+ mt->hiz_mt = intel_miptree_create(intel,
+ mt->target,
+ MESA_FORMAT_X8_Z24,
+ mt->first_level,
+ mt->last_level,
+ mt->width0,
+ mt->height0,
+ mt->depth0,
+ true,
+ num_samples,
+ INTEL_MSAA_LAYOUT_IMS);
+
+ if (!mt->hiz_mt)
+ return false;
+
+ /* Mark that all slices need a HiZ resolve. */
+ struct intel_resolve_map *head = &mt->hiz_map;
+ for (int level = mt->first_level; level <= mt->last_level; ++level) {
+ for (int layer = 0; layer < mt->level[level].depth; ++layer) {
+ head->next = malloc(sizeof(*head->next));
+ head->next->prev = head;
+ head->next->next = NULL;
+ head = head->next;
+
+ head->level = level;
+ head->layer = layer;
+ head->need = GEN6_HIZ_OP_HIZ_RESOLVE;
+ }
+ }
+
+ return true;
+}
+
+void
+intel_miptree_slice_set_needs_hiz_resolve(struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ if (!mt->hiz_mt)
+ return;
+
+ intel_resolve_map_set(&mt->hiz_map,
+ level, layer, GEN6_HIZ_OP_HIZ_RESOLVE);
+}
+
+
+void
+intel_miptree_slice_set_needs_depth_resolve(struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ if (!mt->hiz_mt)
+ return;
+
+ intel_resolve_map_set(&mt->hiz_map,
+ level, layer, GEN6_HIZ_OP_DEPTH_RESOLVE);
+}
+
+static bool
+intel_miptree_slice_resolve(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer,
+ enum gen6_hiz_op need)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ struct intel_resolve_map *item =
+ intel_resolve_map_get(&mt->hiz_map, level, layer);
+
+ if (!item || item->need != need)
+ return false;
+
+ intel_hiz_exec(intel, mt, level, layer, need);
+ intel_resolve_map_remove(item);
+ return true;
+}
+
+bool
+intel_miptree_slice_resolve_hiz(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ return intel_miptree_slice_resolve(intel, mt, level, layer,
+ GEN6_HIZ_OP_HIZ_RESOLVE);
+}
+
+bool
+intel_miptree_slice_resolve_depth(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ uint32_t level,
+ uint32_t layer)
+{
+ return intel_miptree_slice_resolve(intel, mt, level, layer,
+ GEN6_HIZ_OP_DEPTH_RESOLVE);
+}
+
+static bool
+intel_miptree_all_slices_resolve(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ enum gen6_hiz_op need)
+{
+ bool did_resolve = false;
+ struct intel_resolve_map *i, *next;
+
+ for (i = mt->hiz_map.next; i; i = next) {
+ next = i->next;
+ if (i->need != need)
+ continue;
+
+ intel_hiz_exec(intel, mt, i->level, i->layer, need);
+ intel_resolve_map_remove(i);
+ did_resolve = true;
+ }
+
+ return did_resolve;
+}
+
+bool
+intel_miptree_all_slices_resolve_hiz(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ return intel_miptree_all_slices_resolve(intel, mt,
+ GEN6_HIZ_OP_HIZ_RESOLVE);
+}
+
+bool
+intel_miptree_all_slices_resolve_depth(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ return intel_miptree_all_slices_resolve(intel, mt,
+ GEN6_HIZ_OP_DEPTH_RESOLVE);
+}
+
+static void
+intel_miptree_updownsample(struct intel_context *intel,
+ struct intel_mipmap_tree *src,
+ struct intel_mipmap_tree *dst,
+ unsigned width,
+ unsigned height)
+{
+#ifndef I915
+ int src_x0 = 0;
+ int src_y0 = 0;
+ int dst_x0 = 0;
+ int dst_y0 = 0;
+
+ intel_miptree_slice_resolve_depth(intel, src, 0, 0);
+ intel_miptree_slice_resolve_depth(intel, dst, 0, 0);
+
+ brw_blorp_blit_miptrees(intel,
+ src, 0 /* level */, 0 /* layer */,
+ dst, 0 /* level */, 0 /* layer */,
+ src_x0, src_y0,
+ dst_x0, dst_y0,
+ width, height,
+ false, false /*mirror x, y*/);
+
+ if (src->stencil_mt) {
+ brw_blorp_blit_miptrees(intel,
+ src->stencil_mt, 0 /* level */, 0 /* layer */,
+ dst->stencil_mt, 0 /* level */, 0 /* layer */,
+ src_x0, src_y0,
+ dst_x0, dst_y0,
+ width, height,
+ false, false /*mirror x, y*/);
+ }
+#endif /* I915 */
+}
+
+static void
+assert_is_flat(struct intel_mipmap_tree *mt)
+{
+ assert(mt->target == GL_TEXTURE_2D);
+ assert(mt->first_level == 0);
+ assert(mt->last_level == 0);
+}
+
+/**
+ * \brief Downsample from mt to mt->singlesample_mt.
+ *
+ * If the miptree needs no downsample, then skip.
+ */
+void
+intel_miptree_downsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ assert_is_flat(mt);
+
+ if (!mt->need_downsample)
+ return;
+ intel_miptree_updownsample(intel,
+ mt, mt->singlesample_mt,
+ mt->singlesample_mt->width0,
+ mt->singlesample_mt->height0);
+ mt->need_downsample = false;
+
+ /* Strictly speaking, after a downsample on a depth miptree, a hiz
+ * resolve is needed on the singlesample miptree. However, since the
+ * singlesample miptree is never rendered to, the hiz resolve will never
+ * occur. Therefore we do not mark the needed hiz resolve after
+ * downsampling.
+ */
+}
+
+/**
+ * \brief Upsample from mt->singlesample_mt to mt.
+ *
+ * The upsample is done unconditionally.
+ */
+void
+intel_miptree_upsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ assert_is_flat(mt);
+ assert(!mt->need_downsample);
+
+ intel_miptree_updownsample(intel,
+ mt->singlesample_mt, mt,
+ mt->singlesample_mt->width0,
+ mt->singlesample_mt->height0);
+ intel_miptree_slice_set_needs_hiz_resolve(mt, 0, 0);
+}
+
+static void
+intel_miptree_map_gtt(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ unsigned int bw, bh;
+ void *base;
+ unsigned int image_x, image_y;
+ int x = map->x;
+ int y = map->y;
+
+ /* For compressed formats, the stride is the number of bytes per
+ * row of blocks. intel_miptree_get_image_offset() already does
+ * the divide.
+ */
+ _mesa_get_format_block_size(mt->format, &bw, &bh);
+ assert(y % bh == 0);
+ y /= bh;
+
+ base = intel_region_map(intel, mt->region, map->mode);
+
+ if (base == NULL)
+ map->ptr = NULL;
+ else {
+ /* Note that in the case of cube maps, the caller must have passed the
+ * slice number referencing the face.
+ */
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+ x += image_x;
+ y += image_y;
+
+ map->stride = mt->region->pitch * mt->cpp;
+ map->ptr = base + y * map->stride + x * mt->cpp;
+ }
+
+ DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, _mesa_get_format_name(mt->format),
+ x, y, map->ptr, map->stride);
+}
+
+static void
+intel_miptree_unmap_gtt(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ intel_region_unmap(intel, mt->region);
+}
+
+static void
+intel_miptree_map_blit(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ unsigned int image_x, image_y;
+ int x = map->x;
+ int y = map->y;
+ int ret;
+
+ /* The blitter requires the pitch to be aligned to 4. */
+ map->stride = ALIGN(map->w * mt->region->cpp, 4);
+
+ map->bo = drm_intel_bo_alloc(intel->bufmgr, "intel_miptree_map_blit() temp",
+ map->stride * map->h, 4096);
+ if (!map->bo) {
+ fprintf(stderr, "Failed to allocate blit temporary\n");
+ goto fail;
+ }
+
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+ x += image_x;
+ y += image_y;
+
+ if (!intelEmitCopyBlit(intel,
+ mt->region->cpp,
+ mt->region->pitch, mt->region->bo,
+ 0, mt->region->tiling,
+ map->stride / mt->region->cpp, map->bo,
+ 0, I915_TILING_NONE,
+ x, y,
+ 0, 0,
+ map->w, map->h,
+ GL_COPY)) {
+ fprintf(stderr, "Failed to blit\n");
+ goto fail;
+ }
+
+ intel_batchbuffer_flush(intel);
+ ret = drm_intel_bo_map(map->bo, (map->mode & GL_MAP_WRITE_BIT) != 0);
+ if (ret) {
+ fprintf(stderr, "Failed to map blit temporary\n");
+ goto fail;
+ }
+
+ map->ptr = map->bo->virtual;
+
+ DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, _mesa_get_format_name(mt->format),
+ x, y, map->ptr, map->stride);
+
+ return;
+
+fail:
+ drm_intel_bo_unreference(map->bo);
+ map->ptr = NULL;
+ map->stride = 0;
+}
+
+static void
+intel_miptree_unmap_blit(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ assert(!(map->mode & GL_MAP_WRITE_BIT));
+
+ drm_intel_bo_unmap(map->bo);
+ drm_intel_bo_unreference(map->bo);
+}
+
+static void
+intel_miptree_map_s8(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ map->stride = map->w;
+ map->buffer = map->ptr = malloc(map->stride * map->h);
+ if (!map->buffer)
+ return;
+
+ /* One of either READ_BIT or WRITE_BIT or both is set. READ_BIT implies no
+ * INVALIDATE_RANGE_BIT. WRITE_BIT needs the original values read in unless
+ * invalidate is set, since we'll be writing the whole rectangle from our
+ * temporary buffer back out.
+ */
+ if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {
+ uint8_t *untiled_s8_map = map->ptr;
+ uint8_t *tiled_s8_map = intel_region_map(intel, mt->region,
+ GL_MAP_READ_BIT);
+ unsigned int image_x, image_y;
+
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ ptrdiff_t offset = intel_offset_S8(mt->region->pitch,
+ x + image_x + map->x,
+ y + image_y + map->y,
+ intel->has_swizzling);
+ untiled_s8_map[y * map->w + x] = tiled_s8_map[offset];
+ }
+ }
+
+ intel_region_unmap(intel, mt->region);
+
+ DBG("%s: %d,%d %dx%d from mt %p %d,%d = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, map->x + image_x, map->y + image_y, map->ptr, map->stride);
+ } else {
+ DBG("%s: %d,%d %dx%d from mt %p = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, map->ptr, map->stride);
+ }
+}
+
+static void
+intel_miptree_unmap_s8(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ if (map->mode & GL_MAP_WRITE_BIT) {
+ unsigned int image_x, image_y;
+ uint8_t *untiled_s8_map = map->ptr;
+ uint8_t *tiled_s8_map = intel_region_map(intel, mt->region, map->mode);
+
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ ptrdiff_t offset = intel_offset_S8(mt->region->pitch,
+ x + map->x,
+ y + map->y,
+ intel->has_swizzling);
+ tiled_s8_map[offset] = untiled_s8_map[y * map->w + x];
+ }
+ }
+
+ intel_region_unmap(intel, mt->region);
+ }
+
+ free(map->buffer);
+}
+
+static void
+intel_miptree_map_etc1(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ /* For justification of these invariants,
+ * see intel_mipmap_tree:wraps_etc1.
+ */
+ assert(mt->wraps_etc1);
+ assert(mt->format == MESA_FORMAT_RGBX8888_REV);
+
+ /* From the GL_OES_compressed_ETC1_RGB8_texture spec:
+ * INVALID_OPERATION is generated by CompressedTexSubImage2D,
+ * TexSubImage2D, or CopyTexSubImage2D if the texture image <level>
+ * bound to <target> has internal format ETC1_RGB8_OES.
+ *
+ * This implies that intel_miptree_map_etc1() can only be called from
+ * glCompressedTexImage2D, and hence the assertions below hold.
+ */
+ assert(map->mode & GL_MAP_WRITE_BIT);
+ assert(map->mode & GL_MAP_INVALIDATE_RANGE_BIT);
+ assert(map->x == 0);
+ assert(map->y == 0);
+
+ /* Each ETC1 block contains 4x4 pixels in 8 bytes. */
+ map->stride = 2 * map->w;
+ map->buffer = map->ptr = malloc(map->stride * map->h);
+}
+
+static void
+intel_miptree_unmap_etc1(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ uint32_t image_x;
+ uint32_t image_y;
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+
+ uint8_t *xbgr = intel_region_map(intel, mt->region, map->mode)
+ + image_y * mt->region->pitch * mt->region->cpp
+ + image_x * mt->region->cpp;
+
+ _mesa_etc1_unpack_rgba8888(xbgr, mt->region->pitch * mt->region->cpp,
+ map->ptr, map->stride,
+ map->w, map->h);
+
+ intel_region_unmap(intel, mt->region);
+ free(map->buffer);
+}
+
+/**
+ * Mapping function for packed depth/stencil miptrees backed by real separate
+ * miptrees for depth and stencil.
+ *
+ * On gen7, and to support HiZ pre-gen7, we have to have the stencil buffer
+ * separate from the depth buffer. Yet at the GL API level, we have to expose
+ * packed depth/stencil textures and FBO attachments, and Mesa core expects to
+ * be able to map that memory for texture storage and glReadPixels-type
+ * operations. We give Mesa core that access by mallocing a temporary and
+ * copying the data between the actual backing store and the temporary.
+ */
+static void
+intel_miptree_map_depthstencil(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level, unsigned int slice)
+{
+ struct intel_mipmap_tree *z_mt = mt;
+ struct intel_mipmap_tree *s_mt = mt->stencil_mt;
+ bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z32_FLOAT;
+ int packed_bpp = map_z32f_x24s8 ? 8 : 4;
+
+ map->stride = map->w * packed_bpp;
+ map->buffer = map->ptr = malloc(map->stride * map->h);
+ if (!map->buffer)
+ return;
+
+ /* One of either READ_BIT or WRITE_BIT or both is set. READ_BIT implies no
+ * INVALIDATE_RANGE_BIT. WRITE_BIT needs the original values read in unless
+ * invalidate is set, since we'll be writing the whole rectangle from our
+ * temporary buffer back out.
+ */
+ if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {
+ uint32_t *packed_map = map->ptr;
+ uint8_t *s_map = intel_region_map(intel, s_mt->region, GL_MAP_READ_BIT);
+ uint32_t *z_map = intel_region_map(intel, z_mt->region, GL_MAP_READ_BIT);
+ unsigned int s_image_x, s_image_y;
+ unsigned int z_image_x, z_image_y;
+
+ intel_miptree_get_image_offset(s_mt, level, 0, slice,
+ &s_image_x, &s_image_y);
+ intel_miptree_get_image_offset(z_mt, level, 0, slice,
+ &z_image_x, &z_image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ int map_x = map->x + x, map_y = map->y + y;
+ ptrdiff_t s_offset = intel_offset_S8(s_mt->region->pitch,
+ map_x + s_image_x,
+ map_y + s_image_y,
+ intel->has_swizzling);
+ ptrdiff_t z_offset = ((map_y + z_image_y) * z_mt->region->pitch +
+ (map_x + z_image_x));
+ uint8_t s = s_map[s_offset];
+ uint32_t z = z_map[z_offset];
+
+ if (map_z32f_x24s8) {
+ packed_map[(y * map->w + x) * 2 + 0] = z;
+ packed_map[(y * map->w + x) * 2 + 1] = s;
+ } else {
+ packed_map[y * map->w + x] = (s << 24) | (z & 0x00ffffff);
+ }
+ }
+ }
+
+ intel_region_unmap(intel, s_mt->region);
+ intel_region_unmap(intel, z_mt->region);
+
+ DBG("%s: %d,%d %dx%d from z mt %p %d,%d, s mt %p %d,%d = %p/%d\n",
+ __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ z_mt, map->x + z_image_x, map->y + z_image_y,
+ s_mt, map->x + s_image_x, map->y + s_image_y,
+ map->ptr, map->stride);
+ } else {
+ DBG("%s: %d,%d %dx%d from mt %p = %p/%d\n", __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ mt, map->ptr, map->stride);
+ }
+}
+
+static void
+intel_miptree_unmap_depthstencil(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_mipmap_tree *z_mt = mt;
+ struct intel_mipmap_tree *s_mt = mt->stencil_mt;
+ bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z32_FLOAT;
+
+ if (map->mode & GL_MAP_WRITE_BIT) {
+ uint32_t *packed_map = map->ptr;
+ uint8_t *s_map = intel_region_map(intel, s_mt->region, map->mode);
+ uint32_t *z_map = intel_region_map(intel, z_mt->region, map->mode);
+ unsigned int s_image_x, s_image_y;
+ unsigned int z_image_x, z_image_y;
+
+ intel_miptree_get_image_offset(s_mt, level, 0, slice,
+ &s_image_x, &s_image_y);
+ intel_miptree_get_image_offset(z_mt, level, 0, slice,
+ &z_image_x, &z_image_y);
+
+ for (uint32_t y = 0; y < map->h; y++) {
+ for (uint32_t x = 0; x < map->w; x++) {
+ ptrdiff_t s_offset = intel_offset_S8(s_mt->region->pitch,
+ x + s_image_x + map->x,
+ y + s_image_y + map->y,
+ intel->has_swizzling);
+ ptrdiff_t z_offset = ((y + z_image_y) * z_mt->region->pitch +
+ (x + z_image_x));
+
+ if (map_z32f_x24s8) {
+ z_map[z_offset] = packed_map[(y * map->w + x) * 2 + 0];
+ s_map[s_offset] = packed_map[(y * map->w + x) * 2 + 1];
+ } else {
+ uint32_t packed = packed_map[y * map->w + x];
+ s_map[s_offset] = packed >> 24;
+ z_map[z_offset] = packed;
+ }
+ }
+ }
+
+ intel_region_unmap(intel, s_mt->region);
+ intel_region_unmap(intel, z_mt->region);
+
+ DBG("%s: %d,%d %dx%d from z mt %p (%s) %d,%d, s mt %p %d,%d = %p/%d\n",
+ __FUNCTION__,
+ map->x, map->y, map->w, map->h,
+ z_mt, _mesa_get_format_name(z_mt->format),
+ map->x + z_image_x, map->y + z_image_y,
+ s_mt, map->x + s_image_x, map->y + s_image_y,
+ map->ptr, map->stride);
+ }
+
+ free(map->buffer);
+}
+
+/**
+ * Create and attach a map to the miptree at (level, slice). Return the
+ * attached map.
+ */
+static struct intel_miptree_map*
+intel_miptree_attach_map(struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode)
+{
+ struct intel_miptree_map *map = calloc(1, sizeof(*map));
+
+ if (!map)
+ return NULL;
+
+ assert(mt->level[level].slice[slice].map == NULL);
+ mt->level[level].slice[slice].map = map;
+
+ map->mode = mode;
+ map->x = x;
+ map->y = y;
+ map->w = w;
+ map->h = h;
+
+ return map;
+}
+
+/**
+ * Release the map at (level, slice).
+ */
+static void
+intel_miptree_release_map(struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_miptree_map **map;
+
+ map = &mt->level[level].slice[slice].map;
+ free(*map);
+ *map = NULL;
+}
+
+static void
+intel_miptree_map_singlesample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode,
+ void **out_ptr,
+ int *out_stride)
+{
+ struct intel_miptree_map *map;
+
+ assert(mt->num_samples <= 1);
+
+ map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode);
+ if (!map){
+ *out_ptr = NULL;
+ *out_stride = 0;
+ return;
+ }
+
+ intel_miptree_slice_resolve_depth(intel, mt, level, slice);
+ if (map->mode & GL_MAP_WRITE_BIT) {
+ intel_miptree_slice_set_needs_hiz_resolve(mt, level, slice);
+ }
+
+ if (mt->format == MESA_FORMAT_S8) {
+ intel_miptree_map_s8(intel, mt, map, level, slice);
+ } else if (mt->wraps_etc1) {
+ intel_miptree_map_etc1(intel, mt, map, level, slice);
+ } else if (mt->stencil_mt) {
+ intel_miptree_map_depthstencil(intel, mt, map, level, slice);
+ } else if (intel->has_llc &&
+ !(mode & GL_MAP_WRITE_BIT) &&
+ !mt->compressed &&
+ mt->region->tiling == I915_TILING_X) {
+ intel_miptree_map_blit(intel, mt, map, level, slice);
+ } else {
+ intel_miptree_map_gtt(intel, mt, map, level, slice);
+ }
+
+ *out_ptr = map->ptr;
+ *out_stride = map->stride;
+
+ if (map->ptr == NULL)
+ intel_miptree_release_map(mt, level, slice);
+}
+
+static void
+intel_miptree_unmap_singlesample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_miptree_map *map = mt->level[level].slice[slice].map;
+
+ assert(mt->num_samples <= 1);
+
+ if (!map)
+ return;
+
+ DBG("%s: mt %p (%s) level %d slice %d\n", __FUNCTION__,
+ mt, _mesa_get_format_name(mt->format), level, slice);
+
+ if (mt->format == MESA_FORMAT_S8) {
+ intel_miptree_unmap_s8(intel, mt, map, level, slice);
+ } else if (mt->wraps_etc1) {
+ intel_miptree_unmap_etc1(intel, mt, map, level, slice);
+ } else if (mt->stencil_mt) {
+ intel_miptree_unmap_depthstencil(intel, mt, map, level, slice);
+ } else if (map->bo) {
+ intel_miptree_unmap_blit(intel, mt, map, level, slice);
+ } else {
+ intel_miptree_unmap_gtt(intel, mt, map, level, slice);
+ }
+
+ intel_miptree_release_map(mt, level, slice);
+}
+
+static void
+intel_miptree_map_multisample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode,
+ void **out_ptr,
+ int *out_stride)
+{
+ struct intel_miptree_map *map;
+
+ assert(mt->num_samples > 1);
+
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ if (mt->target != GL_TEXTURE_2D ||
+ mt->first_level != 0 ||
+ mt->last_level != 0) {
+ _mesa_problem(&intel->ctx, "attempt to map a multisample miptree for "
+ "which (target, first_level, last_level != "
+ "(GL_TEXTURE_2D, 0, 0)");
+ goto fail;
+ }
+
+ map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode);
+ if (!map)
+ goto fail;
+
+ if (!mt->singlesample_mt) {
+ mt->singlesample_mt =
+ intel_miptree_create_for_renderbuffer(intel,
+ mt->format,
+ mt->singlesample_width0,
+ mt->singlesample_height0,
+ 0 /*num_samples*/);
+ if (!mt->singlesample_mt)
+ goto fail;
+
+ map->singlesample_mt_is_tmp = true;
+ mt->need_downsample = true;
+ }
+
+ intel_miptree_downsample(intel, mt);
+ intel_miptree_map_singlesample(intel, mt->singlesample_mt,
+ level, slice,
+ x, y, w, h,
+ mode,
+ out_ptr, out_stride);
+ return;
+
+fail:
+ intel_miptree_release_map(mt, level, slice);
+ *out_ptr = NULL;
+ *out_stride = 0;
+}
+
+static void
+intel_miptree_unmap_multisample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ struct intel_miptree_map *map = mt->level[level].slice[slice].map;
+
+ assert(mt->num_samples > 1);
+
+ if (!map)
+ return;
+
+ intel_miptree_unmap_singlesample(intel, mt->singlesample_mt, level, slice);
+
+ mt->need_downsample = false;
+ if (map->mode & GL_MAP_WRITE_BIT)
+ intel_miptree_upsample(intel, mt);
+
+ if (map->singlesample_mt_is_tmp)
+ intel_miptree_release(&mt->singlesample_mt);
+
+ intel_miptree_release_map(mt, level, slice);
+}
+
+void
+intel_miptree_map(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice,
+ unsigned int x,
+ unsigned int y,
+ unsigned int w,
+ unsigned int h,
+ GLbitfield mode,
+ void **out_ptr,
+ int *out_stride)
+{
+ if (mt->num_samples <= 1)
+ intel_miptree_map_singlesample(intel, mt,
+ level, slice,
+ x, y, w, h,
+ mode,
+ out_ptr, out_stride);
+ else
+ intel_miptree_map_multisample(intel, mt,
+ level, slice,
+ x, y, w, h,
+ mode,
+ out_ptr, out_stride);
+}
+
+void
+intel_miptree_unmap(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int slice)
+{
+ if (mt->num_samples <= 1)
+ intel_miptree_unmap_singlesample(intel, mt, level, slice);
+ else
+ intel_miptree_unmap_multisample(intel, mt, level, slice);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel.c
index d733c5e8745..bc705105d4d 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel.c
@@ -1 +1,167 @@
-../intel/intel_pixel.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portionsalloc
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/accum.h"
+#include "main/enums.h"
+#include "main/state.h"
+#include "main/bufferobj.h"
+#include "main/context.h"
+#include "swrast/swrast.h"
+
+#include "intel_context.h"
+#include "intel_pixel.h"
+#include "intel_regions.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+static GLenum
+effective_func(GLenum func, bool src_alpha_is_one)
+{
+ if (src_alpha_is_one) {
+ if (func == GL_SRC_ALPHA)
+ return GL_ONE;
+ if (func == GL_ONE_MINUS_SRC_ALPHA)
+ return GL_ZERO;
+ }
+
+ return func;
+}
+
+/**
+ * Check if any fragment operations are in effect which might effect
+ * glDraw/CopyPixels.
+ */
+bool
+intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
+{
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->FragmentProgram._Enabled) {
+ DBG("fallback due to fragment program\n");
+ return false;
+ }
+
+ if (ctx->Color.BlendEnabled &&
+ (effective_func(ctx->Color.Blend[0].SrcRGB, src_alpha_is_one) != GL_ONE ||
+ effective_func(ctx->Color.Blend[0].DstRGB, src_alpha_is_one) != GL_ZERO ||
+ ctx->Color.Blend[0].EquationRGB != GL_FUNC_ADD ||
+ effective_func(ctx->Color.Blend[0].SrcA, src_alpha_is_one) != GL_ONE ||
+ effective_func(ctx->Color.Blend[0].DstA, src_alpha_is_one) != GL_ZERO ||
+ ctx->Color.Blend[0].EquationA != GL_FUNC_ADD)) {
+ DBG("fallback due to blend\n");
+ return false;
+ }
+
+ if (ctx->Texture._EnabledUnits) {
+ DBG("fallback due to texturing\n");
+ return false;
+ }
+
+ if (!(ctx->Color.ColorMask[0][0] &&
+ ctx->Color.ColorMask[0][1] &&
+ ctx->Color.ColorMask[0][2] &&
+ ctx->Color.ColorMask[0][3])) {
+ DBG("fallback due to color masking\n");
+ return false;
+ }
+
+ if (ctx->Color.AlphaEnabled) {
+ DBG("fallback due to alpha\n");
+ return false;
+ }
+
+ if (ctx->Depth.Test) {
+ DBG("fallback due to depth test\n");
+ return false;
+ }
+
+ if (ctx->Fog.Enabled) {
+ DBG("fallback due to fog\n");
+ return false;
+ }
+
+ if (ctx->_ImageTransferState) {
+ DBG("fallback due to image transfer\n");
+ return false;
+ }
+
+ if (ctx->Stencil._Enabled) {
+ DBG("fallback due to image stencil\n");
+ return false;
+ }
+
+ if (ctx->RenderMode != GL_RENDER) {
+ DBG("fallback due to render mode\n");
+ return false;
+ }
+
+ return true;
+}
+
+/* The intel_region struct doesn't really do enough to capture the
+ * format of the pixels in the region. For now this code assumes that
+ * the region is a display surface and hence is either ARGB8888 or
+ * RGB565.
+ * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
+ * know the buffer's pixel format.
+ *
+ * \param format as given to glDraw/ReadPixels
+ * \param type as given to glDraw/ReadPixels
+ */
+bool
+intel_check_blit_format(struct intel_region * region,
+ GLenum format, GLenum type)
+{
+ if (region->cpp == 4 &&
+ (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+ type == GL_UNSIGNED_BYTE) && format == GL_BGRA) {
+ return true;
+ }
+
+ if (region->cpp == 2 &&
+ type == GL_UNSIGNED_SHORT_5_6_5_REV && format == GL_BGR) {
+ return true;
+ }
+
+ DBG("%s: bad format for blit (cpp %d, type %s format %s)\n",
+ __FUNCTION__, region->cpp,
+ _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
+
+ return false;
+}
+
+void
+intelInitPixelFuncs(struct dd_function_table *functions)
+{
+ functions->Accum = _mesa_accum;
+ functions->Bitmap = intelBitmap;
+ functions->CopyPixels = intelCopyPixels;
+ functions->DrawPixels = intelDrawPixels;
+ functions->ReadPixels = intelReadPixels;
+}
+
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
index 9085c7b0397..954dfc50b14 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
@@ -1 +1,340 @@
-../intel/intel_pixel_bitmap.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portionsalloc
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/colormac.h"
+#include "main/condrender.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/pbo.h"
+#include "main/bufferobj.h"
+#include "main/state.h"
+#include "main/texobj.h"
+#include "main/context.h"
+#include "main/fbobject.h"
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
+#include "intel_regions.h"
+#include "intel_buffers.h"
+#include "intel_pixel.h"
+#include "intel_reg.h"
+
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+
+/* Unlike the other intel_pixel_* functions, the expectation here is
+ * that the incoming data is not in a PBO. With the XY_TEXT blit
+ * method, there's no benefit haveing it in a PBO, but we could
+ * implement a path based on XY_MONO_SRC_COPY_BLIT which might benefit
+ * PBO bitmaps. I think they are probably pretty rare though - I
+ * wonder if Xgl uses them?
+ */
+static const GLubyte *map_pbo( struct gl_context *ctx,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ GLubyte *buf;
+
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+ GL_COLOR_INDEX, GL_BITMAP,
+ INT_MAX, (const GLvoid *) bitmap)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)");
+ return NULL;
+ }
+
+ buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+ GL_MAP_READ_BIT,
+ unpack->BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
+ return NULL;
+ }
+
+ return ADD_POINTERS(buf, bitmap);
+}
+
+static bool test_bit( const GLubyte *src, GLuint bit )
+{
+ return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
+}
+
+static void set_bit( GLubyte *dest, GLuint bit )
+{
+ dest[bit/8] |= 1 << (bit % 8);
+}
+
+/* Extract a rectangle's worth of data from the bitmap. Called
+ * per chunk of HW-sized bitmap.
+ */
+static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap,
+ GLuint x, GLuint y,
+ GLuint w, GLuint h,
+ GLubyte *dest,
+ GLuint row_align,
+ bool invert)
+{
+ GLuint src_offset = (x + unpack->SkipPixels) & 0x7;
+ GLuint mask = unpack->LsbFirst ? 0 : 7;
+ GLuint bit = 0;
+ GLint row, col;
+ GLint first, last;
+ GLint incr;
+ GLuint count = 0;
+
+ DBG("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n",
+ __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask);
+
+ if (invert) {
+ first = h-1;
+ last = 0;
+ incr = -1;
+ }
+ else {
+ first = 0;
+ last = h-1;
+ incr = 1;
+ }
+
+ /* Require that dest be pre-zero'd.
+ */
+ for (row = first; row != (last+incr); row += incr) {
+ const GLubyte *rowsrc = _mesa_image_address2d(unpack, bitmap,
+ width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ y + row, x);
+
+ for (col = 0; col < w; col++, bit++) {
+ if (test_bit(rowsrc, (col + src_offset) ^ mask)) {
+ set_bit(dest, bit ^ 7);
+ count++;
+ }
+ }
+
+ if (row_align)
+ bit = ALIGN(bit, row_align);
+ }
+
+ return count;
+}
+
+/**
+ * Returns the low Y value of the vertical range given, flipped according to
+ * whether the framebuffer is or not.
+ */
+static INLINE int
+y_flip(struct gl_framebuffer *fb, int y, int height)
+{
+ if (_mesa_is_user_fbo(fb))
+ return y;
+ else
+ return fb->Height - y - height;
+}
+
+/*
+ * Render a bitmap.
+ */
+static bool
+do_blit_bitmap( struct gl_context *ctx,
+ GLint dstx, GLint dsty,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_region *dst;
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ GLfloat tmpColor[4];
+ GLubyte ubcolor[4];
+ GLuint color;
+ GLsizei bitmap_width = width;
+ GLsizei bitmap_height = height;
+ GLint px, py;
+ GLuint stipple[32];
+ GLint orig_dstx = dstx;
+ GLint orig_dsty = dsty;
+
+ /* Update draw buffer bounds */
+ _mesa_update_state(ctx);
+
+ if (ctx->Depth.Test) {
+ /* The blit path produces incorrect results when depth testing is on.
+ * It seems the blit Z coord is always 1.0 (the far plane) so fragments
+ * will likely be obscured by other, closer geometry.
+ */
+ return false;
+ }
+
+ intel_prepare_render(intel);
+ dst = intel_drawbuf_region(intel);
+
+ if (!dst)
+ return false;
+
+ if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ bitmap = map_pbo(ctx, width, height, unpack, bitmap);
+ if (bitmap == NULL)
+ return true; /* even though this is an error, we're done */
+ }
+
+ COPY_4V(tmpColor, ctx->Current.RasterColor);
+
+ if (_mesa_need_secondary_color(ctx)) {
+ ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor);
+ }
+
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[0], tmpColor[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[1], tmpColor[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[2], tmpColor[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[3], tmpColor[3]);
+
+ if (dst->cpp == 2)
+ color = PACK_COLOR_565(ubcolor[0], ubcolor[1], ubcolor[2]);
+ else
+ color = PACK_COLOR_8888(ubcolor[3], ubcolor[0], ubcolor[1], ubcolor[2]);
+
+ if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
+ return false;
+
+ /* Clip to buffer bounds and scissor. */
+ if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
+ fb->_Xmax, fb->_Ymax,
+ &dstx, &dsty, &width, &height))
+ goto out;
+
+ dsty = y_flip(fb, dsty, height);
+
+#define DY 32
+#define DX 32
+
+ /* Chop it all into chunks that can be digested by hardware: */
+ for (py = 0; py < height; py += DY) {
+ for (px = 0; px < width; px += DX) {
+ int h = MIN2(DY, height - py);
+ int w = MIN2(DX, width - px);
+ GLuint sz = ALIGN(ALIGN(w,8) * h, 64)/8;
+ GLenum logic_op = ctx->Color.ColorLogicOpEnabled ?
+ ctx->Color.LogicOp : GL_COPY;
+
+ assert(sz <= sizeof(stipple));
+ memset(stipple, 0, sz);
+
+ /* May need to adjust this when padding has been introduced in
+ * sz above:
+ *
+ * Have to translate destination coordinates back into source
+ * coordinates.
+ */
+ if (get_bitmap_rect(bitmap_width, bitmap_height, unpack,
+ bitmap,
+ -orig_dstx + (dstx + px),
+ -orig_dsty + y_flip(fb, dsty + py, h),
+ w, h,
+ (GLubyte *)stipple,
+ 8,
+ _mesa_is_winsys_fbo(fb)) == 0)
+ continue;
+
+ if (!intelEmitImmediateColorExpandBlit(intel,
+ dst->cpp,
+ (GLubyte *)stipple,
+ sz,
+ color,
+ dst->pitch,
+ dst->bo,
+ 0,
+ dst->tiling,
+ dstx + px,
+ dsty + py,
+ w, h,
+ logic_op)) {
+ return false;
+ }
+ }
+ }
+out:
+
+ if (unlikely(INTEL_DEBUG & DEBUG_SYNC))
+ intel_batchbuffer_flush(intel);
+
+ if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ /* done with PBO so unmap it now */
+ ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj);
+ }
+
+ intel_check_front_buffer_rendering(intel);
+
+ return true;
+}
+
+
+/* There are a large number of possible ways to implement bitmap on
+ * this hardware, most of them have some sort of drawback. Here are a
+ * few that spring to mind:
+ *
+ * Blit:
+ * - XY_MONO_SRC_BLT_CMD
+ * - use XY_SETUP_CLIP_BLT for cliprect clipping.
+ * - XY_TEXT_BLT
+ * - XY_TEXT_IMMEDIATE_BLT
+ * - blit per cliprect, subject to maximum immediate data size.
+ * - XY_COLOR_BLT
+ * - per pixel or run of pixels
+ * - XY_PIXEL_BLT
+ * - good for sparse bitmaps
+ *
+ * 3D engine:
+ * - Point per pixel
+ * - Translate bitmap to an alpha texture and render as a quad
+ * - Chop bitmap up into 32x32 squares and render w/polygon stipple.
+ */
+void
+intelBitmap(struct gl_context * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * pixels)
+{
+ if (!_mesa_check_conditional_render(ctx))
+ return;
+
+ if (do_blit_bitmap(ctx, x, y, width, height,
+ unpack, pixels))
+ return;
+
+ _mesa_meta_Bitmap(ctx, x, y, width, height, unpack, pixels);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_copy.c
index ee433605904..682a52d97d2 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_copy.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_copy.c
@@ -1 +1,230 @@
-../intel/intel_pixel_copy.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/image.h"
+#include "main/state.h"
+#include "main/mtypes.h"
+#include "main/condrender.h"
+#include "main/fbobject.h"
+#include "drivers/common/meta.h"
+
+#include "intel_context.h"
+#include "intel_buffers.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+#include "intel_fbo.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+/**
+ * Check if any fragment operations are in effect which might effect
+ * glCopyPixels. Differs from intel_check_blit_fragment_ops in that
+ * we allow Scissor.
+ */
+static bool
+intel_check_copypixel_blit_fragment_ops(struct gl_context * ctx)
+{
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ /* Could do logicop with the blitter:
+ */
+ return !(ctx->_ImageTransferState ||
+ ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Stencil._Enabled ||
+ !ctx->Color.ColorMask[0][0] ||
+ !ctx->Color.ColorMask[0][1] ||
+ !ctx->Color.ColorMask[0][2] ||
+ !ctx->Color.ColorMask[0][3] ||
+ ctx->Texture._EnabledUnits ||
+ ctx->FragmentProgram._Enabled ||
+ ctx->Color.BlendEnabled);
+}
+
+
+/**
+ * CopyPixels with the blitter. Don't support zooming, pixel transfer, etc.
+ */
+static bool
+do_blit_copypixels(struct gl_context * ctx,
+ GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint dstx, GLint dsty, GLenum type)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_framebuffer *read_fb = ctx->ReadBuffer;
+ GLint orig_dstx;
+ GLint orig_dsty;
+ GLint orig_srcx;
+ GLint orig_srcy;
+ bool flip = false;
+ struct intel_renderbuffer *draw_irb = NULL;
+ struct intel_renderbuffer *read_irb = NULL;
+ gl_format read_format, draw_format;
+
+ /* Update draw buffer bounds */
+ _mesa_update_state(ctx);
+
+ switch (type) {
+ case GL_COLOR:
+ if (fb->_NumColorDrawBuffers != 1) {
+ fallback_debug("glCopyPixels() fallback: MRT\n");
+ return false;
+ }
+
+ draw_irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
+ read_irb = intel_renderbuffer(read_fb->_ColorReadBuffer);
+ break;
+ case GL_DEPTH_STENCIL_EXT:
+ draw_irb = intel_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ read_irb =
+ intel_renderbuffer(read_fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ break;
+ case GL_DEPTH:
+ fallback_debug("glCopyPixels() fallback: GL_DEPTH\n");
+ return false;
+ case GL_STENCIL:
+ fallback_debug("glCopyPixels() fallback: GL_STENCIL\n");
+ return false;
+ default:
+ fallback_debug("glCopyPixels(): Unknown type\n");
+ return false;
+ }
+
+ if (!draw_irb) {
+ fallback_debug("glCopyPixels() fallback: missing draw buffer\n");
+ return false;
+ }
+
+ if (!read_irb) {
+ fallback_debug("glCopyPixels() fallback: missing read buffer\n");
+ return false;
+ }
+
+ read_format = intel_rb_format(read_irb);
+ draw_format = intel_rb_format(draw_irb);
+
+ if (draw_format != read_format &&
+ !(draw_format == MESA_FORMAT_XRGB8888 &&
+ read_format == MESA_FORMAT_ARGB8888)) {
+ fallback_debug("glCopyPixels() fallback: mismatched formats (%s -> %s\n",
+ _mesa_get_format_name(read_format),
+ _mesa_get_format_name(draw_format));
+ return false;
+ }
+
+ /* Copypixels can be more than a straight copy. Ensure all the
+ * extra operations are disabled:
+ */
+ if (!intel_check_copypixel_blit_fragment_ops(ctx) ||
+ ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F)
+ return false;
+
+ intel_prepare_render(intel);
+
+ intel_flush(&intel->ctx);
+
+ /* Clip to destination buffer. */
+ orig_dstx = dstx;
+ orig_dsty = dsty;
+ if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
+ fb->_Xmax, fb->_Ymax,
+ &dstx, &dsty, &width, &height))
+ goto out;
+ /* Adjust src coords for our post-clipped destination origin */
+ srcx += dstx - orig_dstx;
+ srcy += dsty - orig_dsty;
+
+ /* Clip to source buffer. */
+ orig_srcx = srcx;
+ orig_srcy = srcy;
+ if (!_mesa_clip_to_region(0, 0,
+ read_fb->Width, read_fb->Height,
+ &srcx, &srcy, &width, &height))
+ goto out;
+ /* Adjust dst coords for our post-clipped source origin */
+ dstx += srcx - orig_srcx;
+ dsty += srcy - orig_srcy;
+
+ /* Flip dest Y if it's a window system framebuffer. */
+ if (_mesa_is_winsys_fbo(fb)) {
+ /* copypixels to a window system framebuffer */
+ dsty = fb->Height - dsty - height;
+ flip = !flip;
+ }
+
+ /* Flip source Y if it's a window system framebuffer. */
+ if (_mesa_is_winsys_fbo(read_fb)) {
+ srcy = read_fb->Height - srcy - height;
+ flip = !flip;
+ }
+
+ srcx += read_irb->draw_x;
+ srcy += read_irb->draw_y;
+ dstx += draw_irb->draw_x;
+ dsty += draw_irb->draw_y;
+
+ if (!intel_region_copy(intel,
+ draw_irb->mt->region, 0, dstx, dsty,
+ read_irb->mt->region, 0, srcx, srcy,
+ width, height, flip,
+ ctx->Color.ColorLogicOpEnabled ?
+ ctx->Color.LogicOp : GL_COPY)) {
+ DBG("%s: blit failure\n", __FUNCTION__);
+ return false;
+ }
+
+out:
+ intel_check_front_buffer_rendering(intel);
+
+ DBG("%s: success\n", __FUNCTION__);
+ return true;
+}
+
+
+void
+intelCopyPixels(struct gl_context * ctx,
+ GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint destx, GLint desty, GLenum type)
+{
+ DBG("%s\n", __FUNCTION__);
+
+ if (!_mesa_check_conditional_render(ctx))
+ return;
+
+ if (do_blit_copypixels(ctx, srcx, srcy, width, height, destx, desty, type))
+ return;
+
+ /* this will use swrast if needed */
+ _mesa_meta_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_draw.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_draw.c
index 8431a24edfc..2ec7ed8e269 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_draw.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_draw.c
@@ -1 +1,58 @@
-../intel/intel_pixel_draw.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portionsalloc
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/mtypes.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
+#include "main/texstate.h"
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "intel_context.h"
+#include "intel_pixel.h"
+
+void
+intelDrawPixels(struct gl_context * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ if (format == GL_STENCIL_INDEX) {
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type,
+ unpack, pixels);
+ return;
+ }
+
+ _mesa_meta_DrawPixels(ctx, x, y, width, height, format, type,
+ unpack, pixels);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_read.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_read.c
index cc4589f4d42..ab4e581c400 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_read.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_pixel_read.c
@@ -1 +1,205 @@
-../intel/intel_pixel_read.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/fbobject.h"
+#include "main/image.h"
+#include "main/bufferobj.h"
+#include "main/readpix.h"
+#include "main/state.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+#include "intel_buffer_objects.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+/* For many applications, the new ability to pull the source buffers
+ * back out of the GTT and then do the packing/conversion operations
+ * in software will be as much of an improvement as trying to get the
+ * blitter and/or texture engine to do the work.
+ *
+ * This step is gated on private backbuffers.
+ *
+ * Obviously the frontbuffer can't be pulled back, so that is either
+ * an argument for blit/texture readpixels, or for blitting to a
+ * temporary and then pulling that back.
+ *
+ * When the destination is a pbo, however, it's not clear if it is
+ * ever going to be pulled to main memory (though the access param
+ * will be a good hint). So it sounds like we do want to be able to
+ * choose between blit/texture implementation on the gpu and pullback
+ * and cpu-based copying.
+ *
+ * Unless you can magically turn client memory into a PBO for the
+ * duration of this call, there will be a cpu-based copying step in
+ * any case.
+ */
+
+static bool
+do_blit_readpixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_region *src = intel_readbuf_region(intel);
+ struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj);
+ GLuint dst_offset;
+ GLuint rowLength;
+ drm_intel_bo *dst_buffer;
+ bool all;
+ GLint dst_x, dst_y;
+ GLuint dirty;
+
+ DBG("%s\n", __FUNCTION__);
+
+ if (!src)
+ return false;
+
+ if (!_mesa_is_bufferobj(pack->BufferObj)) {
+ /* PBO only for now:
+ */
+ DBG("%s - not PBO\n", __FUNCTION__);
+ return false;
+ }
+
+
+ if (ctx->_ImageTransferState ||
+ !intel_check_blit_format(src, format, type)) {
+ DBG("%s - bad format for blit\n", __FUNCTION__);
+ return false;
+ }
+
+ if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) {
+ DBG("%s: bad packing params\n", __FUNCTION__);
+ return false;
+ }
+
+ if (pack->RowLength > 0)
+ rowLength = pack->RowLength;
+ else
+ rowLength = width;
+
+ if (pack->Invert) {
+ DBG("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
+ return false;
+ }
+ else {
+ if (_mesa_is_winsys_fbo(ctx->ReadBuffer))
+ rowLength = -rowLength;
+ }
+
+ dst_offset = (GLintptr)pixels;
+ dst_offset += _mesa_image_offset(2, pack, width, height,
+ format, type, 0, 0, 0);
+
+ if (!_mesa_clip_copytexsubimage(ctx,
+ &dst_x, &dst_y,
+ &x, &y,
+ &width, &height)) {
+ return true;
+ }
+
+ dirty = intel->front_buffer_dirty;
+ intel_prepare_render(intel);
+ intel->front_buffer_dirty = dirty;
+
+ all = (width * height * src->cpp == dst->Base.Size &&
+ x == 0 && dst_offset == 0);
+
+ dst_x = 0;
+ dst_y = 0;
+
+ dst_buffer = intel_bufferobj_buffer(intel, dst,
+ all ? INTEL_WRITE_FULL :
+ INTEL_WRITE_PART);
+
+ if (_mesa_is_winsys_fbo(ctx->ReadBuffer))
+ y = ctx->ReadBuffer->Height - (y + height);
+
+ if (!intelEmitCopyBlit(intel,
+ src->cpp,
+ src->pitch, src->bo, 0, src->tiling,
+ rowLength, dst_buffer, dst_offset, false,
+ x, y,
+ dst_x, dst_y,
+ width, height,
+ GL_COPY)) {
+ return false;
+ }
+
+ DBG("%s - DONE\n", __FUNCTION__);
+
+ return true;
+}
+
+void
+intelReadPixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+ struct intel_context *intel = intel_context(ctx);
+ bool dirty;
+
+ intel_flush_rendering_to_batch(ctx);
+
+ DBG("%s\n", __FUNCTION__);
+
+ if (do_blit_readpixels
+ (ctx, x, y, width, height, format, type, pack, pixels))
+ return;
+
+ /* glReadPixels() wont dirty the front buffer, so reset the dirty
+ * flag after calling intel_prepare_render(). */
+ dirty = intel->front_buffer_dirty;
+ intel_prepare_render(intel);
+ intel->front_buffer_dirty = dirty;
+
+ fallback_debug("%s: fallback to swrast\n", __FUNCTION__);
+
+ /* Update Mesa state before calling _mesa_readpixels().
+ * XXX this may not be needed since ReadPixels no longer uses the
+ * span code.
+ */
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ _mesa_readpixels(ctx, x, y, width, height, format, type, pack, pixels);
+
+ /* There's an intel_prepare_render() call in intelSpanRenderStart(). */
+ intel->front_buffer_dirty = dirty;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_regions.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_regions.c
index 89b2f15c10f..7cb008c2f71 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_regions.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_regions.c
@@ -1 +1,473 @@
-../intel/intel_regions.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/* Provide additional functionality on top of bufmgr buffers:
+ * - 2d semantics and blit operations
+ * - refcounting of buffers for multiple images in a buffer.
+ * - refcounting of buffer mappings.
+ * - some logic for moving the buffers to the best memory pools for
+ * given operations.
+ *
+ * Most of this is to make it easier to implement the fixed-layout
+ * mipmap tree required by intel hardware in the face of GL's
+ * programming interface where each image can be specifed in random
+ * order and it isn't clear what layout the tree should have until the
+ * last moment.
+ */
+
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "main/hash.h"
+#include "intel_context.h"
+#include "intel_regions.h"
+#include "intel_blit.h"
+#include "intel_buffer_objects.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+
+#define FILE_DEBUG_FLAG DEBUG_REGION
+
+/* This should be set to the maximum backtrace size desired.
+ * Set it to 0 to disable backtrace debugging.
+ */
+#define DEBUG_BACKTRACE_SIZE 0
+
+#if DEBUG_BACKTRACE_SIZE == 0
+/* Use the standard debug output */
+#define _DBG(...) DBG(__VA_ARGS__)
+#else
+/* Use backtracing debug output */
+#define _DBG(...) {debug_backtrace(); DBG(__VA_ARGS__);}
+
+/* Backtracing debug support */
+#include <execinfo.h>
+
+static void
+debug_backtrace(void)
+{
+ void *trace[DEBUG_BACKTRACE_SIZE];
+ char **strings = NULL;
+ int traceSize;
+ register int i;
+
+ traceSize = backtrace(trace, DEBUG_BACKTRACE_SIZE);
+ strings = backtrace_symbols(trace, traceSize);
+ if (strings == NULL) {
+ DBG("no backtrace:");
+ return;
+ }
+
+ /* Spit out all the strings with a colon separator. Ignore
+ * the first, since we don't really care about the call
+ * to debug_backtrace() itself. Skip until the final "/" in
+ * the trace to avoid really long lines.
+ */
+ for (i = 1; i < traceSize; i++) {
+ char *p = strings[i], *slash = strings[i];
+ while (*p) {
+ if (*p++ == '/') {
+ slash = p;
+ }
+ }
+
+ DBG("%s:", slash);
+ }
+
+ /* Free up the memory, and we're done */
+ free(strings);
+}
+
+#endif
+
+
+
+/* XXX: Thread safety?
+ */
+void *
+intel_region_map(struct intel_context *intel, struct intel_region *region,
+ GLbitfield mode)
+{
+ /* We have the region->map_refcount controlling mapping of the BO because
+ * in software fallbacks we may end up mapping the same buffer multiple
+ * times on Mesa's behalf, so we refcount our mappings to make sure that
+ * the pointer stays valid until the end of the unmap chain. However, we
+ * must not emit any batchbuffers between the start of mapping and the end
+ * of unmapping, or further use of the map will be incoherent with the GPU
+ * rendering done by that batchbuffer. Hence we assert in
+ * intel_batchbuffer_flush() that that doesn't happen, which means that the
+ * flush is only needed on first map of the buffer.
+ */
+
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (drm_intel_bo_busy(region->bo)) {
+ perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
+ }
+ }
+
+ _DBG("%s %p\n", __FUNCTION__, region);
+ if (!region->map_refcount) {
+ intel_flush(&intel->ctx);
+
+ if (region->tiling != I915_TILING_NONE)
+ drm_intel_gem_bo_map_gtt(region->bo);
+ else
+ drm_intel_bo_map(region->bo, true);
+
+ region->map = region->bo->virtual;
+ }
+ if (region->map) {
+ intel->num_mapped_regions++;
+ region->map_refcount++;
+ }
+
+ return region->map;
+}
+
+void
+intel_region_unmap(struct intel_context *intel, struct intel_region *region)
+{
+ _DBG("%s %p\n", __FUNCTION__, region);
+ if (!--region->map_refcount) {
+ if (region->tiling != I915_TILING_NONE)
+ drm_intel_gem_bo_unmap_gtt(region->bo);
+ else
+ drm_intel_bo_unmap(region->bo);
+
+ region->map = NULL;
+ --intel->num_mapped_regions;
+ assert(intel->num_mapped_regions >= 0);
+ }
+}
+
+static struct intel_region *
+intel_region_alloc_internal(struct intel_screen *screen,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
+ uint32_t tiling, drm_intel_bo *buffer)
+{
+ struct intel_region *region;
+
+ region = calloc(sizeof(*region), 1);
+ if (region == NULL)
+ return region;
+
+ region->cpp = cpp;
+ region->width = width;
+ region->height = height;
+ region->pitch = pitch;
+ region->refcount = 1;
+ region->bo = buffer;
+ region->tiling = tiling;
+ region->screen = screen;
+
+ _DBG("%s <-- %p\n", __FUNCTION__, region);
+ return region;
+}
+
+struct intel_region *
+intel_region_alloc(struct intel_screen *screen,
+ uint32_t tiling,
+ GLuint cpp, GLuint width, GLuint height,
+ bool expect_accelerated_upload)
+{
+ drm_intel_bo *buffer;
+ unsigned long flags = 0;
+ unsigned long aligned_pitch;
+ struct intel_region *region;
+
+ if (expect_accelerated_upload)
+ flags |= BO_ALLOC_FOR_RENDER;
+
+ buffer = drm_intel_bo_alloc_tiled(screen->bufmgr, "region",
+ width, height, cpp,
+ &tiling, &aligned_pitch, flags);
+ if (buffer == NULL)
+ return NULL;
+
+ region = intel_region_alloc_internal(screen, cpp, width, height,
+ aligned_pitch / cpp, tiling, buffer);
+ if (region == NULL) {
+ drm_intel_bo_unreference(buffer);
+ return NULL;
+ }
+
+ return region;
+}
+
+bool
+intel_region_flink(struct intel_region *region, uint32_t *name)
+{
+ if (region->name == 0) {
+ if (drm_intel_bo_flink(region->bo, &region->name))
+ return false;
+
+ _mesa_HashInsert(region->screen->named_regions,
+ region->name, region);
+ }
+
+ *name = region->name;
+
+ return true;
+}
+
+struct intel_region *
+intel_region_alloc_for_handle(struct intel_screen *screen,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
+ GLuint handle, const char *name)
+{
+ struct intel_region *region, *dummy;
+ drm_intel_bo *buffer;
+ int ret;
+ uint32_t bit_6_swizzle, tiling;
+
+ region = _mesa_HashLookup(screen->named_regions, handle);
+ if (region != NULL) {
+ dummy = NULL;
+ if (region->width != width || region->height != height ||
+ region->cpp != cpp || region->pitch != pitch) {
+ fprintf(stderr,
+ "Region for name %d already exists but is not compatible\n",
+ handle);
+ return NULL;
+ }
+ intel_region_reference(&dummy, region);
+ return dummy;
+ }
+
+ buffer = intel_bo_gem_create_from_name(screen->bufmgr, name, handle);
+ if (buffer == NULL)
+ return NULL;
+ ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle);
+ if (ret != 0) {
+ fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n",
+ handle, name, strerror(-ret));
+ drm_intel_bo_unreference(buffer);
+ return NULL;
+ }
+
+ region = intel_region_alloc_internal(screen, cpp,
+ width, height, pitch, tiling, buffer);
+ if (region == NULL) {
+ drm_intel_bo_unreference(buffer);
+ return NULL;
+ }
+
+ region->name = handle;
+ _mesa_HashInsert(screen->named_regions, handle, region);
+
+ return region;
+}
+
+void
+intel_region_reference(struct intel_region **dst, struct intel_region *src)
+{
+ _DBG("%s: %p(%d) -> %p(%d)\n", __FUNCTION__,
+ *dst, *dst ? (*dst)->refcount : 0, src, src ? src->refcount : 0);
+
+ if (src != *dst) {
+ if (*dst)
+ intel_region_release(dst);
+
+ if (src)
+ src->refcount++;
+ *dst = src;
+ }
+}
+
+void
+intel_region_release(struct intel_region **region_handle)
+{
+ struct intel_region *region = *region_handle;
+
+ if (region == NULL) {
+ _DBG("%s NULL\n", __FUNCTION__);
+ return;
+ }
+
+ _DBG("%s %p %d\n", __FUNCTION__, region, region->refcount - 1);
+
+ ASSERT(region->refcount > 0);
+ region->refcount--;
+
+ if (region->refcount == 0) {
+ assert(region->map_refcount == 0);
+
+ drm_intel_bo_unreference(region->bo);
+
+ if (region->name > 0)
+ _mesa_HashRemove(region->screen->named_regions, region->name);
+
+ free(region);
+ }
+ *region_handle = NULL;
+}
+
+/*
+ * XXX Move this into core Mesa?
+ */
+void
+_mesa_copy_rect(GLubyte * dst,
+ GLuint cpp,
+ GLuint dst_pitch,
+ GLuint dst_x,
+ GLuint dst_y,
+ GLuint width,
+ GLuint height,
+ const GLubyte * src,
+ GLuint src_pitch, GLuint src_x, GLuint src_y)
+{
+ GLuint i;
+
+ dst_pitch *= cpp;
+ src_pitch *= cpp;
+ dst += dst_x * cpp;
+ src += src_x * cpp;
+ dst += dst_y * dst_pitch;
+ src += src_y * src_pitch;
+ width *= cpp;
+
+ if (width == dst_pitch && width == src_pitch)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+ }
+}
+
+/* Copy rectangular sub-regions. Need better logic about when to
+ * push buffers into AGP - will currently do so whenever possible.
+ */
+bool
+intel_region_copy(struct intel_context *intel,
+ struct intel_region *dst,
+ GLuint dst_offset,
+ GLuint dstx, GLuint dsty,
+ struct intel_region *src,
+ GLuint src_offset,
+ GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+ bool flip,
+ GLenum logicop)
+{
+ uint32_t src_pitch = src->pitch;
+
+ _DBG("%s\n", __FUNCTION__);
+
+ if (intel == NULL)
+ return false;
+
+ assert(src->cpp == dst->cpp);
+
+ if (flip)
+ src_pitch = -src_pitch;
+
+ return intelEmitCopyBlit(intel,
+ dst->cpp,
+ src_pitch, src->bo, src_offset, src->tiling,
+ dst->pitch, dst->bo, dst_offset, dst->tiling,
+ srcx, srcy, dstx, dsty, width, height,
+ logicop);
+}
+
+/**
+ * This function computes masks that may be used to select the bits of the X
+ * and Y coordinates that indicate the offset within a tile. If the region is
+ * untiled, the masks are set to 0.
+ */
+void
+intel_region_get_tile_masks(struct intel_region *region,
+ uint32_t *mask_x, uint32_t *mask_y,
+ bool map_stencil_as_y_tiled)
+{
+ int cpp = region->cpp;
+ uint32_t tiling = region->tiling;
+
+ if (map_stencil_as_y_tiled)
+ tiling = I915_TILING_Y;
+
+ switch (tiling) {
+ default:
+ assert(false);
+ case I915_TILING_NONE:
+ *mask_x = *mask_y = 0;
+ break;
+ case I915_TILING_X:
+ *mask_x = 512 / cpp - 1;
+ *mask_y = 7;
+ break;
+ case I915_TILING_Y:
+ *mask_x = 128 / cpp - 1;
+ *mask_y = 31;
+ break;
+ }
+}
+
+/**
+ * Compute the offset (in bytes) from the start of the region to the given x
+ * and y coordinate. For tiled regions, caller must ensure that x and y are
+ * multiples of the tile size.
+ */
+uint32_t
+intel_region_get_aligned_offset(struct intel_region *region, uint32_t x,
+ uint32_t y, bool map_stencil_as_y_tiled)
+{
+ int cpp = region->cpp;
+ uint32_t pitch = region->pitch * cpp;
+ uint32_t tiling = region->tiling;
+
+ if (map_stencil_as_y_tiled) {
+ tiling = I915_TILING_Y;
+
+ /* When mapping a W-tiled stencil buffer as Y-tiled, each 64-high W-tile
+ * gets transformed into a 32-high Y-tile. Accordingly, the pitch of
+ * the resulting region is twice the pitch of the original region, since
+ * each row in the Y-tiled view corresponds to two rows in the actual
+ * W-tiled surface. So we need to correct the pitch before computing
+ * the offsets.
+ */
+ pitch *= 2;
+ }
+
+ switch (tiling) {
+ default:
+ assert(false);
+ case I915_TILING_NONE:
+ return y * pitch + x * cpp;
+ case I915_TILING_X:
+ assert((x % (512 / cpp)) == 0);
+ assert((y % 8) == 0);
+ return y * pitch + x / (512 / cpp) * 4096;
+ case I915_TILING_Y:
+ assert((x % (128 / cpp)) == 0);
+ assert((y % 32) == 0);
+ return y * pitch + x / (128 / cpp) * 4096;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_resolve_map.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_resolve_map.c
index 77e50fbaea4..04b5c942432 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_resolve_map.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_resolve_map.c
@@ -1 +1,111 @@
-../intel/intel_resolve_map.c \ No newline at end of file
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "intel_resolve_map.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+/**
+ * \brief Set that the miptree slice at (level, layer) needs a resolve.
+ *
+ * If a map element already exists with the given key, then the value is
+ * changed to the given value of \c need.
+ */
+void
+intel_resolve_map_set(struct intel_resolve_map *head,
+ uint32_t level,
+ uint32_t layer,
+ enum gen6_hiz_op need)
+{
+ struct intel_resolve_map **tail = &head->next;
+ struct intel_resolve_map *prev = head;
+
+ while (*tail) {
+ if ((*tail)->level == level && (*tail)->layer == layer) {
+ (*tail)->need = need;
+ return;
+ }
+ prev = *tail;
+ tail = &(*tail)->next;
+ }
+
+ *tail = malloc(sizeof(**tail));
+ (*tail)->prev = prev;
+ (*tail)->next = NULL;
+ (*tail)->level = level;
+ (*tail)->layer = layer;
+ (*tail)->need = need;
+}
+
+/**
+ * \brief Get an element from the map.
+ * \return null if element is not contained in map.
+ */
+struct intel_resolve_map*
+intel_resolve_map_get(struct intel_resolve_map *head,
+ uint32_t level,
+ uint32_t layer)
+{
+ struct intel_resolve_map *item = head->next;
+
+ while (item) {
+ if (item->level == level && item->layer == layer)
+ break;
+ else
+ item = item->next;
+ }
+
+ return item;
+}
+
+/**
+ * \brief Remove and free an element from the map.
+ */
+void
+intel_resolve_map_remove(struct intel_resolve_map *elem)
+{
+ if (elem->prev)
+ elem->prev->next = elem->next;
+ if (elem->next)
+ elem->next->prev = elem->prev;
+ free(elem);
+}
+
+/**
+ * \brief Remove and free all elements of the map.
+ */
+void
+intel_resolve_map_clear(struct intel_resolve_map *head)
+{
+ struct intel_resolve_map *next = head->next;
+ struct intel_resolve_map *trash;
+
+ while (next) {
+ trash = next;
+ next = next->next;
+ free(trash);
+ }
+
+ head->next = NULL;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_screen.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_screen.c
index f2db48272b9..00a1b0122ec 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1 +1,1204 @@
-../intel/intel_screen.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <errno.h>
+#include <time.h>
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/hash.h"
+#include "main/fbobject.h"
+#include "main/mfeatures.h"
+#include "main/version.h"
+#include "swrast/s_renderbuffer.h"
+
+#include "utils.h"
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+ DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
+ /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
+ * DRI_CONF_BO_REUSE_ALL
+ */
+ DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 1, "0:1")
+ DRI_CONF_DESC_BEGIN(en, "Buffer object reuse")
+ DRI_CONF_ENUM(0, "Disable buffer object reuse")
+ DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
+ DRI_CONF_DESC_END
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(texture_tiling, bool, true)
+ DRI_CONF_DESC(en, "Enable texture tiling")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(hiz, bool, true)
+ DRI_CONF_DESC(en, "Enable Hierarchical Z on gen6+")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(early_z, bool, false)
+ DRI_CONF_DESC(en, "Enable early Z in classic mode (unstable, 945-only).")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(fragment_shader, bool, true)
+ DRI_CONF_DESC(en, "Enable limited ARB_fragment_shader support on 915/945.")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_ALLOW_LARGE_TEXTURES(2)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_ALWAYS_FLUSH_BATCH(false)
+ DRI_CONF_ALWAYS_FLUSH_CACHE(false)
+ DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN(false)
+ DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED(false)
+
+ DRI_CONF_OPT_BEGIN(stub_occlusion_query, bool, false)
+ DRI_CONF_DESC(en, "Enable stub ARB_occlusion_query support on 915/945.")
+ DRI_CONF_OPT_END
+
+ DRI_CONF_OPT_BEGIN(shader_precompile, bool, true)
+ DRI_CONF_DESC(en, "Perform code generation at shader link time.")
+ DRI_CONF_OPT_END
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+
+const GLuint __driNConfigOptions = 15;
+
+#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
+#include "intel_bufmgr.h"
+#include "intel_chipset.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_screen.h"
+#include "intel_tex.h"
+#include "intel_regions.h"
+
+#include "i915_drm.h"
+
+#ifdef USE_NEW_INTERFACE
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+#endif /*USE_NEW_INTERFACE */
+
+/**
+ * For debugging purposes, this returns a time in seconds.
+ */
+double
+get_time(void)
+{
+ struct timespec tp;
+
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+
+ return tp.tv_sec + tp.tv_nsec / 1000000000.0;
+}
+
+void
+aub_dump_bmp(struct gl_context *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ for (int i = 0; i < fb->_NumColorDrawBuffers; i++) {
+ struct intel_renderbuffer *irb =
+ intel_renderbuffer(fb->_ColorDrawBuffers[i]);
+
+ if (irb && irb->mt) {
+ enum aub_dump_bmp_format format;
+
+ switch (irb->Base.Base.Format) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ format = AUB_DUMP_BMP_FORMAT_ARGB_8888;
+ break;
+ default:
+ continue;
+ }
+
+ drm_intel_gem_bo_aub_dump_bmp(irb->mt->region->bo,
+ irb->draw_x,
+ irb->draw_y,
+ irb->Base.Base.Width,
+ irb->Base.Base.Height,
+ format,
+ irb->mt->region->pitch *
+ irb->mt->region->cpp,
+ 0);
+ }
+ }
+}
+
+static const __DRItexBufferExtension intelTexBufferExtension = {
+ { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+ intelSetTexBuffer,
+ intelSetTexBuffer2,
+};
+
+static void
+intelDRI2Flush(__DRIdrawable *drawable)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct intel_context *intel = intel_context(ctx);
+ if (intel == NULL)
+ return;
+
+ if (intel->gen < 4)
+ INTEL_FIREVERTICES(intel);
+
+ intel_downsample_for_dri2_flush(intel, drawable);
+ intel->need_throttle = true;
+
+ if (intel->batch.used)
+ intel_batchbuffer_flush(intel);
+
+ if (INTEL_DEBUG & DEBUG_AUB) {
+ aub_dump_bmp(ctx);
+ }
+}
+
+static const struct __DRI2flushExtensionRec intelFlushExtension = {
+ { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
+ intelDRI2Flush,
+ dri2InvalidateDrawable,
+};
+
+struct intel_image_format intel_image_formats[] = {
+ { __DRI_IMAGE_FOURCC_ARGB8888, __DRI_IMAGE_COMPONENTS_RGBA, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
+
+ { __DRI_IMAGE_FOURCC_XRGB8888, __DRI_IMAGE_COMPONENTS_RGB, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB8888, 4 }, } },
+
+ { __DRI_IMAGE_FOURCC_YUV410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV411, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_YUV444, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 2, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
+
+ { __DRI_IMAGE_FOURCC_NV12, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 1, __DRI_IMAGE_FORMAT_GR88, 2 } } },
+
+ { __DRI_IMAGE_FOURCC_NV16, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
+ { 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
+
+ /* For YUYV buffers, we set up two overlapping DRI images and treat
+ * them as planar buffers in the compositors. Plane 0 is GR88 and
+ * samples YU or YV pairs and places Y into the R component, while
+ * plane 1 is ARGB and samples YUYV clusters and places pairs and
+ * places U into the G component and V into A. This lets the
+ * texture sampler interpolate the Y components correctly when
+ * sampling from plane 0, and interpolate U and V correctly when
+ * sampling from plane 1. */
+ { __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
+ { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
+};
+
+static __DRIimage *
+intel_allocate_image(int dri_format, void *loaderPrivate)
+{
+ __DRIimage *image;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->dri_format = dri_format;
+ image->offset = 0;
+
+ switch (dri_format) {
+ case __DRI_IMAGE_FORMAT_RGB565:
+ image->format = MESA_FORMAT_RGB565;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ image->format = MESA_FORMAT_XRGB8888;
+ break;
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ image->format = MESA_FORMAT_ARGB8888;
+ break;
+ case __DRI_IMAGE_FORMAT_ABGR8888:
+ image->format = MESA_FORMAT_RGBA8888_REV;
+ break;
+ case __DRI_IMAGE_FORMAT_XBGR8888:
+ image->format = MESA_FORMAT_RGBX8888_REV;
+ break;
+ case __DRI_IMAGE_FORMAT_R8:
+ image->format = MESA_FORMAT_R8;
+ break;
+ case __DRI_IMAGE_FORMAT_GR88:
+ image->format = MESA_FORMAT_GR88;
+ break;
+ case __DRI_IMAGE_FORMAT_NONE:
+ image->format = MESA_FORMAT_NONE;
+ break;
+ default:
+ free(image);
+ return NULL;
+ }
+
+ image->internal_format = _mesa_get_format_base_format(image->format);
+ image->data = loaderPrivate;
+
+ return image;
+}
+
+static __DRIimage *
+intel_create_image_from_name(__DRIscreen *screen,
+ int width, int height, int format,
+ int name, int pitch, void *loaderPrivate)
+{
+ struct intel_screen *intelScreen = screen->driverPrivate;
+ __DRIimage *image;
+ int cpp;
+
+ image = intel_allocate_image(format, loaderPrivate);
+ if (image->format == MESA_FORMAT_NONE)
+ cpp = 1;
+ else
+ cpp = _mesa_get_format_bytes(image->format);
+ image->region = intel_region_alloc_for_handle(intelScreen,
+ cpp, width, height,
+ pitch, name, "image");
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static __DRIimage *
+intel_create_image_from_renderbuffer(__DRIcontext *context,
+ int renderbuffer, void *loaderPrivate)
+{
+ __DRIimage *image;
+ struct intel_context *intel = context->driverPrivate;
+ struct gl_renderbuffer *rb;
+ struct intel_renderbuffer *irb;
+
+ rb = _mesa_lookup_renderbuffer(&intel->ctx, renderbuffer);
+ if (!rb) {
+ _mesa_error(&intel->ctx,
+ GL_INVALID_OPERATION, "glRenderbufferExternalMESA");
+ return NULL;
+ }
+
+ irb = intel_renderbuffer(rb);
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->internal_format = rb->InternalFormat;
+ image->format = rb->Format;
+ image->offset = 0;
+ image->data = loaderPrivate;
+ intel_region_reference(&image->region, irb->mt->region);
+
+ switch (image->format) {
+ case MESA_FORMAT_RGB565:
+ image->dri_format = __DRI_IMAGE_FORMAT_RGB565;
+ break;
+ case MESA_FORMAT_XRGB8888:
+ image->dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
+ break;
+ case MESA_FORMAT_ARGB8888:
+ image->dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
+ break;
+ case MESA_FORMAT_RGBA8888_REV:
+ image->dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
+ break;
+ case MESA_FORMAT_R8:
+ image->dri_format = __DRI_IMAGE_FORMAT_R8;
+ break;
+ case MESA_FORMAT_RG88:
+ image->dri_format = __DRI_IMAGE_FORMAT_GR88;
+ break;
+ }
+
+ return image;
+}
+
+static void
+intel_destroy_image(__DRIimage *image)
+{
+ intel_region_release(&image->region);
+ FREE(image);
+}
+
+static __DRIimage *
+intel_create_image(__DRIscreen *screen,
+ int width, int height, int format,
+ unsigned int use,
+ void *loaderPrivate)
+{
+ __DRIimage *image;
+ struct intel_screen *intelScreen = screen->driverPrivate;
+ uint32_t tiling;
+ int cpp;
+
+ tiling = I915_TILING_X;
+ if (use & __DRI_IMAGE_USE_CURSOR) {
+ if (width != 64 || height != 64)
+ return NULL;
+ tiling = I915_TILING_NONE;
+ }
+
+ image = intel_allocate_image(format, loaderPrivate);
+ cpp = _mesa_get_format_bytes(image->format);
+ image->region =
+ intel_region_alloc(intelScreen, tiling, cpp, width, height, true);
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static GLboolean
+intel_query_image(__DRIimage *image, int attrib, int *value)
+{
+ switch (attrib) {
+ case __DRI_IMAGE_ATTRIB_STRIDE:
+ *value = image->region->pitch * image->region->cpp;
+ return true;
+ case __DRI_IMAGE_ATTRIB_HANDLE:
+ *value = image->region->bo->handle;
+ return true;
+ case __DRI_IMAGE_ATTRIB_NAME:
+ return intel_region_flink(image->region, (uint32_t *) value);
+ case __DRI_IMAGE_ATTRIB_FORMAT:
+ *value = image->dri_format;
+ return true;
+ case __DRI_IMAGE_ATTRIB_WIDTH:
+ *value = image->region->width;
+ return true;
+ case __DRI_IMAGE_ATTRIB_HEIGHT:
+ *value = image->region->height;
+ return true;
+ case __DRI_IMAGE_ATTRIB_COMPONENTS:
+ if (image->planar_format == NULL)
+ return false;
+ *value = image->planar_format->components;
+ return true;
+ default:
+ return false;
+ }
+}
+
+static __DRIimage *
+intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
+{
+ __DRIimage *image;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ intel_region_reference(&image->region, orig_image->region);
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ image->internal_format = orig_image->internal_format;
+ image->planar_format = orig_image->planar_format;
+ image->dri_format = orig_image->dri_format;
+ image->format = orig_image->format;
+ image->offset = orig_image->offset;
+ image->data = loaderPrivate;
+
+ memcpy(image->strides, orig_image->strides, sizeof(image->strides));
+ memcpy(image->offsets, orig_image->offsets, sizeof(image->offsets));
+
+ return image;
+}
+
+static GLboolean
+intel_validate_usage(__DRIimage *image, unsigned int use)
+{
+ if (use & __DRI_IMAGE_USE_CURSOR) {
+ if (image->region->width != 64 || image->region->height != 64)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static __DRIimage *
+intel_create_image_from_names(__DRIscreen *screen,
+ int width, int height, int fourcc,
+ int *names, int num_names,
+ int *strides, int *offsets,
+ void *loaderPrivate)
+{
+ struct intel_image_format *f = NULL;
+ __DRIimage *image;
+ int i, index;
+
+ if (screen == NULL || names == NULL || num_names != 1)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
+ if (intel_image_formats[i].fourcc == fourcc) {
+ f = &intel_image_formats[i];
+ }
+ }
+
+ if (f == NULL)
+ return NULL;
+
+ image = intel_create_image_from_name(screen, width, height,
+ __DRI_IMAGE_FORMAT_NONE,
+ names[0], strides[0],
+ loaderPrivate);
+
+ if (image == NULL)
+ return NULL;
+
+ image->planar_format = f;
+ for (i = 0; i < f->nplanes; i++) {
+ index = f->planes[i].buffer_index;
+ image->offsets[index] = offsets[index];
+ image->strides[index] = strides[index];
+ }
+
+ return image;
+}
+
+static __DRIimage *
+intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
+{
+ int width, height, offset, stride, dri_format, cpp, index, pitch;
+ struct intel_image_format *f;
+ uint32_t mask_x, mask_y;
+ __DRIimage *image;
+
+ if (parent == NULL || parent->planar_format == NULL)
+ return NULL;
+
+ f = parent->planar_format;
+
+ if (plane >= f->nplanes)
+ return NULL;
+
+ width = parent->region->width >> f->planes[plane].width_shift;
+ height = parent->region->height >> f->planes[plane].height_shift;
+ dri_format = f->planes[plane].dri_format;
+ index = f->planes[plane].buffer_index;
+ offset = parent->offsets[index];
+ stride = parent->strides[index];
+
+ image = intel_allocate_image(dri_format, loaderPrivate);
+ cpp = _mesa_get_format_bytes(image->format); /* safe since no none format */
+ pitch = stride / cpp;
+ if (offset + height * cpp * pitch > parent->region->bo->size) {
+ _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
+ FREE(image);
+ return NULL;
+ }
+
+ image->region = calloc(sizeof(*image->region), 1);
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ image->region->cpp = _mesa_get_format_bytes(image->format);
+ image->region->width = width;
+ image->region->height = height;
+ image->region->pitch = pitch;
+ image->region->refcount = 1;
+ image->region->bo = parent->region->bo;
+ drm_intel_bo_reference(image->region->bo);
+ image->region->tiling = parent->region->tiling;
+ image->region->screen = parent->region->screen;
+ image->offset = offset;
+
+ intel_region_get_tile_masks(image->region, &mask_x, &mask_y, false);
+ if (offset & mask_x)
+ _mesa_warning(NULL,
+ "intel_create_sub_image: offset not on tile boundary");
+
+ return image;
+}
+
+static struct __DRIimageExtensionRec intelImageExtension = {
+ { __DRI_IMAGE, 5 },
+ intel_create_image_from_name,
+ intel_create_image_from_renderbuffer,
+ intel_destroy_image,
+ intel_create_image,
+ intel_query_image,
+ intel_dup_image,
+ intel_validate_usage,
+ intel_create_image_from_names,
+ intel_from_planar
+};
+
+static const __DRIextension *intelScreenExtensions[] = {
+ &intelTexBufferExtension.base,
+ &intelFlushExtension.base,
+ &intelImageExtension.base,
+ &dri2ConfigQueryExtension.base,
+ NULL
+};
+
+static bool
+intel_get_param(__DRIscreen *psp, int param, int *value)
+{
+ int ret;
+ struct drm_i915_getparam gp;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = param;
+ gp.value = value;
+
+ ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+ if (ret) {
+ if (ret != -EINVAL)
+ _mesa_warning(NULL, "drm_i915_getparam: %d", ret);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+intel_get_boolean(__DRIscreen *psp, int param)
+{
+ int value = 0;
+ return intel_get_param(psp, param, &value) && value;
+}
+
+static void
+nop_callback(GLuint key, void *data, void *userData)
+{
+}
+
+static void
+intelDestroyScreen(__DRIscreen * sPriv)
+{
+ struct intel_screen *intelScreen = sPriv->driverPrivate;
+
+ dri_bufmgr_destroy(intelScreen->bufmgr);
+ driDestroyOptionInfo(&intelScreen->optionCache);
+
+ /* Some regions may still have references to them at this point, so
+ * flush the hash table to prevent _mesa_DeleteHashTable() from
+ * complaining about the hash not being empty; */
+ _mesa_HashDeleteAll(intelScreen->named_regions, nop_callback, NULL);
+ _mesa_DeleteHashTable(intelScreen->named_regions);
+
+ FREE(intelScreen);
+ sPriv->driverPrivate = NULL;
+}
+
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+static GLboolean
+intelCreateBuffer(__DRIscreen * driScrnPriv,
+ __DRIdrawable * driDrawPriv,
+ const struct gl_config * mesaVis, GLboolean isPixmap)
+{
+ struct intel_renderbuffer *rb;
+ struct intel_screen *screen = (struct intel_screen*) driScrnPriv->driverPrivate;
+ gl_format rgbFormat;
+ unsigned num_samples = intel_quantize_num_samples(screen, mesaVis->samples);
+ struct gl_framebuffer *fb;
+
+ if (isPixmap)
+ return false;
+
+ fb = CALLOC_STRUCT(gl_framebuffer);
+ if (!fb)
+ return false;
+
+ _mesa_initialize_window_framebuffer(fb, mesaVis);
+
+ if (mesaVis->redBits == 5)
+ rgbFormat = MESA_FORMAT_RGB565;
+ else if (mesaVis->alphaBits == 0)
+ rgbFormat = MESA_FORMAT_XRGB8888;
+ else
+ rgbFormat = MESA_FORMAT_ARGB8888;
+
+ /* setup the hardware-based renderbuffers */
+ rb = intel_create_renderbuffer(rgbFormat, num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base.Base);
+
+ if (mesaVis->doubleBufferMode) {
+ rb = intel_create_renderbuffer(rgbFormat, num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base.Base);
+ }
+
+ /*
+ * Assert here that the gl_config has an expected depth/stencil bit
+ * combination: one of d24/s8, d16/s0, d0/s0. (See intelInitScreen2(),
+ * which constructs the advertised configs.)
+ */
+ if (mesaVis->depthBits == 24) {
+ assert(mesaVis->stencilBits == 8);
+
+ if (screen->hw_has_separate_stencil) {
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_X8_Z24,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base.Base);
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_S8,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base.Base);
+ } else {
+ /*
+ * Use combined depth/stencil. Note that the renderbuffer is
+ * attached to two attachment points.
+ */
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_S8_Z24,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base.Base);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base.Base);
+ }
+ }
+ else if (mesaVis->depthBits == 16) {
+ assert(mesaVis->stencilBits == 0);
+ rb = intel_create_private_renderbuffer(MESA_FORMAT_Z16,
+ num_samples);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base.Base);
+ }
+ else {
+ assert(mesaVis->depthBits == 0);
+ assert(mesaVis->stencilBits == 0);
+ }
+
+ /* now add any/all software-based renderbuffers we may need */
+ _swrast_add_soft_renderbuffers(fb,
+ false, /* never sw color */
+ false, /* never sw depth */
+ false, /* never sw stencil */
+ mesaVis->accumRedBits > 0,
+ false, /* never sw alpha */
+ false /* never sw aux */ );
+ driDrawPriv->driverPrivate = fb;
+
+ return true;
+}
+
+static void
+intelDestroyBuffer(__DRIdrawable * driDrawPriv)
+{
+ struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+
+ _mesa_reference_framebuffer(&fb, NULL);
+}
+
+/* There are probably better ways to do this, such as an
+ * init-designated function to register chipids and createcontext
+ * functions.
+ */
+extern bool
+i830CreateContext(const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ void *sharedContextPrivate);
+
+extern bool
+i915CreateContext(int api,
+ const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ unsigned *error,
+ void *sharedContextPrivate);
+extern bool
+brwCreateContext(int api,
+ const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate);
+
+static GLboolean
+intelCreateContext(gl_api api,
+ const struct gl_config * mesaVis,
+ __DRIcontext * driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate)
+{
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+ struct intel_screen *intelScreen = sPriv->driverPrivate;
+ bool success = false;
+
+#ifdef I915
+ if (IS_9XX(intelScreen->deviceID)) {
+ success = i915CreateContext(api, mesaVis, driContextPriv,
+ major_version, minor_version, error,
+ sharedContextPrivate);
+ } else {
+ switch (api) {
+ case API_OPENGL:
+ if (major_version > 1 || minor_version > 3) {
+ *error = __DRI_CTX_ERROR_BAD_VERSION;
+ success = false;
+ }
+ break;
+ case API_OPENGLES:
+ break;
+ default:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ success = false;
+ }
+
+ if (success) {
+ intelScreen->no_vbo = true;
+ success = i830CreateContext(mesaVis, driContextPriv,
+ sharedContextPrivate);
+ if (!success)
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
+ }
+ }
+#else
+ success = brwCreateContext(api, mesaVis,
+ driContextPriv,
+ major_version, minor_version, flags,
+ error, sharedContextPrivate);
+#endif
+
+ if (success)
+ return true;
+
+ if (driContextPriv->driverPrivate != NULL)
+ intelDestroyContext(driContextPriv);
+
+ return false;
+}
+
+static bool
+intel_init_bufmgr(struct intel_screen *intelScreen)
+{
+ __DRIscreen *spriv = intelScreen->driScrnPriv;
+ int num_fences = 0;
+
+ intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
+
+ intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
+ if (intelScreen->bufmgr == NULL) {
+ fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+ __func__, __LINE__);
+ return false;
+ }
+
+ if (!intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences) ||
+ num_fences == 0) {
+ fprintf(stderr, "[%s: %u] Kernel 2.6.29 required.\n", __func__, __LINE__);
+ return false;
+ }
+
+ drm_intel_bufmgr_gem_enable_fenced_relocs(intelScreen->bufmgr);
+
+ intelScreen->named_regions = _mesa_NewHashTable();
+
+ intelScreen->relaxed_relocations = 0;
+ intelScreen->relaxed_relocations |=
+ intel_get_boolean(spriv, I915_PARAM_HAS_RELAXED_DELTA) << 0;
+
+ return true;
+}
+
+/**
+ * Override intel_screen.hw_has_separate_stencil with environment variable
+ * INTEL_SEPARATE_STENCIL.
+ *
+ * Valid values for INTEL_SEPARATE_STENCIL are "0" and "1". If an invalid
+ * valid value is encountered, a warning is emitted and INTEL_SEPARATE_STENCIL
+ * is ignored.
+ */
+static void
+intel_override_separate_stencil(struct intel_screen *screen)
+{
+ const char *s = getenv("INTEL_SEPARATE_STENCIL");
+ if (!s) {
+ return;
+ } else if (!strncmp("0", s, 2)) {
+ screen->hw_has_separate_stencil = false;
+ } else if (!strncmp("1", s, 2)) {
+ screen->hw_has_separate_stencil = true;
+ } else {
+ fprintf(stderr,
+ "warning: env variable INTEL_SEPARATE_STENCIL=\"%s\" has "
+ "invalid value and is ignored", s);
+ }
+}
+
+static bool
+intel_detect_swizzling(struct intel_screen *screen)
+{
+ drm_intel_bo *buffer;
+ unsigned long flags = 0;
+ unsigned long aligned_pitch;
+ uint32_t tiling = I915_TILING_X;
+ uint32_t swizzle_mode = 0;
+
+ buffer = drm_intel_bo_alloc_tiled(screen->bufmgr, "swizzle test",
+ 64, 64, 4,
+ &tiling, &aligned_pitch, flags);
+ if (buffer == NULL)
+ return false;
+
+ drm_intel_bo_get_tiling(buffer, &tiling, &swizzle_mode);
+ drm_intel_bo_unreference(buffer);
+
+ if (swizzle_mode == I915_BIT_6_SWIZZLE_NONE)
+ return false;
+ else
+ return true;
+}
+
+static __DRIconfig**
+intel_screen_make_configs(__DRIscreen *dri_screen)
+{
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ static const uint8_t singlesample_samples[1] = {0};
+ static const uint8_t multisample_samples[2] = {4, 8};
+
+ struct intel_screen *screen = dri_screen->driverPrivate;
+ GLenum fb_format[3];
+ GLenum fb_type[3];
+ uint8_t depth_bits[4], stencil_bits[4];
+ __DRIconfig **configs = NULL;
+
+ fb_format[0] = GL_RGB;
+ fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
+
+ fb_format[1] = GL_BGR;
+ fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+ fb_format[2] = GL_BGRA;
+ fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+ /* Generate singlesample configs without accumulation buffer. */
+ for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ __DRIconfig **new_configs;
+ const int num_depth_stencil_bits = 2;
+
+ /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil
+ * buffer that has a different number of bits per pixel than the color
+ * buffer. This isn't yet supported here.
+ */
+ depth_bits[0] = 0;
+ stencil_bits[0] = 0;
+
+ if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ depth_bits[1] = 16;
+ stencil_bits[1] = 0;
+ } else {
+ depth_bits[1] = 24;
+ stencil_bits[1] = 8;
+ }
+
+ new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ depth_bits,
+ stencil_bits,
+ num_depth_stencil_bits,
+ back_buffer_modes,
+ ARRAY_SIZE(back_buffer_modes),
+ singlesample_samples, 1,
+ false);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ /* Generate the minimum possible set of configs that include an
+ * accumulation buffer.
+ */
+ for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ __DRIconfig **new_configs;
+
+ if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ depth_bits[0] = 16;
+ stencil_bits[0] = 0;
+ } else {
+ depth_bits[0] = 24;
+ stencil_bits[0] = 8;
+ }
+
+ new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ depth_bits, stencil_bits, 1,
+ back_buffer_modes + 1, 1,
+ singlesample_samples, 1,
+ true);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ /* Generate multisample configs.
+ *
+ * This loop breaks early, and hence is a no-op, on gen < 6.
+ *
+ * Multisample configs must follow the singlesample configs in order to
+ * work around an X server bug present in 1.12. The X server chooses to
+ * associate the first listed RGBA888-Z24S8 config, regardless of its
+ * sample count, with the 32-bit depth visual used for compositing.
+ *
+ * Only doublebuffer configs with GLX_SWAP_UNDEFINED_OML behavior are
+ * supported. Singlebuffer configs are not supported because no one wants
+ * them. GLX_SWAP_COPY_OML is not supported due to page flipping.
+ */
+ for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+ if (screen->gen < 6)
+ break;
+
+ __DRIconfig **new_configs;
+ const int num_depth_stencil_bits = 2;
+ int num_msaa_modes = 0;
+
+ depth_bits[0] = 0;
+ stencil_bits[0] = 0;
+
+ if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+ depth_bits[1] = 16;
+ stencil_bits[1] = 0;
+ } else {
+ depth_bits[1] = 24;
+ stencil_bits[1] = 8;
+ }
+
+ if (screen->gen >= 7)
+ num_msaa_modes = 2;
+ else if (screen->gen == 6)
+ num_msaa_modes = 1;
+
+ new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+ depth_bits,
+ stencil_bits,
+ num_depth_stencil_bits,
+ back_buffer_modes + 1, 1,
+ multisample_samples,
+ num_msaa_modes,
+ false);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ if (configs == NULL) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ __LINE__);
+ return NULL;
+ }
+
+ return configs;
+}
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * Called when using DRI2.
+ *
+ * \return the struct gl_config supported by this driver
+ */
+static const
+__DRIconfig **intelInitScreen2(__DRIscreen *psp)
+{
+ struct intel_screen *intelScreen;
+ unsigned int api_mask;
+
+ if (psp->dri2.loader->base.version <= 2 ||
+ psp->dri2.loader->getBuffersWithFormat == NULL) {
+ fprintf(stderr,
+ "\nERROR! DRI2 loader with getBuffersWithFormat() "
+ "support required\n");
+ return false;
+ }
+
+ /* Allocate the private area */
+ intelScreen = CALLOC(sizeof *intelScreen);
+ if (!intelScreen) {
+ fprintf(stderr, "\nERROR! Allocating private area failed\n");
+ return false;
+ }
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo(&intelScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ intelScreen->driScrnPriv = psp;
+ psp->driverPrivate = (void *) intelScreen;
+
+ if (!intel_init_bufmgr(intelScreen))
+ return false;
+
+ intelScreen->deviceID = drm_intel_bufmgr_gem_get_devid(intelScreen->bufmgr);
+
+ intelScreen->kernel_has_gen7_sol_reset =
+ intel_get_boolean(intelScreen->driScrnPriv,
+ I915_PARAM_HAS_GEN7_SOL_RESET);
+
+ if (IS_GEN7(intelScreen->deviceID)) {
+ intelScreen->gen = 7;
+ } else if (IS_GEN6(intelScreen->deviceID)) {
+ intelScreen->gen = 6;
+ } else if (IS_GEN5(intelScreen->deviceID)) {
+ intelScreen->gen = 5;
+ } else if (IS_965(intelScreen->deviceID)) {
+ intelScreen->gen = 4;
+ } else if (IS_9XX(intelScreen->deviceID)) {
+ intelScreen->gen = 3;
+ } else {
+ intelScreen->gen = 2;
+ }
+
+ intelScreen->hw_has_separate_stencil = intelScreen->gen >= 6;
+ intelScreen->hw_must_use_separate_stencil = intelScreen->gen >= 7;
+
+ int has_llc = 0;
+ bool success = intel_get_param(intelScreen->driScrnPriv, I915_PARAM_HAS_LLC,
+ &has_llc);
+ if (success && has_llc)
+ intelScreen->hw_has_llc = true;
+ else if (!success && intelScreen->gen >= 6)
+ intelScreen->hw_has_llc = true;
+
+ intel_override_separate_stencil(intelScreen);
+
+ api_mask = (1 << __DRI_API_OPENGL);
+#if FEATURE_ES1
+ api_mask |= (1 << __DRI_API_GLES);
+#endif
+#if FEATURE_ES2
+ api_mask |= (1 << __DRI_API_GLES2);
+#endif
+
+ if (IS_9XX(intelScreen->deviceID) || IS_965(intelScreen->deviceID))
+ psp->api_mask = api_mask;
+
+ intelScreen->hw_has_swizzling = intel_detect_swizzling(intelScreen);
+
+ psp->extensions = intelScreenExtensions;
+
+ return (const __DRIconfig**) intel_screen_make_configs(psp);
+}
+
+struct intel_buffer {
+ __DRIbuffer base;
+ struct intel_region *region;
+};
+
+static __DRIbuffer *
+intelAllocateBuffer(__DRIscreen *screen,
+ unsigned attachment, unsigned format,
+ int width, int height)
+{
+ struct intel_buffer *intelBuffer;
+ struct intel_screen *intelScreen = screen->driverPrivate;
+
+ assert(attachment == __DRI_BUFFER_FRONT_LEFT ||
+ attachment == __DRI_BUFFER_BACK_LEFT);
+
+ intelBuffer = CALLOC(sizeof *intelBuffer);
+ if (intelBuffer == NULL)
+ return NULL;
+
+ /* The front and back buffers are color buffers, which are X tiled. */
+ intelBuffer->region = intel_region_alloc(intelScreen,
+ I915_TILING_X,
+ format / 8,
+ width,
+ height,
+ true);
+
+ if (intelBuffer->region == NULL) {
+ FREE(intelBuffer);
+ return NULL;
+ }
+
+ intel_region_flink(intelBuffer->region, &intelBuffer->base.name);
+
+ intelBuffer->base.attachment = attachment;
+ intelBuffer->base.cpp = intelBuffer->region->cpp;
+ intelBuffer->base.pitch =
+ intelBuffer->region->pitch * intelBuffer->region->cpp;
+
+ return &intelBuffer->base;
+}
+
+static void
+intelReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
+{
+ struct intel_buffer *intelBuffer = (struct intel_buffer *) buffer;
+
+ intel_region_release(&intelBuffer->region);
+ free(intelBuffer);
+}
+
+
+const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = intelInitScreen2,
+ .DestroyScreen = intelDestroyScreen,
+ .CreateContext = intelCreateContext,
+ .DestroyContext = intelDestroyContext,
+ .CreateBuffer = intelCreateBuffer,
+ .DestroyBuffer = intelDestroyBuffer,
+ .MakeCurrent = intelMakeCurrent,
+ .UnbindContext = intelUnbindContext,
+ .AllocateBuffer = intelAllocateBuffer,
+ .ReleaseBuffer = intelReleaseBuffer
+};
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+ &driCoreExtension.base,
+ &driDRI2Extension.base,
+ NULL
+};
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_span.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_span.c
index 05e5e8e5833..d7eaa41241e 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_span.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_span.c
@@ -1 +1,215 @@
-../intel/intel_span.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2011 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chad Versace <chad@chad-versace.us>
+ *
+ **************************************************************************/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/colormac.h"
+#include "main/renderbuffer.h"
+
+#include "intel_buffers.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_screen.h"
+#include "intel_span.h"
+#include "intel_regions.h"
+#include "intel_tex.h"
+
+#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
+
+/**
+ * \brief Get pointer offset into stencil buffer.
+ *
+ * The stencil buffer is W tiled. Since the GTT is incapable of W fencing, we
+ * must decode the tile's layout in software.
+ *
+ * See
+ * - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Tile
+ * Format.
+ * - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.3 Tiling Algorithm
+ *
+ * Even though the returned offset is always positive, the return type is
+ * signed due to
+ * commit e8b1c6d6f55f5be3bef25084fdd8b6127517e137
+ * mesa: Fix return type of _mesa_get_format_bytes() (#37351)
+ */
+intptr_t
+intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y, bool swizzled)
+{
+ uint32_t tile_size = 4096;
+ uint32_t tile_width = 64;
+ uint32_t tile_height = 64;
+ uint32_t row_size = 64 * stride;
+
+ uint32_t tile_x = x / tile_width;
+ uint32_t tile_y = y / tile_height;
+
+ /* The byte's address relative to the tile's base addres. */
+ uint32_t byte_x = x % tile_width;
+ uint32_t byte_y = y % tile_height;
+
+ uintptr_t u = tile_y * row_size
+ + tile_x * tile_size
+ + 512 * (byte_x / 8)
+ + 64 * (byte_y / 8)
+ + 32 * ((byte_y / 4) % 2)
+ + 16 * ((byte_x / 4) % 2)
+ + 8 * ((byte_y / 2) % 2)
+ + 4 * ((byte_x / 2) % 2)
+ + 2 * (byte_y % 2)
+ + 1 * (byte_x % 2);
+
+ if (swizzled) {
+ /* adjust for bit6 swizzling */
+ if (((byte_x / 8) % 2) == 1) {
+ if (((byte_y / 8) % 2) == 0) {
+ u += 64;
+ } else {
+ u -= 64;
+ }
+ }
+ }
+
+ return u;
+}
+
+/**
+ * Map the regions needed by intelSpanRenderStart().
+ */
+static void
+intel_span_map_buffers(struct intel_context *intel)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct intel_texture_object *tex_obj;
+
+ for (int i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ continue;
+ tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
+ intel_finalize_mipmap_tree(intel, i);
+ intel_tex_map_images(intel, tex_obj,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+ }
+
+ _swrast_map_renderbuffers(ctx);
+}
+
+/**
+ * Prepare for software rendering. Map current read/draw framebuffers'
+ * renderbuffes and all currently bound texture objects.
+ *
+ * Old note: Moved locking out to get reasonable span performance.
+ */
+void
+intelSpanRenderStart(struct gl_context * ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ intel_flush(ctx);
+ intel_prepare_render(intel);
+ intel_flush(ctx);
+ intel_span_map_buffers(intel);
+}
+
+/**
+ * Called when done software rendering. Unmap the buffers we mapped in
+ * the above function.
+ */
+void
+intelSpanRenderFinish(struct gl_context * ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ GLuint i;
+
+ _swrast_flush(ctx);
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+ intel_tex_unmap_images(intel, intel_texture_object(texObj));
+ }
+ }
+
+ _swrast_unmap_renderbuffers(ctx);
+}
+
+
+void
+intelInitSpanFuncs(struct gl_context * ctx)
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+ if (swdd) {
+ swdd->SpanRenderStart = intelSpanRenderStart;
+ swdd->SpanRenderFinish = intelSpanRenderFinish;
+ }
+}
+
+void
+intel_map_vertex_shader_textures(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ int i;
+
+ if (ctx->VertexProgram._Current == NULL)
+ return;
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled &&
+ ctx->VertexProgram._Current->Base.TexturesUsed[i] != 0) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+
+ intel_tex_map_images(intel, intel_texture_object(texObj),
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+ }
+ }
+}
+
+void
+intel_unmap_vertex_shader_textures(struct gl_context *ctx)
+{
+ struct intel_context *intel = intel_context(ctx);
+ int i;
+
+ if (ctx->VertexProgram._Current == NULL)
+ return;
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled &&
+ ctx->VertexProgram._Current->Base.TexturesUsed[i] != 0) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+
+ intel_tex_unmap_images(intel, intel_texture_object(texObj));
+ }
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_state.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_state.c
index 519672fc359..6a817cdf3f6 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_state.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_state.c
@@ -1 +1,195 @@
-../intel/intel_state.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/enums.h"
+#include "main/colormac.h"
+#include "main/dd.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+
+int
+intel_translate_shadow_compare_func(GLenum func)
+{
+ switch (func) {
+ case GL_NEVER:
+ return COMPAREFUNC_ALWAYS;
+ case GL_LESS:
+ return COMPAREFUNC_LEQUAL;
+ case GL_LEQUAL:
+ return COMPAREFUNC_LESS;
+ case GL_GREATER:
+ return COMPAREFUNC_GEQUAL;
+ case GL_GEQUAL:
+ return COMPAREFUNC_GREATER;
+ case GL_NOTEQUAL:
+ return COMPAREFUNC_EQUAL;
+ case GL_EQUAL:
+ return COMPAREFUNC_NOTEQUAL;
+ case GL_ALWAYS:
+ return COMPAREFUNC_NEVER;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+ return COMPAREFUNC_NEVER;
+}
+
+int
+intel_translate_compare_func(GLenum func)
+{
+ switch (func) {
+ case GL_NEVER:
+ return COMPAREFUNC_NEVER;
+ case GL_LESS:
+ return COMPAREFUNC_LESS;
+ case GL_LEQUAL:
+ return COMPAREFUNC_LEQUAL;
+ case GL_GREATER:
+ return COMPAREFUNC_GREATER;
+ case GL_GEQUAL:
+ return COMPAREFUNC_GEQUAL;
+ case GL_NOTEQUAL:
+ return COMPAREFUNC_NOTEQUAL;
+ case GL_EQUAL:
+ return COMPAREFUNC_EQUAL;
+ case GL_ALWAYS:
+ return COMPAREFUNC_ALWAYS;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+ return COMPAREFUNC_ALWAYS;
+}
+
+int
+intel_translate_stencil_op(GLenum op)
+{
+ switch (op) {
+ case GL_KEEP:
+ return STENCILOP_KEEP;
+ case GL_ZERO:
+ return STENCILOP_ZERO;
+ case GL_REPLACE:
+ return STENCILOP_REPLACE;
+ case GL_INCR:
+ return STENCILOP_INCRSAT;
+ case GL_DECR:
+ return STENCILOP_DECRSAT;
+ case GL_INCR_WRAP:
+ return STENCILOP_INCR;
+ case GL_DECR_WRAP:
+ return STENCILOP_DECR;
+ case GL_INVERT:
+ return STENCILOP_INVERT;
+ default:
+ return STENCILOP_ZERO;
+ }
+}
+
+int
+intel_translate_blend_factor(GLenum factor)
+{
+ switch (factor) {
+ case GL_ZERO:
+ return BLENDFACT_ZERO;
+ case GL_SRC_ALPHA:
+ return BLENDFACT_SRC_ALPHA;
+ case GL_ONE:
+ return BLENDFACT_ONE;
+ case GL_SRC_COLOR:
+ return BLENDFACT_SRC_COLR;
+ case GL_ONE_MINUS_SRC_COLOR:
+ return BLENDFACT_INV_SRC_COLR;
+ case GL_DST_COLOR:
+ return BLENDFACT_DST_COLR;
+ case GL_ONE_MINUS_DST_COLOR:
+ return BLENDFACT_INV_DST_COLR;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ return BLENDFACT_INV_SRC_ALPHA;
+ case GL_DST_ALPHA:
+ return BLENDFACT_DST_ALPHA;
+ case GL_ONE_MINUS_DST_ALPHA:
+ return BLENDFACT_INV_DST_ALPHA;
+ case GL_SRC_ALPHA_SATURATE:
+ return BLENDFACT_SRC_ALPHA_SATURATE;
+ case GL_CONSTANT_COLOR:
+ return BLENDFACT_CONST_COLOR;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ return BLENDFACT_INV_CONST_COLOR;
+ case GL_CONSTANT_ALPHA:
+ return BLENDFACT_CONST_ALPHA;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ return BLENDFACT_INV_CONST_ALPHA;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, factor);
+ return BLENDFACT_ZERO;
+}
+
+int
+intel_translate_logic_op(GLenum opcode)
+{
+ switch (opcode) {
+ case GL_CLEAR:
+ return LOGICOP_CLEAR;
+ case GL_AND:
+ return LOGICOP_AND;
+ case GL_AND_REVERSE:
+ return LOGICOP_AND_RVRSE;
+ case GL_COPY:
+ return LOGICOP_COPY;
+ case GL_COPY_INVERTED:
+ return LOGICOP_COPY_INV;
+ case GL_AND_INVERTED:
+ return LOGICOP_AND_INV;
+ case GL_NOOP:
+ return LOGICOP_NOOP;
+ case GL_XOR:
+ return LOGICOP_XOR;
+ case GL_OR:
+ return LOGICOP_OR;
+ case GL_OR_INVERTED:
+ return LOGICOP_OR_INV;
+ case GL_NOR:
+ return LOGICOP_NOR;
+ case GL_EQUIV:
+ return LOGICOP_EQUIV;
+ case GL_INVERT:
+ return LOGICOP_INV;
+ case GL_OR_REVERSE:
+ return LOGICOP_OR_RVRSE;
+ case GL_NAND:
+ return LOGICOP_NAND;
+ case GL_SET:
+ return LOGICOP_SET;
+ default:
+ return LOGICOP_SET;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_syncobj.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_syncobj.c
index 0b2e56ab246..e965896df60 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_syncobj.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_syncobj.c
@@ -1 +1,132 @@
-../intel/intel_syncobj.c \ No newline at end of file
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file intel_syncobj.c
+ *
+ * Support for ARB_sync
+ *
+ * ARB_sync is implemented by flushing the current batchbuffer and keeping a
+ * reference on it. We can then check for completion or wait for completion
+ * using the normal buffer object mechanisms. This does mean that if an
+ * application is using many sync objects, it will emit small batchbuffers
+ * which may end up being a significant overhead. In other tests of removing
+ * gratuitous batchbuffer syncs in Mesa, it hasn't appeared to be a significant
+ * performance bottleneck, though.
+ */
+
+#include "main/simple_list.h"
+#include "main/imports.h"
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_reg.h"
+
+static struct gl_sync_object *
+intel_new_sync_object(struct gl_context *ctx, GLuint id)
+{
+ struct intel_sync_object *sync;
+
+ sync = calloc(1, sizeof(struct intel_sync_object));
+
+ return &sync->Base;
+}
+
+static void
+intel_delete_sync_object(struct gl_context *ctx, struct gl_sync_object *s)
+{
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ drm_intel_bo_unreference(sync->bo);
+ free(sync);
+}
+
+static void
+intel_fence_sync(struct gl_context *ctx, struct gl_sync_object *s,
+ GLenum condition, GLbitfield flags)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ assert(condition == GL_SYNC_GPU_COMMANDS_COMPLETE);
+ intel_batchbuffer_emit_mi_flush(intel);
+
+ sync->bo = intel->batch.bo;
+ drm_intel_bo_reference(sync->bo);
+
+ intel_flush(ctx);
+}
+
+/* We ignore the user-supplied timeout. This is weaselly -- we're allowed to
+ * round to an implementation-dependent accuracy, and right now our
+ * implementation "rounds" to the wait-forever value.
+ *
+ * The fix would be a new kernel function to do the GTT transition with a
+ * timeout.
+ */
+static void intel_client_wait_sync(struct gl_context *ctx, struct gl_sync_object *s,
+ GLbitfield flags, GLuint64 timeout)
+{
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ if (sync->bo) {
+ drm_intel_bo_wait_rendering(sync->bo);
+ s->StatusFlag = 1;
+ drm_intel_bo_unreference(sync->bo);
+ sync->bo = NULL;
+ }
+}
+
+/* We have nothing to do for WaitSync. Our GL command stream is sequential,
+ * so given that the sync object has already flushed the batchbuffer,
+ * any batchbuffers coming after this waitsync will naturally not occur until
+ * the previous one is done.
+ */
+static void intel_server_wait_sync(struct gl_context *ctx, struct gl_sync_object *s,
+ GLbitfield flags, GLuint64 timeout)
+{
+}
+
+static void intel_check_sync(struct gl_context *ctx, struct gl_sync_object *s)
+{
+ struct intel_sync_object *sync = (struct intel_sync_object *)s;
+
+ if (sync->bo && !drm_intel_bo_busy(sync->bo)) {
+ drm_intel_bo_unreference(sync->bo);
+ sync->bo = NULL;
+ s->StatusFlag = 1;
+ }
+}
+
+void intel_init_syncobj_functions(struct dd_function_table *functions)
+{
+ functions->NewSyncObject = intel_new_sync_object;
+ functions->DeleteSyncObject = intel_delete_sync_object;
+ functions->FenceSync = intel_fence_sync;
+ functions->CheckSync = intel_check_sync;
+ functions->ClientWaitSync = intel_client_wait_sync;
+ functions->ServerWaitSync = intel_server_wait_sync;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex.c
index d77ce749a3e..5d938798d9f 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex.c
@@ -1 +1,222 @@
-../intel/intel_tex.c \ No newline at end of file
+#include "swrast/swrast.h"
+#include "main/renderbuffer.h"
+#include "main/texobj.h"
+#include "main/teximage.h"
+#include "main/mipmap.h"
+#include "drivers/common/meta.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_tex.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static struct gl_texture_image *
+intelNewTextureImage(struct gl_context * ctx)
+{
+ DBG("%s\n", __FUNCTION__);
+ (void) ctx;
+ return (struct gl_texture_image *) CALLOC_STRUCT(intel_texture_image);
+}
+
+static void
+intelDeleteTextureImage(struct gl_context * ctx, struct gl_texture_image *img)
+{
+ /* nothing special (yet) for intel_texture_image */
+ _mesa_delete_texture_image(ctx, img);
+}
+
+
+static struct gl_texture_object *
+intelNewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
+{
+ struct intel_texture_object *obj = CALLOC_STRUCT(intel_texture_object);
+
+ (void) ctx;
+
+ DBG("%s\n", __FUNCTION__);
+ _mesa_initialize_texture_object(&obj->base, name, target);
+
+ return &obj->base;
+}
+
+static void
+intelDeleteTextureObject(struct gl_context *ctx,
+ struct gl_texture_object *texObj)
+{
+ struct intel_texture_object *intelObj = intel_texture_object(texObj);
+
+ intel_miptree_release(&intelObj->mt);
+ _mesa_delete_texture_object(ctx, texObj);
+}
+
+static GLboolean
+intel_alloc_texture_image_buffer(struct gl_context *ctx,
+ struct gl_texture_image *image)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct gl_texture_object *texobj = image->TexObject;
+ struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
+ GLuint slices;
+
+ assert(image->Border == 0);
+
+ /* Because the driver uses AllocTextureImageBuffer() internally, it may end
+ * up mismatched with FreeTextureImageBuffer(), but that is safe to call
+ * multiple times.
+ */
+ ctx->Driver.FreeTextureImageBuffer(ctx, image);
+
+ /* Allocate the swrast_texture_image::ImageOffsets array now */
+ switch (texobj->Target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ slices = image->Depth;
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ slices = image->Height;
+ break;
+ default:
+ slices = 1;
+ }
+ assert(!intel_image->base.ImageOffsets);
+ intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint));
+
+ _swrast_init_texture_image(image);
+
+ if (intel_texobj->mt &&
+ intel_miptree_match_image(intel_texobj->mt, image)) {
+ intel_miptree_reference(&intel_image->mt, intel_texobj->mt);
+ DBG("%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n",
+ __FUNCTION__, texobj, image->Level,
+ image->Width, image->Height, image->Depth, intel_texobj->mt);
+ } else {
+ intel_image->mt = intel_miptree_create_for_teximage(intel, intel_texobj,
+ intel_image,
+ false);
+
+ /* Even if the object currently has a mipmap tree associated
+ * with it, this one is a more likely candidate to represent the
+ * whole object since our level didn't fit what was there
+ * before, and any lower levels would fit into our miptree.
+ */
+ intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
+
+ DBG("%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n",
+ __FUNCTION__, texobj, image->Level,
+ image->Width, image->Height, image->Depth, intel_image->mt);
+ }
+
+ return true;
+}
+
+/**
+ * Called via ctx->Driver.AllocTextureStorage()
+ * Just have to allocate memory for the texture images.
+ */
+static GLboolean
+intel_alloc_texture_storage(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLsizei levels, GLsizei width,
+ GLsizei height, GLsizei depth)
+{
+ const int numFaces = _mesa_num_tex_faces(texObj->Target);
+ int face;
+ int level;
+
+ for (face = 0; face < numFaces; face++) {
+ for (level = 0; level < levels; level++) {
+ struct gl_texture_image *const texImage = texObj->Image[face][level];
+ if (!intel_alloc_texture_image_buffer(ctx, texImage))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void
+intel_free_texture_image_buffer(struct gl_context * ctx,
+ struct gl_texture_image *texImage)
+{
+ struct intel_texture_image *intelImage = intel_texture_image(texImage);
+
+ DBG("%s\n", __FUNCTION__);
+
+ intel_miptree_release(&intelImage->mt);
+
+ if (intelImage->base.Buffer) {
+ _mesa_align_free(intelImage->base.Buffer);
+ intelImage->base.Buffer = NULL;
+ }
+
+ if (intelImage->base.ImageOffsets) {
+ free(intelImage->base.ImageOffsets);
+ intelImage->base.ImageOffsets = NULL;
+ }
+}
+
+/**
+ * Map texture memory/buffer into user space.
+ * Note: the region of interest parameters are ignored here.
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ * \param mapOut returns start of mapping of region of interest
+ * \param rowStrideOut returns row stride in bytes
+ */
+static void
+intel_map_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *tex_image,
+ GLuint slice,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **map,
+ GLint *stride)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(tex_image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+
+ /* Our texture data is always stored in a miptree. */
+ assert(mt);
+
+ /* Check that our caller wasn't confused about how to map a 1D texture. */
+ assert(tex_image->TexObject->Target != GL_TEXTURE_1D_ARRAY ||
+ h == 1);
+
+ /* intel_miptree_map operates on a unified "slice" number that references the
+ * cube face, since it's all just slices to the miptree code.
+ */
+ if (tex_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
+ slice = tex_image->Face;
+
+ intel_miptree_map(intel, mt, tex_image->Level, slice, x, y, w, h, mode,
+ (void **)map, stride);
+}
+
+static void
+intel_unmap_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *tex_image, GLuint slice)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(tex_image);
+ struct intel_mipmap_tree *mt = intel_image->mt;
+
+ if (tex_image->TexObject->Target == GL_TEXTURE_CUBE_MAP)
+ slice = tex_image->Face;
+
+ intel_miptree_unmap(intel, mt, tex_image->Level, slice);
+}
+
+void
+intelInitTextureFuncs(struct dd_function_table *functions)
+{
+ functions->NewTextureObject = intelNewTextureObject;
+ functions->NewTextureImage = intelNewTextureImage;
+ functions->DeleteTextureImage = intelDeleteTextureImage;
+ functions->DeleteTexture = intelDeleteTextureObject;
+ functions->AllocTextureImageBuffer = intel_alloc_texture_image_buffer;
+ functions->FreeTextureImageBuffer = intel_free_texture_image_buffer;
+ functions->AllocTextureStorage = intel_alloc_texture_storage;
+ functions->MapTextureImage = intel_map_texture_image;
+ functions->UnmapTextureImage = intel_unmap_texture_image;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_copy.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_copy.c
index 87196c5d1ed..f4366330f88 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_copy.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_copy.c
@@ -1 +1,171 @@
-../intel/intel_tex_copy.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "main/fbobject.h"
+
+#include "drivers/common/meta.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_fbo.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+
+bool
+intel_copy_texsubimage(struct intel_context *intel,
+ struct intel_texture_image *intelImage,
+ GLint dstx, GLint dsty,
+ struct intel_renderbuffer *irb,
+ GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct intel_region *region;
+ const GLenum internalFormat = intelImage->base.Base.InternalFormat;
+ bool copy_supported = false;
+ bool copy_supported_with_alpha_override = false;
+
+ intel_prepare_render(intel);
+
+ if (!intelImage->mt || !irb || !irb->mt) {
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF))
+ fprintf(stderr, "%s fail %p %p (0x%08x)\n",
+ __FUNCTION__, intelImage->mt, irb, internalFormat);
+ return false;
+ } else {
+ region = irb->mt->region;
+ assert(region);
+ }
+
+ copy_supported = intelImage->base.Base.TexFormat == intel_rb_format(irb);
+
+ /* Converting ARGB8888 to XRGB8888 is trivial: ignore the alpha bits */
+ if (intel_rb_format(irb) == MESA_FORMAT_ARGB8888 &&
+ intelImage->base.Base.TexFormat == MESA_FORMAT_XRGB8888) {
+ copy_supported = true;
+ }
+
+ /* Converting XRGB8888 to ARGB8888 requires setting the alpha bits to 1.0 */
+ if (intel_rb_format(irb) == MESA_FORMAT_XRGB8888 &&
+ intelImage->base.Base.TexFormat == MESA_FORMAT_ARGB8888) {
+ copy_supported_with_alpha_override = true;
+ }
+
+ if (!copy_supported && !copy_supported_with_alpha_override) {
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF))
+ fprintf(stderr, "%s mismatched formats %s, %s\n",
+ __FUNCTION__,
+ _mesa_get_format_name(intelImage->base.Base.TexFormat),
+ _mesa_get_format_name(intel_rb_format(irb)));
+ return false;
+ }
+
+ {
+ GLuint image_x, image_y;
+ GLshort src_pitch;
+
+ /* get dest x/y in destination texture */
+ intel_miptree_get_image_offset(intelImage->mt,
+ intelImage->base.Base.Level,
+ intelImage->base.Base.Face,
+ 0,
+ &image_x, &image_y);
+
+ /* The blitter can't handle Y-tiled buffers. */
+ if (intelImage->mt->region->tiling == I915_TILING_Y) {
+ return false;
+ }
+
+ if (_mesa_is_winsys_fbo(ctx->ReadBuffer)) {
+ /* Flip vertical orientation for system framebuffers */
+ y = ctx->ReadBuffer->Height - (y + height);
+ src_pitch = -region->pitch;
+ } else {
+ /* reading from a FBO, y is already oriented the way we like */
+ src_pitch = region->pitch;
+ }
+
+ /* blit from src buffer to texture */
+ if (!intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ src_pitch,
+ region->bo,
+ 0,
+ region->tiling,
+ intelImage->mt->region->pitch,
+ intelImage->mt->region->bo,
+ 0,
+ intelImage->mt->region->tiling,
+ irb->draw_x + x, irb->draw_y + y,
+ image_x + dstx, image_y + dsty,
+ width, height,
+ GL_COPY)) {
+ return false;
+ }
+ }
+
+ if (copy_supported_with_alpha_override)
+ intel_set_teximage_alpha_to_one(ctx, intelImage);
+
+ return true;
+}
+
+
+static void
+intelCopyTexSubImage(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ if (dims == 3 || !intel_copy_texsubimage(intel_context(ctx),
+ intel_texture_image(texImage),
+ xoffset, yoffset,
+ intel_renderbuffer(rb), x, y, width, height)) {
+ fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
+ _mesa_meta_CopyTexSubImage(ctx, dims, texImage,
+ xoffset, yoffset, zoffset,
+ rb, x, y, width, height);
+ }
+}
+
+
+void
+intelInitTextureCopyImageFuncs(struct dd_function_table *functions)
+{
+ functions->CopyTexSubImage = intelCopyTexSubImage;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_format.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_format.c
index 3415f754705..f53054d55d3 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_format.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_format.c
@@ -1 +1,65 @@
-../intel/intel_tex_format.c \ No newline at end of file
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "main/enums.h"
+#include "main/formats.h"
+
+/**
+ * Returns the renderbuffer DataType for a MESA_FORMAT.
+ */
+GLenum
+intel_mesa_format_to_rb_datatype(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
+ case MESA_FORMAT_SARGB8:
+ case MESA_FORMAT_R8:
+ case MESA_FORMAT_GR88:
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_RGB565:
+ case MESA_FORMAT_ARGB1555:
+ case MESA_FORMAT_ARGB4444:
+ case MESA_FORMAT_S8:
+ return GL_UNSIGNED_BYTE;
+ case MESA_FORMAT_R16:
+ case MESA_FORMAT_RG1616:
+ case MESA_FORMAT_Z16:
+ return GL_UNSIGNED_SHORT;
+ case MESA_FORMAT_X8_Z24:
+ return GL_UNSIGNED_INT;
+ case MESA_FORMAT_S8_Z24:
+ return GL_UNSIGNED_INT_24_8_EXT;
+ case MESA_FORMAT_RGBA_FLOAT32:
+ case MESA_FORMAT_RG_FLOAT32:
+ case MESA_FORMAT_R_FLOAT32:
+ case MESA_FORMAT_INTENSITY_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+ return GL_FLOAT;
+
+ /* The core depthstencil wrappers demand this. */
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+
+ default:
+ /* Unsupported format. We may hit this when people ask for FBO-incomplete
+ * formats.
+ */
+ return GL_NONE;
+ }
+}
+
+int intel_compressed_num_bytes(GLuint mesaFormat)
+{
+ GLuint bw, bh;
+ GLuint block_size;
+
+ block_size = _mesa_get_format_bytes(mesaFormat);
+ _mesa_get_format_block_size(mesaFormat, &bw, &bh);
+
+ return block_size / bw;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_image.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_image.c
index 567abe4974e..fe9040cf1b6 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -1 +1,360 @@
-../intel/intel_tex_image.c \ No newline at end of file
+
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/bufferobj.h"
+#include "main/context.h"
+#include "main/formats.h"
+#include "main/pbo.h"
+#include "main/renderbuffer.h"
+#include "main/texcompress.h"
+#include "main/texgetimage.h"
+#include "main/texobj.h"
+#include "main/teximage.h"
+#include "main/texstore.h"
+
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_buffer_objects.h"
+#include "intel_batchbuffer.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+#include "intel_fbo.h"
+#include "intel_span.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/* Work back from the specified level of the image to the baselevel and create a
+ * miptree of that size.
+ */
+struct intel_mipmap_tree *
+intel_miptree_create_for_teximage(struct intel_context *intel,
+ struct intel_texture_object *intelObj,
+ struct intel_texture_image *intelImage,
+ bool expect_accelerated_upload)
+{
+ GLuint firstLevel;
+ GLuint lastLevel;
+ int width, height, depth;
+ GLuint i;
+
+ intel_miptree_get_dimensions_for_image(&intelImage->base.Base,
+ &width, &height, &depth);
+
+ DBG("%s\n", __FUNCTION__);
+
+ if (intelImage->base.Base.Level > intelObj->base.BaseLevel &&
+ (width == 1 ||
+ (intelObj->base.Target != GL_TEXTURE_1D && height == 1) ||
+ (intelObj->base.Target == GL_TEXTURE_3D && depth == 1))) {
+ /* For this combination, we're at some lower mipmap level and
+ * some important dimension is 1. We can't extrapolate up to a
+ * likely base level width/height/depth for a full mipmap stack
+ * from this info, so just allocate this one level.
+ */
+ firstLevel = intelImage->base.Base.Level;
+ lastLevel = intelImage->base.Base.Level;
+ } else {
+ /* If this image disrespects BaseLevel, allocate from level zero.
+ * Usually BaseLevel == 0, so it's unlikely to happen.
+ */
+ if (intelImage->base.Base.Level < intelObj->base.BaseLevel)
+ firstLevel = 0;
+ else
+ firstLevel = intelObj->base.BaseLevel;
+
+ /* Figure out image dimensions at start level. */
+ for (i = intelImage->base.Base.Level; i > firstLevel; i--) {
+ width <<= 1;
+ if (height != 1)
+ height <<= 1;
+ if (depth != 1)
+ depth <<= 1;
+ }
+
+ /* Guess a reasonable value for lastLevel. This is probably going
+ * to be wrong fairly often and might mean that we have to look at
+ * resizable buffers, or require that buffers implement lazy
+ * pagetable arrangements.
+ */
+ if ((intelObj->base.Sampler.MinFilter == GL_NEAREST ||
+ intelObj->base.Sampler.MinFilter == GL_LINEAR) &&
+ intelImage->base.Base.Level == firstLevel &&
+ (intel->gen < 4 || firstLevel == 0)) {
+ lastLevel = firstLevel;
+ } else if (intelObj->base.Target == GL_TEXTURE_EXTERNAL_OES) {
+ lastLevel = firstLevel;
+ } else {
+ lastLevel = firstLevel + _mesa_logbase2(MAX2(MAX2(width, height), depth));
+ }
+ }
+
+ return intel_miptree_create(intel,
+ intelObj->base.Target,
+ intelImage->base.Base.TexFormat,
+ firstLevel,
+ lastLevel,
+ width,
+ height,
+ depth,
+ expect_accelerated_upload,
+ 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_NONE);
+}
+
+/* There are actually quite a few combinations this will work for,
+ * more than what I've listed here.
+ */
+static bool
+check_pbo_format(GLenum format, GLenum type,
+ gl_format mesa_format)
+{
+ switch (mesa_format) {
+ case MESA_FORMAT_ARGB8888:
+ return (format == GL_BGRA && (type == GL_UNSIGNED_BYTE ||
+ type == GL_UNSIGNED_INT_8_8_8_8_REV));
+ case MESA_FORMAT_RGB565:
+ return (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5);
+ case MESA_FORMAT_L8:
+ return (format == GL_LUMINANCE && type == GL_UNSIGNED_BYTE);
+ case MESA_FORMAT_YCBCR:
+ return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE);
+ default:
+ return false;
+ }
+}
+
+
+/* XXX: Do this for TexSubImage also:
+ */
+static bool
+try_pbo_upload(struct gl_context *ctx,
+ struct gl_texture_image *image,
+ const struct gl_pixelstore_attrib *unpack,
+ GLenum format, GLenum type, const void *pixels)
+{
+ struct intel_texture_image *intelImage = intel_texture_image(image);
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
+ GLuint src_offset, src_stride;
+ GLuint dst_x, dst_y, dst_stride;
+ drm_intel_bo *dst_buffer, *src_buffer;
+
+ if (!_mesa_is_bufferobj(unpack->BufferObj))
+ return false;
+
+ DBG("trying pbo upload\n");
+
+ if (intel->ctx._ImageTransferState ||
+ unpack->SkipPixels || unpack->SkipRows) {
+ DBG("%s: image transfer\n", __FUNCTION__);
+ return false;
+ }
+
+ if (!check_pbo_format(format, type, intelImage->base.Base.TexFormat)) {
+ DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
+ __FUNCTION__, _mesa_get_format_name(intelImage->base.Base.TexFormat),
+ format, type);
+ return false;
+ }
+
+ ctx->Driver.AllocTextureImageBuffer(ctx, image);
+
+ if (!intelImage->mt) {
+ DBG("%s: no miptree\n", __FUNCTION__);
+ return false;
+ }
+
+ dst_buffer = intelImage->mt->region->bo;
+ src_buffer = intel_bufferobj_source(intel, pbo, 64, &src_offset);
+ /* note: potential 64-bit ptr to 32-bit int cast */
+ src_offset += (GLuint) (unsigned long) pixels;
+
+ if (unpack->RowLength > 0)
+ src_stride = unpack->RowLength;
+ else
+ src_stride = image->Width;
+
+ intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level,
+ intelImage->base.Base.Face, 0,
+ &dst_x, &dst_y);
+
+ dst_stride = intelImage->mt->region->pitch;
+
+ if (!intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ src_stride, src_buffer,
+ src_offset, false,
+ dst_stride, dst_buffer, 0,
+ intelImage->mt->region->tiling,
+ 0, 0, dst_x, dst_y, image->Width, image->Height,
+ GL_COPY)) {
+ DBG("%s: blit failed\n", __FUNCTION__);
+ return false;
+ }
+
+ DBG("%s: success\n", __FUNCTION__);
+ return true;
+}
+
+static void
+intelTexImage(struct gl_context * ctx,
+ GLuint dims,
+ struct gl_texture_image *texImage,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *unpack)
+{
+ DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+ texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
+
+ /* Attempt to use the blitter for PBO image uploads.
+ */
+ if (dims <= 2 &&
+ try_pbo_upload(ctx, texImage, unpack, format, type, pixels)) {
+ return;
+ }
+
+ DBG("%s: upload image %dx%dx%d pixels %p\n",
+ __FUNCTION__, texImage->Width, texImage->Height, texImage->Depth,
+ pixels);
+
+ _mesa_store_teximage(ctx, dims, texImage,
+ format, type, pixels, unpack);
+}
+
+
+/**
+ * Binds a region to a texture image, like it was uploaded by glTexImage2D().
+ *
+ * Used for GLX_EXT_texture_from_pixmap and EGL image extensions,
+ */
+static void
+intel_set_texture_image_region(struct gl_context *ctx,
+ struct gl_texture_image *image,
+ struct intel_region *region,
+ GLenum target,
+ GLenum internalFormat,
+ gl_format format,
+ uint32_t offset)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct gl_texture_object *texobj = image->TexObject;
+ struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
+
+ _mesa_init_teximage_fields(&intel->ctx, image,
+ region->width, region->height, 1,
+ 0, internalFormat, format);
+
+ ctx->Driver.FreeTextureImageBuffer(ctx, image);
+
+ intel_image->mt = intel_miptree_create_for_region(intel, target,
+ image->TexFormat,
+ region);
+ if (intel_image->mt == NULL)
+ return;
+
+ intel_image->mt->offset = offset;
+ intel_image->base.RowStride = region->pitch;
+
+ /* Immediately validate the image to the object. */
+ intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
+}
+
+void
+intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
+ GLint texture_format,
+ __DRIdrawable *dPriv)
+{
+ struct gl_framebuffer *fb = dPriv->driverPrivate;
+ struct intel_context *intel = pDRICtx->driverPrivate;
+ struct gl_context *ctx = &intel->ctx;
+ struct intel_texture_object *intelObj;
+ struct intel_renderbuffer *rb;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ int level = 0, internalFormat = 0;
+ gl_format texFormat = MESA_FORMAT_NONE;
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ intelObj = intel_texture_object(texObj);
+
+ if (!intelObj)
+ return;
+
+ if (dPriv->lastStamp != dPriv->dri2.stamp ||
+ !pDRICtx->driScreenPriv->dri2.useInvalidate)
+ intel_update_renderbuffers(pDRICtx, dPriv);
+
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ /* If the region isn't set, then intel_update_renderbuffers was unable
+ * to get the buffers for the drawable.
+ */
+ if (!rb || !rb->mt)
+ return;
+
+ if (rb->mt->cpp == 4) {
+ if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
+ internalFormat = GL_RGB;
+ texFormat = MESA_FORMAT_XRGB8888;
+ }
+ else {
+ internalFormat = GL_RGBA;
+ texFormat = MESA_FORMAT_ARGB8888;
+ }
+ } else if (rb->mt->cpp == 2) {
+ internalFormat = GL_RGB;
+ texFormat = MESA_FORMAT_RGB565;
+ }
+
+ _mesa_lock_texture(&intel->ctx, texObj);
+ texImage = _mesa_get_tex_image(ctx, texObj, target, level);
+ intel_set_texture_image_region(ctx, texImage, rb->mt->region, target,
+ internalFormat, texFormat, 0);
+ _mesa_unlock_texture(&intel->ctx, texObj);
+}
+
+void
+intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
+{
+ /* The old interface didn't have the format argument, so copy our
+ * implementation's behavior at the time.
+ */
+ intelSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
+}
+
+#if FEATURE_OES_EGL_image
+static void
+intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = intel->intelScreen->driScrnPriv;
+ image = screen->dri2.image->lookupEGLImage(screen, image_handle,
+ screen->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ intel_set_texture_image_region(ctx, texImage, image->region,
+ target, image->internal_format,
+ image->format, image->offset);
+}
+#endif
+
+void
+intelInitTextureImageFuncs(struct dd_function_table *functions)
+{
+ functions->TexImage = intelTexImage;
+
+#if FEATURE_OES_EGL_image
+ functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
+#endif
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_layout.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_layout.c
index fe61b441945..65645bc46a4 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_layout.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_layout.c
@@ -1 +1,206 @@
-../intel/intel_tex_layout.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Michel Dänzer <michel@tungstengraphics.com>
+ */
+
+#include "intel_mipmap_tree.h"
+#include "intel_tex_layout.h"
+#include "intel_context.h"
+
+#include "main/image.h"
+#include "main/macros.h"
+
+static unsigned int
+intel_horizontal_texture_alignment_unit(struct intel_context *intel,
+ gl_format format)
+{
+ /**
+ * From the "Alignment Unit Size" section of various specs, namely:
+ * - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4
+ * - i965 and G45 PRMs: Volume 1, Section 6.17.3.4.
+ * - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4
+ * - BSpec (for Ivybridge and slight variations in separate stencil)
+ *
+ * +----------------------------------------------------------------------+
+ * | | alignment unit width ("i") |
+ * | Surface Property |-----------------------------|
+ * | | 915 | 965 | ILK | SNB | IVB |
+ * +----------------------------------------------------------------------+
+ * | YUV 4:2:2 format | 8 | 4 | 4 | 4 | 4 |
+ * | BC1-5 compressed format (DXTn/S3TC) | 4 | 4 | 4 | 4 | 4 |
+ * | FXT1 compressed format | 8 | 8 | 8 | 8 | 8 |
+ * | Depth Buffer (16-bit) | 4 | 4 | 4 | 4 | 8 |
+ * | Depth Buffer (other) | 4 | 4 | 4 | 4 | 4 |
+ * | Separate Stencil Buffer | N/A | N/A | 8 | 8 | 8 |
+ * | All Others | 4 | 4 | 4 | 4 | 4 |
+ * +----------------------------------------------------------------------+
+ *
+ * On IVB+, non-special cases can be overridden by setting the SURFACE_STATE
+ * "Surface Horizontal Alignment" field to HALIGN_4 or HALIGN_8.
+ */
+ if (_mesa_is_format_compressed(format)) {
+ /* The hardware alignment requirements for compressed textures
+ * happen to match the block boundaries.
+ */
+ unsigned int i, j;
+ _mesa_get_format_block_size(format, &i, &j);
+ return i;
+ }
+
+ if (format == MESA_FORMAT_S8)
+ return 8;
+
+ if (intel->gen >= 7 && format == MESA_FORMAT_Z16)
+ return 8;
+
+ return 4;
+}
+
+static unsigned int
+intel_vertical_texture_alignment_unit(struct intel_context *intel,
+ gl_format format)
+{
+ /**
+ * From the "Alignment Unit Size" section of various specs, namely:
+ * - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4
+ * - i965 and G45 PRMs: Volume 1, Section 6.17.3.4.
+ * - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4
+ * - BSpec (for Ivybridge and slight variations in separate stencil)
+ *
+ * +----------------------------------------------------------------------+
+ * | | alignment unit height ("j") |
+ * | Surface Property |-----------------------------|
+ * | | 915 | 965 | ILK | SNB | IVB |
+ * +----------------------------------------------------------------------+
+ * | BC1-5 compressed format (DXTn/S3TC) | 4 | 4 | 4 | 4 | 4 |
+ * | FXT1 compressed format | 4 | 4 | 4 | 4 | 4 |
+ * | Depth Buffer | 2 | 2 | 2 | 4 | 4 |
+ * | Separate Stencil Buffer | N/A | N/A | N/A | 4 | 8 |
+ * | Multisampled (4x or 8x) render target | N/A | N/A | N/A | 4 | 4 |
+ * | All Others | 2 | 2 | 2 | 2 | 2 |
+ * +----------------------------------------------------------------------+
+ *
+ * On SNB+, non-special cases can be overridden by setting the SURFACE_STATE
+ * "Surface Vertical Alignment" field to VALIGN_2 or VALIGN_4.
+ *
+ * We currently don't support multisampling.
+ */
+ if (_mesa_is_format_compressed(format))
+ return 4;
+
+ if (format == MESA_FORMAT_S8)
+ return intel->gen >= 7 ? 8 : 4;
+
+ GLenum base_format = _mesa_get_format_base_format(format);
+
+ if (intel->gen >= 6 &&
+ (base_format == GL_DEPTH_COMPONENT ||
+ base_format == GL_DEPTH_STENCIL)) {
+ return 4;
+ }
+
+ return 2;
+}
+
+void
+intel_get_texture_alignment_unit(struct intel_context *intel,
+ gl_format format,
+ unsigned int *w, unsigned int *h)
+{
+ *w = intel_horizontal_texture_alignment_unit(intel, format);
+ *h = intel_vertical_texture_alignment_unit(intel, format);
+}
+
+void i945_miptree_layout_2d(struct intel_mipmap_tree *mt)
+{
+ GLuint level;
+ GLuint x = 0;
+ GLuint y = 0;
+ GLuint width = mt->width0;
+ GLuint height = mt->height0;
+ GLuint depth = mt->depth0; /* number of array layers. */
+
+ mt->total_width = mt->width0;
+
+ if (mt->compressed) {
+ mt->total_width = ALIGN(mt->width0, mt->align_w);
+ }
+
+ /* May need to adjust width to accomodate the placement of
+ * the 2nd mipmap. This occurs when the alignment
+ * constraints of mipmap placement push the right edge of the
+ * 2nd mipmap out past the width of its parent.
+ */
+ if (mt->first_level != mt->last_level) {
+ GLuint mip1_width;
+
+ if (mt->compressed) {
+ mip1_width = ALIGN(minify(mt->width0), mt->align_w)
+ + ALIGN(minify(minify(mt->width0)), mt->align_w);
+ } else {
+ mip1_width = ALIGN(minify(mt->width0), mt->align_w)
+ + minify(minify(mt->width0));
+ }
+
+ if (mip1_width > mt->total_width) {
+ mt->total_width = mip1_width;
+ }
+ }
+
+ mt->total_height = 0;
+
+ for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
+ GLuint img_height;
+
+ intel_miptree_set_level_info(mt, level, x, y, width,
+ height, depth);
+
+ img_height = ALIGN(height, mt->align_h);
+ if (mt->compressed)
+ img_height /= mt->align_h;
+
+ /* Because the images are packed better, the final offset
+ * might not be the maximal one:
+ */
+ mt->total_height = MAX2(mt->total_height, y + img_height);
+
+ /* Layout_below: step right after second mipmap.
+ */
+ if (level == mt->first_level + 1) {
+ x += ALIGN(width, mt->align_w);
+ }
+ else {
+ y += img_height;
+ }
+
+ width = minify(width);
+ height = minify(height);
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_subimage.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_subimage.c
index b3a8a3d7ca7..ae4b3bca305 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_subimage.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_subimage.c
@@ -1 +1,177 @@
-../intel/intel_tex_subimage.c \ No newline at end of file
+
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mtypes.h"
+#include "main/pbo.h"
+#include "main/texobj.h"
+#include "main/texstore.h"
+#include "main/texcompress.h"
+#include "main/enums.h"
+
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "intel_mipmap_tree.h"
+#include "intel_blit.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static bool
+intel_blit_texsubimage(struct gl_context * ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_image *intelImage = intel_texture_image(texImage);
+ GLuint dstRowStride = 0;
+ drm_intel_bo *temp_bo = NULL;
+ unsigned int blit_x = 0, blit_y = 0;
+ unsigned long pitch;
+ uint32_t tiling_mode = I915_TILING_NONE;
+ GLubyte *dstMap;
+
+ /* Try to do a blit upload of the subimage if the texture is
+ * currently busy.
+ */
+ if (!intelImage->mt)
+ return false;
+
+ /* The blitter can't handle Y tiling */
+ if (intelImage->mt->region->tiling == I915_TILING_Y)
+ return false;
+
+ if (texImage->TexObject->Target != GL_TEXTURE_2D)
+ return false;
+
+ /* On gen6, it's probably not worth swapping to the blit ring to do
+ * this because of all the overhead involved.
+ */
+ if (intel->gen >= 6)
+ return false;
+
+ if (!drm_intel_bo_busy(intelImage->mt->region->bo))
+ return false;
+
+ DBG("BLT subimage %s target %s level %d offset %d,%d %dx%d\n",
+ __FUNCTION__,
+ _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+ texImage->Level, xoffset, yoffset, width, height);
+
+ pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1,
+ format, type, pixels, packing,
+ "glTexSubImage");
+ if (!pixels)
+ return false;
+
+ temp_bo = drm_intel_bo_alloc_tiled(intel->bufmgr,
+ "subimage blit bo",
+ width, height,
+ intelImage->mt->cpp,
+ &tiling_mode,
+ &pitch,
+ 0);
+ if (temp_bo == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+ return false;
+ }
+
+ if (drm_intel_gem_bo_map_gtt(temp_bo)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+ return false;
+ }
+
+ dstMap = temp_bo->virtual;
+ dstRowStride = pitch;
+
+ intel_miptree_get_image_offset(intelImage->mt, texImage->Level,
+ intelImage->base.Base.Face, 0,
+ &blit_x, &blit_y);
+ blit_x += xoffset;
+ blit_y += yoffset;
+
+ if (!_mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ dstRowStride,
+ &dstMap,
+ width, height, 1,
+ format, type, pixels, packing)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+ }
+
+ bool ret;
+ unsigned int dst_pitch = intelImage->mt->region->pitch *
+ intelImage->mt->cpp;
+
+ drm_intel_gem_bo_unmap_gtt(temp_bo);
+
+ ret = intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ dstRowStride / intelImage->mt->cpp,
+ temp_bo, 0, false,
+ dst_pitch / intelImage->mt->cpp,
+ intelImage->mt->region->bo, 0,
+ intelImage->mt->region->tiling,
+ 0, 0, blit_x, blit_y, width, height,
+ GL_COPY);
+ assert(ret);
+
+ drm_intel_bo_unreference(temp_bo);
+ _mesa_unmap_teximage_pbo(ctx, packing);
+
+ return true;
+}
+
+static void
+intelTexSubImage(struct gl_context * ctx,
+ GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing)
+{
+ /* The intel_blit_texsubimage() function only handles 2D images */
+ if (dims != 2 || !intel_blit_texsubimage(ctx, texImage,
+ xoffset, yoffset,
+ width, height,
+ format, type, pixels, packing)) {
+ _mesa_store_texsubimage(ctx, dims, texImage,
+ xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels, packing);
+ }
+}
+
+void
+intelInitTextureSubImageFuncs(struct dd_function_table *functions)
+{
+ functions->TexSubImage = intelTexSubImage;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_validate.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_validate.c
index 41a75674c27..578b4173512 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_validate.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/i965/intel_tex_validate.c
@@ -1 +1,218 @@
-../intel/intel_tex_validate.c \ No newline at end of file
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/samplerobj.h"
+#include "main/texobj.h"
+
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_blit.h"
+#include "intel_tex.h"
+#include "intel_tex_layout.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/**
+ * When validating, we only care about the texture images that could
+ * be seen, so for non-mipmapped modes we want to ignore everything
+ * but BaseLevel.
+ */
+static void
+intel_update_max_level(struct intel_texture_object *intelObj,
+ struct gl_sampler_object *sampler)
+{
+ struct gl_texture_object *tObj = &intelObj->base;
+
+ if (sampler->MinFilter == GL_NEAREST ||
+ sampler->MinFilter == GL_LINEAR) {
+ intelObj->_MaxLevel = tObj->BaseLevel;
+ } else {
+ intelObj->_MaxLevel = tObj->_MaxLevel;
+ }
+}
+
+/*
+ */
+GLuint
+intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
+{
+ struct gl_context *ctx = &intel->ctx;
+ struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
+ struct intel_texture_object *intelObj = intel_texture_object(tObj);
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
+ GLuint face, i;
+ GLuint nr_faces = 0;
+ struct intel_texture_image *firstImage;
+ int width, height, depth;
+
+ /* TBOs require no validation -- they always just point to their BO. */
+ if (tObj->Target == GL_TEXTURE_BUFFER)
+ return true;
+
+ /* We know/require this is true by now:
+ */
+ assert(intelObj->base._BaseComplete);
+
+ /* What levels must the tree include at a minimum?
+ */
+ intel_update_max_level(intelObj, sampler);
+ firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]);
+
+ /* Check tree can hold all active levels. Check tree matches
+ * target, imageFormat, etc.
+ *
+ * For pre-gen4, we have to match first_level == tObj->BaseLevel,
+ * because we don't have the control that gen4 does to make min/mag
+ * determination happen at a nonzero (hardware) baselevel. Because
+ * of that, we just always relayout on baselevel change.
+ */
+ if (intelObj->mt &&
+ (!intel_miptree_match_image(intelObj->mt, &firstImage->base.Base) ||
+ intelObj->mt->first_level != tObj->BaseLevel ||
+ intelObj->mt->last_level < intelObj->_MaxLevel)) {
+ intel_miptree_release(&intelObj->mt);
+ }
+
+
+ /* May need to create a new tree:
+ */
+ if (!intelObj->mt) {
+ intel_miptree_get_dimensions_for_image(&firstImage->base.Base,
+ &width, &height, &depth);
+
+ intelObj->mt = intel_miptree_create(intel,
+ intelObj->base.Target,
+ firstImage->base.Base.TexFormat,
+ tObj->BaseLevel,
+ intelObj->_MaxLevel,
+ width,
+ height,
+ depth,
+ true,
+ 0 /* num_samples */,
+ INTEL_MSAA_LAYOUT_NONE);
+ if (!intelObj->mt)
+ return false;
+ }
+
+ /* Pull in any images not in the object's tree:
+ */
+ nr_faces = _mesa_num_tex_faces(intelObj->base.Target);
+ for (face = 0; face < nr_faces; face++) {
+ for (i = tObj->BaseLevel; i <= intelObj->_MaxLevel; i++) {
+ struct intel_texture_image *intelImage =
+ intel_texture_image(intelObj->base.Image[face][i]);
+ /* skip too small size mipmap */
+ if (intelImage == NULL)
+ break;
+
+ if (intelObj->mt != intelImage->mt) {
+ intel_miptree_copy_teximage(intel, intelImage, intelObj->mt);
+ }
+ }
+ }
+
+ return true;
+}
+
+/**
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ */
+static void
+intel_tex_map_image_for_swrast(struct intel_context *intel,
+ struct intel_texture_image *intel_image,
+ GLbitfield mode)
+{
+ int level;
+ int face;
+ struct intel_mipmap_tree *mt;
+ unsigned int x, y;
+
+ if (!intel_image || !intel_image->mt)
+ return;
+
+ level = intel_image->base.Base.Level;
+ face = intel_image->base.Base.Face;
+ mt = intel_image->mt;
+
+ for (int i = 0; i < mt->level[level].depth; i++)
+ intel_miptree_slice_resolve_depth(intel, mt, level, i);
+
+ if (mt->target == GL_TEXTURE_3D ||
+ mt->target == GL_TEXTURE_2D_ARRAY ||
+ mt->target == GL_TEXTURE_1D_ARRAY) {
+ int i;
+
+ /* ImageOffsets[] is only used for swrast's fetch_texel_3d, so we can't
+ * share code with the normal path.
+ */
+ for (i = 0; i < mt->level[level].depth; i++) {
+ intel_miptree_get_image_offset(mt, level, face, i, &x, &y);
+ intel_image->base.ImageOffsets[i] = x + y * mt->region->pitch;
+ }
+
+ DBG("%s \n", __FUNCTION__);
+
+ intel_image->base.Map = intel_region_map(intel, mt->region, mode);
+ } else {
+ assert(intel_image->base.Base.Depth == 1);
+ intel_miptree_get_image_offset(mt, level, face, 0, &x, &y);
+
+ DBG("%s: (%d,%d) -> (%d, %d)/%d\n",
+ __FUNCTION__, face, level, x, y, mt->region->pitch * mt->cpp);
+
+ intel_image->base.Map = intel_region_map(intel, mt->region, mode) +
+ (x + y * mt->region->pitch) * mt->cpp;
+ }
+
+ intel_image->base.RowStride = mt->region->pitch;
+}
+
+static void
+intel_tex_unmap_image_for_swrast(struct intel_context *intel,
+ struct intel_texture_image *intel_image)
+{
+ if (intel_image && intel_image->mt) {
+ intel_region_unmap(intel, intel_image->mt->region);
+ intel_image->base.Map = NULL;
+ }
+}
+
+/**
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ */
+void
+intel_tex_map_images(struct intel_context *intel,
+ struct intel_texture_object *intelObj,
+ GLbitfield mode)
+{
+ GLuint nr_faces = _mesa_num_tex_faces(intelObj->base.Target);
+ int i, face;
+
+ DBG("%s\n", __FUNCTION__);
+
+ for (i = intelObj->base.BaseLevel; i <= intelObj->_MaxLevel; i++) {
+ for (face = 0; face < nr_faces; face++) {
+ struct intel_texture_image *intel_image =
+ intel_texture_image(intelObj->base.Image[face][i]);
+
+ intel_tex_map_image_for_swrast(intel, intel_image, mode);
+ }
+ }
+}
+
+void
+intel_tex_unmap_images(struct intel_context *intel,
+ struct intel_texture_object *intelObj)
+{
+ GLuint nr_faces = _mesa_num_tex_faces(intelObj->base.Target);
+ int i, face;
+
+ for (i = intelObj->base.BaseLevel; i <= intelObj->_MaxLevel; i++) {
+ for (face = 0; face < nr_faces; face++) {
+ struct intel_texture_image *intel_image =
+ intel_texture_image(intelObj->base.Image[face][i]);
+
+ intel_tex_unmap_image_for_swrast(intel, intel_image);
+ }
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.c
index f6a5f664701..5abc52ba3f7 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.c
@@ -1 +1,233 @@
-../radeon/radeon_buffer_objects.c \ No newline at end of file
+/*
+ * Copyright 2009 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_buffer_objects.h"
+
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/bufferobj.h"
+
+#include "radeon_common.h"
+
+struct radeon_buffer_object *
+get_radeon_buffer_object(struct gl_buffer_object *obj)
+{
+ return (struct radeon_buffer_object *) obj;
+}
+
+static struct gl_buffer_object *
+radeonNewBufferObject(struct gl_context * ctx,
+ GLuint name,
+ GLenum target)
+{
+ struct radeon_buffer_object *obj = CALLOC_STRUCT(radeon_buffer_object);
+
+ _mesa_initialize_buffer_object(ctx, &obj->Base, name, target);
+
+ obj->bo = NULL;
+
+ return &obj->Base;
+}
+
+/**
+ * Called via glDeleteBuffersARB().
+ */
+static void
+radeonDeleteBufferObject(struct gl_context * ctx,
+ struct gl_buffer_object *obj)
+{
+ struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+
+ if (obj->Pointer) {
+ radeon_bo_unmap(radeon_obj->bo);
+ }
+
+ if (radeon_obj->bo) {
+ radeon_bo_unref(radeon_obj->bo);
+ }
+
+ free(radeon_obj);
+}
+
+
+/**
+ * Allocate space for and store data in a buffer object. Any data that was
+ * previously stored in the buffer object is lost. If data is NULL,
+ * memory will be allocated, but no copy will occur.
+ * Called via ctx->Driver.BufferData().
+ * \return GL_TRUE for success, GL_FALSE if out of memory
+ */
+static GLboolean
+radeonBufferData(struct gl_context * ctx,
+ GLenum target,
+ GLsizeiptrARB size,
+ const GLvoid * data,
+ GLenum usage,
+ struct gl_buffer_object *obj)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+
+ radeon_obj->Base.Size = size;
+ radeon_obj->Base.Usage = usage;
+
+ if (radeon_obj->bo != NULL) {
+ radeon_bo_unref(radeon_obj->bo);
+ radeon_obj->bo = NULL;
+ }
+
+ if (size != 0) {
+ radeon_obj->bo = radeon_bo_open(radeon->radeonScreen->bom,
+ 0,
+ size,
+ 32,
+ RADEON_GEM_DOMAIN_GTT,
+ 0);
+
+ if (!radeon_obj->bo)
+ return GL_FALSE;
+
+ if (data != NULL) {
+ radeon_bo_map(radeon_obj->bo, GL_TRUE);
+
+ memcpy(radeon_obj->bo->ptr, data, size);
+
+ radeon_bo_unmap(radeon_obj->bo);
+ }
+ }
+ return GL_TRUE;
+}
+
+/**
+ * Replace data in a subrange of buffer object. If the data range
+ * specified by size + offset extends beyond the end of the buffer or
+ * if data is NULL, no copy is performed.
+ * Called via glBufferSubDataARB().
+ */
+static void
+radeonBufferSubData(struct gl_context * ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ const GLvoid * data,
+ struct gl_buffer_object *obj)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+
+ if (radeon_bo_is_referenced_by_cs(radeon_obj->bo, radeon->cmdbuf.cs)) {
+ radeon_firevertices(radeon);
+ }
+
+ radeon_bo_map(radeon_obj->bo, GL_TRUE);
+
+ memcpy(radeon_obj->bo->ptr + offset, data, size);
+
+ radeon_bo_unmap(radeon_obj->bo);
+}
+
+/**
+ * Called via glGetBufferSubDataARB()
+ */
+static void
+radeonGetBufferSubData(struct gl_context * ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ GLvoid * data,
+ struct gl_buffer_object *obj)
+{
+ struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+
+ radeon_bo_map(radeon_obj->bo, GL_FALSE);
+
+ memcpy(data, radeon_obj->bo->ptr + offset, size);
+
+ radeon_bo_unmap(radeon_obj->bo);
+}
+
+/**
+ * Called via glMapBuffer() and glMapBufferRange()
+ */
+static void *
+radeonMapBufferRange(struct gl_context * ctx,
+ GLintptr offset, GLsizeiptr length,
+ GLbitfield access, struct gl_buffer_object *obj)
+{
+ struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+ const GLboolean write_only =
+ (access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == GL_MAP_WRITE_BIT;
+
+ if (write_only) {
+ ctx->Driver.Flush(ctx);
+ }
+
+ if (radeon_obj->bo == NULL) {
+ obj->Pointer = NULL;
+ return NULL;
+ }
+
+ obj->Offset = offset;
+ obj->Length = length;
+ obj->AccessFlags = access;
+
+ radeon_bo_map(radeon_obj->bo, write_only);
+
+ obj->Pointer = radeon_obj->bo->ptr + offset;
+ return obj->Pointer;
+}
+
+
+/**
+ * Called via glUnmapBufferARB()
+ */
+static GLboolean
+radeonUnmapBuffer(struct gl_context * ctx,
+ struct gl_buffer_object *obj)
+{
+ struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+
+ if (radeon_obj->bo != NULL) {
+ radeon_bo_unmap(radeon_obj->bo);
+ }
+
+ obj->Pointer = NULL;
+ obj->Offset = 0;
+ obj->Length = 0;
+
+ return GL_TRUE;
+}
+
+void
+radeonInitBufferObjectFuncs(struct dd_function_table *functions)
+{
+ functions->NewBufferObject = radeonNewBufferObject;
+ functions->DeleteBuffer = radeonDeleteBufferObject;
+ functions->BufferData = radeonBufferData;
+ functions->BufferSubData = radeonBufferSubData;
+ functions->GetBufferSubData = radeonGetBufferSubData;
+ functions->MapBufferRange = radeonMapBufferRange;
+ functions->UnmapBuffer = radeonUnmapBuffer;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.h
index 2f134fd17b8..d681960825a 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_buffer_objects.h
@@ -1 +1,52 @@
-../radeon/radeon_buffer_objects.h \ No newline at end of file
+/*
+ * Copyright 2009 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef RADEON_BUFFER_OBJECTS_H
+#define RADEON_BUFFER_OBJECTS_H
+
+#include "main/mtypes.h"
+
+struct radeon_bo;
+
+/**
+ * Radeon vertex/pixel buffer object, derived from Mesa's gl_buffer_object.
+ */
+struct radeon_buffer_object
+{
+ struct gl_buffer_object Base;
+ struct radeon_bo *bo;
+};
+
+struct radeon_buffer_object *
+get_radeon_buffer_object(struct gl_buffer_object *obj);
+
+/**
+ * Hook the bufferobject implementation into mesa:
+ */
+void radeonInitBufferObjectFuncs(struct dd_function_table *functions);
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_chipset.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_chipset.h
index eba99001ff8..023c12c790d 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_chipset.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_chipset.h
@@ -1 +1,41 @@
-../radeon/radeon_chipset.h \ No newline at end of file
+#ifndef _RADEON_CHIPSET_H
+#define _RADEON_CHIPSET_H
+
+/* General chip classes:
+ * r100 includes R100, RV100, RV200, RS100, RS200, RS250.
+ * r200 includes R200, RV250, RV280, RS300.
+ * (RS* denotes IGP)
+ */
+
+enum {
+#define CHIPSET(id, name, family) PCI_CHIP_##name = id,
+#if defined(RADEON_R100)
+#include "pci_ids/radeon_pci_ids.h"
+#elif defined(RADEON_R200)
+#include "pci_ids/r200_pci_ids.h"
+#endif
+#undef CHIPSET
+};
+
+enum {
+#if defined(RADEON_R100)
+ CHIP_FAMILY_R100,
+ CHIP_FAMILY_RV100,
+ CHIP_FAMILY_RS100,
+ CHIP_FAMILY_RV200,
+ CHIP_FAMILY_RS200,
+#elif defined(RADEON_R200)
+ CHIP_FAMILY_R200,
+ CHIP_FAMILY_RV250,
+ CHIP_FAMILY_RS300,
+ CHIP_FAMILY_RV280,
+#endif
+ CHIP_FAMILY_LAST
+};
+
+#define RADEON_CHIPSET_TCL (1 << 0) /* tcl support - any radeon */
+#define RADEON_CHIPSET_BROKEN_STENCIL (1 << 1) /* r100 stencil bug */
+#define R200_CHIPSET_YCBCR_BROKEN (1 << 2) /* r200 ycbcr bug */
+#define RADEON_CHIPSET_DEPTH_ALWAYS_TILED (1 << 3) /* M7 and R200s */
+
+#endif /* _RADEON_CHIPSET_H */
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_cmdbuf.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_cmdbuf.h
index a799e1dc6df..9f8d6cc49de 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_cmdbuf.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_cmdbuf.h
@@ -1 +1,113 @@
-../radeon/radeon_cmdbuf.h \ No newline at end of file
+#ifndef COMMON_CMDBUF_H
+#define COMMON_CMDBUF_H
+
+GLboolean rcommonEnsureCmdBufSpace(radeonContextPtr rmesa, int dwords, const char *caller);
+int rcommonFlushCmdBuf(radeonContextPtr rmesa, const char *caller);
+int rcommonFlushCmdBufLocked(radeonContextPtr rmesa, const char *caller);
+void rcommonInitCmdBuf(radeonContextPtr rmesa);
+void rcommonDestroyCmdBuf(radeonContextPtr rmesa);
+
+void rcommonBeginBatch(radeonContextPtr rmesa,
+ int n,
+ int dostate,
+ const char *file,
+ const char *function,
+ int line);
+
+/* +r6/r7 : code here moved */
+
+#define CP_PACKET2 (2 << 30)
+#define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
+#define CP_PACKET0_ONE(reg, n) (RADEON_CP_PACKET0 | RADEON_CP_PACKET0_ONE_REG_WR | ((n)<<16) | ((reg)>>2))
+#define CP_PACKET3(pkt, n) (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
+
+/**
+ * Every function writing to the command buffer needs to declare this
+ * to get the necessary local variables.
+ */
+#define BATCH_LOCALS(rmesa) \
+ const radeonContextPtr b_l_rmesa = rmesa
+
+/**
+ * Prepare writing n dwords to the command buffer,
+ * including producing any necessary state emits on buffer wraparound.
+ */
+#define BEGIN_BATCH(n) rcommonBeginBatch(b_l_rmesa, n, 1, __FILE__, __FUNCTION__, __LINE__)
+
+/**
+ * Same as BEGIN_BATCH, but do not cause automatic state emits.
+ */
+#define BEGIN_BATCH_NO_AUTOSTATE(n) rcommonBeginBatch(b_l_rmesa, n, 0, __FILE__, __FUNCTION__, __LINE__)
+
+/**
+ * Write one dword to the command buffer.
+ */
+#define OUT_BATCH(data) \
+ do { \
+ radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, data);\
+ } while(0)
+
+/**
+ * Write a relocated dword to the command buffer.
+ */
+#define OUT_BATCH_RELOC(data, bo, offset, rd, wd, flags) \
+ do { \
+ int __offset = (offset); \
+ if (0 && __offset) { \
+ fprintf(stderr, "(%s:%s:%d) offset : %d\n", \
+ __FILE__, __FUNCTION__, __LINE__, __offset); \
+ } \
+ radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, __offset); \
+ radeon_cs_write_reloc(b_l_rmesa->cmdbuf.cs, \
+ bo, rd, wd, flags); \
+ } while(0)
+
+
+/**
+ * Write n dwords from ptr to the command buffer.
+ */
+#define OUT_BATCH_TABLE(ptr,n) \
+ do { \
+ radeon_cs_write_table(b_l_rmesa->cmdbuf.cs, (ptr), (n));\
+ } while(0)
+
+/**
+ * Finish writing dwords to the command buffer.
+ * The number of (direct or indirect) OUT_BATCH calls between the previous
+ * BEGIN_BATCH and END_BATCH must match the number specified at BEGIN_BATCH time.
+ */
+#define END_BATCH() \
+ do { \
+ radeon_cs_end(b_l_rmesa->cmdbuf.cs, __FILE__, __FUNCTION__, __LINE__);\
+ } while(0)
+
+/**
+ * After the last END_BATCH() of rendering, this indicates that flushing
+ * the command buffer now is okay.
+ */
+#define COMMIT_BATCH() \
+ do { \
+ } while(0)
+
+
+/** Single register write to command buffer; requires 2 dwords. */
+#define OUT_BATCH_REGVAL(reg, val) \
+ OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), 1)); \
+ OUT_BATCH((val))
+
+/** Continuous register range write to command buffer; requires 1 dword,
+ * expects count dwords afterwards for register contents. */
+#define OUT_BATCH_REGSEQ(reg, count) \
+ OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), (count)))
+
+/* +r6/r7 : code here moved */
+
+/* Fire the buffered vertices no matter what.
+ */
+static INLINE void radeon_firevertices(radeonContextPtr radeon)
+{
+ if (radeon->cmdbuf.cs->cdw || radeon->dma.flush )
+ radeon->glCtx->Driver.Flush(radeon->glCtx); /* +r6/r7 */
+}
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.c
index 67b19ba940d..c9f9b207811 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.c
@@ -1 +1,791 @@
-../radeon/radeon_common.c \ No newline at end of file
+/**************************************************************************
+
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/*
+ - Scissor implementation
+ - buffer swap/copy ioctls
+ - finish/flush
+ - state emission
+ - cmdbuffer management
+*/
+
+#include <errno.h>
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/enums.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "drivers/common/meta.h"
+
+#include "radeon_common.h"
+#include "radeon_drm.h"
+#include "radeon_queryobj.h"
+
+/**
+ * Enable verbose debug output for emit code.
+ * 0 no output
+ * 1 most output
+ * 2 also print state alues
+ */
+#define RADEON_CMDBUF 0
+
+/* =============================================================
+ * Scissoring
+ */
+
+/**
+ * Update cliprects and scissors.
+ */
+void radeonSetCliprects(radeonContextPtr radeon)
+{
+ __DRIdrawable *const drawable = radeon_get_drawable(radeon);
+ __DRIdrawable *const readable = radeon_get_readable(radeon);
+
+ if(drawable == NULL && readable == NULL)
+ return;
+
+ struct radeon_framebuffer *const draw_rfb = drawable->driverPrivate;
+ struct radeon_framebuffer *const read_rfb = readable->driverPrivate;
+
+ if ((draw_rfb->base.Width != drawable->w) ||
+ (draw_rfb->base.Height != drawable->h)) {
+ _mesa_resize_framebuffer(radeon->glCtx, &draw_rfb->base,
+ drawable->w, drawable->h);
+ draw_rfb->base.Initialized = GL_TRUE;
+ }
+
+ if (drawable != readable) {
+ if ((read_rfb->base.Width != readable->w) ||
+ (read_rfb->base.Height != readable->h)) {
+ _mesa_resize_framebuffer(radeon->glCtx, &read_rfb->base,
+ readable->w, readable->h);
+ read_rfb->base.Initialized = GL_TRUE;
+ }
+ }
+
+ if (radeon->state.scissor.enabled)
+ radeonUpdateScissor(radeon->glCtx);
+
+}
+
+
+
+void radeonUpdateScissor( struct gl_context *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLint x = ctx->Scissor.X, y = ctx->Scissor.Y;
+ GLsizei w = ctx->Scissor.Width, h = ctx->Scissor.Height;
+ int x1, y1, x2, y2;
+ int min_x, min_y, max_x, max_y;
+
+ if (!ctx->DrawBuffer)
+ return;
+ min_x = min_y = 0;
+ max_x = ctx->DrawBuffer->Width - 1;
+ max_y = ctx->DrawBuffer->Height - 1;
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ x1 = x;
+ y1 = ctx->DrawBuffer->Height - (y + h);
+ x2 = x + w - 1;
+ y2 = y1 + h - 1;
+ } else {
+ x1 = x;
+ y1 = y;
+ x2 = x + w - 1;
+ y2 = y + h - 1;
+
+ }
+
+ rmesa->state.scissor.rect.x1 = CLAMP(x1, min_x, max_x);
+ rmesa->state.scissor.rect.y1 = CLAMP(y1, min_y, max_y);
+ rmesa->state.scissor.rect.x2 = CLAMP(x2, min_x, max_x);
+ rmesa->state.scissor.rect.y2 = CLAMP(y2, min_y, max_y);
+
+ if (rmesa->vtbl.update_scissor)
+ rmesa->vtbl.update_scissor(ctx);
+}
+
+/* =============================================================
+ * Scissoring
+ */
+
+void radeonScissor(struct gl_context* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ if (ctx->Scissor.Enabled) {
+ /* We don't pipeline cliprect changes */
+ radeon_firevertices(radeon);
+ radeonUpdateScissor(ctx);
+ }
+}
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+uint32_t radeonGetAge(radeonContextPtr radeon)
+{
+ drm_radeon_getparam_t gp;
+ int ret;
+ uint32_t age;
+
+ gp.param = RADEON_PARAM_LAST_CLEAR;
+ gp.value = (int *)&age;
+ ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__,
+ ret);
+ exit(1);
+ }
+
+ return age;
+}
+
+/**
+ * Check if we're about to draw into the front color buffer.
+ * If so, set the intel->front_buffer_dirty field to true.
+ */
+void
+radeon_check_front_buffer_rendering(struct gl_context *ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ if (fb->Name == 0) {
+ /* drawing to window system buffer */
+ if (fb->_NumColorDrawBuffers > 0) {
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+ radeon->front_buffer_dirty = GL_TRUE;
+ }
+ }
+ }
+}
+
+
+void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_renderbuffer *rrbDepth = NULL, *rrbStencil = NULL,
+ *rrbColor = NULL;
+ uint32_t offset = 0;
+
+
+ if (!fb) {
+ /* this can happen during the initial context initialization */
+ return;
+ }
+
+ /* radeons only handle 1 color draw so far */
+ if (fb->_NumColorDrawBuffers != 1) {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE);
+ return;
+ }
+
+ /* Do this here, note core Mesa, since this function is called from
+ * many places within the driver.
+ */
+ if (ctx->NewState & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
+ /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
+ _mesa_update_framebuffer(ctx);
+ /* this updates the DrawBuffer's Width/Height if it's a FBO */
+ _mesa_update_draw_buffer_bounds(ctx);
+ }
+
+ if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ /* this may occur when we're called by glBindFrameBuffer() during
+ * the process of someone setting up renderbuffers, etc.
+ */
+ /*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
+ return;
+ }
+
+ if (fb->Name)
+ ;/* do something depthy/stencily TODO */
+
+
+ /* none */
+ if (fb->Name == 0) {
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+ rrbColor = radeon_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ radeon->front_cliprects = GL_TRUE;
+ } else {
+ rrbColor = radeon_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+ radeon->front_cliprects = GL_FALSE;
+ }
+ } else {
+ /* user FBO in theory */
+ struct radeon_renderbuffer *rrb;
+ rrb = radeon_renderbuffer(fb->_ColorDrawBuffers[0]);
+ if (rrb) {
+ offset = rrb->draw_offset;
+ rrbColor = rrb;
+ }
+ }
+
+ if (rrbColor == NULL)
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE);
+ else
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE);
+
+
+ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
+ rrbDepth = radeon_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ if (rrbDepth && rrbDepth->bo) {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+ } else {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DEPTH_BUFFER, GL_TRUE);
+ }
+ } else {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+ rrbDepth = NULL;
+ }
+
+ if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) {
+ rrbStencil = radeon_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
+ if (rrbStencil && rrbStencil->bo) {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+ /* need to re-compute stencil hw state */
+ if (!rrbDepth)
+ rrbDepth = rrbStencil;
+ } else {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_STENCIL_BUFFER, GL_TRUE);
+ }
+ } else {
+ radeon->vtbl.fallback(ctx, RADEON_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+ if (ctx->Driver.Enable != NULL)
+ ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
+ else
+ ctx->NewState |= _NEW_STENCIL;
+ }
+
+ /* Update culling direction which changes depending on the
+ * orientation of the buffer:
+ */
+ if (ctx->Driver.FrontFace)
+ ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
+ else
+ ctx->NewState |= _NEW_POLYGON;
+
+ /*
+ * Update depth test state
+ */
+ if (ctx->Driver.Enable) {
+ ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
+ (ctx->Depth.Test && fb->Visual.depthBits > 0));
+ /* Need to update the derived ctx->Stencil._Enabled first */
+ ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
+ (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
+ } else {
+ ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL);
+ }
+
+ _mesa_reference_renderbuffer(&radeon->state.depth.rb, &rrbDepth->base.Base);
+ _mesa_reference_renderbuffer(&radeon->state.color.rb, &rrbColor->base.Base);
+ radeon->state.color.draw_offset = offset;
+
+#if 0
+ /* update viewport since it depends on window size */
+ if (ctx->Driver.Viewport) {
+ ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y,
+ ctx->Viewport.Width, ctx->Viewport.Height);
+ } else {
+
+ }
+#endif
+ ctx->NewState |= _NEW_VIEWPORT;
+
+ /* Set state we know depends on drawable parameters:
+ */
+ radeonUpdateScissor(ctx);
+ radeon->NewGLState |= _NEW_SCISSOR;
+
+ if (ctx->Driver.DepthRange)
+ ctx->Driver.DepthRange(ctx,
+ ctx->Viewport.Near,
+ ctx->Viewport.Far);
+
+ /* Update culling direction which changes depending on the
+ * orientation of the buffer:
+ */
+ if (ctx->Driver.FrontFace)
+ ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
+ else
+ ctx->NewState |= _NEW_POLYGON;
+}
+
+/**
+ * Called via glDrawBuffer.
+ */
+void radeonDrawBuffer( struct gl_context *ctx, GLenum mode )
+{
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "%s %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( mode ));
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ const GLboolean was_front_buffer_rendering =
+ radeon->is_front_buffer_rendering;
+
+ radeon->is_front_buffer_rendering = (mode == GL_FRONT_LEFT) ||
+ (mode == GL_FRONT);
+
+ /* If we weren't front-buffer rendering before but we are now, make sure
+ * that the front-buffer has actually been allocated.
+ */
+ if (!was_front_buffer_rendering && radeon->is_front_buffer_rendering) {
+ radeon_update_renderbuffers(radeon->dri.context,
+ radeon->dri.context->driDrawablePriv, GL_FALSE);
+ }
+ }
+
+ radeon_draw_buffer(ctx, ctx->DrawBuffer);
+}
+
+void radeonReadBuffer( struct gl_context *ctx, GLenum mode )
+{
+ if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
+ const GLboolean was_front_buffer_reading = rmesa->is_front_buffer_reading;
+ rmesa->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
+ || (mode == GL_FRONT);
+
+ if (!was_front_buffer_reading && rmesa->is_front_buffer_reading) {
+ radeon_update_renderbuffers(rmesa->dri.context,
+ rmesa->dri.context->driReadablePriv, GL_FALSE);
+ }
+ }
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+ if (ctx->ReadBuffer == ctx->DrawBuffer) {
+ /* This will update FBO completeness status.
+ * A framebuffer will be incomplete if the GL_READ_BUFFER setting
+ * refers to a missing renderbuffer. Calling glReadBuffer can set
+ * that straight and can make the drawing buffer complete.
+ */
+ radeon_draw_buffer(ctx, ctx->DrawBuffer);
+ }
+}
+
+void radeon_window_moved(radeonContextPtr radeon)
+{
+ /* Cliprects has to be updated before doing anything else */
+ radeonSetCliprects(radeon);
+}
+
+void radeon_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ __DRIcontext *driContext = radeon->dri.context;
+ void (*old_viewport)(struct gl_context *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h);
+
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ if (radeon->is_front_buffer_rendering) {
+ ctx->Driver.Flush(ctx);
+ }
+ radeon_update_renderbuffers(driContext, driContext->driDrawablePriv, GL_FALSE);
+ if (driContext->driDrawablePriv != driContext->driReadablePriv)
+ radeon_update_renderbuffers(driContext, driContext->driReadablePriv, GL_FALSE);
+ }
+
+ old_viewport = ctx->Driver.Viewport;
+ ctx->Driver.Viewport = NULL;
+ radeon_window_moved(radeon);
+ radeon_draw_buffer(ctx, radeon->glCtx->DrawBuffer);
+ ctx->Driver.Viewport = old_viewport;
+}
+
+static void radeon_print_state_atom(radeonContextPtr radeon, struct radeon_state_atom *state)
+{
+ int i, j, reg, count;
+ int dwords;
+ uint32_t packet0;
+ if (!radeon_is_debug_enabled(RADEON_STATE, RADEON_VERBOSE) )
+ return;
+
+ dwords = (*state->check) (radeon->glCtx, state);
+
+ fprintf(stderr, " emit %s %d/%d\n", state->name, dwords, state->cmd_size);
+
+ if (state->cmd && radeon_is_debug_enabled(RADEON_STATE, RADEON_TRACE)) {
+ if (dwords > state->cmd_size)
+ dwords = state->cmd_size;
+ for (i = 0; i < dwords;) {
+ packet0 = state->cmd[i];
+ reg = (packet0 & 0x1FFF) << 2;
+ count = ((packet0 & 0x3FFF0000) >> 16) + 1;
+ fprintf(stderr, " %s[%d]: cmdpacket0 (first reg=0x%04x, count=%d)\n",
+ state->name, i, reg, count);
+ ++i;
+ for (j = 0; j < count && i < dwords; j++) {
+ fprintf(stderr, " %s[%d]: 0x%04x = %08x\n",
+ state->name, i, reg, state->cmd[i]);
+ reg += 4;
+ ++i;
+ }
+ }
+ }
+}
+
+/**
+ * Count total size for next state emit.
+ **/
+GLuint radeonCountStateEmitSize(radeonContextPtr radeon)
+{
+ struct radeon_state_atom *atom;
+ GLuint dwords = 0;
+ /* check if we are going to emit full state */
+
+ if (radeon->cmdbuf.cs->cdw && !radeon->hw.all_dirty) {
+ if (!radeon->hw.is_dirty)
+ goto out;
+ foreach(atom, &radeon->hw.atomlist) {
+ if (atom->dirty) {
+ const GLuint atom_size = atom->check(radeon->glCtx, atom);
+ dwords += atom_size;
+ if (RADEON_CMDBUF && atom_size) {
+ radeon_print_state_atom(radeon, atom);
+ }
+ }
+ }
+ } else {
+ foreach(atom, &radeon->hw.atomlist) {
+ const GLuint atom_size = atom->check(radeon->glCtx, atom);
+ dwords += atom_size;
+ if (RADEON_CMDBUF && atom_size) {
+ radeon_print_state_atom(radeon, atom);
+ }
+
+ }
+ }
+out:
+ radeon_print(RADEON_STATE, RADEON_NORMAL, "%s %u\n", __func__, dwords);
+ return dwords;
+}
+
+static INLINE void radeon_emit_atom(radeonContextPtr radeon, struct radeon_state_atom *atom)
+{
+ BATCH_LOCALS(radeon);
+ int dwords;
+
+ dwords = (*atom->check) (radeon->glCtx, atom);
+ if (dwords) {
+
+ radeon_print_state_atom(radeon, atom);
+
+ if (atom->emit) {
+ (*atom->emit)(radeon->glCtx, atom);
+ } else {
+ BEGIN_BATCH_NO_AUTOSTATE(dwords);
+ OUT_BATCH_TABLE(atom->cmd, dwords);
+ END_BATCH();
+ }
+ atom->dirty = GL_FALSE;
+
+ } else {
+ radeon_print(RADEON_STATE, RADEON_VERBOSE, " skip state %s\n", atom->name);
+ }
+
+}
+
+static INLINE void radeonEmitAtoms(radeonContextPtr radeon, GLboolean emitAll)
+{
+ struct radeon_state_atom *atom;
+
+ if (radeon->vtbl.pre_emit_atoms)
+ radeon->vtbl.pre_emit_atoms(radeon);
+
+ /* Emit actual atoms */
+ if (radeon->hw.all_dirty || emitAll) {
+ foreach(atom, &radeon->hw.atomlist)
+ radeon_emit_atom( radeon, atom );
+ } else {
+ foreach(atom, &radeon->hw.atomlist) {
+ if ( atom->dirty )
+ radeon_emit_atom( radeon, atom );
+ }
+ }
+
+ COMMIT_BATCH();
+}
+
+static GLboolean radeon_revalidate_bos(struct gl_context *ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ int ret;
+
+ ret = radeon_cs_space_check(radeon->cmdbuf.cs);
+ if (ret == RADEON_CS_SPACE_FLUSH)
+ return GL_FALSE;
+ return GL_TRUE;
+}
+
+void radeonEmitState(radeonContextPtr radeon)
+{
+ radeon_print(RADEON_STATE, RADEON_NORMAL, "%s\n", __FUNCTION__);
+
+ if (radeon->vtbl.pre_emit_state)
+ radeon->vtbl.pre_emit_state(radeon);
+
+ /* this code used to return here but now it emits zbs */
+ if (radeon->cmdbuf.cs->cdw && !radeon->hw.is_dirty && !radeon->hw.all_dirty)
+ return;
+
+ if (!radeon->cmdbuf.cs->cdw) {
+ if (RADEON_DEBUG & RADEON_STATE)
+ fprintf(stderr, "Begin reemit state\n");
+
+ radeonEmitAtoms(radeon, GL_TRUE);
+ } else {
+
+ if (RADEON_DEBUG & RADEON_STATE)
+ fprintf(stderr, "Begin dirty state\n");
+
+ radeonEmitAtoms(radeon, GL_FALSE);
+ }
+
+ radeon->hw.is_dirty = GL_FALSE;
+ radeon->hw.all_dirty = GL_FALSE;
+}
+
+
+void radeonFlush(struct gl_context *ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ if (RADEON_DEBUG & RADEON_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, radeon->cmdbuf.cs->cdw);
+
+ /* okay if we have no cmds in the buffer &&
+ we have no DMA flush &&
+ we have no DMA buffer allocated.
+ then no point flushing anything at all.
+ */
+ if (!radeon->dma.flush && !radeon->cmdbuf.cs->cdw && is_empty_list(&radeon->dma.reserved))
+ goto flush_front;
+
+ if (radeon->dma.flush)
+ radeon->dma.flush( ctx );
+
+ if (radeon->cmdbuf.cs->cdw)
+ rcommonFlushCmdBuf(radeon, __FUNCTION__);
+
+flush_front:
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer) && radeon->front_buffer_dirty) {
+ __DRIscreen *const screen = radeon->radeonScreen->driScreen;
+
+ if (screen->dri2.loader && (screen->dri2.loader->base.version >= 2)
+ && (screen->dri2.loader->flushFrontBuffer != NULL)) {
+ __DRIdrawable * drawable = radeon_get_drawable(radeon);
+
+ /* We set the dirty bit in radeon_prepare_render() if we're
+ * front buffer rendering once we get there.
+ */
+ radeon->front_buffer_dirty = GL_FALSE;
+
+ (*screen->dri2.loader->flushFrontBuffer)(drawable, drawable->loaderPrivate);
+ }
+ }
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+void radeonFinish(struct gl_context * ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct radeon_renderbuffer *rrb;
+ int i;
+
+ if (ctx->Driver.Flush)
+ ctx->Driver.Flush(ctx); /* +r6/r7 */
+
+ for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+ struct radeon_renderbuffer *rrb;
+ rrb = radeon_renderbuffer(fb->_ColorDrawBuffers[i]);
+ if (rrb && rrb->bo)
+ radeon_bo_wait(rrb->bo);
+ }
+ rrb = radeon_get_depthbuffer(radeon);
+ if (rrb && rrb->bo)
+ radeon_bo_wait(rrb->bo);
+}
+
+/* cmdbuffer */
+/**
+ * Send the current command buffer via ioctl to the hardware.
+ */
+int rcommonFlushCmdBufLocked(radeonContextPtr rmesa, const char *caller)
+{
+ int ret = 0;
+
+ if (rmesa->cmdbuf.flushing) {
+ fprintf(stderr, "Recursive call into r300FlushCmdBufLocked!\n");
+ exit(-1);
+ }
+ rmesa->cmdbuf.flushing = 1;
+
+ if (RADEON_DEBUG & RADEON_IOCTL) {
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+ }
+
+ radeonEmitQueryEnd(rmesa->glCtx);
+
+ if (rmesa->cmdbuf.cs->cdw) {
+ ret = radeon_cs_emit(rmesa->cmdbuf.cs);
+ rmesa->hw.all_dirty = GL_TRUE;
+ }
+ radeon_cs_erase(rmesa->cmdbuf.cs);
+ rmesa->cmdbuf.flushing = 0;
+
+ if (radeon_revalidate_bos(rmesa->glCtx) == GL_FALSE) {
+ fprintf(stderr,"failed to revalidate buffers\n");
+ }
+
+ return ret;
+}
+
+int rcommonFlushCmdBuf(radeonContextPtr rmesa, const char *caller)
+{
+ int ret;
+
+ radeonReleaseDmaRegions(rmesa);
+
+ ret = rcommonFlushCmdBufLocked(rmesa, caller);
+
+ if (ret) {
+ fprintf(stderr, "drmRadeonCmdBuffer: %d. Kernel failed to "
+ "parse or rejected command stream. See dmesg "
+ "for more info.\n", ret);
+ exit(ret);
+ }
+
+ return ret;
+}
+
+/**
+ * Make sure that enough space is available in the command buffer
+ * by flushing if necessary.
+ *
+ * \param dwords The number of dwords we need to be free on the command buffer
+ */
+GLboolean rcommonEnsureCmdBufSpace(radeonContextPtr rmesa, int dwords, const char *caller)
+{
+ if ((rmesa->cmdbuf.cs->cdw + dwords + 128) > rmesa->cmdbuf.size
+ || radeon_cs_need_flush(rmesa->cmdbuf.cs)) {
+ /* If we try to flush empty buffer there is too big rendering operation. */
+ assert(rmesa->cmdbuf.cs->cdw);
+ rcommonFlushCmdBuf(rmesa, caller);
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+void rcommonInitCmdBuf(radeonContextPtr rmesa)
+{
+ GLuint size;
+ struct drm_radeon_gem_info mminfo = { 0 };
+
+ /* Initialize command buffer */
+ size = 256 * driQueryOptioni(&rmesa->optionCache,
+ "command_buffer_size");
+ if (size < 2 * rmesa->hw.max_state_size) {
+ size = 2 * rmesa->hw.max_state_size + 65535;
+ }
+ if (size > 64 * 256)
+ size = 64 * 256;
+
+ radeon_print(RADEON_CS, RADEON_VERBOSE,
+ "sizeof(drm_r300_cmd_header_t)=%zd\n", sizeof(drm_r300_cmd_header_t));
+ radeon_print(RADEON_CS, RADEON_VERBOSE,
+ "sizeof(drm_radeon_cmd_buffer_t)=%zd\n", sizeof(drm_radeon_cmd_buffer_t));
+ radeon_print(RADEON_CS, RADEON_VERBOSE,
+ "Allocating %d bytes command buffer (max state is %d bytes)\n",
+ size * 4, rmesa->hw.max_state_size * 4);
+
+ rmesa->cmdbuf.csm =
+ radeon_cs_manager_gem_ctor(rmesa->radeonScreen->driScreen->fd);
+ if (rmesa->cmdbuf.csm == NULL) {
+ /* FIXME: fatal error */
+ return;
+ }
+ rmesa->cmdbuf.cs = radeon_cs_create(rmesa->cmdbuf.csm, size);
+ assert(rmesa->cmdbuf.cs != NULL);
+ rmesa->cmdbuf.size = size;
+
+ radeon_cs_space_set_flush(rmesa->cmdbuf.cs,
+ (void (*)(void *))rmesa->glCtx->Driver.Flush, rmesa->glCtx);
+
+
+ if (!drmCommandWriteRead(rmesa->dri.fd, DRM_RADEON_GEM_INFO,
+ &mminfo, sizeof(mminfo))) {
+ radeon_cs_set_limit(rmesa->cmdbuf.cs, RADEON_GEM_DOMAIN_VRAM,
+ mminfo.vram_visible);
+ radeon_cs_set_limit(rmesa->cmdbuf.cs, RADEON_GEM_DOMAIN_GTT,
+ mminfo.gart_size);
+ }
+}
+
+/**
+ * Destroy the command buffer
+ */
+void rcommonDestroyCmdBuf(radeonContextPtr rmesa)
+{
+ radeon_cs_destroy(rmesa->cmdbuf.cs);
+ radeon_cs_manager_gem_dtor(rmesa->cmdbuf.csm);
+}
+
+void rcommonBeginBatch(radeonContextPtr rmesa, int n,
+ int dostate,
+ const char *file,
+ const char *function,
+ int line)
+{
+ radeon_cs_begin(rmesa->cmdbuf.cs, n, file, function, line);
+
+ radeon_print(RADEON_CS, RADEON_VERBOSE, "BEGIN_BATCH(%d) at %d, from %s:%i\n",
+ n, rmesa->cmdbuf.cs->cdw, function, line);
+
+}
+
+void radeonUserClear(struct gl_context *ctx, GLuint mask)
+{
+ _mesa_meta_Clear(ctx, mask);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.h
index 5bcb696a9f7..636822faed2 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common.h
@@ -1 +1,88 @@
-../radeon/radeon_common.h \ No newline at end of file
+#ifndef COMMON_MISC_H
+#define COMMON_MISC_H
+
+#include "radeon_common_context.h"
+#include "radeon_dma.h"
+#include "radeon_texture.h"
+
+void radeonUserClear(struct gl_context *ctx, GLuint mask);
+void radeonSetCliprects(radeonContextPtr radeon);
+void radeonUpdateScissor( struct gl_context *ctx );
+void radeonScissor(struct gl_context* ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+
+extern uint32_t radeonGetAge(radeonContextPtr radeon);
+
+void radeonFlush(struct gl_context *ctx);
+void radeonFinish(struct gl_context * ctx);
+void radeonEmitState(radeonContextPtr radeon);
+GLuint radeonCountStateEmitSize(radeonContextPtr radeon);
+
+void radeon_clear_tris(struct gl_context *ctx, GLbitfield mask);
+
+void radeon_window_moved(radeonContextPtr radeon);
+void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb);
+void radeonDrawBuffer( struct gl_context *ctx, GLenum mode );
+void radeonReadBuffer( struct gl_context *ctx, GLenum mode );
+void radeon_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height);
+void radeon_fbo_init(struct radeon_context *radeon);
+void
+radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
+ struct radeon_bo *bo);
+struct radeon_renderbuffer *
+radeon_create_renderbuffer(gl_format format, __DRIdrawable *driDrawPriv);
+
+void
+radeonReadPixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels);
+
+void radeon_check_front_buffer_rendering(struct gl_context *ctx);
+static inline struct radeon_renderbuffer *radeon_renderbuffer(struct gl_renderbuffer *rb)
+{
+ struct radeon_renderbuffer *rrb = (struct radeon_renderbuffer *)rb;
+ radeon_print(RADEON_MEMORY, RADEON_TRACE,
+ "%s(rb %p)\n",
+ __func__, (void *) rb);
+ if (rrb && rrb->base.Base.ClassID == RADEON_RB_CLASS)
+ return rrb;
+ else
+ return NULL;
+}
+
+static inline struct radeon_renderbuffer *radeon_get_renderbuffer(struct gl_framebuffer *fb, int att_index)
+{
+ radeon_print(RADEON_MEMORY, RADEON_TRACE,
+ "%s(fb %p, index %d)\n",
+ __func__, (void *) fb, att_index);
+
+ if (att_index >= 0)
+ return radeon_renderbuffer(fb->Attachment[att_index].Renderbuffer);
+ else
+ return NULL;
+}
+
+static inline struct radeon_renderbuffer *radeon_get_depthbuffer(radeonContextPtr rmesa)
+{
+ struct radeon_renderbuffer *rrb;
+ rrb = radeon_renderbuffer(rmesa->state.depth.rb);
+ if (!rrb)
+ return NULL;
+
+ return rrb;
+}
+
+static inline struct radeon_renderbuffer *radeon_get_colorbuffer(radeonContextPtr rmesa)
+{
+ struct radeon_renderbuffer *rrb;
+
+ rrb = radeon_renderbuffer(rmesa->state.color.rb);
+ if (!rrb)
+ return NULL;
+ return rrb;
+}
+
+#include "radeon_cmdbuf.h"
+
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.c
index 86800f3819c..8ea8925d8a2 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.c
@@ -1 +1,633 @@
-../radeon/radeon_common_context.c \ No newline at end of file
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include "radeon_common.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+#include "utils.h"
+#include "drivers/common/meta.h"
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/fbobject.h"
+#include "main/renderbuffer.h"
+#include "main/state.h"
+#include "main/simple_list.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+
+#ifndef RADEON_DEBUG
+int RADEON_DEBUG = (0);
+#endif
+
+
+static const char* get_chip_family_name(int chip_family)
+{
+ switch(chip_family) {
+#if defined(RADEON_R100)
+ case CHIP_FAMILY_R100: return "R100";
+ case CHIP_FAMILY_RV100: return "RV100";
+ case CHIP_FAMILY_RS100: return "RS100";
+ case CHIP_FAMILY_RV200: return "RV200";
+ case CHIP_FAMILY_RS200: return "RS200";
+#elif defined(RADEON_R200)
+ case CHIP_FAMILY_R200: return "R200";
+ case CHIP_FAMILY_RV250: return "RV250";
+ case CHIP_FAMILY_RS300: return "RS300";
+ case CHIP_FAMILY_RV280: return "RV280";
+#endif
+ default: return "unknown";
+ }
+}
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *radeonGetString(struct gl_context * ctx, GLenum name)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) "Tungsten Graphics, Inc.";
+
+ case GL_RENDERER:
+ {
+ unsigned offset;
+ GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
+ radeon->radeonScreen->AGPMode;
+ char hardwarename[32];
+
+ sprintf(hardwarename, "%s (%s %04X)",
+#if defined(RADEON_R100)
+ "R100",
+#elif defined(RADEON_R200)
+ "R200",
+#endif
+ get_chip_family_name(radeon->radeonScreen->chip_family),
+ radeon->radeonScreen->device_id);
+
+ offset = driGetRendererString(buffer, hardwarename, agp_mode);
+
+ sprintf(&buffer[offset], " %sTCL",
+ !(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
+ ? "" : "NO-");
+
+ strcat(buffer, " DRI2");
+
+ return (GLubyte *) buffer;
+ }
+
+ default:
+ return NULL;
+ }
+}
+
+/* Initialize the driver's misc functions.
+ */
+static void radeonInitDriverFuncs(struct dd_function_table *functions)
+{
+ functions->GetString = radeonGetString;
+}
+
+/**
+ * Create and initialize all common fields of the context,
+ * including the Mesa context itself.
+ */
+GLboolean radeonInitContext(radeonContextPtr radeon,
+ struct dd_function_table* functions,
+ const struct gl_config * glVisual,
+ __DRIcontext * driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+ radeonScreenPtr screen = (radeonScreenPtr) (sPriv->driverPrivate);
+ struct gl_context* ctx;
+ struct gl_context* shareCtx;
+ int fthrottle_mode;
+
+ /* Fill in additional standard functions. */
+ radeonInitDriverFuncs(functions);
+
+ radeon->radeonScreen = screen;
+ /* Allocate and initialize the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((radeonContextPtr)sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ radeon->glCtx = _mesa_create_context(API_OPENGL, glVisual, shareCtx,
+ functions, (void *)radeon);
+ if (!radeon->glCtx)
+ return GL_FALSE;
+
+ ctx = radeon->glCtx;
+ driContextPriv->driverPrivate = radeon;
+
+ _mesa_meta_init(ctx);
+
+ /* DRI fields */
+ radeon->dri.context = driContextPriv;
+ radeon->dri.screen = sPriv;
+ radeon->dri.fd = sPriv->fd;
+ radeon->dri.drmMinor = sPriv->drm_version.minor;
+
+ /* Setup IRQs */
+ fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
+ radeon->iw.irq_seq = -1;
+ radeon->irqsEmitted = 0;
+ radeon->do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
+ radeon->radeonScreen->irq);
+
+ radeon->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
+ if (!radeon->do_irqs)
+ fprintf(stderr,
+ "IRQ's not enabled, falling back to %s: %d %d\n",
+ radeon->do_usleeps ? "usleeps" : "busy waits",
+ fthrottle_mode, radeon->radeonScreen->irq);
+
+ radeon->texture_depth = driQueryOptioni (&radeon->optionCache,
+ "texture_depth");
+ if (radeon->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ radeon->texture_depth = ( glVisual->rgbBits > 16 ) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+ radeon->texture_row_align = 32;
+ radeon->texture_rect_row_align = 64;
+ radeon->texture_compressed_row_align = 32;
+
+ radeon_init_dma(radeon);
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Destroy the command buffer and state atoms.
+ */
+static void radeon_destroy_atom_list(radeonContextPtr radeon)
+{
+ struct radeon_state_atom *atom;
+
+ foreach(atom, &radeon->hw.atomlist) {
+ FREE(atom->cmd);
+ if (atom->lastcmd)
+ FREE(atom->lastcmd);
+ }
+
+}
+
+/**
+ * Cleanup common context fields.
+ * Called by r200DestroyContext
+ */
+void radeonDestroyContext(__DRIcontext *driContextPriv )
+{
+#ifdef RADEON_BO_TRACK
+ FILE *track;
+#endif
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+ radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
+
+ assert(radeon);
+
+ _mesa_meta_free(radeon->glCtx);
+
+ if (radeon == current) {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ radeon_firevertices(radeon);
+ if (!is_empty_list(&radeon->dma.reserved)) {
+ rcommonFlushCmdBuf( radeon, __FUNCTION__ );
+ }
+
+ radeonFreeDmaRegions(radeon);
+ radeonReleaseArrays(radeon->glCtx, ~0);
+ if (radeon->vtbl.free_context)
+ radeon->vtbl.free_context(radeon->glCtx);
+ _swsetup_DestroyContext( radeon->glCtx );
+ _tnl_DestroyContext( radeon->glCtx );
+ _vbo_DestroyContext( radeon->glCtx );
+ _swrast_DestroyContext( radeon->glCtx );
+
+ /* free atom list */
+ /* free the Mesa context */
+ _mesa_destroy_context(radeon->glCtx);
+
+ /* _mesa_destroy_context() might result in calls to functions that
+ * depend on the DriverCtx, so don't set it to NULL before.
+ *
+ * radeon->glCtx->DriverCtx = NULL;
+ */
+ /* free the option cache */
+ driDestroyOptionCache(&radeon->optionCache);
+
+ rcommonDestroyCmdBuf(radeon);
+
+ radeon_destroy_atom_list(radeon);
+
+#ifdef RADEON_BO_TRACK
+ track = fopen("/tmp/tracklog", "w");
+ if (track) {
+ radeon_tracker_print(&radeon->radeonScreen->bom->tracker, track);
+ fclose(track);
+ }
+#endif
+ FREE(radeon);
+}
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean radeonUnbindContext(__DRIcontext * driContextPriv)
+{
+ radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
+ radeon->glCtx);
+
+ /* Unset current context and dispath table */
+ _mesa_make_current(NULL, NULL, NULL);
+
+ return GL_TRUE;
+}
+
+
+static unsigned
+radeon_bits_per_pixel(const struct radeon_renderbuffer *rb)
+{
+ return _mesa_get_format_bytes(rb->base.Base.Format) * 8;
+}
+
+/*
+ * Check if drawable has been invalidated by dri2InvalidateDrawable().
+ * Update renderbuffers if so. This prevents a client from accessing
+ * a backbuffer that has a swap pending but not yet completed.
+ *
+ * See intel_prepare_render for equivalent code in intel driver.
+ *
+ */
+void radeon_prepare_render(radeonContextPtr radeon)
+{
+ __DRIcontext *driContext = radeon->dri.context;
+ __DRIdrawable *drawable;
+ __DRIscreen *screen;
+
+ screen = driContext->driScreenPriv;
+ if (!screen->dri2.loader)
+ return;
+
+ drawable = driContext->driDrawablePriv;
+ if (drawable->dri2.stamp != driContext->dri2.draw_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ radeon_update_renderbuffers(driContext, drawable, GL_FALSE);
+
+ /* Intel driver does the equivalent of this, no clue if it is needed:*/
+ radeon_draw_buffer(radeon->glCtx, radeon->glCtx->DrawBuffer);
+
+ driContext->dri2.draw_stamp = drawable->dri2.stamp;
+ }
+
+ drawable = driContext->driReadablePriv;
+ if (drawable->dri2.stamp != driContext->dri2.read_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ radeon_update_renderbuffers(driContext, drawable, GL_FALSE);
+ driContext->dri2.read_stamp = drawable->dri2.stamp;
+ }
+
+ /* If we're currently rendering to the front buffer, the rendering
+ * that will happen next will probably dirty the front buffer. So
+ * mark it as dirty here.
+ */
+ if (radeon->is_front_buffer_rendering)
+ radeon->front_buffer_dirty = GL_TRUE;
+}
+
+void
+radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
+ GLboolean front_only)
+{
+ unsigned int attachments[10];
+ __DRIbuffer *buffers = NULL;
+ __DRIscreen *screen;
+ struct radeon_renderbuffer *rb;
+ int i, count;
+ struct radeon_framebuffer *draw;
+ radeonContextPtr radeon;
+ char *regname;
+ struct radeon_bo *depth_bo = NULL, *bo;
+
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+ draw = drawable->driverPrivate;
+ screen = context->driScreenPriv;
+ radeon = (radeonContextPtr) context->driverPrivate;
+
+ /* Set this up front, so that in case our buffers get invalidated
+ * while we're getting new buffers, we don't clobber the stamp and
+ * thus ignore the invalidate. */
+ drawable->lastStamp = drawable->dri2.stamp;
+
+ if (screen->dri2.loader
+ && (screen->dri2.loader->base.version > 2)
+ && (screen->dri2.loader->getBuffersWithFormat != NULL)) {
+ struct radeon_renderbuffer *depth_rb;
+ struct radeon_renderbuffer *stencil_rb;
+
+ i = 0;
+ if ((front_only || radeon->is_front_buffer_rendering ||
+ radeon->is_front_buffer_reading ||
+ !draw->color_rb[1])
+ && draw->color_rb[0]) {
+ attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ attachments[i++] = radeon_bits_per_pixel(draw->color_rb[0]);
+ }
+
+ if (!front_only) {
+ if (draw->color_rb[1]) {
+ attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ attachments[i++] = radeon_bits_per_pixel(draw->color_rb[1]);
+ }
+
+ depth_rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+ stencil_rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+
+ if ((depth_rb != NULL) && (stencil_rb != NULL)) {
+ attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
+ attachments[i++] = radeon_bits_per_pixel(depth_rb);
+ } else if (depth_rb != NULL) {
+ attachments[i++] = __DRI_BUFFER_DEPTH;
+ attachments[i++] = radeon_bits_per_pixel(depth_rb);
+ } else if (stencil_rb != NULL) {
+ attachments[i++] = __DRI_BUFFER_STENCIL;
+ attachments[i++] = radeon_bits_per_pixel(stencil_rb);
+ }
+ }
+
+ buffers = (*screen->dri2.loader->getBuffersWithFormat)(drawable,
+ &drawable->w,
+ &drawable->h,
+ attachments, i / 2,
+ &count,
+ drawable->loaderPrivate);
+ } else if (screen->dri2.loader) {
+ i = 0;
+ if (draw->color_rb[0])
+ attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ if (!front_only) {
+ if (draw->color_rb[1])
+ attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ if (radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH))
+ attachments[i++] = __DRI_BUFFER_DEPTH;
+ if (radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL))
+ attachments[i++] = __DRI_BUFFER_STENCIL;
+ }
+
+ buffers = (*screen->dri2.loader->getBuffers)(drawable,
+ &drawable->w,
+ &drawable->h,
+ attachments, i,
+ &count,
+ drawable->loaderPrivate);
+ }
+
+ if (buffers == NULL)
+ return;
+
+ for (i = 0; i < count; i++) {
+ switch (buffers[i].attachment) {
+ case __DRI_BUFFER_FRONT_LEFT:
+ rb = draw->color_rb[0];
+ regname = "dri2 front buffer";
+ break;
+ case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ rb = draw->color_rb[0];
+ regname = "dri2 fake front buffer";
+ break;
+ case __DRI_BUFFER_BACK_LEFT:
+ rb = draw->color_rb[1];
+ regname = "dri2 back buffer";
+ break;
+ case __DRI_BUFFER_DEPTH:
+ rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+ regname = "dri2 depth buffer";
+ break;
+ case __DRI_BUFFER_DEPTH_STENCIL:
+ rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+ regname = "dri2 depth / stencil buffer";
+ break;
+ case __DRI_BUFFER_STENCIL:
+ rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+ regname = "dri2 stencil buffer";
+ break;
+ case __DRI_BUFFER_ACCUM:
+ default:
+ fprintf(stderr,
+ "unhandled buffer attach event, attacment type %d\n",
+ buffers[i].attachment);
+ return;
+ }
+
+ if (rb == NULL)
+ continue;
+
+ if (rb->bo) {
+ uint32_t name = radeon_gem_name_bo(rb->bo);
+ if (name == buffers[i].name)
+ continue;
+ }
+
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr,
+ "attaching buffer %s, %d, at %d, cpp %d, pitch %d\n",
+ regname, buffers[i].name, buffers[i].attachment,
+ buffers[i].cpp, buffers[i].pitch);
+
+ rb->cpp = buffers[i].cpp;
+ rb->pitch = buffers[i].pitch;
+ rb->base.Base.Width = drawable->w;
+ rb->base.Base.Height = drawable->h;
+ rb->has_surface = 0;
+
+ if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_bo) {
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "(reusing depth buffer as stencil)\n");
+ bo = depth_bo;
+ radeon_bo_ref(bo);
+ } else {
+ uint32_t tiling_flags = 0, pitch = 0;
+ int ret;
+
+ bo = radeon_bo_open(radeon->radeonScreen->bom,
+ buffers[i].name,
+ 0,
+ 0,
+ RADEON_GEM_DOMAIN_VRAM,
+ buffers[i].flags);
+
+ if (bo == NULL) {
+ fprintf(stderr, "failed to attach %s %d\n",
+ regname, buffers[i].name);
+ continue;
+ }
+
+ ret = radeon_bo_get_tiling(bo, &tiling_flags, &pitch);
+ if (ret) {
+ fprintf(stderr,
+ "failed to get tiling for %s %d\n",
+ regname, buffers[i].name);
+ radeon_bo_unref(bo);
+ bo = NULL;
+ continue;
+ } else {
+ if (tiling_flags & RADEON_TILING_MACRO)
+ bo->flags |= RADEON_BO_FLAGS_MACRO_TILE;
+ if (tiling_flags & RADEON_TILING_MICRO)
+ bo->flags |= RADEON_BO_FLAGS_MICRO_TILE;
+ }
+ }
+
+ if (buffers[i].attachment == __DRI_BUFFER_DEPTH) {
+ if (draw->base.Visual.depthBits == 16)
+ rb->cpp = 2;
+ depth_bo = bo;
+ }
+
+ radeon_renderbuffer_set_bo(rb, bo);
+ radeon_bo_unref(bo);
+
+ if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
+ rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+ if (rb != NULL) {
+ struct radeon_bo *stencil_bo = NULL;
+
+ if (rb->bo) {
+ uint32_t name = radeon_gem_name_bo(rb->bo);
+ if (name == buffers[i].name)
+ continue;
+ }
+
+ stencil_bo = bo;
+ radeon_bo_ref(stencil_bo);
+ radeon_renderbuffer_set_bo(rb, stencil_bo);
+ radeon_bo_unref(stencil_bo);
+ }
+ }
+ }
+
+ driUpdateFramebufferSize(radeon->glCtx, drawable);
+}
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv)
+{
+ radeonContextPtr radeon;
+ GET_CURRENT_CONTEXT(curCtx);
+ struct gl_framebuffer *drfb, *readfb;
+
+ if (driContextPriv)
+ radeon = (radeonContextPtr)driContextPriv->driverPrivate;
+ else
+ radeon = NULL;
+ /* According to the glXMakeCurrent() man page: "Pending commands to
+ * the previous context, if any, are flushed before it is released."
+ * But only flush if we're actually changing contexts.
+ */
+
+ if ((radeonContextPtr)curCtx && (radeonContextPtr)curCtx != radeon) {
+ _mesa_flush(curCtx);
+ }
+
+ if (!driContextPriv) {
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
+ _mesa_make_current(NULL, NULL, NULL);
+ return GL_TRUE;
+ }
+
+ if(driDrawPriv == NULL && driReadPriv == NULL) {
+ drfb = _mesa_create_framebuffer(&radeon->glCtx->Visual);
+ readfb = drfb;
+ }
+ else {
+ drfb = driDrawPriv->driverPrivate;
+ readfb = driReadPriv->driverPrivate;
+ }
+
+ if(driDrawPriv)
+ radeon_update_renderbuffers(driContextPriv, driDrawPriv, GL_FALSE);
+ if (driDrawPriv != driReadPriv)
+ radeon_update_renderbuffers(driContextPriv, driReadPriv, GL_FALSE);
+ _mesa_reference_renderbuffer(&radeon->state.color.rb,
+ &(radeon_get_renderbuffer(drfb, BUFFER_BACK_LEFT)->base.Base));
+ _mesa_reference_renderbuffer(&radeon->state.depth.rb,
+ &(radeon_get_renderbuffer(drfb, BUFFER_DEPTH)->base.Base));
+
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "%s ctx %p dfb %p rfb %p\n", __FUNCTION__, radeon->glCtx, drfb, readfb);
+
+ if(driDrawPriv)
+ driUpdateFramebufferSize(radeon->glCtx, driDrawPriv);
+ if (driReadPriv != driDrawPriv)
+ driUpdateFramebufferSize(radeon->glCtx, driReadPriv);
+
+ _mesa_make_current(radeon->glCtx, drfb, readfb);
+ if (driDrawPriv == NULL && driReadPriv == NULL)
+ _mesa_reference_framebuffer(&drfb, NULL);
+
+ _mesa_update_state(radeon->glCtx);
+
+ if (radeon->glCtx->DrawBuffer == drfb) {
+ if(driDrawPriv != NULL) {
+ radeon_window_moved(radeon);
+ }
+
+ radeon_draw_buffer(radeon->glCtx, drfb);
+ }
+
+
+ if (RADEON_DEBUG & RADEON_DRI)
+ fprintf(stderr, "End %s\n", __FUNCTION__);
+
+ return GL_TRUE;
+}
+
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.h
index 4d663125500..5c2389208f1 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_common_context.h
@@ -1 +1,530 @@
-../radeon/radeon_common_context.h \ No newline at end of file
+
+#ifndef COMMON_CONTEXT_H
+#define COMMON_CONTEXT_H
+
+#include "main/mm.h"
+#include "math/m_vector.h"
+#include "tnl/t_context.h"
+#include "main/colormac.h"
+
+#include "radeon_debug.h"
+#include "radeon_screen.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "tnl/t_vertex.h"
+#include "swrast/s_context.h"
+
+struct radeon_context;
+
+#include "radeon_bo_gem.h"
+#include "radeon_cs_gem.h"
+
+/* This union is used to avoid warnings/miscompilation
+ with float to uint32_t casts due to strict-aliasing */
+typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
+
+struct radeon_context;
+typedef struct radeon_context radeonContextRec;
+typedef struct radeon_context *radeonContextPtr;
+
+
+#define TEX_0 0x1
+#define TEX_1 0x2
+#define TEX_2 0x4
+#define TEX_3 0x8
+#define TEX_4 0x10
+#define TEX_5 0x20
+
+/* Rasterizing fallbacks */
+/* See correponding strings in r200_swtcl.c */
+#define RADEON_FALLBACK_TEXTURE 0x0001
+#define RADEON_FALLBACK_DRAW_BUFFER 0x0002
+#define RADEON_FALLBACK_STENCIL 0x0004
+#define RADEON_FALLBACK_RENDER_MODE 0x0008
+#define RADEON_FALLBACK_BLEND_EQ 0x0010
+#define RADEON_FALLBACK_BLEND_FUNC 0x0020
+#define RADEON_FALLBACK_DISABLE 0x0040
+#define RADEON_FALLBACK_BORDER_MODE 0x0080
+#define RADEON_FALLBACK_DEPTH_BUFFER 0x0100
+#define RADEON_FALLBACK_STENCIL_BUFFER 0x0200
+
+#define R200_FALLBACK_TEXTURE 0x01
+#define R200_FALLBACK_DRAW_BUFFER 0x02
+#define R200_FALLBACK_STENCIL 0x04
+#define R200_FALLBACK_RENDER_MODE 0x08
+#define R200_FALLBACK_DISABLE 0x10
+#define R200_FALLBACK_BORDER_MODE 0x20
+
+#define RADEON_TCL_FALLBACK_RASTER 0x1 /* rasterization */
+#define RADEON_TCL_FALLBACK_UNFILLED 0x2 /* unfilled tris */
+#define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE 0x4 /* twoside tris */
+#define RADEON_TCL_FALLBACK_MATERIAL 0x8 /* material in vb */
+#define RADEON_TCL_FALLBACK_TEXGEN_0 0x10 /* texgen, unit 0 */
+#define RADEON_TCL_FALLBACK_TEXGEN_1 0x20 /* texgen, unit 1 */
+#define RADEON_TCL_FALLBACK_TEXGEN_2 0x40 /* texgen, unit 2 */
+#define RADEON_TCL_FALLBACK_TCL_DISABLE 0x80 /* user disable */
+#define RADEON_TCL_FALLBACK_FOGCOORDSPEC 0x100 /* fogcoord, sep. spec light */
+
+/* The blit width for texture uploads
+ */
+#define BLIT_WIDTH_BYTES 1024
+
+/* Use the templated vertex format:
+ */
+#define COLOR_IS_RGBA
+#define TAG(x) radeon##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+#define RADEON_RB_CLASS 0xdeadbeef
+
+struct radeon_renderbuffer
+{
+ struct swrast_renderbuffer base;
+
+ struct radeon_bo *bo;
+ unsigned int cpp;
+ /* unsigned int offset; */
+ unsigned int pitch;
+
+ struct radeon_bo *map_bo;
+ GLbitfield map_mode;
+ int map_x, map_y, map_w, map_h;
+ int map_pitch;
+ void *map_buffer;
+
+ uint32_t draw_offset; /* FBO */
+ /* boo Xorg 6.8.2 compat */
+ int has_surface;
+
+ GLuint pf_pending; /**< sequence number of pending flip */
+ __DRIdrawable *dPriv;
+};
+
+struct radeon_framebuffer
+{
+ struct gl_framebuffer base;
+
+ struct radeon_renderbuffer *color_rb[2];
+};
+
+
+struct radeon_colorbuffer_state {
+ int roundEnable;
+ struct gl_renderbuffer *rb;
+ uint32_t draw_offset; /* offset into color renderbuffer - FBOs */
+};
+
+struct radeon_depthbuffer_state {
+ struct gl_renderbuffer *rb;
+};
+
+struct radeon_scissor_state {
+ drm_clip_rect_t rect;
+ GLboolean enabled;
+};
+
+struct radeon_state_atom {
+ struct radeon_state_atom *next, *prev;
+ const char *name; /* for debug */
+ int cmd_size; /* size in bytes */
+ GLuint idx;
+ GLuint is_tcl;
+ GLuint *cmd; /* one or more cmd's */
+ GLuint *lastcmd; /* one or more cmd's */
+ GLboolean dirty; /* dirty-mark in emit_state_list */
+ int (*check) (struct gl_context *, struct radeon_state_atom *atom); /* is this state active? */
+ void (*emit) (struct gl_context *, struct radeon_state_atom *atom);
+};
+
+struct radeon_hw_state {
+ /* Head of the linked list of state atoms. */
+ struct radeon_state_atom atomlist;
+ int max_state_size; /* Number of bytes necessary for a full state emit. */
+ int max_post_flush_size; /* Number of bytes necessary for post flushing emits */
+ GLboolean is_dirty, all_dirty;
+};
+
+
+/* Texture related */
+typedef struct _radeon_texture_image radeon_texture_image;
+
+
+/**
+ * This is a subclass of swrast_texture_image since we use swrast
+ * for software fallback rendering.
+ */
+struct _radeon_texture_image {
+ struct swrast_texture_image base;
+
+ /**
+ * If mt != 0, the image is stored in hardware format in the
+ * given mipmap tree. In this case, base.Data may point into the
+ * mapping of the buffer object that contains the mipmap tree.
+ *
+ * If mt == 0, the image is stored in normal memory pointed to
+ * by base.Data.
+ */
+ struct _radeon_mipmap_tree *mt;
+ struct radeon_bo *bo;
+ GLboolean used_as_render_target;
+};
+
+
+static INLINE radeon_texture_image *get_radeon_texture_image(struct gl_texture_image *image)
+{
+ return (radeon_texture_image*)image;
+}
+
+
+typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
+
+#define RADEON_TXO_MICRO_TILE (1 << 3)
+
+/* Texture object in locally shared texture space.
+ */
+struct radeon_tex_obj {
+ struct gl_texture_object base;
+ struct _radeon_mipmap_tree *mt;
+
+ /**
+ * This is true if we've verified that the mipmap tree above is complete
+ * and so on.
+ */
+ GLboolean validated;
+ /* Minimum LOD to be used during rendering */
+ unsigned minLod;
+ /* Miximum LOD to be used during rendering */
+ unsigned maxLod;
+
+ GLuint override_offset;
+ GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
+ GLuint tile_bits; /* hw texture tile bits used on this texture */
+ struct radeon_bo *bo;
+
+ GLuint pp_txfilter; /* hardware register values */
+ GLuint pp_txformat;
+ GLuint pp_txformat_x;
+ GLuint pp_txsize; /* npot only */
+ GLuint pp_txpitch; /* npot only */
+ GLuint pp_border_color;
+ GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
+
+ GLboolean border_fallback;
+};
+
+static INLINE radeonTexObj* radeon_tex_obj(struct gl_texture_object *texObj)
+{
+ return (radeonTexObj*)texObj;
+}
+
+/* occlusion query */
+struct radeon_query_object {
+ struct gl_query_object Base;
+ struct radeon_bo *bo;
+ int curr_offset;
+ GLboolean emitted_begin;
+
+ /* Double linked list of not flushed query objects */
+ struct radeon_query_object *prev, *next;
+};
+
+/* Need refcounting on dma buffers:
+ */
+struct radeon_dma_buffer {
+ int refcount; /* the number of retained regions in buf */
+ drmBufPtr buf;
+};
+
+struct radeon_aos {
+ struct radeon_bo *bo; /** Buffer object where vertex data is stored */
+ int offset; /** Offset into buffer object, in bytes */
+ int components; /** Number of components per vertex */
+ int stride; /** Stride in dwords (may be 0 for repeating) */
+ int count; /** Number of vertices */
+};
+
+#define DMA_BO_FREE_TIME 100
+
+struct radeon_dma_bo {
+ struct radeon_dma_bo *next, *prev;
+ struct radeon_bo *bo;
+ int expire_counter;
+};
+
+struct radeon_dma {
+ /* Active dma region. Allocations for vertices and retained
+ * regions come from here. Also used for emitting random vertices,
+ * these may be flushed by calling flush_current();
+ */
+ struct radeon_dma_bo free;
+ struct radeon_dma_bo wait;
+ struct radeon_dma_bo reserved;
+ size_t current_used; /** Number of bytes allocated and forgotten about */
+ size_t current_vertexptr; /** End of active vertex region */
+ size_t minimum_size;
+
+ /**
+ * If current_vertexptr != current_used then flush must be non-zero.
+ * flush must be called before non-active vertex allocations can be
+ * performed.
+ */
+ void (*flush) (struct gl_context *);
+};
+
+/* radeon_swtcl.c
+ */
+struct radeon_swtcl_info {
+
+ GLuint RenderIndex;
+ GLuint vertex_size;
+ GLubyte *verts;
+
+ /* Fallback rasterization functions
+ */
+ GLuint hw_primitive;
+ GLenum render_primitive;
+ GLuint numverts;
+
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+
+ GLuint emit_prediction;
+ struct radeon_bo *bo;
+};
+
+#define RADEON_MAX_AOS_ARRAYS 16
+struct radeon_tcl_info {
+ struct radeon_aos aos[RADEON_MAX_AOS_ARRAYS];
+ GLuint aos_count;
+ struct radeon_bo *elt_dma_bo; /** Buffer object that contains element indices */
+ int elt_dma_offset; /** Offset into this buffer object, in bytes */
+};
+
+struct radeon_ioctl {
+ GLuint vertex_offset;
+ GLuint vertex_max;
+ struct radeon_bo *bo;
+ GLuint vertex_size;
+};
+
+#define RADEON_MAX_PRIMS 64
+
+struct radeon_prim {
+ GLuint start;
+ GLuint end;
+ GLuint prim;
+};
+
+static INLINE GLuint radeonPackColor(GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+ switch (cpp) {
+ case 2:
+ return PACK_COLOR_565(r, g, b);
+ case 4:
+ return PACK_COLOR_8888(a, r, g, b);
+ default:
+ return 0;
+ }
+}
+
+#define MAX_CMD_BUF_SZ (16*1024)
+
+#define MAX_DMA_BUF_SZ (64*1024)
+
+struct radeon_store {
+ GLuint statenr;
+ GLuint primnr;
+ char cmd_buf[MAX_CMD_BUF_SZ];
+ int cmd_used;
+ int elts_start;
+};
+
+struct radeon_dri_mirror {
+ __DRIcontext *context; /* DRI context */
+ __DRIscreen *screen; /* DRI screen */
+
+ drm_context_t hwContext;
+ drm_hw_lock_t *hwLock;
+ int hwLockCount;
+ int fd;
+ int drmMinor;
+};
+
+typedef void (*radeon_tri_func) (radeonContextPtr,
+ radeonVertex *,
+ radeonVertex *, radeonVertex *);
+
+typedef void (*radeon_line_func) (radeonContextPtr,
+ radeonVertex *, radeonVertex *);
+
+typedef void (*radeon_point_func) (radeonContextPtr, radeonVertex *);
+
+#define RADEON_MAX_BOS 32
+struct radeon_state {
+ struct radeon_colorbuffer_state color;
+ struct radeon_depthbuffer_state depth;
+ struct radeon_scissor_state scissor;
+};
+
+/**
+ * This structure holds the command buffer while it is being constructed.
+ *
+ * The first batch of commands in the buffer is always the state that needs
+ * to be re-emitted when the context is lost. This batch can be skipped
+ * otherwise.
+ */
+struct radeon_cmdbuf {
+ struct radeon_cs_manager *csm;
+ struct radeon_cs *cs;
+ int size; /** # of dwords total */
+ unsigned int flushing:1; /** whether we're currently in FlushCmdBufLocked */
+};
+
+struct radeon_context {
+ struct gl_context *glCtx;
+ radeonScreenPtr radeonScreen; /* Screen private DRI data */
+
+ /* Texture object bookkeeping
+ */
+ int texture_depth;
+ float initialMaxAnisotropy;
+ uint32_t texture_row_align;
+ uint32_t texture_rect_row_align;
+ uint32_t texture_compressed_row_align;
+
+ struct radeon_dma dma;
+ struct radeon_hw_state hw;
+ /* Rasterization and vertex state:
+ */
+ GLuint TclFallback;
+ GLuint Fallback;
+ GLuint NewGLState;
+ GLbitfield64 tnl_index_bitset; /* index of bits for last tnl_install_attrs */
+
+ /* Drawable information */
+ unsigned int lastStamp;
+ drm_radeon_sarea_t *sarea; /* Private SAREA data */
+
+ /* Mirrors of some DRI state */
+ struct radeon_dri_mirror dri;
+
+ /* Busy waiting */
+ GLuint do_usleeps;
+ GLuint do_irqs;
+ GLuint irqsEmitted;
+ drm_radeon_irq_wait_t iw;
+
+ /* Derived state - for r300 only */
+ struct radeon_state state;
+
+ struct radeon_swtcl_info swtcl;
+ struct radeon_tcl_info tcl;
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+
+ struct radeon_cmdbuf cmdbuf;
+
+ struct radeon_debug debug;
+
+ drm_clip_rect_t fboRect;
+ GLboolean front_cliprects;
+
+ /**
+ * Set if rendering has occured to the drawable's front buffer.
+ *
+ * This is used in the DRI2 case to detect that glFlush should also copy
+ * the contents of the fake front buffer to the real front buffer.
+ */
+ GLboolean front_buffer_dirty;
+
+ /**
+ * Track whether front-buffer rendering is currently enabled
+ *
+ * A separate flag is used to track this in order to support MRT more
+ * easily.
+ */
+ GLboolean is_front_buffer_rendering;
+
+ /**
+ * Track whether front-buffer is the current read target.
+ *
+ * This is closely associated with is_front_buffer_rendering, but may
+ * be set separately. The DRI2 fake front buffer must be referenced
+ * either way.
+ */
+ GLboolean is_front_buffer_reading;
+
+ struct {
+ struct radeon_query_object *current;
+ struct radeon_state_atom queryobj;
+ } query;
+
+ struct {
+ void (*get_lock)(radeonContextPtr radeon);
+ void (*update_viewport_offset)(struct gl_context *ctx);
+ void (*emit_cs_header)(struct radeon_cs *cs, radeonContextPtr rmesa);
+ void (*swtcl_flush)(struct gl_context *ctx, uint32_t offset);
+ void (*pre_emit_atoms)(radeonContextPtr rmesa);
+ void (*pre_emit_state)(radeonContextPtr rmesa);
+ void (*fallback)(struct gl_context *ctx, GLuint bit, GLboolean mode);
+ void (*free_context)(struct gl_context *ctx);
+ void (*emit_query_finish)(radeonContextPtr radeon);
+ void (*update_scissor)(struct gl_context *ctx);
+ unsigned (*check_blit)(gl_format mesa_format, uint32_t dst_pitch);
+ unsigned (*blit)(struct gl_context *ctx,
+ struct radeon_bo *src_bo,
+ intptr_t src_offset,
+ gl_format src_mesaformat,
+ unsigned src_pitch,
+ unsigned src_width,
+ unsigned src_height,
+ unsigned src_x_offset,
+ unsigned src_y_offset,
+ struct radeon_bo *dst_bo,
+ intptr_t dst_offset,
+ gl_format dst_mesaformat,
+ unsigned dst_pitch,
+ unsigned dst_width,
+ unsigned dst_height,
+ unsigned dst_x_offset,
+ unsigned dst_y_offset,
+ unsigned reg_width,
+ unsigned reg_height,
+ unsigned flip_y);
+ unsigned (*is_format_renderable)(gl_format mesa_format);
+ } vtbl;
+};
+
+#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
+
+static inline __DRIdrawable* radeon_get_drawable(radeonContextPtr radeon)
+{
+ return radeon->dri.context->driDrawablePriv;
+}
+
+static inline __DRIdrawable* radeon_get_readable(radeonContextPtr radeon)
+{
+ return radeon->dri.context->driReadablePriv;
+}
+
+GLboolean radeonInitContext(radeonContextPtr radeon,
+ struct dd_function_table* functions,
+ const struct gl_config * glVisual,
+ __DRIcontext * driContextPriv,
+ void *sharedContextPrivate);
+
+void radeonCleanupContext(radeonContextPtr radeon);
+GLboolean radeonUnbindContext(__DRIcontext * driContextPriv);
+void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
+ GLboolean front_only);
+GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv);
+extern void radeonDestroyContext(__DRIcontext * driContextPriv);
+void radeon_prepare_render(radeonContextPtr radeon);
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.c
index c98c2e074c5..dd0afb809a0 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.c
@@ -1 +1,108 @@
-../radeon/radeon_debug.c \ No newline at end of file
+/*
+ * Copyright © 2009 Pauli Nieminen
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Pauli Nieminen <suokkos@gmail.com>
+ */
+
+#include "utils.h"
+
+#include "radeon_debug.h"
+#include "radeon_common_context.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+static const struct dri_debug_control debug_control[] = {
+ {"fall", RADEON_FALLBACKS},
+ {"tex", RADEON_TEXTURE},
+ {"ioctl", RADEON_IOCTL},
+ {"verts", RADEON_VERTS},
+ {"render", RADEON_RENDER},
+ {"swrender", RADEON_SWRENDER},
+ {"state", RADEON_STATE},
+ {"shader", RADEON_SHADER},
+ {"vfmt", RADEON_VFMT},
+ {"vtxf", RADEON_VFMT},
+ {"dri", RADEON_DRI},
+ {"dma", RADEON_DMA},
+ {"sanity", RADEON_SANITY},
+ {"sync", RADEON_SYNC},
+ {"pixel", RADEON_PIXEL},
+ {"mem", RADEON_MEMORY},
+ {"cs", RADEON_CS},
+ {"allmsg", ~RADEON_SYNC}, /* avoid the term "sync" because the parser uses strstr */
+ {NULL, 0}
+};
+
+radeon_debug_type_t radeon_enabled_debug_types;
+
+void radeon_init_debug(void)
+{
+ radeon_enabled_debug_types = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
+
+ radeon_enabled_debug_types |= RADEON_GENERAL;
+}
+
+void _radeon_debug_add_indent(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ const size_t length = sizeof(radeon->debug.indent)
+ / sizeof(radeon->debug.indent[0]);
+ if (radeon->debug.indent_depth < length - 1) {
+ radeon->debug.indent[radeon->debug.indent_depth] = '\t';
+ ++radeon->debug.indent_depth;
+ };
+}
+
+void _radeon_debug_remove_indent(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ if (radeon->debug.indent_depth > 0) {
+ radeon->debug.indent[radeon->debug.indent_depth] = '\0';
+ --radeon->debug.indent_depth;
+ }
+}
+
+void _radeon_print(const radeon_debug_type_t type,
+ const radeon_debug_level_t level,
+ const char* message,
+ ...)
+{
+ va_list values;
+
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ // FIXME: Make this multi thread safe
+ if (radeon->debug.indent_depth)
+ fprintf(stderr, "%s", radeon->debug.indent);
+ }
+ va_start( values, message );
+ vfprintf(stderr, message, values);
+ va_end( values );
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.h
index bd8aa28e89e..449c27a3fe1 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_debug.h
@@ -1 +1,174 @@
-../radeon/radeon_debug.h \ No newline at end of file
+/*
+ * Copyright © 2009 Pauli Nieminen
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Pauli Nieminen <suokkos@gmail.com>
+ */
+
+#ifndef RADEON_DEBUG_H_INCLUDED
+#define RADEON_DEBUG_H_INCLUDED
+
+#include <stdlib.h>
+
+typedef enum radeon_debug_levels {
+ RADEON_CRITICAL = 0, /* Only errors */
+ RADEON_IMPORTANT = 1, /* Important warnings and messages */
+ RADEON_NORMAL = 2, /* Normal log messages usefull for debugging */
+ RADEON_VERBOSE = 3, /* Extra details to debugging */
+ RADEON_TRACE = 4 /* Log about everything that happens */
+} radeon_debug_level_t;
+
+/**
+ * Compile time option to change level of debugging compiled to dri driver.
+ * Selecting critical level is not recommended because perfromance gains are
+ * going to minimal but you will lose a lot of important warnings in case of
+ * errors.
+ */
+#ifndef RADEON_DEBUG_LEVEL
+# ifdef DEBUG
+# define RADEON_DEBUG_LEVEL RADEON_TRACE
+# else
+# define RADEON_DEBUG_LEVEL RADEON_VERBOSE
+# endif
+#endif
+
+typedef enum radeon_debug_types {
+ RADEON_TEXTURE = 0x00001,
+ RADEON_STATE = 0x00002,
+ RADEON_IOCTL = 0x00004,
+ RADEON_RENDER = 0x00008,
+ RADEON_SWRENDER = 0x00010,
+ RADEON_FALLBACKS = 0x00020,
+ RADEON_VFMT = 0x00040,
+ RADEON_SHADER = 0x00080,
+ RADEON_CS = 0x00100,
+ RADEON_DRI = 0x00200,
+ RADEON_DMA = 0x00400,
+ RADEON_SANITY = 0x00800,
+ RADEON_SYNC = 0x01000,
+ RADEON_PIXEL = 0x02000,
+ RADEON_MEMORY = 0x04000,
+ RADEON_VERTS = 0x08000,
+ RADEON_GENERAL = 0x10000 /* Used for errors and warnings */
+} radeon_debug_type_t;
+
+#define RADEON_MAX_INDENT 5
+
+struct radeon_debug {
+ size_t indent_depth;
+ char indent[RADEON_MAX_INDENT];
+};
+
+extern radeon_debug_type_t radeon_enabled_debug_types;
+
+/**
+ * Compabibility layer for old debug code
+ **/
+#define RADEON_DEBUG radeon_enabled_debug_types
+
+static inline int radeon_is_debug_enabled(const radeon_debug_type_t type,
+ const radeon_debug_level_t level)
+{
+ return RADEON_DEBUG_LEVEL >= level
+ && (type & radeon_enabled_debug_types);
+}
+/*
+ * define macro for gcc specific __attribute__ if using alternative compiler
+ */
+#ifndef __GNUC__
+#define __attribute__(x) /*empty*/
+#endif
+
+
+extern void _radeon_print(const radeon_debug_type_t type,
+ const radeon_debug_level_t level,
+ const char* message,
+ ...) __attribute__((format(printf,3,4)));
+/**
+ * Print out debug message if channel specified by type is enabled
+ * and compile time debugging level is at least as high as level parameter
+ */
+#define radeon_print(type, level, ...) do { \
+ const radeon_debug_level_t _debug_level = (level); \
+ const radeon_debug_type_t _debug_type = (type); \
+ /* Compile out if level of message is too high */ \
+ if (radeon_is_debug_enabled(type, level)) { \
+ _radeon_print(_debug_type, _debug_level, \
+ __VA_ARGS__); \
+ } \
+} while(0)
+
+/**
+ * printf style function for writing error messages.
+ */
+#define radeon_error(...) do { \
+ radeon_print(RADEON_GENERAL, RADEON_CRITICAL, \
+ __VA_ARGS__); \
+} while(0)
+
+/**
+ * printf style function for writing warnings.
+ */
+#define radeon_warning(...) do { \
+ radeon_print(RADEON_GENERAL, RADEON_IMPORTANT, \
+ __VA_ARGS__); \
+} while(0)
+
+extern void radeon_init_debug(void);
+extern void _radeon_debug_add_indent(void);
+extern void _radeon_debug_remove_indent(void);
+
+static inline void radeon_debug_add_indent(void)
+{
+ if (RADEON_DEBUG_LEVEL >= RADEON_VERBOSE) {
+ _radeon_debug_add_indent();
+ }
+}
+static inline void radeon_debug_remove_indent(void)
+{
+ if (RADEON_DEBUG_LEVEL >= RADEON_VERBOSE) {
+ _radeon_debug_remove_indent();
+ }
+}
+
+
+/* From http://gcc. gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
+ I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
+ with other compilers ... GLUE!
+*/
+#define WARN_ONCE(...) do { \
+ static int __warn_once=1; \
+ if(__warn_once){ \
+ radeon_warning("*********************************WARN_ONCE*********************************\n"); \
+ radeon_warning("File %s function %s line %d\n", \
+ __FILE__, __FUNCTION__, __LINE__); \
+ radeon_warning(__VA_ARGS__);\
+ radeon_warning("***************************************************************************\n"); \
+ __warn_once=0;\
+ } \
+ } while(0)
+
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.c
index 43be0006255..61cddda5dc1 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.c
@@ -1 +1,511 @@
-../radeon/radeon_dma.c \ No newline at end of file
+/**************************************************************************
+
+Copyright (C) 2004 Nicolai Haehnle.
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <errno.h>
+#include "radeon_common.h"
+#include "radeon_fog.h"
+#include "main/simple_list.h"
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
+ : "0" (nr), \
+ "D" ((long)dst), \
+ "S" ((long)src) ); \
+} while (0)
+#else
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int j; \
+ for ( j = 0 ; j < nr ; j++ ) \
+ dst[j] = ((int *)src)[j]; \
+ dst += nr; \
+} while (0)
+#endif
+
+void radeonEmitVec4(uint32_t *out, const GLvoid * data, int stride, int count)
+{
+ int i;
+
+ if (RADEON_DEBUG & RADEON_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 4)
+ COPY_DWORDS(out, data, count);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out++;
+ data += stride;
+ }
+}
+
+void radeonEmitVec8(uint32_t *out, const GLvoid * data, int stride, int count)
+{
+ int i;
+
+ if (RADEON_DEBUG & RADEON_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 8)
+ COPY_DWORDS(out, data, count * 2);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out += 2;
+ data += stride;
+ }
+}
+
+void radeonEmitVec12(uint32_t *out, const GLvoid * data, int stride, int count)
+{
+ int i;
+
+ if (RADEON_DEBUG & RADEON_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 12) {
+ COPY_DWORDS(out, data, count * 3);
+ }
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out[2] = *(int *)(data + 8);
+ out += 3;
+ data += stride;
+ }
+}
+
+void radeonEmitVec16(uint32_t *out, const GLvoid * data, int stride, int count)
+{
+ int i;
+
+ if (RADEON_DEBUG & RADEON_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 16)
+ COPY_DWORDS(out, data, count * 4);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out[2] = *(int *)(data + 8);
+ out[3] = *(int *)(data + 12);
+ out += 4;
+ data += stride;
+ }
+}
+
+void rcommon_emit_vector(struct gl_context * ctx, struct radeon_aos *aos,
+ const GLvoid * data, int size, int stride, int count)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ uint32_t *out;
+
+ if (stride == 0) {
+ radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * 4, 32);
+ count = 1;
+ aos->stride = 0;
+ } else {
+ radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
+ aos->stride = size;
+ }
+
+ aos->components = size;
+ aos->count = count;
+
+ radeon_bo_map(aos->bo, 1);
+ out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
+ switch (size) {
+ case 1: radeonEmitVec4(out, data, stride, count); break;
+ case 2: radeonEmitVec8(out, data, stride, count); break;
+ case 3: radeonEmitVec12(out, data, stride, count); break;
+ case 4: radeonEmitVec16(out, data, stride, count); break;
+ default:
+ assert(0);
+ break;
+ }
+ radeon_bo_unmap(aos->bo);
+}
+
+void rcommon_emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
+ GLvoid *data, int stride, int count)
+{
+ int i;
+ float *out;
+ int size = 1;
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & RADEON_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 0) {
+ radeonAllocDmaRegion( rmesa, &aos->bo, &aos->offset, size * 4, 32 );
+ count = 1;
+ aos->stride = 0;
+ } else {
+ radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
+ aos->stride = size;
+ }
+
+ aos->components = size;
+ aos->count = count;
+
+ /* Emit the data */
+ radeon_bo_map(aos->bo, 1);
+ out = (float*)((char*)aos->bo->ptr + aos->offset);
+ for (i = 0; i < count; i++) {
+ out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );
+ out++;
+ data += stride;
+ }
+ radeon_bo_unmap(aos->bo);
+}
+
+void radeon_init_dma(radeonContextPtr rmesa)
+{
+ make_empty_list(&rmesa->dma.free);
+ make_empty_list(&rmesa->dma.wait);
+ make_empty_list(&rmesa->dma.reserved);
+ rmesa->dma.minimum_size = MAX_DMA_BUF_SZ;
+}
+
+void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
+{
+ struct radeon_dma_bo *dma_bo = NULL;
+ /* we set minimum sizes to at least requested size
+ aligned to next 16 bytes. */
+ if (size > rmesa->dma.minimum_size)
+ rmesa->dma.minimum_size = (size + 15) & (~15);
+
+ radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %Zi\n",
+ __FUNCTION__, size, rmesa->dma.minimum_size);
+
+ if (is_empty_list(&rmesa->dma.free)
+ || last_elem(&rmesa->dma.free)->bo->size < size) {
+ dma_bo = CALLOC_STRUCT(radeon_dma_bo);
+ assert(dma_bo);
+
+again_alloc:
+ dma_bo->bo = radeon_bo_open(rmesa->radeonScreen->bom,
+ 0, rmesa->dma.minimum_size, 4,
+ RADEON_GEM_DOMAIN_GTT, 0);
+
+ if (!dma_bo->bo) {
+ rcommonFlushCmdBuf(rmesa, __FUNCTION__);
+ goto again_alloc;
+ }
+ insert_at_head(&rmesa->dma.reserved, dma_bo);
+ } else {
+ /* We push and pop buffers from end of list so we can keep
+ counter on unused buffers for later freeing them from
+ begin of list */
+ dma_bo = last_elem(&rmesa->dma.free);
+ remove_from_list(dma_bo);
+ insert_at_head(&rmesa->dma.reserved, dma_bo);
+ }
+
+ rmesa->dma.current_used = 0;
+ rmesa->dma.current_vertexptr = 0;
+
+ if (radeon_cs_space_check_with_bo(rmesa->cmdbuf.cs,
+ first_elem(&rmesa->dma.reserved)->bo,
+ RADEON_GEM_DOMAIN_GTT, 0))
+ fprintf(stderr,"failure to revalidate BOs - badness\n");
+
+ if (is_empty_list(&rmesa->dma.reserved)) {
+ /* Cmd buff have been flushed in radeon_revalidate_bos */
+ goto again_alloc;
+ }
+ radeon_bo_map(first_elem(&rmesa->dma.reserved)->bo, 1);
+}
+
+/* Allocates a region from rmesa->dma.current. If there isn't enough
+ * space in current, grab a new buffer (and discard what was left of current)
+ */
+void radeonAllocDmaRegion(radeonContextPtr rmesa,
+ struct radeon_bo **pbo, int *poffset,
+ int bytes, int alignment)
+{
+ if (RADEON_DEBUG & RADEON_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush(rmesa->glCtx);
+
+ assert(rmesa->dma.current_used == rmesa->dma.current_vertexptr);
+
+ alignment--;
+ rmesa->dma.current_used = (rmesa->dma.current_used + alignment) & ~alignment;
+
+ if (is_empty_list(&rmesa->dma.reserved)
+ || rmesa->dma.current_used + bytes > first_elem(&rmesa->dma.reserved)->bo->size)
+ radeonRefillCurrentDmaRegion(rmesa, bytes);
+
+ *poffset = rmesa->dma.current_used;
+ *pbo = first_elem(&rmesa->dma.reserved)->bo;
+ radeon_bo_ref(*pbo);
+
+ /* Always align to at least 16 bytes */
+ rmesa->dma.current_used = (rmesa->dma.current_used + bytes + 15) & ~15;
+ rmesa->dma.current_vertexptr = rmesa->dma.current_used;
+
+ assert(rmesa->dma.current_used <= first_elem(&rmesa->dma.reserved)->bo->size);
+}
+
+void radeonFreeDmaRegions(radeonContextPtr rmesa)
+{
+ struct radeon_dma_bo *dma_bo;
+ struct radeon_dma_bo *temp;
+ if (RADEON_DEBUG & RADEON_DMA)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ foreach_s(dma_bo, temp, &rmesa->dma.free) {
+ remove_from_list(dma_bo);
+ radeon_bo_unref(dma_bo->bo);
+ FREE(dma_bo);
+ }
+
+ foreach_s(dma_bo, temp, &rmesa->dma.wait) {
+ remove_from_list(dma_bo);
+ radeon_bo_unref(dma_bo->bo);
+ FREE(dma_bo);
+ }
+
+ foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
+ remove_from_list(dma_bo);
+ radeon_bo_unref(dma_bo->bo);
+ FREE(dma_bo);
+ }
+}
+
+void radeonReturnDmaRegion(radeonContextPtr rmesa, int return_bytes)
+{
+ if (is_empty_list(&rmesa->dma.reserved))
+ return;
+
+ if (RADEON_DEBUG & RADEON_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, return_bytes);
+ rmesa->dma.current_used -= return_bytes;
+ rmesa->dma.current_vertexptr = rmesa->dma.current_used;
+}
+
+static int radeon_bo_is_idle(struct radeon_bo* bo)
+{
+ uint32_t domain;
+ int ret = radeon_bo_is_busy(bo, &domain);
+ if (ret == -EINVAL) {
+ WARN_ONCE("Your libdrm or kernel doesn't have support for busy query.\n"
+ "This may cause small performance drop for you.\n");
+ }
+ return ret != -EBUSY;
+}
+
+void radeonReleaseDmaRegions(radeonContextPtr rmesa)
+{
+ struct radeon_dma_bo *dma_bo;
+ struct radeon_dma_bo *temp;
+ const int expire_at = ++rmesa->dma.free.expire_counter + DMA_BO_FREE_TIME;
+ const int time = rmesa->dma.free.expire_counter;
+
+ if (RADEON_DEBUG & RADEON_DMA) {
+ size_t free = 0,
+ wait = 0,
+ reserved = 0;
+ foreach(dma_bo, &rmesa->dma.free)
+ ++free;
+
+ foreach(dma_bo, &rmesa->dma.wait)
+ ++wait;
+
+ foreach(dma_bo, &rmesa->dma.reserved)
+ ++reserved;
+
+ fprintf(stderr, "%s: free %zu, wait %zu, reserved %zu, minimum_size: %zu\n",
+ __FUNCTION__, free, wait, reserved, rmesa->dma.minimum_size);
+ }
+
+ /* move waiting bos to free list.
+ wait list provides gpu time to handle data before reuse */
+ foreach_s(dma_bo, temp, &rmesa->dma.wait) {
+ if (dma_bo->expire_counter == time) {
+ WARN_ONCE("Leaking dma buffer object!\n");
+ radeon_bo_unref(dma_bo->bo);
+ remove_from_list(dma_bo);
+ FREE(dma_bo);
+ continue;
+ }
+ /* free objects that are too small to be used because of large request */
+ if (dma_bo->bo->size < rmesa->dma.minimum_size) {
+ radeon_bo_unref(dma_bo->bo);
+ remove_from_list(dma_bo);
+ FREE(dma_bo);
+ continue;
+ }
+ if (!radeon_bo_is_idle(dma_bo->bo)) {
+ break;
+ }
+ remove_from_list(dma_bo);
+ dma_bo->expire_counter = expire_at;
+ insert_at_tail(&rmesa->dma.free, dma_bo);
+ }
+
+ /* move reserved to wait list */
+ foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
+ radeon_bo_unmap(dma_bo->bo);
+ /* free objects that are too small to be used because of large request */
+ if (dma_bo->bo->size < rmesa->dma.minimum_size) {
+ radeon_bo_unref(dma_bo->bo);
+ remove_from_list(dma_bo);
+ FREE(dma_bo);
+ continue;
+ }
+ remove_from_list(dma_bo);
+ dma_bo->expire_counter = expire_at;
+ insert_at_tail(&rmesa->dma.wait, dma_bo);
+ }
+
+ /* free bos that have been unused for some time */
+ foreach_s(dma_bo, temp, &rmesa->dma.free) {
+ if (dma_bo->expire_counter != time)
+ break;
+ remove_from_list(dma_bo);
+ radeon_bo_unref(dma_bo->bo);
+ FREE(dma_bo);
+ }
+
+}
+
+
+/* Flush vertices in the current dma region.
+ */
+void rcommon_flush_last_swtcl_prim( struct gl_context *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct radeon_dma *dma = &rmesa->dma;
+
+ if (RADEON_DEBUG & RADEON_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ dma->flush = NULL;
+
+ radeon_bo_unmap(rmesa->swtcl.bo);
+
+ if (!is_empty_list(&dma->reserved)) {
+ GLuint current_offset = dma->current_used;
+
+ assert (dma->current_used +
+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+ dma->current_vertexptr);
+
+ if (dma->current_used != dma->current_vertexptr) {
+ dma->current_used = dma->current_vertexptr;
+
+ rmesa->vtbl.swtcl_flush(ctx, current_offset);
+ }
+ rmesa->swtcl.numverts = 0;
+ }
+ radeon_bo_unref(rmesa->swtcl.bo);
+ rmesa->swtcl.bo = NULL;
+}
+/* Alloc space in the current dma region.
+ */
+void *
+rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
+{
+ GLuint bytes = vsize * nverts;
+ void *head;
+ if (RADEON_DEBUG & RADEON_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if(is_empty_list(&rmesa->dma.reserved)
+ ||rmesa->dma.current_vertexptr + bytes > first_elem(&rmesa->dma.reserved)->bo->size) {
+ if (rmesa->dma.flush) {
+ rmesa->dma.flush(rmesa->glCtx);
+ }
+
+ radeonRefillCurrentDmaRegion(rmesa, bytes);
+
+ return NULL;
+ }
+
+ if (!rmesa->dma.flush) {
+ /* if cmdbuf flushed DMA restart */
+ rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ rmesa->dma.flush = rcommon_flush_last_swtcl_prim;
+ }
+
+ ASSERT( vsize == rmesa->swtcl.vertex_size * 4 );
+ ASSERT( rmesa->dma.flush == rcommon_flush_last_swtcl_prim );
+ ASSERT( rmesa->dma.current_used +
+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+ rmesa->dma.current_vertexptr );
+
+ if (!rmesa->swtcl.bo) {
+ rmesa->swtcl.bo = first_elem(&rmesa->dma.reserved)->bo;
+ radeon_bo_ref(rmesa->swtcl.bo);
+ radeon_bo_map(rmesa->swtcl.bo, 1);
+ }
+
+ head = (rmesa->swtcl.bo->ptr + rmesa->dma.current_vertexptr);
+ rmesa->dma.current_vertexptr += bytes;
+ rmesa->swtcl.numverts += nverts;
+ return head;
+}
+
+void radeonReleaseArrays( struct gl_context *ctx, GLuint newinputs )
+{
+ radeonContextPtr radeon = RADEON_CONTEXT( ctx );
+ int i;
+ if (RADEON_DEBUG & RADEON_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (radeon->dma.flush) {
+ radeon->dma.flush(radeon->glCtx);
+ }
+ for (i = 0; i < radeon->tcl.aos_count; i++) {
+ if (radeon->tcl.aos[i].bo) {
+ radeon_bo_unref(radeon->tcl.aos[i].bo);
+ radeon->tcl.aos[i].bo = NULL;
+
+ }
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.h
index 82e50634e3c..db7b84ebd1e 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_dma.h
@@ -1 +1,60 @@
-../radeon/radeon_dma.h \ No newline at end of file
+/**************************************************************************
+
+Copyright (C) 2004 Nicolai Haehnle.
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef RADEON_DMA_H
+#define RADEON_DMA_H
+
+void radeonEmitVec4(uint32_t *out, const GLvoid * data, int stride, int count);
+void radeonEmitVec8(uint32_t *out, const GLvoid * data, int stride, int count);
+void radeonEmitVec12(uint32_t *out, const GLvoid * data, int stride, int count);
+void radeonEmitVec16(uint32_t *out, const GLvoid * data, int stride, int count);
+
+void rcommon_emit_vector(struct gl_context * ctx, struct radeon_aos *aos,
+ const GLvoid * data, int size, int stride, int count);
+void rcommon_emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
+ GLvoid *data, int stride, int count);
+
+void radeonReturnDmaRegion(radeonContextPtr rmesa, int return_bytes);
+void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size);
+void radeon_init_dma(radeonContextPtr rmesa);
+void radeonReturnDmaRegion(radeonContextPtr rmesa, int return_bytes);
+void radeonAllocDmaRegion(radeonContextPtr rmesa,
+ struct radeon_bo **pbo, int *poffset,
+ int bytes, int alignment);
+void radeonReleaseDmaRegions(radeonContextPtr rmesa);
+
+void rcommon_flush_last_swtcl_prim(struct gl_context *ctx);
+
+void *rcommonAllocDmaLowVerts(radeonContextPtr rmesa, int nverts, int vsize);
+void radeonFreeDmaRegions(radeonContextPtr rmesa);
+void radeonReleaseArrays( struct gl_context *ctx, GLuint newinputs );
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fbo.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fbo.c
index 0d738d8d780..f597f35c0f7 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fbo.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fbo.c
@@ -1 +1,980 @@
-../radeon/radeon_fbo.c \ No newline at end of file
+/**************************************************************************
+ *
+ * Copyright 2008 Red Hat Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/context.h"
+#include "swrast/swrast.h"
+#include "drivers/common/meta.h"
+
+#include "radeon_common.h"
+#include "radeon_mipmap_tree.h"
+
+#define FILE_DEBUG_FLAG RADEON_TEXTURE
+#define DBG(...) do { \
+ if (RADEON_DEBUG & FILE_DEBUG_FLAG) \
+ printf(__VA_ARGS__); \
+} while(0)
+
+static struct gl_framebuffer *
+radeon_new_framebuffer(struct gl_context *ctx, GLuint name)
+{
+ return _mesa_new_framebuffer(ctx, name);
+}
+
+static void
+radeon_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(rb %p, rrb %p) \n",
+ __func__, rb, rrb);
+
+ ASSERT(rrb);
+
+ if (rrb && rrb->bo) {
+ radeon_bo_unref(rrb->bo);
+ }
+ _mesa_delete_renderbuffer(ctx, rb);
+}
+
+#if defined(RADEON_R100)
+static GLuint get_depth_z32(const struct radeon_renderbuffer * rrb,
+ GLint x, GLint y)
+{
+ GLuint ba, address = 0;
+
+ ba = (y >> 4) * (rrb->pitch >> 6) + (x >> 4);
+
+ address |= (x & 0x7) << 2;
+ address |= (y & 0x3) << 5;
+ address |= (((x & 0x10) >> 2) ^ (y & 0x4)) << 5;
+ address |= (ba & 3) << 8;
+ address |= (y & 0x8) << 7;
+ address |= (((x & 0x8) << 1) ^ (y & 0x10)) << 7;
+ address |= (ba & ~0x3) << 10;
+ return address;
+}
+
+static GLuint get_depth_z16(const struct radeon_renderbuffer * rrb,
+ GLint x, GLint y)
+{
+ GLuint ba, address = 0; /* a[0] = 0 */
+
+ ba = (y / 16) * (rrb->pitch >> 6) + (x / 32);
+
+ address |= (x & 0x7) << 1; /* a[1..3] = x[0..2] */
+ address |= (y & 0x7) << 4; /* a[4..6] = y[0..2] */
+ address |= (x & 0x8) << 4; /* a[7] = x[3] */
+ address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
+ address |= (y & 0x8) << 7; /* a[10] = y[3] */
+ address |= ((x & 0x10) ^ (y & 0x10)) << 7;/* a[11] = x[4] ^ y[4] */
+ address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
+ return address;
+}
+#endif
+
+#if defined(RADEON_R200)
+static GLuint get_depth_z32(const struct radeon_renderbuffer * rrb,
+ GLint x, GLint y)
+{
+ GLuint offset;
+ GLuint b;
+ offset = 0;
+ b = (((y & 0x7ff) >> 4) * (rrb->pitch >> 7) + (x >> 5));
+ offset += (b >> 1) << 12;
+ offset += (((rrb->pitch >> 7) & 0x1) ? (b & 0x1) : ((b & 0x1) ^ ((y >> 4) & 0x1))) << 11;
+ offset += ((y >> 2) & 0x3) << 9;
+ offset += ((x >> 2) & 0x1) << 8;
+ offset += ((x >> 3) & 0x3) << 6;
+ offset += ((y >> 1) & 0x1) << 5;
+ offset += ((x >> 1) & 0x1) << 4;
+ offset += (y & 0x1) << 3;
+ offset += (x & 0x1) << 2;
+
+ return offset;
+}
+
+static GLuint get_depth_z16(const struct radeon_renderbuffer *rrb,
+ GLint x, GLint y)
+{
+ GLuint offset;
+ GLuint b;
+
+ offset = 0;
+ b = (((y >> 4) * (rrb->pitch >> 7) + (x >> 6)));
+ offset += (b >> 1) << 12;
+ offset += (((rrb->pitch >> 7) & 0x1) ? (b & 0x1) : ((b & 0x1) ^ ((y >> 4) & 0x1))) << 11;
+ offset += ((y >> 2) & 0x3) << 9;
+ offset += ((x >> 3) & 0x1) << 8;
+ offset += ((x >> 4) & 0x3) << 6;
+ offset += ((x >> 2) & 0x1) << 5;
+ offset += ((y >> 1) & 0x1) << 4;
+ offset += ((x >> 1) & 0x1) << 3;
+ offset += (y & 0x1) << 2;
+ offset += (x & 0x1) << 1;
+
+ return offset;
+}
+#endif
+
+static void
+radeon_map_renderbuffer_s8z24(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ uint32_t *untiled_s8z24_map, *tiled_s8z24_map;
+ int ret;
+ int y_flip = (rb->Name == 0) ? -1 : 1;
+ int y_bias = (rb->Name == 0) ? (rb->Height - 1) : 0;
+ uint32_t pitch = w * rrb->cpp;
+
+ rrb->map_pitch = pitch;
+
+ rrb->map_buffer = malloc(w * h * 4);
+ ret = radeon_bo_map(rrb->bo, !!(mode & GL_MAP_WRITE_BIT));
+ assert(!ret);
+ untiled_s8z24_map = rrb->map_buffer;
+ tiled_s8z24_map = rrb->bo->ptr;
+
+ for (uint32_t pix_y = 0; pix_y < h; ++ pix_y) {
+ for (uint32_t pix_x = 0; pix_x < w; ++pix_x) {
+ uint32_t flipped_y = y_flip * (int32_t)(y + pix_y) + y_bias;
+ uint32_t src_offset = get_depth_z32(rrb, x + pix_x, flipped_y);
+ uint32_t dst_offset = pix_y * rrb->map_pitch + pix_x * rrb->cpp;
+ untiled_s8z24_map[dst_offset/4] = tiled_s8z24_map[src_offset/4];
+ }
+ }
+
+ radeon_bo_unmap(rrb->bo);
+
+ *out_map = rrb->map_buffer;
+ *out_stride = rrb->map_pitch;
+}
+
+static void
+radeon_map_renderbuffer_z16(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ uint16_t *untiled_z16_map, *tiled_z16_map;
+ int ret;
+ int y_flip = (rb->Name == 0) ? -1 : 1;
+ int y_bias = (rb->Name == 0) ? (rb->Height - 1) : 0;
+ uint32_t pitch = w * rrb->cpp;
+
+ rrb->map_pitch = pitch;
+
+ rrb->map_buffer = malloc(w * h * 2);
+ ret = radeon_bo_map(rrb->bo, !!(mode & GL_MAP_WRITE_BIT));
+ assert(!ret);
+
+ untiled_z16_map = rrb->map_buffer;
+ tiled_z16_map = rrb->bo->ptr;
+
+ for (uint32_t pix_y = 0; pix_y < h; ++ pix_y) {
+ for (uint32_t pix_x = 0; pix_x < w; ++pix_x) {
+ uint32_t flipped_y = y_flip * (int32_t)(y + pix_y) + y_bias;
+ uint32_t src_offset = get_depth_z16(rrb, x + pix_x, flipped_y);
+ uint32_t dst_offset = pix_y * rrb->map_pitch + pix_x * rrb->cpp;
+ untiled_z16_map[dst_offset/2] = tiled_z16_map[src_offset/2];
+ }
+ }
+
+ radeon_bo_unmap(rrb->bo);
+
+ *out_map = rrb->map_buffer;
+ *out_stride = rrb->map_pitch;
+}
+
+static void
+radeon_map_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ GLubyte *map;
+ GLboolean ok;
+ int stride, flip_stride;
+ int ret;
+ int src_x, src_y;
+
+ if (!rrb || !rrb->bo) {
+ *out_map = NULL;
+ *out_stride = 0;
+ return;
+ }
+
+ rrb->map_mode = mode;
+ rrb->map_x = x;
+ rrb->map_y = y;
+ rrb->map_w = w;
+ rrb->map_h = h;
+ rrb->map_pitch = rrb->pitch;
+
+ ok = rmesa->vtbl.check_blit(rb->Format, rrb->pitch / rrb->cpp);
+ if (ok) {
+ if (rb->Name) {
+ src_x = x;
+ src_y = y;
+ } else {
+ src_x = x;
+ src_y = rrb->base.Base.Height - y - h;
+ }
+
+ /* Make a temporary buffer and blit the current contents of the renderbuffer
+ * out to it. This gives us linear access to the buffer, instead of having
+ * to do detiling in software.
+ */
+
+ rrb->map_pitch = rrb->pitch;
+
+ assert(!rrb->map_bo);
+ rrb->map_bo = radeon_bo_open(rmesa->radeonScreen->bom, 0,
+ rrb->map_pitch * h, 4,
+ RADEON_GEM_DOMAIN_GTT, 0);
+
+ ok = rmesa->vtbl.blit(ctx, rrb->bo, rrb->draw_offset,
+ rb->Format, rrb->pitch / rrb->cpp,
+ rb->Width, rb->Height,
+ src_x, src_y,
+ rrb->map_bo, 0,
+ rb->Format, rrb->map_pitch / rrb->cpp,
+ w, h,
+ 0, 0,
+ w, h,
+ GL_FALSE);
+ assert(ok);
+
+ ret = radeon_bo_map(rrb->map_bo, !!(mode & GL_MAP_WRITE_BIT));
+ assert(!ret);
+
+ map = rrb->map_bo->ptr;
+
+ if (rb->Name) {
+ *out_map = map;
+ *out_stride = rrb->map_pitch;
+ } else {
+ *out_map = map + (h - 1) * rrb->map_pitch;
+ *out_stride = -rrb->map_pitch;
+ }
+ return;
+ }
+
+ /* sw fallback flush stuff */
+ if (radeon_bo_is_referenced_by_cs(rrb->bo, rmesa->cmdbuf.cs)) {
+ radeon_firevertices(rmesa);
+ }
+
+ if ((rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_DEPTH_ALWAYS_TILED) && !rrb->has_surface) {
+ if (rb->Format == MESA_FORMAT_S8_Z24 || rb->Format == MESA_FORMAT_X8_Z24) {
+ radeon_map_renderbuffer_s8z24(ctx, rb, x, y, w, h,
+ mode, out_map, out_stride);
+ return;
+ }
+ if (rb->Format == MESA_FORMAT_Z16) {
+ radeon_map_renderbuffer_z16(ctx, rb, x, y, w, h,
+ mode, out_map, out_stride);
+ return;
+ }
+ }
+
+ ret = radeon_bo_map(rrb->bo, !!(mode & GL_MAP_WRITE_BIT));
+ assert(!ret);
+
+ map = rrb->bo->ptr;
+ stride = rrb->map_pitch;
+
+ if (rb->Name == 0) {
+ y = rb->Height - 1 - y;
+ flip_stride = -stride;
+ } else {
+ flip_stride = stride;
+ map += rrb->draw_offset;
+ }
+
+ map += x * rrb->cpp;
+ map += (int)y * stride;
+
+ *out_map = map;
+ *out_stride = flip_stride;
+}
+
+static void
+radeon_unmap_renderbuffer_s8z24(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+
+ if (!rrb->map_buffer)
+ return;
+
+ if (rrb->map_mode & GL_MAP_WRITE_BIT) {
+ uint32_t *untiled_s8z24_map = rrb->map_buffer;
+ uint32_t *tiled_s8z24_map;
+ int y_flip = (rb->Name == 0) ? -1 : 1;
+ int y_bias = (rb->Name == 0) ? (rb->Height - 1) : 0;
+
+ radeon_bo_map(rrb->bo, 1);
+
+ tiled_s8z24_map = rrb->bo->ptr;
+
+ for (uint32_t pix_y = 0; pix_y < rrb->map_h; pix_y++) {
+ for (uint32_t pix_x = 0; pix_x < rrb->map_w; pix_x++) {
+ uint32_t flipped_y = y_flip * (int32_t)(pix_y + rrb->map_y) + y_bias;
+ uint32_t dst_offset = get_depth_z32(rrb, rrb->map_x + pix_x, flipped_y);
+ uint32_t src_offset = pix_y * rrb->map_pitch + pix_x * rrb->cpp;
+ tiled_s8z24_map[dst_offset/4] = untiled_s8z24_map[src_offset/4];
+ }
+ }
+ radeon_bo_unmap(rrb->bo);
+ }
+ free(rrb->map_buffer);
+ rrb->map_buffer = NULL;
+}
+
+static void
+radeon_unmap_renderbuffer_z16(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+
+ if (!rrb->map_buffer)
+ return;
+
+ if (rrb->map_mode & GL_MAP_WRITE_BIT) {
+ uint16_t *untiled_z16_map = rrb->map_buffer;
+ uint16_t *tiled_z16_map;
+ int y_flip = (rb->Name == 0) ? -1 : 1;
+ int y_bias = (rb->Name == 0) ? (rb->Height - 1) : 0;
+
+ radeon_bo_map(rrb->bo, 1);
+
+ tiled_z16_map = rrb->bo->ptr;
+
+ for (uint32_t pix_y = 0; pix_y < rrb->map_h; pix_y++) {
+ for (uint32_t pix_x = 0; pix_x < rrb->map_w; pix_x++) {
+ uint32_t flipped_y = y_flip * (int32_t)(pix_y + rrb->map_y) + y_bias;
+ uint32_t dst_offset = get_depth_z16(rrb, rrb->map_x + pix_x, flipped_y);
+ uint32_t src_offset = pix_y * rrb->map_pitch + pix_x * rrb->cpp;
+ tiled_z16_map[dst_offset/2] = untiled_z16_map[src_offset/2];
+ }
+ }
+ radeon_bo_unmap(rrb->bo);
+ }
+ free(rrb->map_buffer);
+ rrb->map_buffer = NULL;
+}
+
+
+static void
+radeon_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ GLboolean ok;
+
+ if ((rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_DEPTH_ALWAYS_TILED) && !rrb->has_surface) {
+ if (rb->Format == MESA_FORMAT_S8_Z24 || rb->Format == MESA_FORMAT_X8_Z24) {
+ radeon_unmap_renderbuffer_s8z24(ctx, rb);
+ return;
+ }
+ if (rb->Format == MESA_FORMAT_Z16) {
+ radeon_unmap_renderbuffer_z16(ctx, rb);
+ return;
+ }
+ }
+
+ if (!rrb->map_bo) {
+ if (rrb->bo)
+ radeon_bo_unmap(rrb->bo);
+ return;
+ }
+
+ radeon_bo_unmap(rrb->map_bo);
+
+ if (rrb->map_mode & GL_MAP_WRITE_BIT) {
+ ok = rmesa->vtbl.blit(ctx, rrb->map_bo, 0,
+ rb->Format, rrb->map_pitch / rrb->cpp,
+ rrb->map_w, rrb->map_h,
+ 0, 0,
+ rrb->bo, rrb->draw_offset,
+ rb->Format, rrb->pitch / rrb->cpp,
+ rb->Width, rb->Height,
+ rrb->map_x, rrb->map_y,
+ rrb->map_w, rrb->map_h,
+ GL_FALSE);
+ assert(ok);
+ }
+
+ radeon_bo_unref(rrb->map_bo);
+ rrb->map_bo = NULL;
+}
+
+
+/**
+ * Called via glRenderbufferStorageEXT() to set the format and allocate
+ * storage for a user-created renderbuffer.
+ */
+static GLboolean
+radeon_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width, GLuint height)
+{
+ struct radeon_context *radeon = RADEON_CONTEXT(ctx);
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ uint32_t size, pitch;
+ int cpp;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, rb %p) \n",
+ __func__, ctx, rb);
+
+ ASSERT(rb->Name != 0);
+ switch (internalFormat) {
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ rb->Format = _radeon_texformat_rgb565;
+ cpp = 2;
+ break;
+ case GL_RGB:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ rb->Format = _radeon_texformat_argb8888;
+ cpp = 4;
+ break;
+ case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ rb->Format = _radeon_texformat_argb8888;
+ cpp = 4;
+ break;
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ /* alloc a depth+stencil buffer */
+ rb->Format = MESA_FORMAT_S8_Z24;
+ cpp = 4;
+ break;
+ case GL_DEPTH_COMPONENT16:
+ rb->Format = MESA_FORMAT_Z16;
+ cpp = 2;
+ break;
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ rb->Format = MESA_FORMAT_X8_Z24;
+ cpp = 4;
+ break;
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ rb->Format = MESA_FORMAT_S8_Z24;
+ cpp = 4;
+ break;
+ default:
+ _mesa_problem(ctx,
+ "Unexpected format in radeon_alloc_renderbuffer_storage");
+ return GL_FALSE;
+ }
+
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
+ if (ctx->Driver.Flush)
+ ctx->Driver.Flush(ctx); /* +r6/r7 */
+
+ if (rrb->bo)
+ radeon_bo_unref(rrb->bo);
+
+ pitch = ((cpp * width + 63) & ~63) / cpp;
+
+ if (RADEON_DEBUG & RADEON_MEMORY)
+ fprintf(stderr,"Allocating %d x %d radeon RBO (pitch %d)\n", width,
+ height, pitch);
+
+ size = pitch * height * cpp;
+ rrb->pitch = pitch * cpp;
+ rrb->cpp = cpp;
+ rrb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+ 0,
+ size,
+ 0,
+ RADEON_GEM_DOMAIN_VRAM,
+ 0);
+ rb->Width = width;
+ rb->Height = height;
+ return GL_TRUE;
+}
+
+#if FEATURE_OES_EGL_image
+static void
+radeon_image_target_renderbuffer_storage(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ void *image_handle)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_renderbuffer *rrb;
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = radeon->radeonScreen->driScreen;
+ image = screen->dri2.image->lookupEGLImage(screen, image_handle,
+ screen->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ rrb = radeon_renderbuffer(rb);
+
+ if (ctx->Driver.Flush)
+ ctx->Driver.Flush(ctx); /* +r6/r7 */
+
+ if (rrb->bo)
+ radeon_bo_unref(rrb->bo);
+ rrb->bo = image->bo;
+ radeon_bo_ref(rrb->bo);
+ fprintf(stderr, "image->bo: %p, name: %d, rbs: w %d -> p %d\n", image->bo, image->bo->handle,
+ image->width, image->pitch);
+
+ rrb->cpp = image->cpp;
+ rrb->pitch = image->pitch * image->cpp;
+
+ rb->Format = image->format;
+ rb->InternalFormat = image->internal_format;
+ rb->Width = image->width;
+ rb->Height = image->height;
+ rb->Format = image->format;
+ rb->_BaseFormat = _mesa_base_fbo_format(radeon->glCtx,
+ image->internal_format);
+}
+#endif
+
+/**
+ * Called for each hardware renderbuffer when a _window_ is resized.
+ * Just update fields.
+ * Not used for user-created renderbuffers!
+ */
+static GLboolean
+radeon_alloc_window_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ ASSERT(rb->Name == 0);
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, rb %p) \n",
+ __func__, ctx, rb);
+
+
+ return GL_TRUE;
+}
+
+
+static void
+radeon_resize_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint width, GLuint height)
+{
+ struct radeon_framebuffer *radeon_fb = (struct radeon_framebuffer*)fb;
+ int i;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, fb %p) \n",
+ __func__, ctx, fb);
+
+ _mesa_resize_framebuffer(ctx, fb, width, height);
+
+ fb->Initialized = GL_TRUE; /* XXX remove someday */
+
+ if (fb->Name != 0) {
+ return;
+ }
+
+ /* Make sure all window system renderbuffers are up to date */
+ for (i = 0; i < 2; i++) {
+ struct gl_renderbuffer *rb = &radeon_fb->color_rb[i]->base.Base;
+
+ /* only resize if size is changing */
+ if (rb && (rb->Width != width || rb->Height != height)) {
+ rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
+ }
+ }
+}
+
+
+/** Dummy function for gl_renderbuffer::AllocStorage() */
+static GLboolean
+radeon_nop_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ _mesa_problem(ctx, "radeon_op_alloc_storage should never be called.");
+ return GL_FALSE;
+}
+
+
+/**
+ * Create a renderbuffer for a window's color, depth and/or stencil buffer.
+ * Not used for user-created renderbuffers.
+ */
+struct radeon_renderbuffer *
+radeon_create_renderbuffer(gl_format format, __DRIdrawable *driDrawPriv)
+{
+ struct radeon_renderbuffer *rrb;
+ struct gl_renderbuffer *rb;
+
+ rrb = CALLOC_STRUCT(radeon_renderbuffer);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s( rrb %p ) \n",
+ __func__, rrb);
+
+ if (!rrb)
+ return NULL;
+
+ rb = &rrb->base.Base;
+
+ _mesa_init_renderbuffer(rb, 0);
+ rb->ClassID = RADEON_RB_CLASS;
+ rb->Format = format;
+ rb->_BaseFormat = _mesa_get_format_base_format(format);
+ rb->InternalFormat = _mesa_get_format_base_format(format);
+
+ rrb->dPriv = driDrawPriv;
+
+ rb->Delete = radeon_delete_renderbuffer;
+ rb->AllocStorage = radeon_alloc_window_storage;
+
+ rrb->bo = NULL;
+ return rrb;
+}
+
+static struct gl_renderbuffer *
+radeon_new_renderbuffer(struct gl_context * ctx, GLuint name)
+{
+ struct radeon_renderbuffer *rrb;
+ struct gl_renderbuffer *rb;
+
+
+ rrb = CALLOC_STRUCT(radeon_renderbuffer);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, rrb %p) \n",
+ __func__, ctx, rrb);
+
+ if (!rrb)
+ return NULL;
+
+ rb = &rrb->base.Base;
+
+ _mesa_init_renderbuffer(rb, name);
+ rb->ClassID = RADEON_RB_CLASS;
+ rb->Delete = radeon_delete_renderbuffer;
+ rb->AllocStorage = radeon_alloc_renderbuffer_storage;
+
+ return rb;
+}
+
+static void
+radeon_bind_framebuffer(struct gl_context * ctx, GLenum target,
+ struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
+{
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, fb %p, target %s) \n",
+ __func__, ctx, fb,
+ _mesa_lookup_enum_by_nr(target));
+
+ if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
+ radeon_draw_buffer(ctx, fb);
+ }
+ else {
+ /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
+ }
+}
+
+static void
+radeon_framebuffer_renderbuffer(struct gl_context * ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment, struct gl_renderbuffer *rb)
+{
+
+ if (ctx->Driver.Flush)
+ ctx->Driver.Flush(ctx); /* +r6/r7 */
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, fb %p, rb %p) \n",
+ __func__, ctx, fb, rb);
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ radeon_draw_buffer(ctx, fb);
+}
+
+static GLboolean
+radeon_update_wrapper(struct gl_context *ctx, struct radeon_renderbuffer *rrb,
+ struct gl_texture_image *texImage)
+{
+ struct gl_renderbuffer *rb = &rrb->base.Base;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, rrb %p, texImage %p, texFormat %s) \n",
+ __func__, ctx, rrb, texImage, _mesa_get_format_name(texImage->TexFormat));
+
+ rrb->cpp = _mesa_get_format_bytes(texImage->TexFormat);
+ rrb->pitch = texImage->Width * rrb->cpp;
+ rb->Format = texImage->TexFormat;
+ rb->InternalFormat = texImage->InternalFormat;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, rb->InternalFormat);
+ rb->Width = texImage->Width;
+ rb->Height = texImage->Height;
+ rb->Delete = radeon_delete_renderbuffer;
+ rb->AllocStorage = radeon_nop_alloc_storage;
+
+ return GL_TRUE;
+}
+
+
+static struct radeon_renderbuffer *
+radeon_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage)
+{
+ const GLuint name = ~0; /* not significant, but distinct for debugging */
+ struct radeon_renderbuffer *rrb;
+
+ /* make an radeon_renderbuffer to wrap the texture image */
+ rrb = CALLOC_STRUCT(radeon_renderbuffer);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, rrb %p, texImage %p) \n",
+ __func__, ctx, rrb, texImage);
+
+ if (!rrb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture");
+ return NULL;
+ }
+
+ _mesa_init_renderbuffer(&rrb->base.Base, name);
+ rrb->base.Base.ClassID = RADEON_RB_CLASS;
+
+ if (!radeon_update_wrapper(ctx, rrb, texImage)) {
+ free(rrb);
+ return NULL;
+ }
+
+ return rrb;
+
+}
+static void
+radeon_render_texture(struct gl_context * ctx,
+ struct gl_framebuffer *fb,
+ struct gl_renderbuffer_attachment *att)
+{
+ struct gl_texture_image *newImage
+ = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(att->Renderbuffer);
+ radeon_texture_image *radeon_image;
+ GLuint imageOffset;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, fb %p, rrb %p, att %p)\n",
+ __func__, ctx, fb, rrb, att);
+
+ (void) fb;
+
+ ASSERT(newImage);
+
+ radeon_image = (radeon_texture_image *)newImage;
+
+ if (!radeon_image->mt) {
+ /* Fallback on drawing to a texture without a miptree.
+ */
+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+ else if (!rrb) {
+ rrb = radeon_wrap_texture(ctx, newImage);
+ if (rrb) {
+ /* bind the wrapper to the attachment point */
+ _mesa_reference_renderbuffer(&att->Renderbuffer, &rrb->base.Base);
+ }
+ else {
+ /* fallback to software rendering */
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+ }
+
+ if (!radeon_update_wrapper(ctx, rrb, newImage)) {
+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+ _swrast_render_texture(ctx, fb, att);
+ return;
+ }
+
+ DBG("Begin render texture tid %lx tex=%u w=%d h=%d refcount=%d\n",
+ _glthread_GetID(),
+ att->Texture->Name, newImage->Width, newImage->Height,
+ rrb->base.Base.RefCount);
+
+ /* point the renderbufer's region to the texture image region */
+ if (rrb->bo != radeon_image->mt->bo) {
+ if (rrb->bo)
+ radeon_bo_unref(rrb->bo);
+ rrb->bo = radeon_image->mt->bo;
+ radeon_bo_ref(rrb->bo);
+ }
+
+ /* compute offset of the particular 2D image within the texture region */
+ imageOffset = radeon_miptree_image_offset(radeon_image->mt,
+ att->CubeMapFace,
+ att->TextureLevel);
+
+ if (att->Texture->Target == GL_TEXTURE_3D) {
+ imageOffset += radeon_image->mt->levels[att->TextureLevel].rowstride *
+ radeon_image->mt->levels[att->TextureLevel].height *
+ att->Zoffset;
+ }
+
+ /* store that offset in the region, along with the correct pitch for
+ * the image we are rendering to */
+ rrb->draw_offset = imageOffset;
+ rrb->pitch = radeon_image->mt->levels[att->TextureLevel].rowstride;
+ radeon_image->used_as_render_target = GL_TRUE;
+
+ /* update drawing region, etc */
+ radeon_draw_buffer(ctx, fb);
+}
+
+static void
+radeon_finish_render_texture(struct gl_context * ctx,
+ struct gl_renderbuffer_attachment *att)
+{
+ struct gl_texture_object *tex_obj = att->Texture;
+ struct gl_texture_image *image =
+ tex_obj->Image[att->CubeMapFace][att->TextureLevel];
+ radeon_texture_image *radeon_image = (radeon_texture_image *)image;
+
+ if (radeon_image)
+ radeon_image->used_as_render_target = GL_FALSE;
+
+ if (ctx->Driver.Flush)
+ ctx->Driver.Flush(ctx); /* +r6/r7 */
+}
+static void
+radeon_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ gl_format mesa_format;
+ int i;
+
+ for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) {
+ struct gl_renderbuffer_attachment *att;
+ if (i == -2) {
+ att = &fb->Attachment[BUFFER_DEPTH];
+ } else if (i == -1) {
+ att = &fb->Attachment[BUFFER_STENCIL];
+ } else {
+ att = &fb->Attachment[BUFFER_COLOR0 + i];
+ }
+
+ if (att->Type == GL_TEXTURE) {
+ mesa_format = att->Texture->Image[att->CubeMapFace][att->TextureLevel]->TexFormat;
+ } else {
+ /* All renderbuffer formats are renderable, but not sampable */
+ continue;
+ }
+
+ if (!radeon->vtbl.is_format_renderable(mesa_format)){
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED;
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s: HW doesn't support format %s as output format of attachment %d\n",
+ __FUNCTION__, _mesa_get_format_name(mesa_format), i);
+ return;
+ }
+ }
+}
+
+void radeon_fbo_init(struct radeon_context *radeon)
+{
+#if FEATURE_EXT_framebuffer_object
+ radeon->glCtx->Driver.NewFramebuffer = radeon_new_framebuffer;
+ radeon->glCtx->Driver.NewRenderbuffer = radeon_new_renderbuffer;
+ radeon->glCtx->Driver.MapRenderbuffer = radeon_map_renderbuffer;
+ radeon->glCtx->Driver.UnmapRenderbuffer = radeon_unmap_renderbuffer;
+ radeon->glCtx->Driver.BindFramebuffer = radeon_bind_framebuffer;
+ radeon->glCtx->Driver.FramebufferRenderbuffer = radeon_framebuffer_renderbuffer;
+ radeon->glCtx->Driver.RenderTexture = radeon_render_texture;
+ radeon->glCtx->Driver.FinishRenderTexture = radeon_finish_render_texture;
+ radeon->glCtx->Driver.ResizeBuffers = radeon_resize_buffers;
+ radeon->glCtx->Driver.ValidateFramebuffer = radeon_validate_framebuffer;
+#endif
+#if FEATURE_EXT_framebuffer_blit
+ radeon->glCtx->Driver.BlitFramebuffer = _mesa_meta_BlitFramebuffer;
+#endif
+#if FEATURE_OES_EGL_image
+ radeon->glCtx->Driver.EGLImageTargetRenderbufferStorage =
+ radeon_image_target_renderbuffer_storage;
+#endif
+}
+
+
+void radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
+ struct radeon_bo *bo)
+{
+ struct radeon_bo *old;
+ old = rb->bo;
+ rb->bo = bo;
+ radeon_bo_ref(bo);
+ if (old)
+ radeon_bo_unref(old);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.c
index 231aa4ffcb3..bd2642b1304 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.c
@@ -1 +1,125 @@
-../radeon/radeon_fog.c \ No newline at end of file
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc., Austin, Texas.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/macros.h"
+
+#include "radeon_fog.h"
+
+/**********************************************************************/
+/* Fog blend factor computation for hw tcl */
+/* same calculation used as in t_vb_fog.c */
+/**********************************************************************/
+
+#define FOG_EXP_TABLE_SIZE 256
+#define FOG_MAX (10.0)
+#define EXP_FOG_MAX .0006595
+#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
+static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
+
+#if 1
+#define NEG_EXP( result, narg ) \
+do { \
+ GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR)); \
+ GLint k = (GLint) f; \
+ if (k > FOG_EXP_TABLE_SIZE-2) \
+ result = (GLfloat) EXP_FOG_MAX; \
+ else \
+ result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \
+} while (0)
+#else
+#define NEG_EXP( result, narg ) \
+do { \
+ result = exp(-narg); \
+} while (0)
+#endif
+
+
+/**
+ * Initialize the exp_table[] lookup table for approximating exp().
+ */
+void
+radeonInitStaticFogData( void )
+{
+ GLfloat f = 0.0F;
+ GLint i = 0;
+ for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
+ exp_table[i] = (GLfloat) exp(-f);
+ }
+}
+
+/**
+ * Compute per-vertex fog blend factors from fog coordinates by
+ * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
+ * Fog coordinates are distances from the eye (typically between the
+ * near and far clip plane distances).
+ * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
+ * Fog blend factors are in the range [0,1].
+ */
+float
+radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord )
+{
+ GLfloat end = ctx->Fog.End;
+ GLfloat d, temp;
+ const GLfloat z = FABSF(fogcoord);
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ if (ctx->Fog.Start == ctx->Fog.End)
+ d = 1.0F;
+ else
+ d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ temp = (end - z) * d;
+ return CLAMP(temp, 0.0F, 1.0F);
+ break;
+ case GL_EXP:
+ d = ctx->Fog.Density;
+ NEG_EXP( temp, d * z );
+ return temp;
+ break;
+ case GL_EXP2:
+ d = ctx->Fog.Density*ctx->Fog.Density;
+ NEG_EXP( temp, d * z * z );
+ return temp;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
+ return 0;
+ }
+}
+
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.h
index 76c40f621f3..0c3b8d5166b 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_fog.h
@@ -1 +1,44 @@
-../radeon/radeon_fog.h \ No newline at end of file
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc., Austin, Texas.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef RADEON_FOG_H
+#define RADEON_FOG_H
+
+void
+radeonInitStaticFogData( void );
+
+float
+radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord );
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.c
index 31c0cfbe942..f4fb3a55a5d 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.c
@@ -1 +1,610 @@
-../radeon/radeon_mipmap_tree.c \ No newline at end of file
+/*
+ * Copyright (C) 2009 Maciej Cencora.
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_mipmap_tree.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "main/simple_list.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
+#include "main/enums.h"
+#include "radeon_texture.h"
+#include "radeon_tile.h"
+
+static unsigned get_aligned_compressed_row_stride(
+ gl_format format,
+ unsigned width,
+ unsigned minStride)
+{
+ const unsigned blockBytes = _mesa_get_format_bytes(format);
+ unsigned blockWidth, blockHeight;
+ unsigned stride;
+
+ _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
+
+ /* Count number of blocks required to store the given width.
+ * And then multiple it with bytes required to store a block.
+ */
+ stride = (width + blockWidth - 1) / blockWidth * blockBytes;
+
+ /* Round the given minimum stride to the next full blocksize.
+ * (minStride + blockBytes - 1) / blockBytes * blockBytes
+ */
+ if ( stride < minStride )
+ stride = (minStride + blockBytes - 1) / blockBytes * blockBytes;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s width %u, minStride %u, block(bytes %u, width %u):"
+ "stride %u\n",
+ __func__, width, minStride,
+ blockBytes, blockWidth,
+ stride);
+
+ return stride;
+}
+
+unsigned get_texture_image_size(
+ gl_format format,
+ unsigned rowStride,
+ unsigned height,
+ unsigned depth,
+ unsigned tiling)
+{
+ if (_mesa_is_format_compressed(format)) {
+ unsigned blockWidth, blockHeight;
+
+ _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
+
+ return rowStride * ((height + blockHeight - 1) / blockHeight) * depth;
+ } else if (tiling) {
+ /* Need to align height to tile height */
+ unsigned tileWidth, tileHeight;
+
+ get_tile_size(format, &tileWidth, &tileHeight);
+ tileHeight--;
+
+ height = (height + tileHeight) & ~tileHeight;
+ }
+
+ return rowStride * height * depth;
+}
+
+unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width, unsigned tiling, GLuint target)
+{
+ if (_mesa_is_format_compressed(format)) {
+ return get_aligned_compressed_row_stride(format, width, rmesa->texture_compressed_row_align);
+ } else {
+ unsigned row_align;
+
+ if (!_mesa_is_pow_two(width) || target == GL_TEXTURE_RECTANGLE) {
+ row_align = rmesa->texture_rect_row_align - 1;
+ } else if (tiling) {
+ unsigned tileWidth, tileHeight;
+ get_tile_size(format, &tileWidth, &tileHeight);
+ row_align = tileWidth * _mesa_get_format_bytes(format) - 1;
+ } else {
+ row_align = rmesa->texture_row_align - 1;
+ }
+
+ return (_mesa_format_row_stride(format, width) + row_align) & ~row_align;
+ }
+}
+
+/**
+ * Compute sizes and fill in offset and blit information for the given
+ * image (determined by \p face and \p level).
+ *
+ * \param curOffset points to the offset at which the image is to be stored
+ * and is updated by this function according to the size of the image.
+ */
+static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree *mt,
+ GLuint face, GLuint level, GLuint* curOffset)
+{
+ radeon_mipmap_level *lvl = &mt->levels[level];
+ GLuint height;
+
+ height = _mesa_next_pow_two_32(lvl->height);
+
+ lvl->rowstride = get_texture_image_row_stride(rmesa, mt->mesaFormat, lvl->width, mt->tilebits, mt->target);
+ lvl->size = get_texture_image_size(mt->mesaFormat, lvl->rowstride, height, lvl->depth, mt->tilebits);
+
+ assert(lvl->size > 0);
+
+ lvl->faces[face].offset = *curOffset;
+ *curOffset += lvl->size;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p) level %d, face %d: rs:%d %dx%d at %d\n",
+ __func__, rmesa,
+ level, face,
+ lvl->rowstride, lvl->width, height, lvl->faces[face].offset);
+}
+
+static GLuint minify(GLuint size, GLuint levels)
+{
+ size = size >> levels;
+ if (size < 1)
+ size = 1;
+ return size;
+}
+
+
+static void calculate_miptree_layout(radeonContextPtr rmesa, radeon_mipmap_tree *mt)
+{
+ GLuint curOffset, i, face, level;
+
+ assert(mt->numLevels <= rmesa->glCtx->Const.MaxTextureLevels);
+
+ curOffset = 0;
+ for(face = 0; face < mt->faces; face++) {
+
+ for(i = 0, level = mt->baseLevel; i < mt->numLevels; i++, level++) {
+ mt->levels[level].valid = 1;
+ mt->levels[level].width = minify(mt->width0, i);
+ mt->levels[level].height = minify(mt->height0, i);
+ mt->levels[level].depth = minify(mt->depth0, i);
+ compute_tex_image_offset(rmesa, mt, face, level, &curOffset);
+ }
+ }
+
+ /* Note the required size in memory */
+ mt->totalsize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p, %p) total size %d\n",
+ __func__, rmesa, mt, mt->totalsize);
+}
+
+/**
+ * Create a new mipmap tree, calculate its layout and allocate memory.
+ */
+radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa,
+ GLenum target, gl_format mesaFormat, GLuint baseLevel, GLuint numLevels,
+ GLuint width0, GLuint height0, GLuint depth0, GLuint tilebits)
+{
+ radeon_mipmap_tree *mt = CALLOC_STRUCT(_radeon_mipmap_tree);
+
+ radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
+ "%s(%p) new tree is %p.\n",
+ __func__, rmesa, mt);
+
+ mt->mesaFormat = mesaFormat;
+ mt->refcount = 1;
+ mt->target = target;
+ mt->faces = _mesa_num_tex_faces(target);
+ mt->baseLevel = baseLevel;
+ mt->numLevels = numLevels;
+ mt->width0 = width0;
+ mt->height0 = height0;
+ mt->depth0 = depth0;
+ mt->tilebits = tilebits;
+
+ calculate_miptree_layout(rmesa, mt);
+
+ mt->bo = radeon_bo_open(rmesa->radeonScreen->bom,
+ 0, mt->totalsize, 1024,
+ RADEON_GEM_DOMAIN_VRAM,
+ 0);
+
+ return mt;
+}
+
+void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr)
+{
+ assert(!*ptr);
+
+ mt->refcount++;
+ assert(mt->refcount > 0);
+
+ *ptr = mt;
+}
+
+void radeon_miptree_unreference(radeon_mipmap_tree **ptr)
+{
+ radeon_mipmap_tree *mt = *ptr;
+ if (!mt)
+ return;
+
+ assert(mt->refcount > 0);
+
+ mt->refcount--;
+ if (!mt->refcount) {
+ radeon_bo_unref(mt->bo);
+ free(mt);
+ }
+
+ *ptr = 0;
+}
+
+/**
+ * Calculate min and max LOD for the given texture object.
+ * @param[in] tObj texture object whose LOD values to calculate
+ * @param[out] pminLod minimal LOD
+ * @param[out] pmaxLod maximal LOD
+ */
+static void calculate_min_max_lod(struct gl_sampler_object *samp, struct gl_texture_object *tObj,
+ unsigned *pminLod, unsigned *pmaxLod)
+{
+ int minLod, maxLod;
+ /* Yes, this looks overly complicated, but it's all needed.
+ */
+ switch (tObj->Target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ if (samp->MinFilter == GL_NEAREST || samp->MinFilter == GL_LINEAR) {
+ /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
+ */
+ minLod = maxLod = tObj->BaseLevel;
+ } else {
+ minLod = tObj->BaseLevel + (GLint)(samp->MinLod);
+ minLod = MAX2(minLod, tObj->BaseLevel);
+ minLod = MIN2(minLod, tObj->MaxLevel);
+ maxLod = tObj->BaseLevel + (GLint)(samp->MaxLod + 0.5);
+ maxLod = MIN2(maxLod, tObj->MaxLevel);
+ maxLod = MIN2(maxLod, tObj->Image[0][minLod]->MaxNumLevels - 1 + minLod);
+ maxLod = MAX2(maxLod, minLod); /* need at least one level */
+ }
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_TEXTURE_4D_SGIS:
+ minLod = maxLod = 0;
+ break;
+ default:
+ return;
+ }
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s(%p) target %s, min %d, max %d.\n",
+ __func__, tObj,
+ _mesa_lookup_enum_by_nr(tObj->Target),
+ minLod, maxLod);
+
+ /* save these values */
+ *pminLod = minLod;
+ *pmaxLod = maxLod;
+}
+
+/**
+ * Checks whether the given miptree can hold the given texture image at the
+ * given face and level.
+ */
+GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
+ struct gl_texture_image *texImage)
+{
+ radeon_mipmap_level *lvl;
+ GLuint level = texImage->Level;
+ if (texImage->TexFormat != mt->mesaFormat)
+ return GL_FALSE;
+
+ lvl = &mt->levels[level];
+ if (!lvl->valid ||
+ lvl->width != texImage->Width ||
+ lvl->height != texImage->Height ||
+ lvl->depth != texImage->Depth)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+/**
+ * Checks whether the given miptree has the right format to store the given texture object.
+ */
+static GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_texture_object *texObj)
+{
+ struct gl_texture_image *firstImage;
+ unsigned numLevels;
+ radeon_mipmap_level *mtBaseLevel;
+
+ if (texObj->BaseLevel < mt->baseLevel)
+ return GL_FALSE;
+
+ mtBaseLevel = &mt->levels[texObj->BaseLevel - mt->baseLevel];
+ firstImage = texObj->Image[0][texObj->BaseLevel];
+ numLevels = MIN2(texObj->_MaxLevel - texObj->BaseLevel + 1, firstImage->MaxNumLevels);
+
+ if (radeon_is_debug_enabled(RADEON_TEXTURE,RADEON_TRACE)) {
+ fprintf(stderr, "Checking if miptree %p matches texObj %p\n", mt, texObj);
+ fprintf(stderr, "target %d vs %d\n", mt->target, texObj->Target);
+ fprintf(stderr, "format %d vs %d\n", mt->mesaFormat, firstImage->TexFormat);
+ fprintf(stderr, "numLevels %d vs %d\n", mt->numLevels, numLevels);
+ fprintf(stderr, "width0 %d vs %d\n", mtBaseLevel->width, firstImage->Width);
+ fprintf(stderr, "height0 %d vs %d\n", mtBaseLevel->height, firstImage->Height);
+ fprintf(stderr, "depth0 %d vs %d\n", mtBaseLevel->depth, firstImage->Depth);
+ if (mt->target == texObj->Target &&
+ mt->mesaFormat == firstImage->TexFormat &&
+ mt->numLevels >= numLevels &&
+ mtBaseLevel->width == firstImage->Width &&
+ mtBaseLevel->height == firstImage->Height &&
+ mtBaseLevel->depth == firstImage->Depth) {
+ fprintf(stderr, "MATCHED\n");
+ } else {
+ fprintf(stderr, "NOT MATCHED\n");
+ }
+ }
+
+ return (mt->target == texObj->Target &&
+ mt->mesaFormat == firstImage->TexFormat &&
+ mt->numLevels >= numLevels &&
+ mtBaseLevel->width == firstImage->Width &&
+ mtBaseLevel->height == firstImage->Height &&
+ mtBaseLevel->depth == firstImage->Depth);
+}
+
+/**
+ * Try to allocate a mipmap tree for the given texture object.
+ * @param[in] rmesa radeon context
+ * @param[in] t radeon texture object
+ */
+void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t)
+{
+ struct gl_texture_object *texObj = &t->base;
+ struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel];
+ GLuint numLevels;
+ assert(!t->mt);
+
+ if (!texImg) {
+ radeon_warning("%s(%p) No image in given texture object(%p).\n",
+ __func__, rmesa, t);
+ return;
+ }
+
+
+ numLevels = MIN2(texObj->MaxLevel - texObj->BaseLevel + 1, texImg->MaxNumLevels);
+
+ t->mt = radeon_miptree_create(rmesa, t->base.Target,
+ texImg->TexFormat, texObj->BaseLevel,
+ numLevels, texImg->Width, texImg->Height,
+ texImg->Depth, t->tile_bits);
+}
+
+GLuint
+radeon_miptree_image_offset(radeon_mipmap_tree *mt,
+ GLuint face, GLuint level)
+{
+ if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
+ return (mt->levels[level].faces[face].offset);
+ else
+ return mt->levels[level].faces[0].offset;
+}
+
+/**
+ * Ensure that the given image is stored in the given miptree from now on.
+ */
+static void migrate_image_to_miptree(radeon_mipmap_tree *mt,
+ radeon_texture_image *image,
+ int face, int level)
+{
+ radeon_mipmap_level *dstlvl = &mt->levels[level];
+ unsigned char *dest;
+
+ assert(image->mt != mt);
+ assert(dstlvl->valid);
+ assert(dstlvl->width == image->base.Base.Width);
+ assert(dstlvl->height == image->base.Base.Height);
+ assert(dstlvl->depth == image->base.Base.Depth);
+
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
+ "%s miptree %p, image %p, face %d, level %d.\n",
+ __func__, mt, image, face, level);
+
+ radeon_bo_map(mt->bo, GL_TRUE);
+ dest = mt->bo->ptr + dstlvl->faces[face].offset;
+
+ if (image->mt) {
+ /* Format etc. should match, so we really just need a memcpy().
+ * In fact, that memcpy() could be done by the hardware in many
+ * cases, provided that we have a proper memory manager.
+ */
+ assert(mt->mesaFormat == image->base.Base.TexFormat);
+
+ radeon_mipmap_level *srclvl = &image->mt->levels[image->base.Base.Level];
+
+ assert(image->base.Base.Level == level);
+ assert(srclvl->size == dstlvl->size);
+ assert(srclvl->rowstride == dstlvl->rowstride);
+
+ radeon_bo_map(image->mt->bo, GL_FALSE);
+
+ memcpy(dest,
+ image->mt->bo->ptr + srclvl->faces[face].offset,
+ dstlvl->size);
+ radeon_bo_unmap(image->mt->bo);
+
+ radeon_miptree_unreference(&image->mt);
+ } else if (image->base.Map) {
+ /* This condition should be removed, it's here to workaround
+ * a segfault when mapping textures during software fallbacks.
+ */
+ radeon_print(RADEON_FALLBACKS, RADEON_IMPORTANT,
+ "%s Trying to map texture in software fallback.\n",
+ __func__);
+ const uint32_t srcrowstride = _mesa_format_row_stride(image->base.Base.TexFormat, image->base.Base.Width);
+ uint32_t rows = image->base.Base.Height * image->base.Base.Depth;
+
+ if (_mesa_is_format_compressed(image->base.Base.TexFormat)) {
+ uint32_t blockWidth, blockHeight;
+ _mesa_get_format_block_size(image->base.Base.TexFormat, &blockWidth, &blockHeight);
+ rows = (rows + blockHeight - 1) / blockHeight;
+ }
+
+ copy_rows(dest, dstlvl->rowstride, image->base.Map, srcrowstride,
+ rows, srcrowstride);
+
+ _mesa_align_free(image->base.Map);
+ image->base.Map = 0;
+ }
+
+ radeon_bo_unmap(mt->bo);
+
+ radeon_miptree_reference(mt, &image->mt);
+}
+
+/**
+ * Filter matching miptrees, and select one with the most of data.
+ * @param[in] texObj radeon texture object
+ * @param[in] firstLevel first texture level to check
+ * @param[in] lastLevel last texture level to check
+ */
+static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
+ unsigned firstLevel,
+ unsigned lastLevel)
+{
+ const unsigned numLevels = lastLevel - firstLevel + 1;
+ unsigned *mtSizes = calloc(numLevels, sizeof(unsigned));
+ radeon_mipmap_tree **mts = calloc(numLevels, sizeof(radeon_mipmap_tree *));
+ unsigned mtCount = 0;
+ unsigned maxMtIndex = 0;
+ radeon_mipmap_tree *tmp;
+ unsigned int level;
+ int i;
+
+ for (level = firstLevel; level <= lastLevel; ++level) {
+ radeon_texture_image *img = get_radeon_texture_image(texObj->base.Image[0][level]);
+ unsigned found = 0;
+ // TODO: why this hack??
+ if (!img)
+ break;
+
+ if (!img->mt)
+ continue;
+
+ for (i = 0; i < mtCount; ++i) {
+ if (mts[i] == img->mt) {
+ found = 1;
+ mtSizes[i] += img->mt->levels[img->base.Base.Level].size;
+ break;
+ }
+ }
+
+ if (!found && radeon_miptree_matches_texture(img->mt, &texObj->base)) {
+ mtSizes[mtCount] = img->mt->levels[img->base.Base.Level].size;
+ mts[mtCount] = img->mt;
+ mtCount++;
+ }
+ }
+
+ if (mtCount == 0) {
+ free(mtSizes);
+ free(mts);
+ return NULL;
+ }
+
+ for (i = 1; i < mtCount; ++i) {
+ if (mtSizes[i] > mtSizes[maxMtIndex]) {
+ maxMtIndex = i;
+ }
+ }
+
+ tmp = mts[maxMtIndex];
+ free(mtSizes);
+ free(mts);
+
+ return tmp;
+}
+
+/**
+ * Validate texture mipmap tree.
+ * If individual images are stored in different mipmap trees
+ * use the mipmap tree that has the most of the correct data.
+ */
+int radeon_validate_texture_miptree(struct gl_context * ctx,
+ struct gl_sampler_object *samp,
+ struct gl_texture_object *texObj)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeonTexObj *t = radeon_tex_obj(texObj);
+ radeon_mipmap_tree *dst_miptree;
+
+ if (samp == &texObj->Sampler && (t->validated || t->image_override)) {
+ return GL_TRUE;
+ }
+
+ calculate_min_max_lod(samp, &t->base, &t->minLod, &t->maxLod);
+
+ radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
+ "%s: Validating texture %p now, minLod = %d, maxLod = %d\n",
+ __FUNCTION__, texObj ,t->minLod, t->maxLod);
+
+ dst_miptree = get_biggest_matching_miptree(t, t->base.BaseLevel, t->base._MaxLevel);
+
+ radeon_miptree_unreference(&t->mt);
+ if (!dst_miptree) {
+ radeon_try_alloc_miptree(rmesa, t);
+ radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
+ "%s: No matching miptree found, allocated new one %p\n",
+ __FUNCTION__, t->mt);
+
+ } else {
+ radeon_miptree_reference(dst_miptree, &t->mt);
+ radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
+ "%s: Using miptree %p\n", __FUNCTION__, t->mt);
+ }
+
+ const unsigned faces = _mesa_num_tex_faces(texObj->Target);
+ unsigned face, level;
+ radeon_texture_image *img;
+ /* Validate only the levels that will actually be used during rendering */
+ for (face = 0; face < faces; ++face) {
+ for (level = t->minLod; level <= t->maxLod; ++level) {
+ img = get_radeon_texture_image(texObj->Image[face][level]);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "Checking image level %d, face %d, mt %p ... ",
+ level, face, img->mt);
+
+ if (img->mt != t->mt && !img->used_as_render_target) {
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "MIGRATING\n");
+
+ struct radeon_bo *src_bo = (img->mt) ? img->mt->bo : img->bo;
+ if (src_bo && radeon_bo_is_referenced_by_cs(src_bo, rmesa->cmdbuf.cs)) {
+ radeon_firevertices(rmesa);
+ }
+ migrate_image_to_miptree(t->mt, img, face, level);
+ } else
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE, "OK\n");
+ }
+ }
+
+ t->validated = GL_TRUE;
+
+ return GL_TRUE;
+}
+
+uint32_t get_base_teximage_offset(radeonTexObj *texObj)
+{
+ if (!texObj->mt) {
+ return 0;
+ } else {
+ return radeon_miptree_image_offset(texObj->mt, 0, texObj->minLod);
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.h
index 254d50cf8c5..74007ffdebc 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_mipmap_tree.h
@@ -1 +1,106 @@
-../radeon/radeon_mipmap_tree.h \ No newline at end of file
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __RADEON_MIPMAP_TREE_H_
+#define __RADEON_MIPMAP_TREE_H_
+
+#include "radeon_common.h"
+
+typedef struct _radeon_mipmap_tree radeon_mipmap_tree;
+typedef struct _radeon_mipmap_level radeon_mipmap_level;
+typedef struct _radeon_mipmap_image radeon_mipmap_image;
+
+struct _radeon_mipmap_image {
+ GLuint offset; /** Offset of this image from the start of mipmap tree buffer, in bytes */
+};
+
+struct _radeon_mipmap_level {
+ GLuint width;
+ GLuint height;
+ GLuint depth;
+ GLuint size; /** Size of each image, in bytes */
+ GLuint rowstride; /** in bytes */
+ GLuint valid;
+ radeon_mipmap_image faces[6];
+};
+
+/* store the max possible in the miptree */
+#define RADEON_MIPTREE_MAX_TEXTURE_LEVELS 15
+
+/**
+ * A mipmap tree contains texture images in the layout that the hardware
+ * expects.
+ *
+ * The meta-data of mipmap trees is immutable, i.e. you cannot change the
+ * layout on-the-fly; however, the texture contents (i.e. texels) can be
+ * changed.
+ */
+struct _radeon_mipmap_tree {
+ struct radeon_bo *bo;
+ GLuint refcount;
+
+ GLuint totalsize; /** total size of the miptree, in bytes */
+
+ GLenum target; /** GL_TEXTURE_xxx */
+ GLenum mesaFormat; /** MESA_FORMAT_xxx */
+ GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */
+ GLuint baseLevel; /** gl_texture_object->baseLevel it was created for */
+ GLuint numLevels; /** Number of mip levels stored in this mipmap tree */
+
+ GLuint width0; /** Width of baseLevel image */
+ GLuint height0; /** Height of baseLevel image */
+ GLuint depth0; /** Depth of baseLevel image */
+
+ GLuint tilebits; /** RADEON_TXO_xxx_TILE */
+
+ radeon_mipmap_level levels[RADEON_MIPTREE_MAX_TEXTURE_LEVELS];
+};
+
+void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr);
+void radeon_miptree_unreference(radeon_mipmap_tree **ptr);
+
+GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
+ struct gl_texture_image *texImage);
+
+void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t);
+GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
+ GLuint face, GLuint level);
+uint32_t get_base_teximage_offset(radeonTexObj *texObj);
+
+unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width, unsigned tiling, unsigned target);
+
+unsigned get_texture_image_size(
+ gl_format format,
+ unsigned rowStride,
+ unsigned height,
+ unsigned depth,
+ unsigned tiling);
+
+radeon_mipmap_tree *radeon_miptree_create(radeonContextPtr rmesa,
+ GLenum target, gl_format mesaFormat, GLuint baseLevel, GLuint numLevels,
+ GLuint width0, GLuint height0, GLuint depth0, GLuint tilebits);
+#endif /* __RADEON_MIPMAP_TREE_H_ */
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_pixel_read.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_pixel_read.c
index 3b03803126f..db5e01da49b 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_pixel_read.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_pixel_read.c
@@ -1 +1,221 @@
-../radeon/radeon_pixel_read.c \ No newline at end of file
+/*
+ * Copyright (C) 2010 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "stdint.h"
+#include "main/bufferobj.h"
+#include "main/enums.h"
+#include "main/fbobject.h"
+#include "main/image.h"
+#include "main/readpix.h"
+#include "main/state.h"
+
+#include "radeon_buffer_objects.h"
+#include "radeon_common_context.h"
+#include "radeon_debug.h"
+#include "radeon_mipmap_tree.h"
+
+static gl_format gl_format_and_type_to_mesa_format(GLenum format, GLenum type)
+{
+ switch (format)
+ {
+ case GL_RGB:
+ switch (type) {
+ case GL_UNSIGNED_SHORT_5_6_5:
+ return MESA_FORMAT_RGB565;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return MESA_FORMAT_RGB565_REV;
+ }
+ break;
+ case GL_RGBA:
+ switch (type) {
+ case GL_FLOAT:
+ return MESA_FORMAT_RGBA_FLOAT32;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ return MESA_FORMAT_RGBA5551;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ return MESA_FORMAT_RGBA8888;
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ return MESA_FORMAT_RGBA8888_REV;
+ }
+ break;
+ case GL_BGRA:
+ switch (type) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ return MESA_FORMAT_ARGB4444_REV;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return MESA_FORMAT_ARGB4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ return MESA_FORMAT_ARGB1555_REV;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return MESA_FORMAT_ARGB1555;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ return MESA_FORMAT_ARGB8888_REV;
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ return MESA_FORMAT_ARGB8888;
+
+ }
+ break;
+ }
+
+ return MESA_FORMAT_NONE;
+}
+
+static GLboolean
+do_blit_readpixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ const struct radeon_renderbuffer *rrb = radeon_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
+ const gl_format dst_format = gl_format_and_type_to_mesa_format(format, type);
+ unsigned dst_rowstride, dst_imagesize, aligned_rowstride, flip_y;
+ struct radeon_bo *dst_buffer;
+ GLint dst_x = 0, dst_y = 0;
+ intptr_t dst_offset;
+
+ /* It's not worth if number of pixels to copy is really small */
+ if (width * height < 100) {
+ return GL_FALSE;
+ }
+
+ if (dst_format == MESA_FORMAT_NONE ||
+ !radeon->vtbl.check_blit(dst_format, rrb->pitch / rrb->cpp) || !radeon->vtbl.blit) {
+ return GL_FALSE;
+ }
+
+ if (ctx->_ImageTransferState || ctx->Color.ColorLogicOpEnabled) {
+ return GL_FALSE;
+ }
+
+ if (pack->SwapBytes || pack->LsbFirst) {
+ return GL_FALSE;
+ }
+
+ if (pack->RowLength > 0) {
+ dst_rowstride = pack->RowLength;
+ } else {
+ dst_rowstride = width;
+ }
+
+ if (!_mesa_clip_copytexsubimage(ctx, &dst_x, &dst_y, &x, &y, &width, &height)) {
+ return GL_TRUE;
+ }
+ assert(x >= 0 && y >= 0);
+
+ aligned_rowstride = get_texture_image_row_stride(radeon, dst_format, dst_rowstride, 0, GL_TEXTURE_2D);
+ dst_rowstride *= _mesa_get_format_bytes(dst_format);
+ if (_mesa_is_bufferobj(pack->BufferObj) && aligned_rowstride != dst_rowstride)
+ return GL_FALSE;
+ dst_imagesize = get_texture_image_size(dst_format,
+ aligned_rowstride,
+ height, 1, 0);
+
+ if (!_mesa_is_bufferobj(pack->BufferObj))
+ {
+ dst_buffer = radeon_bo_open(radeon->radeonScreen->bom, 0, dst_imagesize, 1024, RADEON_GEM_DOMAIN_GTT, 0);
+ dst_offset = 0;
+ }
+ else
+ {
+ dst_buffer = get_radeon_buffer_object(pack->BufferObj)->bo;
+ dst_offset = (intptr_t)pixels;
+ }
+
+ /* Disable source Y flipping for FBOs */
+ flip_y = _mesa_is_winsys_fbo(ctx->ReadBuffer);
+ if (pack->Invert) {
+ y = rrb->base.Base.Height - height - y;
+ flip_y = !flip_y;
+ }
+
+ if (radeon->vtbl.blit(ctx,
+ rrb->bo,
+ rrb->draw_offset,
+ rrb->base.Base.Format,
+ rrb->pitch / rrb->cpp,
+ rrb->base.Base.Width,
+ rrb->base.Base.Height,
+ x,
+ y,
+ dst_buffer,
+ dst_offset,
+ dst_format,
+ aligned_rowstride / _mesa_get_format_bytes(dst_format),
+ width,
+ height,
+ 0, /* dst_x */
+ 0, /* dst_y */
+ width,
+ height,
+ flip_y))
+ {
+ if (!_mesa_is_bufferobj(pack->BufferObj))
+ {
+ radeon_bo_map(dst_buffer, 0);
+ copy_rows(pixels, dst_rowstride, dst_buffer->ptr,
+ aligned_rowstride, height, dst_rowstride);
+ radeon_bo_unmap(dst_buffer);
+ radeon_bo_unref(dst_buffer);
+ }
+
+ return GL_TRUE;
+ }
+
+ if (!_mesa_is_bufferobj(pack->BufferObj))
+ radeon_bo_unref(dst_buffer);
+
+ return GL_FALSE;
+}
+
+void
+radeonReadPixels(struct gl_context * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ radeon_prepare_render(radeon);
+
+ if (do_blit_readpixels(ctx, x, y, width, height, format, type, pack, pixels))
+ return;
+
+ /* Update Mesa state before calling _mesa_readpixels().
+ * XXX this may not be needed since ReadPixels no longer uses the
+ * span code.
+ */
+ radeon_print(RADEON_FALLBACKS, RADEON_NORMAL,
+ "Falling back to sw for ReadPixels (format %s, type %s)\n",
+ _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(type));
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ _mesa_readpixels(ctx, x, y, width, height, format, type, pack, pixels);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.c
index 1d6ebc1c48b..5c02f5c2ed0 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.c
@@ -1 +1,217 @@
-../radeon/radeon_queryobj.c \ No newline at end of file
+/*
+ * Copyright © 2008-2009 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Maciej Cencora <m.cencora@gmail.com>
+ *
+ */
+#include "radeon_common.h"
+#include "radeon_queryobj.h"
+#include "radeon_debug.h"
+
+#include "main/imports.h"
+#include "main/simple_list.h"
+
+#include <inttypes.h>
+
+static void radeonQueryGetResult(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct radeon_query_object *query = (struct radeon_query_object *)q;
+ uint32_t *result;
+ int i;
+
+ radeon_print(RADEON_STATE, RADEON_VERBOSE,
+ "%s: query id %d, result %d\n",
+ __FUNCTION__, query->Base.Id, (int) query->Base.Result);
+
+ radeon_bo_map(query->bo, GL_FALSE);
+ result = query->bo->ptr;
+
+ query->Base.Result = 0;
+ for (i = 0; i < query->curr_offset/sizeof(uint32_t); ++i) {
+ query->Base.Result += LE32_TO_CPU(result[i]);
+ radeon_print(RADEON_STATE, RADEON_TRACE, "result[%d] = %d\n", i, LE32_TO_CPU(result[i]));
+ }
+
+ radeon_bo_unmap(query->bo);
+}
+
+static struct gl_query_object * radeonNewQueryObject(struct gl_context *ctx, GLuint id)
+{
+ struct radeon_query_object *query;
+
+ query = calloc(1, sizeof(struct radeon_query_object));
+
+ query->Base.Id = id;
+ query->Base.Result = 0;
+ query->Base.Active = GL_FALSE;
+ query->Base.Ready = GL_TRUE;
+
+ radeon_print(RADEON_STATE, RADEON_VERBOSE,"%s: query id %d\n", __FUNCTION__, query->Base.Id);
+
+ return &query->Base;
+}
+
+static void radeonDeleteQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct radeon_query_object *query = (struct radeon_query_object *)q;
+
+ radeon_print(RADEON_STATE, RADEON_NORMAL, "%s: query id %d\n", __FUNCTION__, q->Id);
+
+ if (query->bo) {
+ radeon_bo_unref(query->bo);
+ }
+
+ free(query);
+}
+
+static void radeonWaitQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_query_object *query = (struct radeon_query_object *)q;
+
+ /* If the cmdbuf with packets for this query hasn't been flushed yet, do it now */
+ if (radeon_bo_is_referenced_by_cs(query->bo, radeon->cmdbuf.cs))
+ ctx->Driver.Flush(ctx);
+
+ radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s: query id %d, bo %p, offset %d\n", __FUNCTION__, q->Id, query->bo, query->curr_offset);
+
+ radeonQueryGetResult(ctx, q);
+
+ query->Base.Ready = GL_TRUE;
+}
+
+
+static void radeonBeginQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_query_object *query = (struct radeon_query_object *)q;
+
+ radeon_print(RADEON_STATE, RADEON_NORMAL, "%s: query id %d\n", __FUNCTION__, q->Id);
+
+ assert(radeon->query.current == NULL);
+
+ if (radeon->dma.flush)
+ radeon->dma.flush(radeon->glCtx);
+
+ if (!query->bo) {
+ query->bo = radeon_bo_open(radeon->radeonScreen->bom, 0, RADEON_QUERY_PAGE_SIZE, RADEON_QUERY_PAGE_SIZE, RADEON_GEM_DOMAIN_GTT, 0);
+ }
+ query->curr_offset = 0;
+
+ radeon->query.current = query;
+
+ radeon->query.queryobj.dirty = GL_TRUE;
+ radeon->hw.is_dirty = GL_TRUE;
+}
+
+void radeonEmitQueryEnd(struct gl_context *ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_query_object *query = radeon->query.current;
+
+ if (!query)
+ return;
+
+ if (query->emitted_begin == GL_FALSE)
+ return;
+
+ radeon_print(RADEON_STATE, RADEON_NORMAL, "%s: query id %d, bo %p, offset %d\n", __FUNCTION__, query->Base.Id, query->bo, query->curr_offset);
+
+ radeon_cs_space_check_with_bo(radeon->cmdbuf.cs,
+ query->bo,
+ 0, RADEON_GEM_DOMAIN_GTT);
+
+ radeon->vtbl.emit_query_finish(radeon);
+}
+
+static void radeonEndQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ radeon_print(RADEON_STATE, RADEON_NORMAL, "%s: query id %d\n", __FUNCTION__, q->Id);
+
+ if (radeon->dma.flush)
+ radeon->dma.flush(radeon->glCtx);
+ radeonEmitQueryEnd(ctx);
+
+ radeon->query.current = NULL;
+}
+
+static void radeonCheckQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ radeon_print(RADEON_STATE, RADEON_TRACE, "%s: query id %d\n", __FUNCTION__, q->Id);
+\
+#ifdef DRM_RADEON_GEM_BUSY
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ struct radeon_query_object *query = (struct radeon_query_object *)q;
+ uint32_t domain;
+
+ /* Need to perform a flush, as per ARB_occlusion_query spec */
+ if (radeon_bo_is_referenced_by_cs(query->bo, radeon->cmdbuf.cs)) {
+ ctx->Driver.Flush(ctx);
+ }
+
+ if (radeon_bo_is_busy(query->bo, &domain) == 0) {
+ radeonQueryGetResult(ctx, q);
+ query->Base.Ready = GL_TRUE;
+ }
+#else
+ radeonWaitQuery(ctx, q);
+#endif
+}
+
+void radeonInitQueryObjFunctions(struct dd_function_table *functions)
+{
+ functions->NewQueryObject = radeonNewQueryObject;
+ functions->DeleteQuery = radeonDeleteQuery;
+ functions->BeginQuery = radeonBeginQuery;
+ functions->EndQuery = radeonEndQuery;
+ functions->CheckQuery = radeonCheckQuery;
+ functions->WaitQuery = radeonWaitQuery;
+}
+
+int radeon_check_query_active(struct gl_context *ctx, struct radeon_state_atom *atom)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct radeon_query_object *query = radeon->query.current;
+
+ if (!query || query->emitted_begin)
+ return 0;
+ return atom->cmd_size;
+}
+
+void radeon_emit_queryobj(struct gl_context *ctx, struct radeon_state_atom *atom)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ BATCH_LOCALS(radeon);
+ int dwords;
+
+ dwords = (*atom->check) (ctx, atom);
+
+ BEGIN_BATCH_NO_AUTOSTATE(dwords);
+ OUT_BATCH_TABLE(atom->cmd, dwords);
+ END_BATCH();
+
+ radeon->query.current->emitted_begin = GL_TRUE;
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.h
index 8f6f842b0a6..e5063934824 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_queryobj.h
@@ -1 +1,55 @@
-../radeon/radeon_queryobj.h \ No newline at end of file
+/*
+ * Copyright © 2008 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Maciej Cencora <m.cencora@gmail.com>
+ *
+ */
+
+#include "main/imports.h"
+#include "main/simple_list.h"
+#include "radeon_common_context.h"
+
+extern void radeonEmitQueryBegin(struct gl_context *ctx);
+extern void radeonEmitQueryEnd(struct gl_context *ctx);
+
+extern void radeonInitQueryObjFunctions(struct dd_function_table *functions);
+
+#define RADEON_QUERY_PAGE_SIZE 4096
+
+int radeon_check_query_active(struct gl_context *ctx, struct radeon_state_atom *atom);
+void radeon_emit_queryobj(struct gl_context *ctx, struct radeon_state_atom *atom);
+
+static inline void radeon_init_query_stateobj(radeonContextPtr radeon, int SZ)
+{
+ radeon->query.queryobj.cmd_size = (SZ);
+ radeon->query.queryobj.cmd = (uint32_t*)CALLOC((SZ) * sizeof(uint32_t));
+ radeon->query.queryobj.name = "queryobj";
+ radeon->query.queryobj.idx = 0;
+ radeon->query.queryobj.check = radeon_check_query_active;
+ radeon->query.queryobj.dirty = GL_FALSE;
+ radeon->query.queryobj.emit = radeon_emit_queryobj;
+
+ radeon->hw.max_state_size += (SZ);
+ insert_at_tail(&radeon->hw.atomlist, &radeon->query.queryobj);
+}
+
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.c
index 86161118dd3..27b57c5a3ea 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.c
@@ -1 +1,796 @@
-../radeon/radeon_screen.c \ No newline at end of file
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/**
+ * \file radeon_screen.c
+ * Screen initialization functions for the Radeon driver.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Gareth Hughes <gareth@valinux.com>
+ */
+
+#include <errno.h>
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/fbobject.h"
+#include "swrast/s_renderbuffer.h"
+
+#define STANDALONE_MMIO
+#include "radeon_chipset.h"
+#include "radeon_macros.h"
+#include "radeon_screen.h"
+#include "radeon_common.h"
+#include "radeon_common_context.h"
+#if defined(RADEON_R100)
+#include "radeon_context.h"
+#include "radeon_tex.h"
+#elif defined(RADEON_R200)
+#include "r200_context.h"
+#include "r200_tex.h"
+#endif
+
+#include "utils.h"
+
+#include "GL/internal/dri_interface.h"
+
+/* Radeon configuration
+ */
+#include "xmlpool.h"
+
+#define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \
+ DRI_CONF_DESC(en,"Size of command buffer (in KB)") \
+ DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \
+DRI_CONF_OPT_END
+
+#if defined(RADEON_R100) /* R100 */
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_MAX_TEXTURE_UNITS(3,2,3)
+ DRI_CONF_HYPERZ(false)
+ DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
+ DRI_CONF_NO_NEG_LOD_BIAS(false)
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+ DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+ DRI_CONF_ALLOW_LARGE_TEXTURES(2)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 15;
+
+#elif defined(RADEON_R200)
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_MAX_TEXTURE_UNITS(6,2,6)
+ DRI_CONF_HYPERZ(false)
+ DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
+ DRI_CONF_NO_NEG_LOD_BIAS(false)
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+ DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+ DRI_CONF_ALLOW_LARGE_TEXTURES(2)
+ DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0")
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_SOFTWARE
+ DRI_CONF_NV_VERTEX_PROGRAM(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 17;
+
+#endif
+
+#ifndef RADEON_INFO_TILE_CONFIG
+#define RADEON_INFO_TILE_CONFIG 0x6
+#endif
+
+static int
+radeonGetParam(__DRIscreen *sPriv, int param, void *value)
+{
+ int ret;
+ drm_radeon_getparam_t gp = { 0 };
+ struct drm_radeon_info info = { 0 };
+
+ if (sPriv->drm_version.major >= 2) {
+ info.value = (uint64_t)(uintptr_t)value;
+ switch (param) {
+ case RADEON_PARAM_DEVICE_ID:
+ info.request = RADEON_INFO_DEVICE_ID;
+ break;
+ case RADEON_PARAM_NUM_GB_PIPES:
+ info.request = RADEON_INFO_NUM_GB_PIPES;
+ break;
+ case RADEON_PARAM_NUM_Z_PIPES:
+ info.request = RADEON_INFO_NUM_Z_PIPES;
+ break;
+ case RADEON_INFO_TILE_CONFIG:
+ info.request = RADEON_INFO_TILE_CONFIG;
+ break;
+ default:
+ return -EINVAL;
+ }
+ ret = drmCommandWriteRead(sPriv->fd, DRM_RADEON_INFO, &info, sizeof(info));
+ } else {
+ gp.param = param;
+ gp.value = value;
+
+ ret = drmCommandWriteRead(sPriv->fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+ }
+ return ret;
+}
+
+#if defined(RADEON_R100)
+static const __DRItexBufferExtension radeonTexBufferExtension = {
+ { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+ radeonSetTexBuffer,
+ radeonSetTexBuffer2,
+};
+#elif defined(RADEON_R200)
+static const __DRItexBufferExtension r200TexBufferExtension = {
+ { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+ r200SetTexBuffer,
+ r200SetTexBuffer2,
+};
+#endif
+
+static void
+radeonDRI2Flush(__DRIdrawable *drawable)
+{
+ radeonContextPtr rmesa;
+
+ rmesa = (radeonContextPtr) drawable->driContextPriv->driverPrivate;
+ radeonFlush(rmesa->glCtx);
+}
+
+static const struct __DRI2flushExtensionRec radeonFlushExtension = {
+ { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
+ radeonDRI2Flush,
+ dri2InvalidateDrawable,
+};
+
+static __DRIimage *
+radeon_create_image_from_name(__DRIscreen *screen,
+ int width, int height, int format,
+ int name, int pitch, void *loaderPrivate)
+{
+ __DRIimage *image;
+ radeonScreenPtr radeonScreen = screen->driverPrivate;
+
+ if (name == 0)
+ return NULL;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ switch (format) {
+ case __DRI_IMAGE_FORMAT_RGB565:
+ image->format = MESA_FORMAT_RGB565;
+ image->internal_format = GL_RGB;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ image->format = MESA_FORMAT_XRGB8888;
+ image->internal_format = GL_RGB;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ image->format = MESA_FORMAT_ARGB8888;
+ image->internal_format = GL_RGBA;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ default:
+ free(image);
+ return NULL;
+ }
+
+ image->data = loaderPrivate;
+ image->cpp = _mesa_get_format_bytes(image->format);
+ image->width = width;
+ image->pitch = pitch;
+ image->height = height;
+
+ image->bo = radeon_bo_open(radeonScreen->bom,
+ (uint32_t)name,
+ image->pitch * image->height * image->cpp,
+ 0,
+ RADEON_GEM_DOMAIN_VRAM,
+ 0);
+
+ if (image->bo == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static __DRIimage *
+radeon_create_image_from_renderbuffer(__DRIcontext *context,
+ int renderbuffer, void *loaderPrivate)
+{
+ __DRIimage *image;
+ radeonContextPtr radeon = context->driverPrivate;
+ struct gl_renderbuffer *rb;
+ struct radeon_renderbuffer *rrb;
+
+ rb = _mesa_lookup_renderbuffer(radeon->glCtx, renderbuffer);
+ if (!rb) {
+ _mesa_error(radeon->glCtx,
+ GL_INVALID_OPERATION, "glRenderbufferExternalMESA");
+ return NULL;
+ }
+
+ rrb = radeon_renderbuffer(rb);
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->internal_format = rb->InternalFormat;
+ image->format = rb->Format;
+ image->cpp = rrb->cpp;
+ image->data_type = GL_UNSIGNED_BYTE;
+ image->data = loaderPrivate;
+ radeon_bo_ref(rrb->bo);
+ image->bo = rrb->bo;
+
+ image->width = rb->Width;
+ image->height = rb->Height;
+ image->pitch = rrb->pitch / image->cpp;
+
+ return image;
+}
+
+static void
+radeon_destroy_image(__DRIimage *image)
+{
+ radeon_bo_unref(image->bo);
+ FREE(image);
+}
+
+static __DRIimage *
+radeon_create_image(__DRIscreen *screen,
+ int width, int height, int format,
+ unsigned int use,
+ void *loaderPrivate)
+{
+ __DRIimage *image;
+ radeonScreenPtr radeonScreen = screen->driverPrivate;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->dri_format = format;
+
+ switch (format) {
+ case __DRI_IMAGE_FORMAT_RGB565:
+ image->format = MESA_FORMAT_RGB565;
+ image->internal_format = GL_RGB;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ image->format = MESA_FORMAT_XRGB8888;
+ image->internal_format = GL_RGB;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ image->format = MESA_FORMAT_ARGB8888;
+ image->internal_format = GL_RGBA;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ default:
+ free(image);
+ return NULL;
+ }
+
+ image->data = loaderPrivate;
+ image->cpp = _mesa_get_format_bytes(image->format);
+ image->width = width;
+ image->height = height;
+ image->pitch = ((image->cpp * image->width + 255) & ~255) / image->cpp;
+
+ image->bo = radeon_bo_open(radeonScreen->bom,
+ 0,
+ image->pitch * image->height * image->cpp,
+ 0,
+ RADEON_GEM_DOMAIN_VRAM,
+ 0);
+
+ if (image->bo == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static GLboolean
+radeon_query_image(__DRIimage *image, int attrib, int *value)
+{
+ switch (attrib) {
+ case __DRI_IMAGE_ATTRIB_STRIDE:
+ *value = image->pitch * image->cpp;
+ return GL_TRUE;
+ case __DRI_IMAGE_ATTRIB_HANDLE:
+ *value = image->bo->handle;
+ return GL_TRUE;
+ case __DRI_IMAGE_ATTRIB_NAME:
+ radeon_gem_get_kernel_name(image->bo, (uint32_t *) value);
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+static struct __DRIimageExtensionRec radeonImageExtension = {
+ { __DRI_IMAGE, 1 },
+ radeon_create_image_from_name,
+ radeon_create_image_from_renderbuffer,
+ radeon_destroy_image,
+ radeon_create_image,
+ radeon_query_image
+};
+
+static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
+{
+ screen->device_id = device_id;
+ screen->chip_flags = 0;
+ switch ( device_id ) {
+#if defined(RADEON_R100)
+ case PCI_CHIP_RN50_515E:
+ case PCI_CHIP_RN50_5969:
+ return -1;
+
+ case PCI_CHIP_RADEON_LY:
+ case PCI_CHIP_RADEON_LZ:
+ case PCI_CHIP_RADEON_QY:
+ case PCI_CHIP_RADEON_QZ:
+ screen->chip_family = CHIP_FAMILY_RV100;
+ break;
+
+ case PCI_CHIP_RS100_4136:
+ case PCI_CHIP_RS100_4336:
+ screen->chip_family = CHIP_FAMILY_RS100;
+ break;
+
+ case PCI_CHIP_RS200_4137:
+ case PCI_CHIP_RS200_4337:
+ case PCI_CHIP_RS250_4237:
+ case PCI_CHIP_RS250_4437:
+ screen->chip_family = CHIP_FAMILY_RS200;
+ break;
+
+ case PCI_CHIP_RADEON_QD:
+ case PCI_CHIP_RADEON_QE:
+ case PCI_CHIP_RADEON_QF:
+ case PCI_CHIP_RADEON_QG:
+ /* all original radeons (7200) presumably have a stencil op bug */
+ screen->chip_family = CHIP_FAMILY_R100;
+ screen->chip_flags = RADEON_CHIPSET_TCL | RADEON_CHIPSET_BROKEN_STENCIL | RADEON_CHIPSET_DEPTH_ALWAYS_TILED;
+ break;
+
+ case PCI_CHIP_RV200_QW:
+ case PCI_CHIP_RV200_QX:
+ case PCI_CHIP_RADEON_LW:
+ case PCI_CHIP_RADEON_LX:
+ screen->chip_family = CHIP_FAMILY_RV200;
+ screen->chip_flags = RADEON_CHIPSET_TCL | RADEON_CHIPSET_DEPTH_ALWAYS_TILED;
+ break;
+
+#elif defined(RADEON_R200)
+ case PCI_CHIP_R200_BB:
+ case PCI_CHIP_R200_QH:
+ case PCI_CHIP_R200_QL:
+ case PCI_CHIP_R200_QM:
+ screen->chip_family = CHIP_FAMILY_R200;
+ screen->chip_flags = RADEON_CHIPSET_TCL | RADEON_CHIPSET_DEPTH_ALWAYS_TILED;
+ break;
+
+ case PCI_CHIP_RV250_If:
+ case PCI_CHIP_RV250_Ig:
+ case PCI_CHIP_RV250_Ld:
+ case PCI_CHIP_RV250_Lf:
+ case PCI_CHIP_RV250_Lg:
+ screen->chip_family = CHIP_FAMILY_RV250;
+ screen->chip_flags = R200_CHIPSET_YCBCR_BROKEN | RADEON_CHIPSET_TCL | RADEON_CHIPSET_DEPTH_ALWAYS_TILED;
+ break;
+
+ case PCI_CHIP_RV280_4C6E:
+ case PCI_CHIP_RV280_5960:
+ case PCI_CHIP_RV280_5961:
+ case PCI_CHIP_RV280_5962:
+ case PCI_CHIP_RV280_5964:
+ case PCI_CHIP_RV280_5965:
+ case PCI_CHIP_RV280_5C61:
+ case PCI_CHIP_RV280_5C63:
+ screen->chip_family = CHIP_FAMILY_RV280;
+ screen->chip_flags = RADEON_CHIPSET_TCL | RADEON_CHIPSET_DEPTH_ALWAYS_TILED;
+ break;
+
+ case PCI_CHIP_RS300_5834:
+ case PCI_CHIP_RS300_5835:
+ case PCI_CHIP_RS350_7834:
+ case PCI_CHIP_RS350_7835:
+ screen->chip_family = CHIP_FAMILY_RS300;
+ screen->chip_flags = RADEON_CHIPSET_DEPTH_ALWAYS_TILED;
+ break;
+#endif
+
+ default:
+ fprintf(stderr, "unknown chip id 0x%x, can't guess.\n",
+ device_id);
+ return -1;
+ }
+
+ return 0;
+}
+
+static radeonScreenPtr
+radeonCreateScreen2(__DRIscreen *sPriv)
+{
+ radeonScreenPtr screen;
+ int i;
+ int ret;
+ uint32_t device_id = 0;
+
+ /* Allocate the private area */
+ screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );
+ if ( !screen ) {
+ fprintf(stderr, "%s: Could not allocate memory for screen structure", __FUNCTION__);
+ fprintf(stderr, "leaving here\n");
+ return NULL;
+ }
+
+ radeon_init_debug();
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ screen->chip_flags = 0;
+
+ screen->irq = 1;
+
+ ret = radeonGetParam(sPriv, RADEON_PARAM_DEVICE_ID, &device_id);
+ if (ret) {
+ FREE( screen );
+ fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_DEVICE_ID): %d\n", ret);
+ return NULL;
+ }
+
+ ret = radeon_set_screen_flags(screen, device_id);
+ if (ret == -1)
+ return NULL;
+
+ if (getenv("RADEON_NO_TCL"))
+ screen->chip_flags &= ~RADEON_CHIPSET_TCL;
+
+ i = 0;
+ screen->extensions[i++] = &dri2ConfigQueryExtension.base;
+
+#if defined(RADEON_R100)
+ screen->extensions[i++] = &radeonTexBufferExtension.base;
+#elif defined(RADEON_R200)
+ screen->extensions[i++] = &r200TexBufferExtension.base;
+#endif
+
+ screen->extensions[i++] = &radeonFlushExtension.base;
+ screen->extensions[i++] = &radeonImageExtension.base;
+
+ screen->extensions[i++] = NULL;
+ sPriv->extensions = screen->extensions;
+
+ screen->driScreen = sPriv;
+ screen->bom = radeon_bo_manager_gem_ctor(sPriv->fd);
+ if (screen->bom == NULL) {
+ free(screen);
+ return NULL;
+ }
+ return screen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+static void
+radeonDestroyScreen( __DRIscreen *sPriv )
+{
+ radeonScreenPtr screen = (radeonScreenPtr)sPriv->driverPrivate;
+
+ if (!screen)
+ return;
+
+#ifdef RADEON_BO_TRACK
+ radeon_tracker_print(&screen->bom->tracker, stderr);
+#endif
+ radeon_bo_manager_gem_dtor(screen->bom);
+
+ /* free all option information */
+ driDestroyOptionInfo (&screen->optionCache);
+
+ FREE( screen );
+ sPriv->driverPrivate = NULL;
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+radeonInitDriver( __DRIscreen *sPriv )
+{
+ sPriv->driverPrivate = (void *) radeonCreateScreen2( sPriv );
+ if ( !sPriv->driverPrivate ) {
+ radeonDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Create the Mesa framebuffer and renderbuffers for a given window/drawable.
+ *
+ * \todo This function (and its interface) will need to be updated to support
+ * pbuffers.
+ */
+static GLboolean
+radeonCreateBuffer( __DRIscreen *driScrnPriv,
+ __DRIdrawable *driDrawPriv,
+ const struct gl_config *mesaVis,
+ GLboolean isPixmap )
+{
+ radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->driverPrivate;
+
+ const GLboolean swDepth = GL_FALSE;
+ const GLboolean swAlpha = GL_FALSE;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24;
+ gl_format rgbFormat;
+ struct radeon_framebuffer *rfb;
+
+ if (isPixmap)
+ return GL_FALSE; /* not implemented */
+
+ rfb = CALLOC_STRUCT(radeon_framebuffer);
+ if (!rfb)
+ return GL_FALSE;
+
+ _mesa_initialize_window_framebuffer(&rfb->base, mesaVis);
+
+ if (mesaVis->redBits == 5)
+ rgbFormat = _mesa_little_endian() ? MESA_FORMAT_RGB565 : MESA_FORMAT_RGB565_REV;
+ else if (mesaVis->alphaBits == 0)
+ rgbFormat = _mesa_little_endian() ? MESA_FORMAT_XRGB8888 : MESA_FORMAT_XRGB8888_REV;
+ else
+ rgbFormat = _mesa_little_endian() ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB8888_REV;
+
+ /* front color renderbuffer */
+ rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
+ _mesa_add_renderbuffer(&rfb->base, BUFFER_FRONT_LEFT, &rfb->color_rb[0]->base.Base);
+ rfb->color_rb[0]->has_surface = 1;
+
+ /* back color renderbuffer */
+ if (mesaVis->doubleBufferMode) {
+ rfb->color_rb[1] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
+ _mesa_add_renderbuffer(&rfb->base, BUFFER_BACK_LEFT, &rfb->color_rb[1]->base.Base);
+ rfb->color_rb[1]->has_surface = 1;
+ }
+
+ if (mesaVis->depthBits == 24) {
+ if (mesaVis->stencilBits == 8) {
+ struct radeon_renderbuffer *depthStencilRb =
+ radeon_create_renderbuffer(MESA_FORMAT_S8_Z24, driDrawPriv);
+ _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depthStencilRb->base.Base);
+ _mesa_add_renderbuffer(&rfb->base, BUFFER_STENCIL, &depthStencilRb->base.Base);
+ depthStencilRb->has_surface = screen->depthHasSurface;
+ } else {
+ /* depth renderbuffer */
+ struct radeon_renderbuffer *depth =
+ radeon_create_renderbuffer(MESA_FORMAT_X8_Z24, driDrawPriv);
+ _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base.Base);
+ depth->has_surface = screen->depthHasSurface;
+ }
+ } else if (mesaVis->depthBits == 16) {
+ /* just 16-bit depth buffer, no hw stencil */
+ struct radeon_renderbuffer *depth =
+ radeon_create_renderbuffer(MESA_FORMAT_Z16, driDrawPriv);
+ _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base.Base);
+ depth->has_surface = screen->depthHasSurface;
+ }
+
+ _swrast_add_soft_renderbuffers(&rfb->base,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) rfb;
+
+ return (driDrawPriv->driverPrivate != NULL);
+}
+
+
+static void radeon_cleanup_renderbuffers(struct radeon_framebuffer *rfb)
+{
+ struct radeon_renderbuffer *rb;
+
+ rb = rfb->color_rb[0];
+ if (rb && rb->bo) {
+ radeon_bo_unref(rb->bo);
+ rb->bo = NULL;
+ }
+ rb = rfb->color_rb[1];
+ if (rb && rb->bo) {
+ radeon_bo_unref(rb->bo);
+ rb->bo = NULL;
+ }
+ rb = radeon_get_renderbuffer(&rfb->base, BUFFER_DEPTH);
+ if (rb && rb->bo) {
+ radeon_bo_unref(rb->bo);
+ rb->bo = NULL;
+ }
+}
+
+void
+radeonDestroyBuffer(__DRIdrawable *driDrawPriv)
+{
+ struct radeon_framebuffer *rfb;
+ if (!driDrawPriv)
+ return;
+
+ rfb = (void*)driDrawPriv->driverPrivate;
+ if (!rfb)
+ return;
+ radeon_cleanup_renderbuffers(rfb);
+ _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
+}
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * Called when using DRI2.
+ *
+ * \return the struct gl_config supported by this driver
+ */
+static const
+__DRIconfig **radeonInitScreen2(__DRIscreen *psp)
+{
+ GLenum fb_format[3];
+ GLenum fb_type[3];
+ /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
+ * support pageflipping at all.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, /*, GLX_SWAP_COPY_OML*/
+ };
+ uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];
+ int color;
+ __DRIconfig **configs = NULL;
+
+ if (!radeonInitDriver(psp)) {
+ return NULL;
+ }
+ depth_bits[0] = 0;
+ stencil_bits[0] = 0;
+ depth_bits[1] = 16;
+ stencil_bits[1] = 0;
+ depth_bits[2] = 24;
+ stencil_bits[2] = 0;
+ depth_bits[3] = 24;
+ stencil_bits[3] = 8;
+
+ msaa_samples_array[0] = 0;
+
+ fb_format[0] = GL_RGB;
+ fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
+
+ fb_format[1] = GL_BGR;
+ fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+ fb_format[2] = GL_BGRA;
+ fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+ for (color = 0; color < ARRAY_SIZE(fb_format); color++) {
+ __DRIconfig **new_configs;
+
+ new_configs = driCreateConfigs(fb_format[color], fb_type[color],
+ depth_bits,
+ stencil_bits,
+ ARRAY_SIZE(depth_bits),
+ back_buffer_modes,
+ ARRAY_SIZE(back_buffer_modes),
+ msaa_samples_array,
+ ARRAY_SIZE(msaa_samples_array),
+ GL_TRUE);
+ configs = driConcatConfigs(configs, new_configs);
+ }
+
+ if (configs == NULL) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ __LINE__);
+ return NULL;
+ }
+
+ return (const __DRIconfig **)configs;
+}
+
+const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = radeonInitScreen2,
+ .DestroyScreen = radeonDestroyScreen,
+#if defined(RADEON_R200)
+ .CreateContext = r200CreateContext,
+ .DestroyContext = r200DestroyContext,
+#else
+ .CreateContext = r100CreateContext,
+ .DestroyContext = radeonDestroyContext,
+#endif
+ .CreateBuffer = radeonCreateBuffer,
+ .DestroyBuffer = radeonDestroyBuffer,
+ .MakeCurrent = radeonMakeCurrent,
+ .UnbindContext = radeonUnbindContext,
+};
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+ &driCoreExtension.base,
+ &driDRI2Extension.base,
+ NULL
+};
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.h
index 23bb6bd4598..dd618f5836f 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_screen.h
@@ -1 +1,122 @@
-../radeon/radeon_screen.h \ No newline at end of file
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __RADEON_SCREEN_H__
+#define __RADEON_SCREEN_H__
+
+/*
+ * IMPORTS: these headers contain all the DRI, X and kernel-related
+ * definitions that we need.
+ */
+#include "dri_util.h"
+#include "radeon_dri.h"
+#include "radeon_chipset.h"
+#include "radeon_reg.h"
+#include "drm_sarea.h"
+#include "xmlconfig.h"
+
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ drmAddress map; /* Mapping of the DRM region */
+} radeonRegionRec, *radeonRegionPtr;
+
+typedef struct radeon_screen {
+ int chip_family;
+ int chip_flags;
+ int cpp;
+ int card_type;
+ int device_id; /* PCI ID */
+ int AGPMode;
+ unsigned int irq; /* IRQ number (0 means none) */
+
+ unsigned int fbLocation;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ /* Shared texture data */
+ int numTexHeaps;
+ int texOffset[RADEON_NR_TEX_HEAPS];
+ int texSize[RADEON_NR_TEX_HEAPS];
+ int logTexGranularity[RADEON_NR_TEX_HEAPS];
+
+ radeonRegionRec mmio;
+ radeonRegionRec status;
+ radeonRegionRec gartTextures;
+
+ drmBufMapPtr buffers;
+
+ __volatile__ uint32_t *scratch;
+
+ __DRIscreen *driScreen;
+ unsigned int sarea_priv_offset;
+ unsigned int gart_buffer_offset; /* offset in card memory space */
+ unsigned int gart_texture_offset; /* offset in card memory space */
+ unsigned int gart_base;
+
+ GLboolean depthHasSurface;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+
+ const __DRIextension *extensions[17];
+
+ int num_gb_pipes;
+ int num_z_pipes;
+ drm_radeon_sarea_t *sarea; /* Private SAREA data */
+ struct radeon_bo_manager *bom;
+
+} radeonScreenRec, *radeonScreenPtr;
+
+struct __DRIimageRec {
+ struct radeon_bo *bo;
+ GLenum internal_format;
+ uint32_t dri_format;
+ GLuint format;
+ GLenum data_type;
+ int width, height; /* in pixels */
+ int pitch; /* in pixels */
+ int cpp;
+ void *data;
+};
+
+extern void radeonDestroyBuffer(__DRIdrawable *driDrawPriv);
+#endif /* __RADEON_SCREEN_H__ */
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.c
index 232868c4c9e..0617adc5bc5 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.c
@@ -1 +1,161 @@
-../radeon/radeon_span.c \ No newline at end of file
+/**************************************************************************
+
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include "main/glheader.h"
+#include "main/texformat.h"
+#include "main/renderbuffer.h"
+#include "main/samplerobj.h"
+#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
+
+#include "radeon_common.h"
+#include "radeon_span.h"
+
+
+static void
+radeon_renderbuffer_map(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ GLubyte *map;
+ int stride;
+
+ if (!rb || !rrb)
+ return;
+
+ ctx->Driver.MapRenderbuffer(ctx, rb, 0, 0, rb->Width, rb->Height,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
+ &map, &stride);
+
+ rrb->base.Map = map;
+ rrb->base.RowStride = stride;
+ /* No floating point color buffers, use GLubytes */
+ rrb->base.ColorType = GL_UNSIGNED_BYTE;
+}
+
+static void
+radeon_renderbuffer_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+ if (!rb || !rrb)
+ return;
+
+ ctx->Driver.UnmapRenderbuffer(ctx, rb);
+
+ rrb->base.Map = NULL;
+ rrb->base.RowStride = 0;
+}
+
+static void
+radeon_map_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ radeon_print(RADEON_MEMORY, RADEON_TRACE,
+ "%s( %p , fb %p )\n",
+ __func__, ctx, fb);
+
+ /* check for render to textures */
+ for (i = 0; i < BUFFER_COUNT; i++)
+ radeon_renderbuffer_map(ctx, fb->Attachment[i].Renderbuffer);
+
+ radeon_check_front_buffer_rendering(ctx);
+}
+
+static void
+radeon_unmap_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ radeon_print(RADEON_MEMORY, RADEON_TRACE,
+ "%s( %p , fb %p)\n",
+ __func__, ctx, fb);
+
+ /* check for render to textures */
+ for (i = 0; i < BUFFER_COUNT; i++)
+ radeon_renderbuffer_unmap(ctx, fb->Attachment[i].Renderbuffer);
+
+ radeon_check_front_buffer_rendering(ctx);
+}
+
+static void radeonSpanRenderStart(struct gl_context * ctx)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int i;
+
+ radeon_firevertices(rmesa);
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ radeon_validate_texture_miptree(ctx, _mesa_get_samplerobj(ctx, i),
+ ctx->Texture.Unit[i]._Current);
+ radeon_swrast_map_texture_images(ctx, ctx->Texture.Unit[i]._Current);
+ }
+ }
+
+ radeon_map_framebuffer(ctx, ctx->DrawBuffer);
+ if (ctx->ReadBuffer != ctx->DrawBuffer)
+ radeon_map_framebuffer(ctx, ctx->ReadBuffer);
+}
+
+static void radeonSpanRenderFinish(struct gl_context * ctx)
+{
+ int i;
+
+ _swrast_flush(ctx);
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++)
+ if (ctx->Texture.Unit[i]._ReallyEnabled)
+ radeon_swrast_unmap_texture_images(ctx, ctx->Texture.Unit[i]._Current);
+
+ radeon_unmap_framebuffer(ctx, ctx->DrawBuffer);
+ if (ctx->ReadBuffer != ctx->DrawBuffer)
+ radeon_unmap_framebuffer(ctx, ctx->ReadBuffer);
+}
+
+void radeonInitSpanFuncs(struct gl_context * ctx)
+{
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+ swdd->SpanRenderStart = radeonSpanRenderStart;
+ swdd->SpanRenderFinish = radeonSpanRenderFinish;
+}
+
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.h
index f9d634508c2..64517b59237 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_span.h
@@ -1 +1,47 @@
-../radeon/radeon_span.h \ No newline at end of file
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Kevin E. Martin <martin@valinux.com>
+ */
+
+#ifndef __RADEON_SPAN_H__
+#define __RADEON_SPAN_H__
+
+extern void radeonInitSpanFuncs(struct gl_context * ctx);
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tex_copy.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tex_copy.c
index dfa5ba34e65..a6c406b2bff 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tex_copy.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tex_copy.c
@@ -1 +1,160 @@
-../radeon/radeon_tex_copy.c \ No newline at end of file
+/*
+ * Copyright (C) 2009 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_common.h"
+#include "radeon_texture.h"
+
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "drivers/common/meta.h"
+
+#include "radeon_mipmap_tree.h"
+
+static GLboolean
+do_copy_texsubimage(struct gl_context *ctx,
+ struct radeon_tex_obj *tobj,
+ radeon_texture_image *timg,
+ GLint dstx, GLint dsty,
+ struct radeon_renderbuffer *rrb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ const GLuint face = timg->base.Base.Face;
+ const GLuint level = timg->base.Base.Level;
+ unsigned src_bpp;
+ unsigned dst_bpp;
+ gl_format src_mesaformat;
+ gl_format dst_mesaformat;
+ unsigned flip_y;
+
+ if (!radeon->vtbl.blit) {
+ return GL_FALSE;
+ }
+
+ // This is software renderbuffer, fallback to swrast
+ if (!rrb) {
+ return GL_FALSE;
+ }
+
+ if (_mesa_get_format_bits(timg->base.Base.TexFormat, GL_DEPTH_BITS) > 0) {
+ /* copying depth values */
+ flip_y = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Type == GL_NONE;
+ } else {
+ /* copying color */
+ flip_y = ctx->ReadBuffer->Attachment[BUFFER_COLOR0].Type == GL_NONE;
+ }
+
+ if (!timg->mt) {
+ radeon_validate_texture_miptree(ctx, &tobj->base.Sampler, &tobj->base);
+ }
+
+ assert(rrb->bo);
+ assert(timg->mt);
+ assert(timg->mt->bo);
+ assert(timg->base.Base.Width >= dstx + width);
+ assert(timg->base.Base.Height >= dsty + height);
+
+ intptr_t src_offset = rrb->draw_offset;
+ intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, face, level);
+
+ if (0) {
+ fprintf(stderr, "%s: copying to face %d, level %d\n",
+ __FUNCTION__, face, level);
+ fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset);
+ fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n",
+ x, y, rrb->base.Base.Width, rrb->base.Base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp);
+ fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size);
+
+ }
+
+ src_mesaformat = rrb->base.Base.Format;
+ dst_mesaformat = timg->base.Base.TexFormat;
+ src_bpp = _mesa_get_format_bytes(src_mesaformat);
+ dst_bpp = _mesa_get_format_bytes(dst_mesaformat);
+ if (!radeon->vtbl.check_blit(dst_mesaformat, rrb->pitch / rrb->cpp)) {
+ /* depth formats tend to be special */
+ if (_mesa_get_format_bits(dst_mesaformat, GL_DEPTH_BITS) > 0)
+ return GL_FALSE;
+
+ if (src_bpp != dst_bpp)
+ return GL_FALSE;
+
+ switch (dst_bpp) {
+ case 2:
+ src_mesaformat = MESA_FORMAT_RGB565;
+ dst_mesaformat = MESA_FORMAT_RGB565;
+ break;
+ case 4:
+ src_mesaformat = MESA_FORMAT_ARGB8888;
+ dst_mesaformat = MESA_FORMAT_ARGB8888;
+ break;
+ case 1:
+ src_mesaformat = MESA_FORMAT_A8;
+ dst_mesaformat = MESA_FORMAT_A8;
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ /* blit from src buffer to texture */
+ return radeon->vtbl.blit(ctx, rrb->bo, src_offset, src_mesaformat, rrb->pitch/rrb->cpp,
+ rrb->base.Base.Width, rrb->base.Base.Height, x, y,
+ timg->mt->bo, dst_offset, dst_mesaformat,
+ timg->mt->levels[level].rowstride / dst_bpp,
+ timg->base.Base.Width, timg->base.Base.Height,
+ dstx, dsty, width, height, flip_y);
+}
+
+void
+radeonCopyTexSubImage(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ radeon_prepare_render(radeon);
+
+ if (dims != 2 || !do_copy_texsubimage(ctx,
+ radeon_tex_obj(texImage->TexObject),
+ (radeon_texture_image *)texImage,
+ xoffset, yoffset,
+ radeon_renderbuffer(rb), x, y, width, height)) {
+
+ radeon_print(RADEON_FALLBACKS, RADEON_NORMAL,
+ "Falling back to sw for glCopyTexSubImage2D\n");
+
+ _mesa_meta_CopyTexSubImage(ctx, dims, texImage,
+ xoffset, yoffset, zoffset,
+ rb, x, y, width, height);
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.c
index a822710915f..e405f9746f1 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.c
@@ -1 +1,833 @@
-../radeon/radeon_texture.c \ No newline at end of file
+/*
+ * Copyright (C) 2009 Maciej Cencora.
+ * Copyright (C) 2008 Nicolai Haehnle.
+ * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+ *
+ * The Weather Channel (TM) funded Tungsten Graphics to develop the
+ * initial release of the Radeon 8500 driver under the XFree86 license.
+ * This notice must be preserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/enums.h"
+#include "main/mfeatures.h"
+#include "main/mipmap.h"
+#include "main/pbo.h"
+#include "main/texcompress.h"
+#include "main/texstore.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
+#include "drivers/common/meta.h"
+
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+
+#include "radeon_common.h"
+
+#include "radeon_mipmap_tree.h"
+
+static void teximage_assign_miptree(radeonContextPtr rmesa,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+static radeon_mipmap_tree *radeon_miptree_create_for_teximage(radeonContextPtr rmesa,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+void copy_rows(void* dst, GLuint dststride, const void* src, GLuint srcstride,
+ GLuint numrows, GLuint rowsize)
+{
+ assert(rowsize <= dststride);
+ assert(rowsize <= srcstride);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s dst %p, stride %u, src %p, stride %u, "
+ "numrows %u, rowsize %u.\n",
+ __func__, dst, dststride,
+ src, srcstride,
+ numrows, rowsize);
+
+ if (rowsize == srcstride && rowsize == dststride) {
+ memcpy(dst, src, numrows*rowsize);
+ } else {
+ GLuint i;
+ for(i = 0; i < numrows; ++i) {
+ memcpy(dst, src, rowsize);
+ dst += dststride;
+ src += srcstride;
+ }
+ }
+}
+
+/* textures */
+/**
+ * Allocate an empty texture image object.
+ */
+struct gl_texture_image *radeonNewTextureImage(struct gl_context *ctx)
+{
+ return CALLOC(sizeof(radeon_texture_image));
+}
+
+
+/**
+ * Delete a texture image object.
+ */
+static void
+radeonDeleteTextureImage(struct gl_context *ctx, struct gl_texture_image *img)
+{
+ /* nothing special (yet) for radeon_texture_image */
+ _mesa_delete_texture_image(ctx, img);
+}
+
+static GLboolean
+radeonAllocTextureImageBuffer(struct gl_context *ctx,
+ struct gl_texture_image *timage)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_texture_image *image = get_radeon_texture_image(timage);
+ struct gl_texture_object *texobj = timage->TexObject;
+ int slices;
+
+ ctx->Driver.FreeTextureImageBuffer(ctx, timage);
+
+ switch (texobj->Target) {
+ case GL_TEXTURE_3D:
+ slices = timage->Depth;
+ break;
+ default:
+ slices = 1;
+ }
+ assert(!image->base.ImageOffsets);
+ image->base.ImageOffsets = malloc(slices * sizeof(GLuint));
+ teximage_assign_miptree(rmesa, texobj, timage);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Free memory associated with this texture image.
+ */
+void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_image *timage)
+{
+ radeon_texture_image* image = get_radeon_texture_image(timage);
+
+ if (image->mt) {
+ radeon_miptree_unreference(&image->mt);
+ } else {
+ _swrast_free_texture_image_buffer(ctx, timage);
+ }
+ if (image->bo) {
+ radeon_bo_unref(image->bo);
+ image->bo = NULL;
+ }
+ if (image->base.Buffer) {
+ _mesa_align_free(image->base.Buffer);
+ image->base.Buffer = NULL;
+ }
+
+ if (image->base.ImageOffsets) {
+ free(image->base.ImageOffsets);
+ image->base.ImageOffsets = NULL;
+ }
+}
+
+/* Set Data pointer and additional data for mapped texture image */
+static void teximage_set_map_data(radeon_texture_image *image)
+{
+ radeon_mipmap_level *lvl;
+
+ if (!image->mt) {
+ radeon_warning("%s(%p) Trying to set map data without miptree.\n",
+ __func__, image);
+
+ return;
+ }
+
+ lvl = &image->mt->levels[image->base.Base.Level];
+
+ image->base.Map = image->mt->bo->ptr + lvl->faces[image->base.Base.Face].offset;
+ image->base.RowStride = lvl->rowstride / _mesa_get_format_bytes(image->base.Base.TexFormat);
+}
+
+
+/**
+ * Map a single texture image for glTexImage and friends.
+ */
+void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable)
+{
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
+ "%s(img %p), write_enable %s.\n",
+ __func__, image,
+ write_enable ? "true": "false");
+ if (image->mt) {
+ assert(!image->base.Map);
+
+ radeon_bo_map(image->mt->bo, write_enable);
+ teximage_set_map_data(image);
+ }
+}
+
+
+void radeon_teximage_unmap(radeon_texture_image *image)
+{
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
+ "%s(img %p)\n",
+ __func__, image);
+ if (image->mt) {
+ assert(image->base.Map);
+
+ image->base.Map = 0;
+ radeon_bo_unmap(image->mt->bo);
+ }
+}
+
+/**
+ * Map texture memory/buffer into user space.
+ * Note: the region of interest parameters are ignored here.
+ * \param mapOut returns start of mapping of region of interest
+ * \param rowStrideOut returns row stride in bytes
+ */
+static void
+radeon_map_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLuint slice,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **map,
+ GLint *stride)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_texture_image *image = get_radeon_texture_image(texImage);
+ radeon_mipmap_tree *mt = image->mt;
+ GLuint texel_size = _mesa_get_format_bytes(texImage->TexFormat);
+ GLuint width = texImage->Width;
+ GLuint height = texImage->Height;
+ struct radeon_bo *bo = !image->mt ? image->bo : image->mt->bo;
+ unsigned int bw, bh;
+ GLboolean write = (mode & GL_MAP_WRITE_BIT) != 0;
+
+ _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
+ assert(y % bh == 0);
+ y /= bh;
+ texel_size /= bw;
+
+ if (bo && radeon_bo_is_referenced_by_cs(bo, rmesa->cmdbuf.cs)) {
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
+ "%s for texture that is "
+ "queued for GPU processing.\n",
+ __func__);
+ radeon_firevertices(rmesa);
+ }
+
+ if (image->bo) {
+ /* TFP case */
+ radeon_bo_map(image->bo, write);
+ *stride = get_texture_image_row_stride(rmesa, texImage->TexFormat, width, 0, texImage->TexObject->Target);
+ *map = bo->ptr;
+ } else if (likely(mt)) {
+ void *base;
+ radeon_mipmap_level *lvl = &image->mt->levels[texImage->Level];
+
+ radeon_bo_map(mt->bo, write);
+ base = mt->bo->ptr + lvl->faces[image->base.Base.Face].offset;
+
+ *stride = lvl->rowstride;
+ *map = base + (slice * height) * *stride;
+ } else {
+ /* texture data is in malloc'd memory */
+
+ assert(map);
+
+ *stride = _mesa_format_row_stride(texImage->TexFormat, width);
+ *map = image->base.Buffer + (slice * height) * *stride;
+ }
+
+ *map += y * *stride + x * texel_size;
+}
+
+static void
+radeon_unmap_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *texImage, GLuint slice)
+{
+ radeon_texture_image *image = get_radeon_texture_image(texImage);
+
+ if (image->bo)
+ radeon_bo_unmap(image->bo);
+ else if (image->mt)
+ radeon_bo_unmap(image->mt->bo);
+}
+
+/* try to find a format which will only need a memcopy */
+static gl_format radeonChoose8888TexFormat(radeonContextPtr rmesa,
+ GLenum srcFormat,
+ GLenum srcType, GLboolean fbo)
+{
+#if defined(RADEON_R100)
+ /* r100 can only do this */
+ return _radeon_texformat_argb8888;
+#elif defined(RADEON_R200)
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *)&ui);
+
+ if (fbo)
+ return _radeon_texformat_argb8888;
+
+ if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
+ return MESA_FORMAT_RGBA8888;
+ } else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
+ return MESA_FORMAT_RGBA8888_REV;
+ } else
+ return _radeon_texformat_argb8888;
+#endif
+}
+
+gl_format radeonChooseTextureFormat_mesa(struct gl_context * ctx,
+ GLenum target,
+ GLint internalFormat,
+ GLenum format,
+ GLenum type)
+{
+ return radeonChooseTextureFormat(ctx, internalFormat, format,
+ type, 0);
+}
+
+gl_format radeonChooseTextureFormat(struct gl_context * ctx,
+ GLint internalFormat,
+ GLenum format,
+ GLenum type, GLboolean fbo)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32);
+ const GLboolean force16bpt =
+ (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16);
+ (void)format;
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s InternalFormat=%s(%d) type=%s format=%s\n",
+ __func__,
+ _mesa_lookup_enum_by_nr(internalFormat), internalFormat,
+ _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "%s do32bpt=%d force16bpt=%d\n",
+ __func__, do32bpt, force16bpt);
+
+ switch (internalFormat) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ switch (type) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? _radeon_texformat_argb8888 :
+ _radeon_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _radeon_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _radeon_texformat_argb1555;
+ default:
+ return do32bpt ? radeonChoose8888TexFormat(rmesa, format, type, fbo) :
+ _radeon_texformat_argb4444;
+ }
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ switch (type) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _radeon_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _radeon_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return _radeon_texformat_rgb565;
+ default:
+ return do32bpt ? _radeon_texformat_argb8888 :
+ _radeon_texformat_rgb565;
+ }
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return !force16bpt ?
+ radeonChoose8888TexFormat(rmesa, format, type, fbo) :
+ _radeon_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return _radeon_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return _radeon_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return !force16bpt ? _radeon_texformat_argb8888 :
+ _radeon_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return _radeon_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+#if defined(RADEON_R200)
+ /* r200: can't use a8 format since interpreting hw I8 as a8 would result
+ in wrong rgb values (same as alpha value instead of 0). */
+ return _radeon_texformat_al88;
+#else
+ return MESA_FORMAT_A8;
+#endif
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return MESA_FORMAT_L8;
+
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ return _radeon_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return MESA_FORMAT_I8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)
+ return MESA_FORMAT_YCBCR;
+ else
+ return MESA_FORMAT_YCBCR_REV;
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return MESA_FORMAT_RGB_DXT1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return MESA_FORMAT_RGBA_DXT1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return MESA_FORMAT_RGBA_DXT3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return MESA_FORMAT_RGBA_DXT5;
+
+ case GL_ALPHA16F_ARB:
+ return MESA_FORMAT_ALPHA_FLOAT16;
+ case GL_ALPHA32F_ARB:
+ return MESA_FORMAT_ALPHA_FLOAT32;
+ case GL_LUMINANCE16F_ARB:
+ return MESA_FORMAT_LUMINANCE_FLOAT16;
+ case GL_LUMINANCE32F_ARB:
+ return MESA_FORMAT_LUMINANCE_FLOAT32;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
+ case GL_INTENSITY16F_ARB:
+ return MESA_FORMAT_INTENSITY_FLOAT16;
+ case GL_INTENSITY32F_ARB:
+ return MESA_FORMAT_INTENSITY_FLOAT32;
+ case GL_RGB16F_ARB:
+ return MESA_FORMAT_RGBA_FLOAT16;
+ case GL_RGB32F_ARB:
+ return MESA_FORMAT_RGBA_FLOAT32;
+ case GL_RGBA16F_ARB:
+ return MESA_FORMAT_RGBA_FLOAT16;
+ case GL_RGBA32F_ARB:
+ return MESA_FORMAT_RGBA_FLOAT32;
+
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ return MESA_FORMAT_S8_Z24;
+
+ /* EXT_texture_sRGB */
+ case GL_SRGB:
+ case GL_SRGB8:
+ case GL_SRGB_ALPHA:
+ case GL_SRGB8_ALPHA8:
+ case GL_COMPRESSED_SRGB:
+ case GL_COMPRESSED_SRGB_ALPHA:
+ return MESA_FORMAT_SARGB8;
+
+ case GL_SLUMINANCE:
+ case GL_SLUMINANCE8:
+ case GL_COMPRESSED_SLUMINANCE:
+ return MESA_FORMAT_SL8;
+
+ case GL_SLUMINANCE_ALPHA:
+ case GL_SLUMINANCE8_ALPHA8:
+ case GL_COMPRESSED_SLUMINANCE_ALPHA:
+ return MESA_FORMAT_SLA8;
+
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ return MESA_FORMAT_SRGB_DXT1;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ return MESA_FORMAT_SRGBA_DXT1;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ return MESA_FORMAT_SRGBA_DXT3;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ return MESA_FORMAT_SRGBA_DXT5;
+
+ default:
+ _mesa_problem(ctx,
+ "unexpected internalFormat 0x%x in %s",
+ (int)internalFormat, __func__);
+ return MESA_FORMAT_NONE;
+ }
+
+ return MESA_FORMAT_NONE; /* never get here */
+}
+
+/** Check if given image is valid within current texture object.
+ */
+static void teximage_assign_miptree(radeonContextPtr rmesa,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ radeonTexObj *t = radeon_tex_obj(texObj);
+ radeon_texture_image* image = get_radeon_texture_image(texImage);
+
+ /* Try using current miptree, or create new if there isn't any */
+ if (!t->mt || !radeon_miptree_matches_image(t->mt, texImage)) {
+ radeon_miptree_unreference(&t->mt);
+ t->mt = radeon_miptree_create_for_teximage(rmesa,
+ texObj,
+ texImage);
+
+ radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
+ "%s: texObj %p, texImage %p, "
+ "texObj miptree doesn't match, allocated new miptree %p\n",
+ __FUNCTION__, texObj, texImage, t->mt);
+ }
+
+ /* Miptree alocation may have failed,
+ * when there was no image for baselevel specified */
+ if (t->mt) {
+ radeon_miptree_reference(t->mt, &image->mt);
+ } else
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
+ "%s Failed to allocate miptree.\n", __func__);
+}
+
+unsigned radeonIsFormatRenderable(gl_format mesa_format)
+{
+ if (mesa_format == _radeon_texformat_argb8888 || mesa_format == _radeon_texformat_rgb565 ||
+ mesa_format == _radeon_texformat_argb1555 || mesa_format == _radeon_texformat_argb4444)
+ return 1;
+
+ switch (mesa_format)
+ {
+ case MESA_FORMAT_Z16:
+ case MESA_FORMAT_S8_Z24:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#if FEATURE_OES_EGL_image
+void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ radeonTexObj *t = radeon_tex_obj(texObj);
+ radeon_texture_image *radeonImage = get_radeon_texture_image(texImage);
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = radeon->dri.screen;
+ image = screen->dri2.image->lookupEGLImage(screen, image_handle,
+ screen->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ radeonFreeTextureImageBuffer(ctx, texImage);
+
+ texImage->Width = image->width;
+ texImage->Height = image->height;
+ texImage->Depth = 1;
+ texImage->_BaseFormat = GL_RGBA;
+ texImage->TexFormat = image->format;
+ radeonImage->base.RowStride = image->pitch;
+ texImage->InternalFormat = image->internal_format;
+
+ if(t->mt)
+ {
+ radeon_miptree_unreference(&t->mt);
+ t->mt = NULL;
+ }
+
+ /* NOTE: The following is *very* ugly and will probably break. But
+ I don't know how to deal with it, without creating a whole new
+ function like radeon_miptree_from_bo() so I'm going with the
+ easy but error-prone way. */
+
+ radeon_try_alloc_miptree(radeon, t);
+
+ radeon_miptree_reference(t->mt, &radeonImage->mt);
+
+ if (t->mt == NULL)
+ {
+ radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
+ "%s Failed to allocate miptree.\n", __func__);
+ return;
+ }
+
+ /* Particularly ugly: this is guaranteed to break, if image->bo is
+ not of the required size for a miptree. */
+ radeon_bo_unref(t->mt->bo);
+ radeon_bo_ref(image->bo);
+ t->mt->bo = image->bo;
+
+ if (!radeon_miptree_matches_image(t->mt, &radeonImage->base.Base))
+ fprintf(stderr, "miptree doesn't match image\n");
+}
+#endif
+
+gl_format _radeon_texformat_rgba8888 = MESA_FORMAT_NONE;
+gl_format _radeon_texformat_argb8888 = MESA_FORMAT_NONE;
+gl_format _radeon_texformat_rgb565 = MESA_FORMAT_NONE;
+gl_format _radeon_texformat_argb4444 = MESA_FORMAT_NONE;
+gl_format _radeon_texformat_argb1555 = MESA_FORMAT_NONE;
+gl_format _radeon_texformat_al88 = MESA_FORMAT_NONE;
+/*@}*/
+
+
+static void
+radeonInitTextureFormats(void)
+{
+ if (_mesa_little_endian()) {
+ _radeon_texformat_rgba8888 = MESA_FORMAT_RGBA8888;
+ _radeon_texformat_argb8888 = MESA_FORMAT_ARGB8888;
+ _radeon_texformat_rgb565 = MESA_FORMAT_RGB565;
+ _radeon_texformat_argb4444 = MESA_FORMAT_ARGB4444;
+ _radeon_texformat_argb1555 = MESA_FORMAT_ARGB1555;
+ _radeon_texformat_al88 = MESA_FORMAT_AL88;
+ }
+ else {
+ _radeon_texformat_rgba8888 = MESA_FORMAT_RGBA8888_REV;
+ _radeon_texformat_argb8888 = MESA_FORMAT_ARGB8888_REV;
+ _radeon_texformat_rgb565 = MESA_FORMAT_RGB565_REV;
+ _radeon_texformat_argb4444 = MESA_FORMAT_ARGB4444_REV;
+ _radeon_texformat_argb1555 = MESA_FORMAT_ARGB1555_REV;
+ _radeon_texformat_al88 = MESA_FORMAT_AL88_REV;
+ }
+}
+
+void
+radeon_init_common_texture_funcs(radeonContextPtr radeon,
+ struct dd_function_table *functions)
+{
+ functions->NewTextureImage = radeonNewTextureImage;
+ functions->DeleteTextureImage = radeonDeleteTextureImage;
+ functions->AllocTextureImageBuffer = radeonAllocTextureImageBuffer;
+ functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
+ functions->MapTextureImage = radeon_map_texture_image;
+ functions->UnmapTextureImage = radeon_unmap_texture_image;
+
+ functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
+
+ functions->CopyTexSubImage = radeonCopyTexSubImage;
+
+ functions->Bitmap = _mesa_meta_Bitmap;
+#if FEATURE_OES_EGL_image
+ functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d;
+#endif
+
+ radeonInitTextureFormats();
+}
+
+static void
+radeon_swrast_map_image(radeonContextPtr rmesa,
+ radeon_texture_image *image)
+{
+ GLuint level, face;
+ radeon_mipmap_tree *mt;
+ GLuint texel_size;
+ radeon_mipmap_level *lvl;
+ int rs;
+
+ if (!image || !image->mt)
+ return;
+
+ texel_size = _mesa_get_format_bytes(image->base.Base.TexFormat);
+ level = image->base.Base.Level;
+ face = image->base.Base.Face;
+ mt = image->mt;
+
+ lvl = &image->mt->levels[level];
+
+ rs = lvl->rowstride / texel_size;
+
+ radeon_bo_map(mt->bo, 1);
+
+ image->base.Map = mt->bo->ptr + lvl->faces[face].offset;
+ if (mt->target == GL_TEXTURE_3D) {
+ int i;
+
+ for (i = 0; i < mt->levels[level].depth; i++)
+ image->base.ImageOffsets[i] = rs * lvl->height * i;
+ }
+ image->base.RowStride = rs;
+}
+
+static void
+radeon_swrast_unmap_image(radeonContextPtr rmesa,
+ radeon_texture_image *image)
+{
+ if (image && image->mt) {
+ image->base.Map = NULL;
+ radeon_bo_unmap(image->mt->bo);
+ }
+}
+
+void
+radeon_swrast_map_texture_images(struct gl_context *ctx,
+ struct gl_texture_object *texObj)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint nr_faces = _mesa_num_tex_faces(texObj->Target);
+ int i, face;
+
+ for (i = texObj->BaseLevel; i <= texObj->_MaxLevel; i++) {
+ for (face = 0; face < nr_faces; face++) {
+ radeon_texture_image *image = get_radeon_texture_image(texObj->Image[face][i]);
+ radeon_swrast_map_image(rmesa, image);
+ }
+ }
+}
+
+void
+radeon_swrast_unmap_texture_images(struct gl_context *ctx,
+ struct gl_texture_object *texObj)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint nr_faces = _mesa_num_tex_faces(texObj->Target);
+ int i, face;
+
+ for (i = texObj->BaseLevel; i <= texObj->_MaxLevel; i++) {
+ for (face = 0; face < nr_faces; face++) {
+ radeon_texture_image *image = get_radeon_texture_image(texObj->Image[face][i]);
+ radeon_swrast_unmap_image(rmesa, image);
+ }
+ }
+
+}
+
+static radeon_mipmap_tree *radeon_miptree_create_for_teximage(radeonContextPtr rmesa,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ radeonTexObj *t = radeon_tex_obj(texObj);
+ GLuint firstLevel;
+ GLuint lastLevel;
+ int width, height, depth;
+ int i;
+
+ width = texImage->Width;
+ height = texImage->Height;
+ depth = texImage->Depth;
+
+ if (texImage->Level > texObj->BaseLevel &&
+ (width == 1 ||
+ (texObj->Target != GL_TEXTURE_1D && height == 1) ||
+ (texObj->Target == GL_TEXTURE_3D && depth == 1))) {
+ /* For this combination, we're at some lower mipmap level and
+ * some important dimension is 1. We can't extrapolate up to a
+ * likely base level width/height/depth for a full mipmap stack
+ * from this info, so just allocate this one level.
+ */
+ firstLevel = texImage->Level;
+ lastLevel = texImage->Level;
+ } else {
+ if (texImage->Level < texObj->BaseLevel)
+ firstLevel = 0;
+ else
+ firstLevel = texObj->BaseLevel;
+
+ for (i = texImage->Level; i > firstLevel; i--) {
+ width <<= 1;
+ if (height != 1)
+ height <<= 1;
+ if (depth != 1)
+ depth <<= 1;
+ }
+ if ((texObj->Sampler.MinFilter == GL_NEAREST ||
+ texObj->Sampler.MinFilter == GL_LINEAR) &&
+ texImage->Level == firstLevel) {
+ lastLevel = firstLevel;
+ } else {
+ lastLevel = firstLevel + _mesa_logbase2(MAX2(MAX2(width, height), depth));
+ }
+ }
+
+ return radeon_miptree_create(rmesa, texObj->Target,
+ texImage->TexFormat, firstLevel, lastLevel - firstLevel + 1,
+ width, height, depth,
+ t->tile_bits);
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.h
index 17fac3d5ea5..88aace840bb 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_texture.h
@@ -1 +1,91 @@
-../radeon/radeon_texture.h \ No newline at end of file
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+ *
+ * The Weather Channel (TM) funded Tungsten Graphics to develop the
+ * initial release of the Radeon 8500 driver under the XFree86 license.
+ * This notice must be preserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef RADEON_TEXTURE_H
+#define RADEON_TEXTURE_H
+
+#include "main/formats.h"
+#include "main/mfeatures.h"
+
+extern gl_format _radeon_texformat_rgba8888;
+extern gl_format _radeon_texformat_argb8888;
+extern gl_format _radeon_texformat_rgb565;
+extern gl_format _radeon_texformat_argb4444;
+extern gl_format _radeon_texformat_argb1555;
+extern gl_format _radeon_texformat_al88;
+
+extern
+void copy_rows(void* dst, GLuint dststride, const void* src, GLuint srcstride,
+ GLuint numrows, GLuint rowsize);
+struct gl_texture_image *radeonNewTextureImage(struct gl_context *ctx);
+void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_image *timage);
+
+void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable);
+void radeon_teximage_unmap(radeon_texture_image *image);
+int radeon_validate_texture_miptree(struct gl_context * ctx,
+ struct gl_sampler_object *samp,
+ struct gl_texture_object *texObj);
+
+
+void radeon_swrast_map_texture_images(struct gl_context *ctx, struct gl_texture_object *texObj);
+void radeon_swrast_unmap_texture_images(struct gl_context *ctx, struct gl_texture_object *texObj);
+
+gl_format radeonChooseTextureFormat_mesa(struct gl_context * ctx,
+ GLenum target,
+ GLint internalFormat,
+ GLenum format,
+ GLenum type);
+
+gl_format radeonChooseTextureFormat(struct gl_context * ctx,
+ GLint internalFormat,
+ GLenum format,
+ GLenum type, GLboolean fbo);
+
+void radeonCopyTexSubImage(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height);
+
+unsigned radeonIsFormatRenderable(gl_format mesa_format);
+
+#if FEATURE_OES_EGL_image
+void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle);
+#endif
+
+void
+radeon_init_common_texture_funcs(radeonContextPtr radeon,
+ struct dd_function_table *functions);
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.c b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.c
index d4bfe27da64..403da110106 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.c
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.c
@@ -1 +1,512 @@
-../radeon/radeon_tile.c \ No newline at end of file
+/*
+ * Copyright (C) 2010 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_tile.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "main/macros.h"
+#include "radeon_debug.h"
+
+#define MICRO_TILE_SIZE 32
+
+static void micro_tile_8_x_4_8bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 8, tile_height = 4;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint8_t *src2 = (uint8_t *)src + src_pitch * row + col;
+ uint8_t *dst2 = (uint8_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint8_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint8_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_4_x_4_16bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 4, tile_height = 4;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint16_t *src2 = (uint16_t *)src + src_pitch * row + col;
+ uint16_t *dst2 = (uint16_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint16_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_8_x_2_16bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 8, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint16_t *src2 = (uint16_t *)src + src_pitch * row + col;
+ uint16_t *dst2 = (uint16_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint16_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_4_x_2_32bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 4, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint32_t *src2 = (uint32_t *)src + src_pitch * row + col;
+ uint32_t *dst2 = (uint32_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint32_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint32_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_2_x_2_64bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 2, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint64_t *src2 = (uint64_t *)src + src_pitch * row + col;
+ uint64_t *dst2 = (uint64_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint64_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint64_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_1_x_1_128bit(const void * src, unsigned src_pitch,
+ void * dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned i, j;
+ const unsigned elem_size = 16; /* sizeof(uint128_t) */
+
+ for (j = 0; j < height; ++j)
+ {
+ for (i = 0; i < width; ++i)
+ {
+ memcpy(dst, src, width * elem_size);
+ dst += dst_pitch * elem_size;
+ src += src_pitch * elem_size;
+ }
+ }
+}
+
+void tile_image(const void * src, unsigned src_pitch,
+ void *dst, unsigned dst_pitch,
+ gl_format format, unsigned width, unsigned height)
+{
+ assert(src_pitch >= width);
+ assert(dst_pitch >= width);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "Software tiling: src_pitch %d, dst_pitch %d, width %d, height %d, bpp %d\n",
+ src_pitch, dst_pitch, width, height, _mesa_get_format_bytes(format));
+
+ switch (_mesa_get_format_bytes(format))
+ {
+ case 16:
+ micro_tile_1_x_1_128bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 8:
+ micro_tile_2_x_2_64bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 4:
+ micro_tile_4_x_2_32bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 2:
+ if (_mesa_get_format_bits(format, GL_DEPTH_BITS))
+ {
+ micro_tile_4_x_4_16bit(src, src_pitch, dst, dst_pitch, width, height);
+ }
+ else
+ {
+ micro_tile_8_x_2_16bit(src, src_pitch, dst, dst_pitch, width, height);
+ }
+ break;
+ case 1:
+ micro_tile_8_x_4_8bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+static void micro_untile_8_x_4_8bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current destination row */
+ unsigned col; /* current destination column */
+ unsigned k; /* current tile number */
+ const unsigned tile_width = 8, tile_height = 4;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ assert(src_pitch % tile_width == 0);
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint8_t *src2 = (uint8_t *)src + row * src_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint8_t);
+ uint8_t *dst2 = (uint8_t *)dst + dst_pitch * row + col;
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint8_t));
+ dst2 += dst_pitch;
+ src2 += tile_width;
+ }
+ }
+ }
+}
+
+static void micro_untile_8_x_2_16bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current destination row */
+ unsigned col; /* current destination column */
+ unsigned k; /* current tile number */
+ const unsigned tile_width = 8, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ assert(src_pitch % tile_width == 0);
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint16_t *src2 = (uint16_t *)src + row * src_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t);
+ uint16_t *dst2 = (uint16_t *)dst + dst_pitch * row + col;
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint16_t));
+ dst2 += dst_pitch;
+ src2 += tile_width;
+ }
+ }
+ }
+}
+
+static void micro_untile_4_x_4_16bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current destination row */
+ unsigned col; /* current destination column */
+ unsigned k; /* current tile number */
+ const unsigned tile_width = 4, tile_height = 4;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ assert(src_pitch % tile_width == 0);
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint16_t *src2 = (uint16_t *)src + row * src_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t);
+ uint16_t *dst2 = (uint16_t *)dst + dst_pitch * row + col;
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint16_t));
+ dst2 += dst_pitch;
+ src2 += tile_width;
+ }
+ }
+ }
+}
+
+static void micro_untile_4_x_2_32bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current destination row */
+ unsigned col; /* current destination column */
+ unsigned k; /* current tile number */
+ const unsigned tile_width = 4, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ assert(src_pitch % tile_width == 0);
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint32_t *src2 = (uint32_t *)src + row * src_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint32_t);
+ uint32_t *dst2 = (uint32_t *)dst + dst_pitch * row + col;
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint32_t));
+ dst2 += dst_pitch;
+ src2 += tile_width;
+ }
+ }
+ }
+}
+
+static void micro_untile_2_x_2_64bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current destination row */
+ unsigned col; /* current destination column */
+ unsigned k; /* current tile number */
+ const unsigned tile_width = 2, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ assert(src_pitch % tile_width == 0);
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint64_t *src2 = (uint64_t *)src + row * src_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint64_t);
+ uint64_t *dst2 = (uint64_t *)dst + dst_pitch * row + col;
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint64_t));
+ dst2 += dst_pitch;
+ src2 += tile_width;
+ }
+ }
+ }
+}
+
+static void micro_untile_1_x_1_128bit(const void * src, unsigned src_pitch,
+ void * dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned i, j;
+ const unsigned elem_size = 16; /* sizeof(uint128_t) */
+
+ for (j = 0; j < height; ++j)
+ {
+ for (i = 0; i < width; ++i)
+ {
+ memcpy(dst, src, width * elem_size);
+ dst += dst_pitch * elem_size;
+ src += src_pitch * elem_size;
+ }
+ }
+}
+
+void untile_image(const void * src, unsigned src_pitch,
+ void *dst, unsigned dst_pitch,
+ gl_format format, unsigned width, unsigned height)
+{
+ assert(src_pitch >= width);
+ assert(dst_pitch >= width);
+
+ radeon_print(RADEON_TEXTURE, RADEON_TRACE,
+ "Software untiling: src_pitch %d, dst_pitch %d, width %d, height %d, bpp %d\n",
+ src_pitch, dst_pitch, width, height, _mesa_get_format_bytes(format));
+
+ switch (_mesa_get_format_bytes(format))
+ {
+ case 16:
+ micro_untile_1_x_1_128bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 8:
+ micro_untile_2_x_2_64bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 4:
+ micro_untile_4_x_2_32bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 2:
+ if (_mesa_get_format_bits(format, GL_DEPTH_BITS))
+ {
+ micro_untile_4_x_4_16bit(src, src_pitch, dst, dst_pitch, width, height);
+ }
+ else
+ {
+ micro_untile_8_x_2_16bit(src, src_pitch, dst, dst_pitch, width, height);
+ }
+ break;
+ case 1:
+ micro_untile_8_x_4_8bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+void get_tile_size(gl_format format, unsigned *block_width, unsigned *block_height)
+{
+ switch (_mesa_get_format_bytes(format))
+ {
+ case 16:
+ *block_width = 1;
+ *block_height = 1;
+ break;
+ case 8:
+ *block_width = 2;
+ *block_height = 2;
+ break;
+ case 4:
+ *block_width = 4;
+ *block_height = 2;
+ break;
+ case 2:
+ if (_mesa_get_format_bits(format, GL_DEPTH_BITS))
+ {
+ *block_width = 4;
+ *block_height = 4;
+ }
+ else
+ {
+ *block_width = 8;
+ *block_height = 2;
+ }
+ break;
+ case 1:
+ *block_width = 8;
+ *block_height = 4;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.h
index 31074c581ea..31d9c5611c3 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/radeon_tile.h
@@ -1 +1,38 @@
-../radeon/radeon_tile.h \ No newline at end of file
+/*
+ * Copyright (C) 2010 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <main/formats.h>
+
+void tile_image(const void * src, unsigned src_pitch,
+ void *dst, unsigned dst_pitch,
+ gl_format format, unsigned width, unsigned height);
+
+void untile_image(const void * src, unsigned src_pitch,
+ void *dst, unsigned dst_pitch,
+ gl_format format, unsigned width, unsigned height);
+
+void get_tile_size(gl_format format, unsigned *block_width, unsigned *block_height);
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_dri.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_dri.h
index 27c591d3c9d..dc513721075 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_dri.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_dri.h
@@ -1 +1,115 @@
-../../radeon/server/radeon_dri.h \ No newline at end of file
+/**
+ * \file server/radeon_dri.h
+ * \brief Radeon server-side structures.
+ *
+ * \author Kevin E. Martin <martin@xfree86.org>
+ * \author Rickard E. Faith <faith@valinux.com>
+ */
+
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario,
+ * VA Linux Systems Inc., Fremont, California.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
+ * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _RADEON_DRI_
+#define _RADEON_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "radeon_drm.h"
+
+/* DRI Driver defaults */
+#define RADEON_DEFAULT_CP_PIO_MODE RADEON_CSQ_PRIPIO_INDPIO
+#define RADEON_DEFAULT_CP_BM_MODE RADEON_CSQ_PRIBM_INDBM
+#define RADEON_DEFAULT_AGP_MODE 1
+#define RADEON_DEFAULT_AGP_FAST_WRITE 0
+#define RADEON_DEFAULT_AGP_SIZE 8 /* MB (must be 2^n and > 4MB) */
+#define RADEON_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */
+#define RADEON_DEFAULT_BUFFER_SIZE 2 /* MB (must be page aligned) */
+#define RADEON_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */
+#define RADEON_DEFAULT_CP_TIMEOUT 10000 /* usecs */
+#define RADEON_DEFAULT_PAGE_FLIP 0 /* page flipping diabled */
+#define RADEON_BUFFER_ALIGN 0x00000fff
+
+/**
+ * \brief Radeon DRI driver private data.
+ */
+typedef struct {
+ /**
+ * \name DRI screen private data
+ */
+ /*@{*/
+ int deviceID; /**< \brief PCI device ID */
+ int width; /**< \brief width in pixels of display */
+ int height; /**< \brief height in scanlines of display */
+ int depth; /**< \brief depth of display (8, 15, 16, 24) */
+ int bpp; /**< \brief bit depth of display (8, 16, 24, 32) */
+
+ int IsPCI; /**< \brief is current card a PCI card? */
+ int AGPMode; /**< \brief AGP mode */
+
+ int frontOffset; /**< \brief front buffer offset */
+ int frontPitch; /**< \brief front buffer pitch */
+ int backOffset; /**< \brief shared back buffer offset */
+ int backPitch; /**< \brief shared back buffer pitch */
+ int depthOffset; /**< \brief shared depth buffer offset */
+ int depthPitch; /**< \brief shared depth buffer pitch */
+ int textureOffset; /**< \brief start of texture data in frame buffer */
+ int textureSize; /**< \brief size of texture date */
+ int log2TexGran; /**< \brief log2 texture granularity */
+ /*@}*/
+
+ /**
+ * \name MMIO register data
+ */
+ /*@{*/
+ drm_handle_t registerHandle; /**< \brief MMIO register map size */
+ drmSize registerSize; /**< \brief MMIO register map handle */
+ /*@}*/
+
+ /**
+ * \name CP in-memory status information
+ */
+ /*@{*/
+ drm_handle_t statusHandle; /**< \brief status map handle */
+ drmSize statusSize; /**< \brief status map size */
+ /*@}*/
+
+ /**
+ * \name CP AGP Texture data
+ */
+ /*@{*/
+ drm_handle_t gartTexHandle; /**< \brief AGP texture area map handle */
+ drmSize gartTexMapSize; /**< \brief AGP texture area map size */
+ int log2GARTTexGran; /**< \brief AGP texture granularity in log base 2 */
+ int gartTexOffset; /**< \brief AGP texture area offset in AGP space */
+ /*@}*/
+
+ unsigned int sarea_priv_offset; /**< \brief offset of the private SAREA data*/
+} RADEONDRIRec, *RADEONDRIPtr;
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_macros.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_macros.h
index c56cd735b83..355262c9bab 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_macros.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_macros.h
@@ -1 +1,128 @@
-../../radeon/server/radeon_macros.h \ No newline at end of file
+/**
+ * \file server/radeon_macros.h
+ * \brief Macros for Radeon MMIO operation.
+ *
+ * \authors Kevin E. Martin <martin@xfree86.org>
+ * \authors Rickard E. Faith <faith@valinux.com>
+ * \authors Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
+ * VA Linux Systems Inc., Fremont, California.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
+ * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _RADEON_MACROS_H_
+#define _RADEON_MACROS_H_
+
+#include <mmio.h>
+
+# define MMIO_IN8(base, offset) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ read_MMIO_LE32(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = CPU_TO_LE32(val)
+
+
+ /* Memory mapped register access macros */
+#define INREG8(addr) MMIO_IN8(RADEONMMIO, addr)
+#define INREG(addr) MMIO_IN32(RADEONMMIO, addr)
+#define OUTREG8(addr, val) MMIO_OUT8(RADEONMMIO, addr, val)
+#define OUTREG(addr, val) MMIO_OUT32(RADEONMMIO, addr, val)
+
+#define ADDRREG(addr) ((volatile GLuint *)(pointer)(RADEONMMIO + (addr)))
+
+
+#define OUTREGP(addr, val, mask) \
+do { \
+ GLuint tmp = INREG(addr); \
+ tmp &= (mask); \
+ tmp |= (val); \
+ OUTREG(addr, tmp); \
+} while (0)
+
+#define INPLL(dpy, addr) RADEONINPLL(dpy, addr)
+
+#define OUTPLL(addr, val) \
+do { \
+ OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \
+ RADEON_PLL_WR_EN)); \
+ OUTREG(RADEON_CLOCK_CNTL_DATA, val); \
+} while (0)
+
+#define OUTPLLP(dpy, addr, val, mask) \
+do { \
+ GLuint tmp = INPLL(dpy, addr); \
+ tmp &= (mask); \
+ tmp |= (val); \
+ OUTPLL(addr, tmp); \
+} while (0)
+
+#define OUTPAL_START(idx) \
+do { \
+ OUTREG8(RADEON_PALETTE_INDEX, (idx)); \
+} while (0)
+
+#define OUTPAL_NEXT(r, g, b) \
+do { \
+ OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \
+} while (0)
+
+#define OUTPAL_NEXT_CARD32(v) \
+do { \
+ OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \
+} while (0)
+
+#define OUTPAL(idx, r, g, b) \
+do { \
+ OUTPAL_START((idx)); \
+ OUTPAL_NEXT((r), (g), (b)); \
+} while (0)
+
+#define INPAL_START(idx) \
+do { \
+ OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \
+} while (0)
+
+#define INPAL_NEXT() INREG(RADEON_PALETTE_DATA)
+
+#define PAL_SELECT(idx) \
+do { \
+ if (!idx) { \
+ OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) & \
+ (GLuint)~RADEON_DAC2_PALETTE_ACC_CTL); \
+ } else { \
+ OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) | \
+ RADEON_DAC2_PALETTE_ACC_CTL); \
+ } \
+} while (0)
+
+
+#endif
diff --git a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_reg.h b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_reg.h
index e2349dcb685..7ba5b38c4cb 120000..100644
--- a/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_reg.h
+++ b/chromium/third_party/mesa/src/src/mesa/drivers/dri/r200/server/radeon_reg.h
@@ -1 +1,2163 @@
-../../radeon/server/radeon_reg.h \ No newline at end of file
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
+ * VA Linux Systems Inc., Fremont, California.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
+ * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@xfree86.org>
+ * Rickard E. Faith <faith@valinux.com>
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ *
+ * References:
+ *
+ * !!!! FIXME !!!!
+ * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical
+ * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April
+ * 1999.
+ *
+ * !!!! FIXME !!!!
+ * RAGE 128 Software Development Manual (Technical Reference Manual P/N
+ * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999.
+ *
+ */
+
+/* !!!! FIXME !!!! NOTE: THIS FILE HAS BEEN CONVERTED FROM r128_reg.h
+ * AND CONTAINS REGISTERS AND REGISTER DEFINITIONS THAT ARE NOT CORRECT
+ * ON THE RADEON. A FULL AUDIT OF THIS CODE IS NEEDED! */
+
+#ifndef _RADEON_REG_H_
+#define _RADEON_REG_H_
+
+ /* Registers for 2D/Video/Overlay */
+#define RADEON_ADAPTER_ID 0x0f2c /* PCI */
+#define RADEON_AGP_BASE 0x0170
+#define RADEON_AGP_CNTL 0x0174
+# define RADEON_AGP_APER_SIZE_256MB (0x00 << 0)
+# define RADEON_AGP_APER_SIZE_128MB (0x20 << 0)
+# define RADEON_AGP_APER_SIZE_64MB (0x30 << 0)
+# define RADEON_AGP_APER_SIZE_32MB (0x38 << 0)
+# define RADEON_AGP_APER_SIZE_16MB (0x3c << 0)
+# define RADEON_AGP_APER_SIZE_8MB (0x3e << 0)
+# define RADEON_AGP_APER_SIZE_4MB (0x3f << 0)
+# define RADEON_AGP_APER_SIZE_MASK (0x3f << 0)
+#define RADEON_AGP_COMMAND 0x0f60 /* PCI */
+#define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config*/
+# define RADEON_AGP_ENABLE (1<<8)
+#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */
+#define RADEON_AGP_STATUS 0x0f5c /* PCI */
+# define RADEON_AGP_1X_MODE 0x01
+# define RADEON_AGP_2X_MODE 0x02
+# define RADEON_AGP_4X_MODE 0x04
+# define RADEON_AGP_FW_MODE 0x10
+# define RADEON_AGP_MODE_MASK 0x17
+#define RADEON_ATTRDR 0x03c1 /* VGA */
+#define RADEON_ATTRDW 0x03c0 /* VGA */
+#define RADEON_ATTRX 0x03c0 /* VGA */
+#define RADEON_AUX_SC_CNTL 0x1660
+# define RADEON_AUX1_SC_EN (1 << 0)
+# define RADEON_AUX1_SC_MODE_OR (0 << 1)
+# define RADEON_AUX1_SC_MODE_NAND (1 << 1)
+# define RADEON_AUX2_SC_EN (1 << 2)
+# define RADEON_AUX2_SC_MODE_OR (0 << 3)
+# define RADEON_AUX2_SC_MODE_NAND (1 << 3)
+# define RADEON_AUX3_SC_EN (1 << 4)
+# define RADEON_AUX3_SC_MODE_OR (0 << 5)
+# define RADEON_AUX3_SC_MODE_NAND (1 << 5)
+#define RADEON_AUX1_SC_BOTTOM 0x1670
+#define RADEON_AUX1_SC_LEFT 0x1664
+#define RADEON_AUX1_SC_RIGHT 0x1668
+#define RADEON_AUX1_SC_TOP 0x166c
+#define RADEON_AUX2_SC_BOTTOM 0x1680
+#define RADEON_AUX2_SC_LEFT 0x1674
+#define RADEON_AUX2_SC_RIGHT 0x1678
+#define RADEON_AUX2_SC_TOP 0x167c
+#define RADEON_AUX3_SC_BOTTOM 0x1690
+#define RADEON_AUX3_SC_LEFT 0x1684
+#define RADEON_AUX3_SC_RIGHT 0x1688
+#define RADEON_AUX3_SC_TOP 0x168c
+#define RADEON_AUX_WINDOW_HORZ_CNTL 0x02d8
+#define RADEON_AUX_WINDOW_VERT_CNTL 0x02dc
+
+#define RADEON_BASE_CODE 0x0f0b
+#define RADEON_BIOS_0_SCRATCH 0x0010
+#define RADEON_BIOS_1_SCRATCH 0x0014
+#define RADEON_BIOS_2_SCRATCH 0x0018
+#define RADEON_BIOS_3_SCRATCH 0x001c
+#define RADEON_BIOS_4_SCRATCH 0x0020
+#define RADEON_BIOS_5_SCRATCH 0x0024
+#define RADEON_BIOS_6_SCRATCH 0x0028
+#define RADEON_BIOS_7_SCRATCH 0x002c
+#define RADEON_BIOS_ROM 0x0f30 /* PCI */
+#define RADEON_BIST 0x0f0f /* PCI */
+#define RADEON_BRUSH_DATA0 0x1480
+#define RADEON_BRUSH_DATA1 0x1484
+#define RADEON_BRUSH_DATA10 0x14a8
+#define RADEON_BRUSH_DATA11 0x14ac
+#define RADEON_BRUSH_DATA12 0x14b0
+#define RADEON_BRUSH_DATA13 0x14b4
+#define RADEON_BRUSH_DATA14 0x14b8
+#define RADEON_BRUSH_DATA15 0x14bc
+#define RADEON_BRUSH_DATA16 0x14c0
+#define RADEON_BRUSH_DATA17 0x14c4
+#define RADEON_BRUSH_DATA18 0x14c8
+#define RADEON_BRUSH_DATA19 0x14cc
+#define RADEON_BRUSH_DATA2 0x1488
+#define RADEON_BRUSH_DATA20 0x14d0
+#define RADEON_BRUSH_DATA21 0x14d4
+#define RADEON_BRUSH_DATA22 0x14d8
+#define RADEON_BRUSH_DATA23 0x14dc
+#define RADEON_BRUSH_DATA24 0x14e0
+#define RADEON_BRUSH_DATA25 0x14e4
+#define RADEON_BRUSH_DATA26 0x14e8
+#define RADEON_BRUSH_DATA27 0x14ec
+#define RADEON_BRUSH_DATA28 0x14f0
+#define RADEON_BRUSH_DATA29 0x14f4
+#define RADEON_BRUSH_DATA3 0x148c
+#define RADEON_BRUSH_DATA30 0x14f8
+#define RADEON_BRUSH_DATA31 0x14fc
+#define RADEON_BRUSH_DATA32 0x1500
+#define RADEON_BRUSH_DATA33 0x1504
+#define RADEON_BRUSH_DATA34 0x1508
+#define RADEON_BRUSH_DATA35 0x150c
+#define RADEON_BRUSH_DATA36 0x1510
+#define RADEON_BRUSH_DATA37 0x1514
+#define RADEON_BRUSH_DATA38 0x1518
+#define RADEON_BRUSH_DATA39 0x151c
+#define RADEON_BRUSH_DATA4 0x1490
+#define RADEON_BRUSH_DATA40 0x1520
+#define RADEON_BRUSH_DATA41 0x1524
+#define RADEON_BRUSH_DATA42 0x1528
+#define RADEON_BRUSH_DATA43 0x152c
+#define RADEON_BRUSH_DATA44 0x1530
+#define RADEON_BRUSH_DATA45 0x1534
+#define RADEON_BRUSH_DATA46 0x1538
+#define RADEON_BRUSH_DATA47 0x153c
+#define RADEON_BRUSH_DATA48 0x1540
+#define RADEON_BRUSH_DATA49 0x1544
+#define RADEON_BRUSH_DATA5 0x1494
+#define RADEON_BRUSH_DATA50 0x1548
+#define RADEON_BRUSH_DATA51 0x154c
+#define RADEON_BRUSH_DATA52 0x1550
+#define RADEON_BRUSH_DATA53 0x1554
+#define RADEON_BRUSH_DATA54 0x1558
+#define RADEON_BRUSH_DATA55 0x155c
+#define RADEON_BRUSH_DATA56 0x1560
+#define RADEON_BRUSH_DATA57 0x1564
+#define RADEON_BRUSH_DATA58 0x1568
+#define RADEON_BRUSH_DATA59 0x156c
+#define RADEON_BRUSH_DATA6 0x1498
+#define RADEON_BRUSH_DATA60 0x1570
+#define RADEON_BRUSH_DATA61 0x1574
+#define RADEON_BRUSH_DATA62 0x1578
+#define RADEON_BRUSH_DATA63 0x157c
+#define RADEON_BRUSH_DATA7 0x149c
+#define RADEON_BRUSH_DATA8 0x14a0
+#define RADEON_BRUSH_DATA9 0x14a4
+#define RADEON_BRUSH_SCALE 0x1470
+#define RADEON_BRUSH_Y_X 0x1474
+#define RADEON_BUS_CNTL 0x0030
+# define RADEON_BUS_MASTER_DIS (1 << 6)
+# define RADEON_BUS_RD_DISCARD_EN (1 << 24)
+# define RADEON_BUS_RD_ABORT_EN (1 << 25)
+# define RADEON_BUS_MSTR_DISCONNECT_EN (1 << 28)
+# define RADEON_BUS_WRT_BURST (1 << 29)
+# define RADEON_BUS_READ_BURST (1 << 30)
+#define RADEON_BUS_CNTL1 0x0034
+# define RADEON_BUS_WAIT_ON_LOCK_EN (1 << 4)
+
+#define RADEON_CACHE_CNTL 0x1724
+#define RADEON_CACHE_LINE 0x0f0c /* PCI */
+#define RADEON_CAP0_TRIG_CNTL 0x0950 /* ? */
+#define RADEON_CAP1_TRIG_CNTL 0x09c0 /* ? */
+#define RADEON_CAPABILITIES_ID 0x0f50 /* PCI */
+#define RADEON_CAPABILITIES_PTR 0x0f34 /* PCI */
+#define RADEON_CLK_PIN_CNTL 0x0001 /* PLL */
+#define RADEON_CLOCK_CNTL_DATA 0x000c
+#define RADEON_CLOCK_CNTL_INDEX 0x0008
+# define RADEON_PLL_WR_EN (1 << 7)
+# define RADEON_PLL_DIV_SEL (3 << 8)
+# define RADEON_PLL2_DIV_SEL_MASK ~(3 << 8)
+#define RADEON_CLR_CMP_CLR_3D 0x1a24
+#define RADEON_CLR_CMP_CLR_DST 0x15c8
+#define RADEON_CLR_CMP_CLR_SRC 0x15c4
+#define RADEON_CLR_CMP_CNTL 0x15c0
+# define RADEON_SRC_CMP_EQ_COLOR (4 << 0)
+# define RADEON_SRC_CMP_NEQ_COLOR (5 << 0)
+# define RADEON_CLR_CMP_SRC_SOURCE (1 << 24)
+#define RADEON_CLR_CMP_MASK 0x15cc
+# define RADEON_CLR_CMP_MSK 0xffffffff
+#define RADEON_CLR_CMP_MASK_3D 0x1A28
+#define RADEON_COMMAND 0x0f04 /* PCI */
+#define RADEON_COMPOSITE_SHADOW_ID 0x1a0c
+#define RADEON_CONFIG_APER_0_BASE 0x0100
+#define RADEON_CONFIG_APER_1_BASE 0x0104
+#define RADEON_CONFIG_APER_SIZE 0x0108
+#define RADEON_CONFIG_BONDS 0x00e8
+#define RADEON_CONFIG_CNTL 0x00e0
+# define RADEON_CFG_ATI_REV_A11 (0 << 16)
+# define RADEON_CFG_ATI_REV_A12 (1 << 16)
+# define RADEON_CFG_ATI_REV_A13 (2 << 16)
+# define RADEON_CFG_ATI_REV_ID_MASK (0xf << 16)
+#define RADEON_CONFIG_MEMSIZE 0x00f8
+#define RADEON_CONFIG_MEMSIZE_EMBEDDED 0x0114
+#define RADEON_CONFIG_REG_1_BASE 0x010c
+#define RADEON_CONFIG_REG_APER_SIZE 0x0110
+#define RADEON_CONFIG_XSTRAP 0x00e4
+#define RADEON_CONSTANT_COLOR_C 0x1d34
+# define RADEON_CONSTANT_COLOR_MASK 0x00ffffff
+# define RADEON_CONSTANT_COLOR_ONE 0x00ffffff
+# define RADEON_CONSTANT_COLOR_ZERO 0x00000000
+#define RADEON_CRC_CMDFIFO_ADDR 0x0740
+#define RADEON_CRC_CMDFIFO_DOUT 0x0744
+#define RADEON_GRPH_BUFFER_CNTL 0x02f0
+# define RADEON_GRPH_START_REQ_MASK (0x7f)
+# define RADEON_GRPH_START_REQ_SHIFT 0
+# define RADEON_GRPH_STOP_REQ_MASK (0x7f<<8)
+# define RADEON_GRPH_STOP_REQ_SHIFT 8
+# define RADEON_GRPH_CRITICAL_POINT_MASK (0x7f<<16)
+# define RADEON_GRPH_CRITICAL_POINT_SHIFT 16
+# define RADEON_GRPH_CRITICAL_CNTL (1<<28)
+# define RADEON_GRPH_BUFFER_SIZE (1<<29)
+# define RADEON_GRPH_CRITICAL_AT_SOF (1<<30)
+# define RADEON_GRPH_STOP_CNTL (1<<31)
+#define RADEON_GRPH2_BUFFER_CNTL 0x03f0
+# define RADEON_GRPH2_START_REQ_MASK (0x7f)
+# define RADEON_GRPH2_START_REQ_SHIFT 0
+# define RADEON_GRPH2_STOP_REQ_MASK (0x7f<<8)
+# define RADEON_GRPH2_STOP_REQ_SHIFT 8
+# define RADEON_GRPH2_CRITICAL_POINT_MASK (0x7f<<16)
+# define RADEON_GRPH2_CRITICAL_POINT_SHIFT 16
+# define RADEON_GRPH2_CRITICAL_CNTL (1<<28)
+# define RADEON_GRPH2_BUFFER_SIZE (1<<29)
+# define RADEON_GRPH2_CRITICAL_AT_SOF (1<<30)
+# define RADEON_GRPH2_STOP_CNTL (1<<31)
+#define RADEON_CRTC_CRNT_FRAME 0x0214
+#define RADEON_CRTC_EXT_CNTL 0x0054
+# define RADEON_CRTC_VGA_XOVERSCAN (1 << 0)
+# define RADEON_VGA_ATI_LINEAR (1 << 3)
+# define RADEON_XCRT_CNT_EN (1 << 6)
+# define RADEON_CRTC_HSYNC_DIS (1 << 8)
+# define RADEON_CRTC_VSYNC_DIS (1 << 9)
+# define RADEON_CRTC_DISPLAY_DIS (1 << 10)
+# define RADEON_CRTC_SYNC_TRISTAT (1 << 11)
+# define RADEON_CRTC_CRT_ON (1 << 15)
+#define RADEON_CRTC_EXT_CNTL_DPMS_BYTE 0x0055
+# define RADEON_CRTC_HSYNC_DIS_BYTE (1 << 0)
+# define RADEON_CRTC_VSYNC_DIS_BYTE (1 << 1)
+# define RADEON_CRTC_DISPLAY_DIS_BYTE (1 << 2)
+#define RADEON_CRTC_GEN_CNTL 0x0050
+# define RADEON_CRTC_DBL_SCAN_EN (1 << 0)
+# define RADEON_CRTC_INTERLACE_EN (1 << 1)
+# define RADEON_CRTC_CSYNC_EN (1 << 4)
+# define RADEON_CRTC_CUR_EN (1 << 16)
+# define RADEON_CRTC_CUR_MODE_MASK (7 << 17)
+# define RADEON_CRTC_ICON_EN (1 << 20)
+# define RADEON_CRTC_EXT_DISP_EN (1 << 24)
+# define RADEON_CRTC_EN (1 << 25)
+# define RADEON_CRTC_DISP_REQ_EN_B (1 << 26)
+#define RADEON_CRTC2_GEN_CNTL 0x03f8
+# define RADEON_CRTC2_DBL_SCAN_EN (1 << 0)
+# define RADEON_CRTC2_INTERLACE_EN (1 << 1)
+# define RADEON_CRTC2_SYNC_TRISTAT (1 << 4)
+# define RADEON_CRTC2_HSYNC_TRISTAT (1 << 5)
+# define RADEON_CRTC2_VSYNC_TRISTAT (1 << 6)
+# define RADEON_CRTC2_CRT2_ON (1 << 7)
+# define RADEON_CRTC2_ICON_EN (1 << 15)
+# define RADEON_CRTC2_CUR_EN (1 << 16)
+# define RADEON_CRTC2_CUR_MODE_MASK (7 << 20)
+# define RADEON_CRTC2_DISP_DIS (1 << 23)
+# define RADEON_CRTC2_EN (1 << 25)
+# define RADEON_CRTC2_DISP_REQ_EN_B (1 << 26)
+# define RADEON_CRTC2_CSYNC_EN (1 << 27)
+# define RADEON_CRTC2_HSYNC_DIS (1 << 28)
+# define RADEON_CRTC2_VSYNC_DIS (1 << 29)
+#define RADEON_CRTC_MORE_CNTL 0x27c
+# define RADEON_CRTC_H_CUTOFF_ACTIVE_EN (1<<4)
+# define RADEON_CRTC_V_CUTOFF_ACTIVE_EN (1<<5)
+#define RADEON_CRTC_GUI_TRIG_VLINE 0x0218
+#define RADEON_CRTC_H_SYNC_STRT_WID 0x0204
+# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0)
+# define RADEON_CRTC_H_SYNC_STRT_CHAR (0x3ff << 3)
+# define RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT 3
+# define RADEON_CRTC_H_SYNC_WID (0x3f << 16)
+# define RADEON_CRTC_H_SYNC_WID_SHIFT 16
+# define RADEON_CRTC_H_SYNC_POL (1 << 23)
+#define RADEON_CRTC2_H_SYNC_STRT_WID 0x0304
+# define RADEON_CRTC2_H_SYNC_STRT_PIX (0x07 << 0)
+# define RADEON_CRTC2_H_SYNC_STRT_CHAR (0x3ff << 3)
+# define RADEON_CRTC2_H_SYNC_STRT_CHAR_SHIFT 3
+# define RADEON_CRTC2_H_SYNC_WID (0x3f << 16)
+# define RADEON_CRTC2_H_SYNC_WID_SHIFT 16
+# define RADEON_CRTC2_H_SYNC_POL (1 << 23)
+#define RADEON_CRTC_H_TOTAL_DISP 0x0200
+# define RADEON_CRTC_H_TOTAL (0x03ff << 0)
+# define RADEON_CRTC_H_TOTAL_SHIFT 0
+# define RADEON_CRTC_H_DISP (0x01ff << 16)
+# define RADEON_CRTC_H_DISP_SHIFT 16
+#define RADEON_CRTC2_H_TOTAL_DISP 0x0300
+# define RADEON_CRTC2_H_TOTAL (0x03ff << 0)
+# define RADEON_CRTC2_H_TOTAL_SHIFT 0
+# define RADEON_CRTC2_H_DISP (0x01ff << 16)
+# define RADEON_CRTC2_H_DISP_SHIFT 16
+#define RADEON_CRTC_OFFSET 0x0224
+#define RADEON_CRTC2_OFFSET 0x0324
+#define RADEON_CRTC_OFFSET_CNTL 0x0228
+# define RADEON_CRTC_TILE_EN (1 << 15)
+#define RADEON_CRTC2_OFFSET_CNTL 0x0328
+# define RADEON_CRTC2_TILE_EN (1 << 15)
+#define RADEON_CRTC_PITCH 0x022c
+#define RADEON_CRTC2_PITCH 0x032c
+#define RADEON_CRTC_STATUS 0x005c
+# define RADEON_CRTC_VBLANK_SAVE (1 << 1)
+# define RADEON_CRTC_VBLANK_SAVE_CLEAR (1 << 1)
+#define RADEON_CRTC2_STATUS 0x03fc
+# define RADEON_CRTC2_VBLANK_SAVE (1 << 1)
+# define RADEON_CRTC2_VBLANK_SAVE_CLEAR (1 << 1)
+#define RADEON_CRTC_V_SYNC_STRT_WID 0x020c
+# define RADEON_CRTC_V_SYNC_STRT (0x7ff << 0)
+# define RADEON_CRTC_V_SYNC_STRT_SHIFT 0
+# define RADEON_CRTC_V_SYNC_WID (0x1f << 16)
+# define RADEON_CRTC_V_SYNC_WID_SHIFT 16
+# define RADEON_CRTC_V_SYNC_POL (1 << 23)
+#define RADEON_CRTC2_V_SYNC_STRT_WID 0x030c
+# define RADEON_CRTC2_V_SYNC_STRT (0x7ff << 0)
+# define RADEON_CRTC2_V_SYNC_STRT_SHIFT 0
+# define RADEON_CRTC2_V_SYNC_WID (0x1f << 16)
+# define RADEON_CRTC2_V_SYNC_WID_SHIFT 16
+# define RADEON_CRTC2_V_SYNC_POL (1 << 23)
+#define RADEON_CRTC_V_TOTAL_DISP 0x0208
+# define RADEON_CRTC_V_TOTAL (0x07ff << 0)
+# define RADEON_CRTC_V_TOTAL_SHIFT 0
+# define RADEON_CRTC_V_DISP (0x07ff << 16)
+# define RADEON_CRTC_V_DISP_SHIFT 16
+#define RADEON_CRTC2_V_TOTAL_DISP 0x0308
+# define RADEON_CRTC2_V_TOTAL (0x07ff << 0)
+# define RADEON_CRTC2_V_TOTAL_SHIFT 0
+# define RADEON_CRTC2_V_DISP (0x07ff << 16)
+# define RADEON_CRTC2_V_DISP_SHIFT 16
+#define RADEON_CRTC_VLINE_CRNT_VLINE 0x0210
+# define RADEON_CRTC_CRNT_VLINE_MASK (0x7ff << 16)
+#define RADEON_CRTC2_CRNT_FRAME 0x0314
+#define RADEON_CRTC2_GUI_TRIG_VLINE 0x0318
+#define RADEON_CRTC2_STATUS 0x03fc
+#define RADEON_CRTC2_VLINE_CRNT_VLINE 0x0310
+#define RADEON_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */
+#define RADEON_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */
+#define RADEON_CUR_CLR0 0x026c
+#define RADEON_CUR_CLR1 0x0270
+#define RADEON_CUR_HORZ_VERT_OFF 0x0268
+#define RADEON_CUR_HORZ_VERT_POSN 0x0264
+#define RADEON_CUR_OFFSET 0x0260
+# define RADEON_CUR_LOCK (1 << 31)
+#define RADEON_CUR2_CLR0 0x036c
+#define RADEON_CUR2_CLR1 0x0370
+#define RADEON_CUR2_HORZ_VERT_OFF 0x0368
+#define RADEON_CUR2_HORZ_VERT_POSN 0x0364
+#define RADEON_CUR2_OFFSET 0x0360
+# define RADEON_CUR2_LOCK (1 << 31)
+
+#define RADEON_DAC_CNTL 0x0058
+# define RADEON_DAC_RANGE_CNTL (3 << 0)
+# define RADEON_DAC_RANGE_CNTL_MASK 0x03
+# define RADEON_DAC_BLANKING (1 << 2)
+# define RADEON_DAC_CMP_EN (1 << 3)
+# define RADEON_DAC_CMP_OUTPUT (1 << 7)
+# define RADEON_DAC_8BIT_EN (1 << 8)
+# define RADEON_DAC_VGA_ADR_EN (1 << 13)
+# define RADEON_DAC_PDWN (1 << 15)
+# define RADEON_DAC_MASK_ALL (0xff << 24)
+#define RADEON_DAC_CNTL2 0x007c
+# define RADEON_DAC2_DAC_CLK_SEL (1 << 0)
+# define RADEON_DAC2_DAC2_CLK_SEL (1 << 1)
+# define RADEON_DAC2_PALETTE_ACC_CTL (1 << 5)
+#define RADEON_DAC_EXT_CNTL 0x0280
+# define RADEON_DAC_FORCE_BLANK_OFF_EN (1 << 4)
+# define RADEON_DAC_FORCE_DATA_EN (1 << 5)
+# define RADEON_DAC_FORCE_DATA_SEL_MASK (3 << 6)
+# define RADEON_DAC_FORCE_DATA_MASK 0x0003ff00
+# define RADEON_DAC_FORCE_DATA_SHIFT 8
+#define RADEON_TV_DAC_CNTL 0x088c
+# define RADEON_TV_DAC_STD_MASK 0x0300
+# define RADEON_TV_DAC_RDACPD (1 << 24)
+# define RADEON_TV_DAC_GDACPD (1 << 25)
+# define RADEON_TV_DAC_BDACPD (1 << 26)
+#define RADEON_DISP_HW_DEBUG 0x0d14
+# define RADEON_CRT2_DISP1_SEL (1 << 5)
+#define RADEON_DISP_OUTPUT_CNTL 0x0d64
+# define RADEON_DISP_DAC_SOURCE_MASK 0x03
+# define RADEON_DISP_DAC2_SOURCE_MASK 0x0c
+# define RADEON_DISP_DAC_SOURCE_CRTC2 0x01
+# define RADEON_DISP_DAC2_SOURCE_CRTC2 0x04
+#define RADEON_DAC_CRC_SIG 0x02cc
+#define RADEON_DAC_DATA 0x03c9 /* VGA */
+#define RADEON_DAC_MASK 0x03c6 /* VGA */
+#define RADEON_DAC_R_INDEX 0x03c7 /* VGA */
+#define RADEON_DAC_W_INDEX 0x03c8 /* VGA */
+#define RADEON_DDA_CONFIG 0x02e0
+#define RADEON_DDA_ON_OFF 0x02e4
+#define RADEON_DEFAULT_OFFSET 0x16e0
+#define RADEON_DEFAULT_PITCH 0x16e4
+#define RADEON_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
+# define RADEON_DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
+# define RADEON_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
+#define RADEON_DESTINATION_3D_CLR_CMP_VAL 0x1820
+#define RADEON_DESTINATION_3D_CLR_CMP_MSK 0x1824
+#define RADEON_DEVICE_ID 0x0f02 /* PCI */
+#define RADEON_DISP_MISC_CNTL 0x0d00
+# define RADEON_SOFT_RESET_GRPH_PP (1 << 0)
+#define RADEON_DISP_MERGE_CNTL 0x0d60
+# define RADEON_DISP_ALPHA_MODE_MASK 0x03
+# define RADEON_DISP_ALPHA_MODE_KEY 0
+# define RADEON_DISP_ALPHA_MODE_PER_PIXEL 1
+# define RADEON_DISP_ALPHA_MODE_GLOBAL 2
+# define RADEON_DISP_RGB_OFFSET_EN (1<<8)
+# define RADEON_DISP_GRPH_ALPHA_MASK (0xff << 16)
+# define RADEON_DISP_OV0_ALPHA_MASK (0xff << 24)
+# define RADEON_DISP_LIN_TRANS_BYPASS (0x01 << 9)
+#define RADEON_DISP2_MERGE_CNTL 0x0d68
+# define RADEON_DISP2_RGB_OFFSET_EN (1<<8)
+#define RADEON_DISP_LIN_TRANS_GRPH_A 0x0d80
+#define RADEON_DISP_LIN_TRANS_GRPH_B 0x0d84
+#define RADEON_DISP_LIN_TRANS_GRPH_C 0x0d88
+#define RADEON_DISP_LIN_TRANS_GRPH_D 0x0d8c
+#define RADEON_DISP_LIN_TRANS_GRPH_E 0x0d90
+#define RADEON_DISP_LIN_TRANS_GRPH_F 0x0d98
+#define RADEON_DP_BRUSH_BKGD_CLR 0x1478
+#define RADEON_DP_BRUSH_FRGD_CLR 0x147c
+#define RADEON_DP_CNTL 0x16c0
+# define RADEON_DST_X_LEFT_TO_RIGHT (1 << 0)
+# define RADEON_DST_Y_TOP_TO_BOTTOM (1 << 1)
+#define RADEON_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0
+# define RADEON_DST_Y_MAJOR (1 << 2)
+# define RADEON_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15)
+# define RADEON_DST_X_DIR_LEFT_TO_RIGHT (1 << 31)
+#define RADEON_DP_DATATYPE 0x16c4
+# define RADEON_HOST_BIG_ENDIAN_EN (1 << 29)
+#define RADEON_DP_GUI_MASTER_CNTL 0x146c
+# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
+# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
+# define RADEON_GMC_SRC_CLIPPING (1 << 2)
+# define RADEON_GMC_DST_CLIPPING (1 << 3)
+# define RADEON_GMC_BRUSH_DATATYPE_MASK (0x0f << 4)
+# define RADEON_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4)
+# define RADEON_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4)
+# define RADEON_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4)
+# define RADEON_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4)
+# define RADEON_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4)
+# define RADEON_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4)
+# define RADEON_GMC_BRUSH_32x32_MONO_FG_BG (8 << 4)
+# define RADEON_GMC_BRUSH_32x32_MONO_FG_LA (9 << 4)
+# define RADEON_GMC_BRUSH_8x8_COLOR (10 << 4)
+# define RADEON_GMC_BRUSH_1X8_COLOR (12 << 4)
+# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4)
+# define RADEON_GMC_BRUSH_NONE (15 << 4)
+# define RADEON_GMC_DST_8BPP_CI (2 << 8)
+# define RADEON_GMC_DST_15BPP (3 << 8)
+# define RADEON_GMC_DST_16BPP (4 << 8)
+# define RADEON_GMC_DST_24BPP (5 << 8)
+# define RADEON_GMC_DST_32BPP (6 << 8)
+# define RADEON_GMC_DST_8BPP_RGB (7 << 8)
+# define RADEON_GMC_DST_Y8 (8 << 8)
+# define RADEON_GMC_DST_RGB8 (9 << 8)
+# define RADEON_GMC_DST_VYUY (11 << 8)
+# define RADEON_GMC_DST_YVYU (12 << 8)
+# define RADEON_GMC_DST_AYUV444 (14 << 8)
+# define RADEON_GMC_DST_ARGB4444 (15 << 8)
+# define RADEON_GMC_DST_DATATYPE_MASK (0x0f << 8)
+# define RADEON_GMC_DST_DATATYPE_SHIFT 8
+# define RADEON_GMC_SRC_DATATYPE_MASK (3 << 12)
+# define RADEON_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12)
+# define RADEON_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12)
+# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12)
+# define RADEON_GMC_BYTE_PIX_ORDER (1 << 14)
+# define RADEON_GMC_BYTE_MSB_TO_LSB (0 << 14)
+# define RADEON_GMC_BYTE_LSB_TO_MSB (1 << 14)
+# define RADEON_GMC_CONVERSION_TEMP (1 << 15)
+# define RADEON_GMC_CONVERSION_TEMP_6500 (0 << 15)
+# define RADEON_GMC_CONVERSION_TEMP_9300 (1 << 15)
+# define RADEON_GMC_ROP3_MASK (0xff << 16)
+# define RADEON_DP_SRC_SOURCE_MASK (7 << 24)
+# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24)
+# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24)
+# define RADEON_GMC_3D_FCN_EN (1 << 27)
+# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28)
+# define RADEON_GMC_AUX_CLIP_DIS (1 << 29)
+# define RADEON_GMC_WR_MSK_DIS (1 << 30)
+# define RADEON_GMC_LD_BRUSH_Y_X (1 << 31)
+# define RADEON_ROP3_ZERO 0x00000000
+# define RADEON_ROP3_DSa 0x00880000
+# define RADEON_ROP3_SDna 0x00440000
+# define RADEON_ROP3_S 0x00cc0000
+# define RADEON_ROP3_DSna 0x00220000
+# define RADEON_ROP3_D 0x00aa0000
+# define RADEON_ROP3_DSx 0x00660000
+# define RADEON_ROP3_DSo 0x00ee0000
+# define RADEON_ROP3_DSon 0x00110000
+# define RADEON_ROP3_DSxn 0x00990000
+# define RADEON_ROP3_Dn 0x00550000
+# define RADEON_ROP3_SDno 0x00dd0000
+# define RADEON_ROP3_Sn 0x00330000
+# define RADEON_ROP3_DSno 0x00bb0000
+# define RADEON_ROP3_DSan 0x00770000
+# define RADEON_ROP3_ONE 0x00ff0000
+# define RADEON_ROP3_DPa 0x00a00000
+# define RADEON_ROP3_PDna 0x00500000
+# define RADEON_ROP3_P 0x00f00000
+# define RADEON_ROP3_DPna 0x000a0000
+# define RADEON_ROP3_D 0x00aa0000
+# define RADEON_ROP3_DPx 0x005a0000
+# define RADEON_ROP3_DPo 0x00fa0000
+# define RADEON_ROP3_DPon 0x00050000
+# define RADEON_ROP3_PDxn 0x00a50000
+# define RADEON_ROP3_PDno 0x00f50000
+# define RADEON_ROP3_Pn 0x000f0000
+# define RADEON_ROP3_DPno 0x00af0000
+# define RADEON_ROP3_DPan 0x005f0000
+#define RADEON_DP_GUI_MASTER_CNTL_C 0x1c84
+#define RADEON_DP_MIX 0x16c8
+#define RADEON_DP_SRC_BKGD_CLR 0x15dc
+#define RADEON_DP_SRC_FRGD_CLR 0x15d8
+#define RADEON_DP_WRITE_MASK 0x16cc
+#define RADEON_DST_BRES_DEC 0x1630
+#define RADEON_DST_BRES_ERR 0x1628
+#define RADEON_DST_BRES_INC 0x162c
+#define RADEON_DST_BRES_LNTH 0x1634
+#define RADEON_DST_BRES_LNTH_SUB 0x1638
+#define RADEON_DST_HEIGHT 0x1410
+#define RADEON_DST_HEIGHT_WIDTH 0x143c
+#define RADEON_DST_HEIGHT_WIDTH_8 0x158c
+#define RADEON_DST_HEIGHT_WIDTH_BW 0x15b4
+#define RADEON_DST_HEIGHT_Y 0x15a0
+#define RADEON_DST_LINE_START 0x1600
+#define RADEON_DST_LINE_END 0x1604
+#define RADEON_DST_LINE_PATCOUNT 0x1608
+# define RADEON_BRES_CNTL_SHIFT 8
+#define RADEON_DST_OFFSET 0x1404
+#define RADEON_DST_PITCH 0x1408
+#define RADEON_DST_PITCH_OFFSET 0x142c
+#define RADEON_DST_PITCH_OFFSET_C 0x1c80
+# define RADEON_PITCH_SHIFT 21
+# define RADEON_DST_TILE_LINEAR (0 << 30)
+# define RADEON_DST_TILE_MACRO (1 << 30)
+# define RADEON_DST_TILE_MICRO (2 << 30)
+# define RADEON_DST_TILE_BOTH (3 << 30)
+#define RADEON_DST_WIDTH 0x140c
+#define RADEON_DST_WIDTH_HEIGHT 0x1598
+#define RADEON_DST_WIDTH_X 0x1588
+#define RADEON_DST_WIDTH_X_INCY 0x159c
+#define RADEON_DST_X 0x141c
+#define RADEON_DST_X_SUB 0x15a4
+#define RADEON_DST_X_Y 0x1594
+#define RADEON_DST_Y 0x1420
+#define RADEON_DST_Y_SUB 0x15a8
+#define RADEON_DST_Y_X 0x1438
+
+#define RADEON_FCP_CNTL 0x0910
+# define RADEON_FCP0_SRC_PCICLK 0
+# define RADEON_FCP0_SRC_PCLK 1
+# define RADEON_FCP0_SRC_PCLKb 2
+# define RADEON_FCP0_SRC_HREF 3
+# define RADEON_FCP0_SRC_GND 4
+# define RADEON_FCP0_SRC_HREFb 5
+#define RADEON_FLUSH_1 0x1704
+#define RADEON_FLUSH_2 0x1708
+#define RADEON_FLUSH_3 0x170c
+#define RADEON_FLUSH_4 0x1710
+#define RADEON_FLUSH_5 0x1714
+#define RADEON_FLUSH_6 0x1718
+#define RADEON_FLUSH_7 0x171c
+#define RADEON_FOG_3D_TABLE_START 0x1810
+#define RADEON_FOG_3D_TABLE_END 0x1814
+#define RADEON_FOG_3D_TABLE_DENSITY 0x181c
+#define RADEON_FOG_TABLE_INDEX 0x1a14
+#define RADEON_FOG_TABLE_DATA 0x1a18
+#define RADEON_FP_CRTC_H_TOTAL_DISP 0x0250
+#define RADEON_FP_CRTC_V_TOTAL_DISP 0x0254
+#define RADEON_FP_CRTC2_H_TOTAL_DISP 0x0350
+#define RADEON_FP_CRTC2_V_TOTAL_DISP 0x0354
+# define RADEON_FP_CRTC_H_TOTAL_MASK 0x000003ff
+# define RADEON_FP_CRTC_H_DISP_MASK 0x01ff0000
+# define RADEON_FP_CRTC_V_TOTAL_MASK 0x00000fff
+# define RADEON_FP_CRTC_V_DISP_MASK 0x0fff0000
+# define RADEON_FP_H_SYNC_STRT_CHAR_MASK 0x00001ff8
+# define RADEON_FP_H_SYNC_WID_MASK 0x003f0000
+# define RADEON_FP_V_SYNC_STRT_MASK 0x00000fff
+# define RADEON_FP_V_SYNC_WID_MASK 0x001f0000
+# define RADEON_FP_CRTC_H_TOTAL_SHIFT 0x00000000
+# define RADEON_FP_CRTC_H_DISP_SHIFT 0x00000010
+# define RADEON_FP_CRTC_V_TOTAL_SHIFT 0x00000000
+# define RADEON_FP_CRTC_V_DISP_SHIFT 0x00000010
+# define RADEON_FP_H_SYNC_STRT_CHAR_SHIFT 0x00000003
+# define RADEON_FP_H_SYNC_WID_SHIFT 0x00000010
+# define RADEON_FP_V_SYNC_STRT_SHIFT 0x00000000
+# define RADEON_FP_V_SYNC_WID_SHIFT 0x00000010
+#define RADEON_FP_GEN_CNTL 0x0284
+# define RADEON_FP_FPON (1 << 0)
+# define RADEON_FP_TMDS_EN (1 << 2)
+# define RADEON_FP_PANEL_FORMAT (1 << 3)
+# define RADEON_FP_EN_TMDS (1 << 7)
+# define RADEON_FP_DETECT_SENSE (1 << 8)
+# define RADEON_FP_SEL_CRTC2 (1 << 13)
+# define RADEON_FP_CRTC_DONT_SHADOW_HPAR (1 << 15)
+# define RADEON_FP_CRTC_DONT_SHADOW_VPAR (1 << 16)
+# define RADEON_FP_CRTC_DONT_SHADOW_HEND (1 << 17)
+# define RADEON_FP_CRTC_USE_SHADOW_VEND (1 << 18)
+# define RADEON_FP_RMX_HVSYNC_CONTROL_EN (1 << 20)
+# define RADEON_FP_DFP_SYNC_SEL (1 << 21)
+# define RADEON_FP_CRTC_LOCK_8DOT (1 << 22)
+# define RADEON_FP_CRT_SYNC_SEL (1 << 23)
+# define RADEON_FP_USE_SHADOW_EN (1 << 24)
+# define RADEON_FP_CRT_SYNC_ALT (1 << 26)
+#define RADEON_FP2_GEN_CNTL 0x0288
+# define RADEON_FP2_BLANK_EN (1 << 1)
+# define RADEON_FP2_ON (1 << 2)
+# define RADEON_FP2_PANEL_FORMAT (1 << 3)
+# define RADEON_FP2_SOURCE_SEL_MASK (3 << 10)
+# define RADEON_FP2_SOURCE_SEL_CRTC2 (1 << 10)
+# define RADEON_FP2_SRC_SEL_MASK (3 << 13)
+# define RADEON_FP2_SRC_SEL_CRTC2 (1 << 13)
+# define RADEON_FP2_FP_POL (1 << 16)
+# define RADEON_FP2_LP_POL (1 << 17)
+# define RADEON_FP2_SCK_POL (1 << 18)
+# define RADEON_FP2_LCD_CNTL_MASK (7 << 19)
+# define RADEON_FP2_PAD_FLOP_EN (1 << 22)
+# define RADEON_FP2_CRC_EN (1 << 23)
+# define RADEON_FP2_CRC_READ_EN (1 << 24)
+# define RADEON_FP2_DV0_EN (1 << 25)
+# define RADEON_FP2_DV0_RATE_SEL_SDR (1 << 26)
+#define RADEON_FP_H_SYNC_STRT_WID 0x02c4
+#define RADEON_FP_H2_SYNC_STRT_WID 0x03c4
+#define RADEON_FP_HORZ_STRETCH 0x028c
+#define RADEON_FP_HORZ2_STRETCH 0x038c
+# define RADEON_HORZ_STRETCH_RATIO_MASK 0xffff
+# define RADEON_HORZ_STRETCH_RATIO_MAX 4096
+# define RADEON_HORZ_PANEL_SIZE (0x1ff << 16)
+# define RADEON_HORZ_PANEL_SHIFT 16
+# define RADEON_HORZ_STRETCH_PIXREP (0 << 25)
+# define RADEON_HORZ_STRETCH_BLEND (1 << 26)
+# define RADEON_HORZ_STRETCH_ENABLE (1 << 25)
+# define RADEON_HORZ_AUTO_RATIO (1 << 27)
+# define RADEON_HORZ_FP_LOOP_STRETCH (0x7 << 28)
+# define RADEON_HORZ_AUTO_RATIO_INC (1 << 31)
+#define RADEON_FP_V_SYNC_STRT_WID 0x02c8
+#define RADEON_FP_VERT_STRETCH 0x0290
+#define RADEON_FP_V2_SYNC_STRT_WID 0x03c8
+#define RADEON_FP_VERT2_STRETCH 0x0390
+# define RADEON_VERT_PANEL_SIZE (0xfff << 12)
+# define RADEON_VERT_PANEL_SHIFT 12
+# define RADEON_VERT_STRETCH_RATIO_MASK 0xfff
+# define RADEON_VERT_STRETCH_RATIO_SHIFT 0
+# define RADEON_VERT_STRETCH_RATIO_MAX 4096
+# define RADEON_VERT_STRETCH_ENABLE (1 << 25)
+# define RADEON_VERT_STRETCH_LINEREP (0 << 26)
+# define RADEON_VERT_STRETCH_BLEND (1 << 26)
+# define RADEON_VERT_AUTO_RATIO_EN (1 << 27)
+# define RADEON_VERT_STRETCH_RESERVED 0xf1000000
+
+#define RADEON_GEN_INT_CNTL 0x0040
+#define RADEON_GEN_INT_STATUS 0x0044
+# define RADEON_VSYNC_INT_AK (1 << 2)
+# define RADEON_VSYNC_INT (1 << 2)
+# define RADEON_VSYNC2_INT_AK (1 << 6)
+# define RADEON_VSYNC2_INT (1 << 6)
+#define RADEON_GENENB 0x03c3 /* VGA */
+#define RADEON_GENFC_RD 0x03ca /* VGA */
+#define RADEON_GENFC_WT 0x03da /* VGA, 0x03ba */
+#define RADEON_GENMO_RD 0x03cc /* VGA */
+#define RADEON_GENMO_WT 0x03c2 /* VGA */
+#define RADEON_GENS0 0x03c2 /* VGA */
+#define RADEON_GENS1 0x03da /* VGA, 0x03ba */
+#define RADEON_GPIO_MONID 0x0068 /* DDC interface via I2C */
+#define RADEON_GPIO_MONIDB 0x006c
+#define RADEON_GPIO_CRT2_DDC 0x006c
+#define RADEON_GPIO_DVI_DDC 0x0064
+#define RADEON_GPIO_VGA_DDC 0x0060
+# define RADEON_GPIO_A_0 (1 << 0)
+# define RADEON_GPIO_A_1 (1 << 1)
+# define RADEON_GPIO_Y_0 (1 << 8)
+# define RADEON_GPIO_Y_1 (1 << 9)
+# define RADEON_GPIO_Y_SHIFT_0 8
+# define RADEON_GPIO_Y_SHIFT_1 9
+# define RADEON_GPIO_EN_0 (1 << 16)
+# define RADEON_GPIO_EN_1 (1 << 17)
+# define RADEON_GPIO_MASK_0 (1 << 24) /*??*/
+# define RADEON_GPIO_MASK_1 (1 << 25) /*??*/
+#define RADEON_GRPH8_DATA 0x03cf /* VGA */
+#define RADEON_GRPH8_IDX 0x03ce /* VGA */
+#define RADEON_GUI_SCRATCH_REG0 0x15e0
+#define RADEON_GUI_SCRATCH_REG1 0x15e4
+#define RADEON_GUI_SCRATCH_REG2 0x15e8
+#define RADEON_GUI_SCRATCH_REG3 0x15ec
+#define RADEON_GUI_SCRATCH_REG4 0x15f0
+#define RADEON_GUI_SCRATCH_REG5 0x15f4
+
+#define RADEON_HEADER 0x0f0e /* PCI */
+#define RADEON_HOST_DATA0 0x17c0
+#define RADEON_HOST_DATA1 0x17c4
+#define RADEON_HOST_DATA2 0x17c8
+#define RADEON_HOST_DATA3 0x17cc
+#define RADEON_HOST_DATA4 0x17d0
+#define RADEON_HOST_DATA5 0x17d4
+#define RADEON_HOST_DATA6 0x17d8
+#define RADEON_HOST_DATA7 0x17dc
+#define RADEON_HOST_DATA_LAST 0x17e0
+#define RADEON_HOST_PATH_CNTL 0x0130
+# define RADEON_HDP_SOFT_RESET (1 << 26)
+#define RADEON_HTOTAL_CNTL 0x0009 /* PLL */
+#define RADEON_HTOTAL2_CNTL 0x002e /* PLL */
+
+#define RADEON_I2C_CNTL_1 0x0094 /* ? */
+#define RADEON_DVI_I2C_CNTL_1 0x02e4 /* ? */
+#define RADEON_INTERRUPT_LINE 0x0f3c /* PCI */
+#define RADEON_INTERRUPT_PIN 0x0f3d /* PCI */
+#define RADEON_IO_BASE 0x0f14 /* PCI */
+
+#define RADEON_LATENCY 0x0f0d /* PCI */
+#define RADEON_LEAD_BRES_DEC 0x1608
+#define RADEON_LEAD_BRES_LNTH 0x161c
+#define RADEON_LEAD_BRES_LNTH_SUB 0x1624
+#define RADEON_LVDS_GEN_CNTL 0x02d0
+# define RADEON_LVDS_ON (1 << 0)
+# define RADEON_LVDS_DISPLAY_DIS (1 << 1)
+# define RADEON_LVDS_PANEL_TYPE (1 << 2)
+# define RADEON_LVDS_PANEL_FORMAT (1 << 3)
+# define RADEON_LVDS_EN (1 << 7)
+# define RADEON_LVDS_DIGON (1 << 18)
+# define RADEON_LVDS_BLON (1 << 19)
+# define RADEON_LVDS_SEL_CRTC2 (1 << 23)
+#define RADEON_LVDS_PLL_CNTL 0x02d4
+# define RADEON_HSYNC_DELAY_SHIFT 28
+# define RADEON_HSYNC_DELAY_MASK (0xf << 28)
+
+#define RADEON_MAX_LATENCY 0x0f3f /* PCI */
+#define RADEON_MC_AGP_LOCATION 0x014c
+#define RADEON_MC_FB_LOCATION 0x0148
+#define RADEON_DISPLAY_BASE_ADDR 0x23c
+#define RADEON_DISPLAY2_BASE_ADDR 0x33c
+#define RADEON_OV0_BASE_ADDR 0x43c
+#define RADEON_NB_TOM 0x15c
+#define RADEON_MCLK_CNTL 0x0012 /* PLL */
+# define RADEON_FORCEON_MCLKA (1 << 16)
+# define RADEON_FORCEON_MCLKB (1 << 17)
+# define RADEON_FORCEON_YCLKA (1 << 18)
+# define RADEON_FORCEON_YCLKB (1 << 19)
+# define RADEON_FORCEON_MC (1 << 20)
+# define RADEON_FORCEON_AIC (1 << 21)
+#define RADEON_MDGPIO_A_REG 0x01ac
+#define RADEON_MDGPIO_EN_REG 0x01b0
+#define RADEON_MDGPIO_MASK 0x0198
+#define RADEON_MDGPIO_Y_REG 0x01b4
+#define RADEON_MEM_ADDR_CONFIG 0x0148
+#define RADEON_MEM_BASE 0x0f10 /* PCI */
+#define RADEON_MEM_CNTL 0x0140
+# define RADEON_MEM_NUM_CHANNELS_MASK 0x01
+# define RADEON_MEM_USE_B_CH_ONLY (1<<1)
+# define RV100_HALF_MODE (1<<3)
+#define RADEON_MEM_TIMING_CNTL 0x0144 /* EXT_MEM_CNTL */
+#define RADEON_MEM_INIT_LAT_TIMER 0x0154
+#define RADEON_MEM_INTF_CNTL 0x014c
+#define RADEON_MEM_SDRAM_MODE_REG 0x0158
+#define RADEON_MEM_STR_CNTL 0x0150
+#define RADEON_MEM_VGA_RP_SEL 0x003c
+#define RADEON_MEM_VGA_WP_SEL 0x0038
+#define RADEON_MIN_GRANT 0x0f3e /* PCI */
+#define RADEON_MM_DATA 0x0004
+#define RADEON_MM_INDEX 0x0000
+#define RADEON_MPLL_CNTL 0x000e /* PLL */
+#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */
+#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */
+
+#define RADEON_N_VIF_COUNT 0x0248
+
+#define RADEON_OV0_AUTO_FLIP_CNTL 0x0470
+#define RADEON_OV0_COLOUR_CNTL 0x04E0
+#define RADEON_OV0_DEINTERLACE_PATTERN 0x0474
+#define RADEON_OV0_EXCLUSIVE_HORZ 0x0408
+# define RADEON_EXCL_HORZ_START_MASK 0x000000ff
+# define RADEON_EXCL_HORZ_END_MASK 0x0000ff00
+# define RADEON_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000
+# define RADEON_EXCL_HORZ_EXCLUSIVE_EN 0x80000000
+#define RADEON_OV0_EXCLUSIVE_VERT 0x040C
+# define RADEON_EXCL_VERT_START_MASK 0x000003ff
+# define RADEON_EXCL_VERT_END_MASK 0x03ff0000
+#define RADEON_OV0_FILTER_CNTL 0x04A0
+#define RADEON_OV0_FOUR_TAP_COEF_0 0x04B0
+#define RADEON_OV0_FOUR_TAP_COEF_1 0x04B4
+#define RADEON_OV0_FOUR_TAP_COEF_2 0x04B8
+#define RADEON_OV0_FOUR_TAP_COEF_3 0x04BC
+#define RADEON_OV0_FOUR_TAP_COEF_4 0x04C0
+#define RADEON_OV0_GAMMA_000_00F 0x0d40
+#define RADEON_OV0_GAMMA_010_01F 0x0d44
+#define RADEON_OV0_GAMMA_020_03F 0x0d48
+#define RADEON_OV0_GAMMA_040_07F 0x0d4c
+#define RADEON_OV0_GAMMA_080_0BF 0x0e00
+#define RADEON_OV0_GAMMA_0C0_0FF 0x0e04
+#define RADEON_OV0_GAMMA_100_13F 0x0e08
+#define RADEON_OV0_GAMMA_140_17F 0x0e0c
+#define RADEON_OV0_GAMMA_180_1BF 0x0e10
+#define RADEON_OV0_GAMMA_1C0_1FF 0x0e14
+#define RADEON_OV0_GAMMA_200_23F 0x0e18
+#define RADEON_OV0_GAMMA_240_27F 0x0e1c
+#define RADEON_OV0_GAMMA_280_2BF 0x0e20
+#define RADEON_OV0_GAMMA_2C0_2FF 0x0e24
+#define RADEON_OV0_GAMMA_300_33F 0x0e28
+#define RADEON_OV0_GAMMA_340_37F 0x0e2c
+#define RADEON_OV0_GAMMA_380_3BF 0x0d50
+#define RADEON_OV0_GAMMA_3C0_3FF 0x0d54
+#define RADEON_OV0_GRAPHICS_KEY_CLR_LOW 0x04EC
+#define RADEON_OV0_GRAPHICS_KEY_CLR_HIGH 0x04F0
+#define RADEON_OV0_H_INC 0x0480
+#define RADEON_OV0_KEY_CNTL 0x04F4
+# define RADEON_VIDEO_KEY_FN_MASK 0x00000003L
+# define RADEON_VIDEO_KEY_FN_FALSE 0x00000000L
+# define RADEON_VIDEO_KEY_FN_TRUE 0x00000001L
+# define RADEON_VIDEO_KEY_FN_EQ 0x00000002L
+# define RADEON_VIDEO_KEY_FN_NE 0x00000003L
+# define RADEON_GRAPHIC_KEY_FN_MASK 0x00000030L
+# define RADEON_GRAPHIC_KEY_FN_FALSE 0x00000000L
+# define RADEON_GRAPHIC_KEY_FN_TRUE 0x00000010L
+# define RADEON_GRAPHIC_KEY_FN_EQ 0x00000020L
+# define RADEON_GRAPHIC_KEY_FN_NE 0x00000030L
+# define RADEON_CMP_MIX_MASK 0x00000100L
+# define RADEON_CMP_MIX_OR 0x00000000L
+# define RADEON_CMP_MIX_AND 0x00000100L
+#define RADEON_OV0_LIN_TRANS_A 0x0d20
+#define RADEON_OV0_LIN_TRANS_B 0x0d24
+#define RADEON_OV0_LIN_TRANS_C 0x0d28
+#define RADEON_OV0_LIN_TRANS_D 0x0d2c
+#define RADEON_OV0_LIN_TRANS_E 0x0d30
+#define RADEON_OV0_LIN_TRANS_F 0x0d34
+#define RADEON_OV0_P1_BLANK_LINES_AT_TOP 0x0430
+# define RADEON_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL
+# define RADEON_P1_ACTIVE_LINES_M1 0x0fff0000L
+#define RADEON_OV0_P1_H_ACCUM_INIT 0x0488
+#define RADEON_OV0_P1_V_ACCUM_INIT 0x0428
+# define RADEON_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L
+# define RADEON_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L
+#define RADEON_OV0_P1_X_START_END 0x0494
+#define RADEON_OV0_P2_X_START_END 0x0498
+#define RADEON_OV0_P23_BLANK_LINES_AT_TOP 0x0434
+# define RADEON_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL
+# define RADEON_P23_ACTIVE_LINES_M1 0x07ff0000L
+#define RADEON_OV0_P23_H_ACCUM_INIT 0x048C
+#define RADEON_OV0_P23_V_ACCUM_INIT 0x042C
+#define RADEON_OV0_P3_X_START_END 0x049C
+#define RADEON_OV0_REG_LOAD_CNTL 0x0410
+# define RADEON_REG_LD_CTL_LOCK 0x00000001L
+# define RADEON_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L
+# define RADEON_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L
+# define RADEON_REG_LD_CTL_LOCK_READBACK 0x00000008L
+#define RADEON_OV0_SCALE_CNTL 0x0420
+# define RADEON_SCALER_HORZ_PICK_NEAREST 0x00000004L
+# define RADEON_SCALER_VERT_PICK_NEAREST 0x00000008L
+# define RADEON_SCALER_SIGNED_UV 0x00000010L
+# define RADEON_SCALER_GAMMA_SEL_MASK 0x00000060L
+# define RADEON_SCALER_GAMMA_SEL_BRIGHT 0x00000000L
+# define RADEON_SCALER_GAMMA_SEL_G22 0x00000020L
+# define RADEON_SCALER_GAMMA_SEL_G18 0x00000040L
+# define RADEON_SCALER_GAMMA_SEL_G14 0x00000060L
+# define RADEON_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L
+# define RADEON_SCALER_SURFAC_FORMAT 0x00000f00L
+# define RADEON_SCALER_SOURCE_15BPP 0x00000300L
+# define RADEON_SCALER_SOURCE_16BPP 0x00000400L
+# define RADEON_SCALER_SOURCE_32BPP 0x00000600L
+# define RADEON_SCALER_SOURCE_YUV9 0x00000900L
+# define RADEON_SCALER_SOURCE_YUV12 0x00000A00L
+# define RADEON_SCALER_SOURCE_VYUY422 0x00000B00L
+# define RADEON_SCALER_SOURCE_YVYU422 0x00000C00L
+# define RADEON_SCALER_ADAPTIVE_DEINT 0x00001000L
+# define RADEON_SCALER_TEMPORAL_DEINT 0x00002000L
+# define RADEON_SCALER_SMART_SWITCH 0x00008000L
+# define RADEON_SCALER_BURST_PER_PLANE 0x007F0000L
+# define RADEON_SCALER_DOUBLE_BUFFER 0x01000000L
+# define RADEON_SCALER_DIS_LIMIT 0x08000000L
+# define RADEON_SCALER_INT_EMU 0x20000000L
+# define RADEON_SCALER_ENABLE 0x40000000L
+# define RADEON_SCALER_SOFT_RESET 0x80000000L
+# define RADEON_SCALER_ADAPTIVE_DEINT 0x00001000L
+#define RADEON_OV0_STEP_BY 0x0484
+#define RADEON_OV0_TEST 0x04F8
+#define RADEON_OV0_V_INC 0x0424
+#define RADEON_OV0_VID_BUF_PITCH0_VALUE 0x0460
+#define RADEON_OV0_VID_BUF_PITCH1_VALUE 0x0464
+#define RADEON_OV0_VID_BUF0_BASE_ADRS 0x0440
+# define RADEON_VIF_BUF0_PITCH_SEL 0x00000001L
+# define RADEON_VIF_BUF0_TILE_ADRS 0x00000002L
+# define RADEON_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L
+# define RADEON_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L
+#define RADEON_OV0_VID_BUF1_BASE_ADRS 0x0444
+# define RADEON_VIF_BUF1_PITCH_SEL 0x00000001L
+# define RADEON_VIF_BUF1_TILE_ADRS 0x00000002L
+# define RADEON_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L
+# define RADEON_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L
+#define RADEON_OV0_VID_BUF2_BASE_ADRS 0x0448
+# define RADEON_VIF_BUF2_PITCH_SEL 0x00000001L
+# define RADEON_VIF_BUF2_TILE_ADRS 0x00000002L
+# define RADEON_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L
+# define RADEON_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L
+#define RADEON_OV0_VID_BUF3_BASE_ADRS 0x044C
+#define RADEON_OV0_VID_BUF4_BASE_ADRS 0x0450
+#define RADEON_OV0_VID_BUF5_BASE_ADRS 0x0454
+#define RADEON_OV0_VIDEO_KEY_CLR_HIGH 0x04E8
+#define RADEON_OV0_VIDEO_KEY_CLR_LOW 0x04E4
+#define RADEON_OV0_Y_X_START 0x0400
+#define RADEON_OV0_Y_X_END 0x0404
+#define RADEON_OV1_Y_X_START 0x0600
+#define RADEON_OV1_Y_X_END 0x0604
+#define RADEON_OVR_CLR 0x0230
+#define RADEON_OVR_WID_LEFT_RIGHT 0x0234
+#define RADEON_OVR_WID_TOP_BOTTOM 0x0238
+
+#define RADEON_P2PLL_CNTL 0x002a /* P2PLL */
+# define RADEON_P2PLL_RESET (1 << 0)
+# define RADEON_P2PLL_SLEEP (1 << 1)
+# define RADEON_P2PLL_ATOMIC_UPDATE_EN (1 << 16)
+# define RADEON_P2PLL_VGA_ATOMIC_UPDATE_EN (1 << 17)
+# define RADEON_P2PLL_ATOMIC_UPDATE_VSYNC (1 << 18)
+#define RADEON_P2PLL_DIV_0 0x002c
+# define RADEON_P2PLL_FB0_DIV_MASK 0x07ff
+# define RADEON_P2PLL_POST0_DIV_MASK 0x00070000
+#define RADEON_P2PLL_REF_DIV 0x002B /* PLL */
+# define RADEON_P2PLL_REF_DIV_MASK 0x03ff
+# define RADEON_P2PLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
+# define RADEON_P2PLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
+#define RADEON_PALETTE_DATA 0x00b4
+#define RADEON_PALETTE_30_DATA 0x00b8
+#define RADEON_PALETTE_INDEX 0x00b0
+#define RADEON_PCI_GART_PAGE 0x017c
+#define RADEON_PIXCLKS_CNTL 0x002d
+# define RADEON_PIX2CLK_SRC_SEL_MASK 0x03
+# define RADEON_PIX2CLK_SRC_SEL_CPUCLK 0x00
+# define RADEON_PIX2CLK_SRC_SEL_PSCANCLK 0x01
+# define RADEON_PIX2CLK_SRC_SEL_BYTECLK 0x02
+# define RADEON_PIX2CLK_SRC_SEL_P2PLLCLK 0x03
+# define RADEON_PIX2CLK_ALWAYS_ONb (1<<6)
+# define RADEON_PIX2CLK_DAC_ALWAYS_ONb (1<<7)
+# define RADEON_PIXCLK_TV_SRC_SEL (1 << 8)
+# define RADEON_PIXCLK_LVDS_ALWAYS_ONb (1 << 14)
+# define RADEON_PIXCLK_TMDS_ALWAYS_ONb (1 << 15)
+#define RADEON_PLANE_3D_MASK_C 0x1d44
+#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */
+#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */
+#define RADEON_PMI_DATA 0x0f63 /* PCI */
+#define RADEON_PMI_NXT_CAP_PTR 0x0f5d /* PCI */
+#define RADEON_PMI_PMC_REG 0x0f5e /* PCI */
+#define RADEON_PMI_PMCSR_REG 0x0f60 /* PCI */
+#define RADEON_PMI_REGISTER 0x0f5c /* PCI */
+#define RADEON_PPLL_CNTL 0x0002 /* PLL */
+# define RADEON_PPLL_RESET (1 << 0)
+# define RADEON_PPLL_SLEEP (1 << 1)
+# define RADEON_PPLL_ATOMIC_UPDATE_EN (1 << 16)
+# define RADEON_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17)
+# define RADEON_PPLL_ATOMIC_UPDATE_VSYNC (1 << 18)
+#define RADEON_PPLL_DIV_0 0x0004 /* PLL */
+#define RADEON_PPLL_DIV_1 0x0005 /* PLL */
+#define RADEON_PPLL_DIV_2 0x0006 /* PLL */
+#define RADEON_PPLL_DIV_3 0x0007 /* PLL */
+# define RADEON_PPLL_FB3_DIV_MASK 0x07ff
+# define RADEON_PPLL_POST3_DIV_MASK 0x00070000
+#define RADEON_PPLL_REF_DIV 0x0003 /* PLL */
+# define RADEON_PPLL_REF_DIV_MASK 0x03ff
+# define RADEON_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
+# define RADEON_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
+#define RADEON_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */
+
+#define RADEON_RBBM_GUICNTL 0x172c
+# define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
+# define RADEON_HOST_DATA_SWAP_16BIT (1 << 0)
+# define RADEON_HOST_DATA_SWAP_32BIT (2 << 0)
+# define RADEON_HOST_DATA_SWAP_HDW (3 << 0)
+#define RADEON_RBBM_SOFT_RESET 0x00f0
+# define RADEON_SOFT_RESET_CP (1 << 0)
+# define RADEON_SOFT_RESET_HI (1 << 1)
+# define RADEON_SOFT_RESET_SE (1 << 2)
+# define RADEON_SOFT_RESET_RE (1 << 3)
+# define RADEON_SOFT_RESET_PP (1 << 4)
+# define RADEON_SOFT_RESET_E2 (1 << 5)
+# define RADEON_SOFT_RESET_RB (1 << 6)
+# define RADEON_SOFT_RESET_HDP (1 << 7)
+#define RADEON_RBBM_STATUS 0x0e40
+# define RADEON_RBBM_FIFOCNT_MASK 0x007f
+# define RADEON_RBBM_ACTIVE (1 << 31)
+#define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c
+# define RADEON_RB2D_DC_FLUSH (3 << 0)
+# define RADEON_RB2D_DC_FREE (3 << 2)
+# define RADEON_RB2D_DC_FLUSH_ALL 0xf
+# define RADEON_RB2D_DC_BUSY (1 << 31)
+#define RADEON_RB2D_DSTCACHE_MODE 0x3428
+#define RADEON_REG_BASE 0x0f18 /* PCI */
+#define RADEON_REGPROG_INF 0x0f09 /* PCI */
+#define RADEON_REVISION_ID 0x0f08 /* PCI */
+
+#define RADEON_SC_BOTTOM 0x164c
+#define RADEON_SC_BOTTOM_RIGHT 0x16f0
+#define RADEON_SC_BOTTOM_RIGHT_C 0x1c8c
+#define RADEON_SC_LEFT 0x1640
+#define RADEON_SC_RIGHT 0x1644
+#define RADEON_SC_TOP 0x1648
+#define RADEON_SC_TOP_LEFT 0x16ec
+#define RADEON_SC_TOP_LEFT_C 0x1c88
+# define RADEON_SC_SIGN_MASK_LO 0x8000
+# define RADEON_SC_SIGN_MASK_HI 0x80000000
+#define RADEON_SCLK_CNTL 0x000d /* PLL */
+# define RADEON_DYN_STOP_LAT_MASK 0x00007ff8
+# define RADEON_CP_MAX_DYN_STOP_LAT 0x0008
+# define RADEON_SCLK_FORCEON_MASK 0xffff8000
+#define RADEON_SCLK_MORE_CNTL 0x0035 /* PLL */
+# define RADEON_SCLK_MORE_FORCEON 0x0700
+#define RADEON_SDRAM_MODE_REG 0x0158
+#define RADEON_SEQ8_DATA 0x03c5 /* VGA */
+#define RADEON_SEQ8_IDX 0x03c4 /* VGA */
+#define RADEON_SNAPSHOT_F_COUNT 0x0244
+#define RADEON_SNAPSHOT_VH_COUNTS 0x0240
+#define RADEON_SNAPSHOT_VIF_COUNT 0x024c
+#define RADEON_SRC_OFFSET 0x15ac
+#define RADEON_SRC_PITCH 0x15b0
+#define RADEON_SRC_PITCH_OFFSET 0x1428
+#define RADEON_SRC_SC_BOTTOM 0x165c
+#define RADEON_SRC_SC_BOTTOM_RIGHT 0x16f4
+#define RADEON_SRC_SC_RIGHT 0x1654
+#define RADEON_SRC_X 0x1414
+#define RADEON_SRC_X_Y 0x1590
+#define RADEON_SRC_Y 0x1418
+#define RADEON_SRC_Y_X 0x1434
+#define RADEON_STATUS 0x0f06 /* PCI */
+#define RADEON_SUBPIC_CNTL 0x0540 /* ? */
+#define RADEON_SUB_CLASS 0x0f0a /* PCI */
+#define RADEON_SURFACE_CNTL 0x0b00
+# define RADEON_SURF_TRANSLATION_DIS (1 << 8)
+# define RADEON_NONSURF_AP0_SWP_16BPP (1 << 20)
+# define RADEON_NONSURF_AP0_SWP_32BPP (1 << 21)
+#define RADEON_SURFACE0_INFO 0x0b0c
+# define RADEON_SURF_TILE_COLOR_MACRO (0 << 16)
+# define RADEON_SURF_TILE_COLOR_BOTH (1 << 16)
+# define RADEON_SURF_TILE_DEPTH_32BPP (2 << 16)
+# define RADEON_SURF_TILE_DEPTH_16BPP (3 << 16)
+# define R200_SURF_TILE_NONE (0 << 16)
+# define R200_SURF_TILE_COLOR_MACRO (1 << 16)
+# define R200_SURF_TILE_COLOR_MICRO (2 << 16)
+# define R200_SURF_TILE_COLOR_BOTH (3 << 16)
+# define R200_SURF_TILE_DEPTH_32BPP (4 << 16)
+# define R200_SURF_TILE_DEPTH_16BPP (5 << 16)
+# define RADEON_SURF_AP0_SWP_16BPP (1 << 20)
+# define RADEON_SURF_AP0_SWP_32BPP (1 << 21)
+# define RADEON_SURF_AP1_SWP_16BPP (1 << 22)
+# define RADEON_SURF_AP1_SWP_32BPP (1 << 23)
+#define RADEON_SURFACE0_LOWER_BOUND 0x0b04
+#define RADEON_SURFACE0_UPPER_BOUND 0x0b08
+#define RADEON_SURFACE1_INFO 0x0b1c
+#define RADEON_SURFACE1_LOWER_BOUND 0x0b14
+#define RADEON_SURFACE1_UPPER_BOUND 0x0b18
+#define RADEON_SURFACE2_INFO 0x0b2c
+#define RADEON_SURFACE2_LOWER_BOUND 0x0b24
+#define RADEON_SURFACE2_UPPER_BOUND 0x0b28
+#define RADEON_SURFACE3_INFO 0x0b3c
+#define RADEON_SURFACE3_LOWER_BOUND 0x0b34
+#define RADEON_SURFACE3_UPPER_BOUND 0x0b38
+#define RADEON_SURFACE4_INFO 0x0b4c
+#define RADEON_SURFACE4_LOWER_BOUND 0x0b44
+#define RADEON_SURFACE4_UPPER_BOUND 0x0b48
+#define RADEON_SURFACE5_INFO 0x0b5c
+#define RADEON_SURFACE5_LOWER_BOUND 0x0b54
+#define RADEON_SURFACE5_UPPER_BOUND 0x0b58
+#define RADEON_SURFACE6_INFO 0x0b6c
+#define RADEON_SURFACE6_LOWER_BOUND 0x0b64
+#define RADEON_SURFACE6_UPPER_BOUND 0x0b68
+#define RADEON_SURFACE7_INFO 0x0b7c
+#define RADEON_SURFACE7_LOWER_BOUND 0x0b74
+#define RADEON_SURFACE7_UPPER_BOUND 0x0b78
+#define RADEON_SW_SEMAPHORE 0x013c
+
+#define RADEON_TEST_DEBUG_CNTL 0x0120
+#define RADEON_TEST_DEBUG_MUX 0x0124
+#define RADEON_TEST_DEBUG_OUT 0x012c
+#define RADEON_TMDS_PLL_CNTL 0x02a8
+#define RADEON_TMDS_TRANSMITTER_CNTL 0x02a4
+# define RADEON_TMDS_TRANSMITTER_PLLEN 1
+# define RADEON_TMDS_TRANSMITTER_PLLRST 2
+#define RADEON_TRAIL_BRES_DEC 0x1614
+#define RADEON_TRAIL_BRES_ERR 0x160c
+#define RADEON_TRAIL_BRES_INC 0x1610
+#define RADEON_TRAIL_X 0x1618
+#define RADEON_TRAIL_X_SUB 0x1620
+
+#define RADEON_VCLK_ECP_CNTL 0x0008 /* PLL */
+# define RADEON_VCLK_SRC_SEL_MASK 0x03
+# define RADEON_VCLK_SRC_SEL_CPUCLK 0x00
+# define RADEON_VCLK_SRC_SEL_PSCANCLK 0x01
+# define RADEON_VCLK_SRC_SEL_BYTECLK 0x02
+# define RADEON_VCLK_SRC_SEL_PPLLCLK 0x03
+# define RADEON_PIXCLK_ALWAYS_ONb (1<<6)
+# define RADEON_PIXCLK_DAC_ALWAYS_ONb (1<<7)
+
+#define RADEON_VENDOR_ID 0x0f00 /* PCI */
+#define RADEON_VGA_DDA_CONFIG 0x02e8
+#define RADEON_VGA_DDA_ON_OFF 0x02ec
+#define RADEON_VID_BUFFER_CONTROL 0x0900
+#define RADEON_VIDEOMUX_CNTL 0x0190
+#define RADEON_VIPH_CONTROL 0x0c40 /* ? */
+
+#define RADEON_WAIT_UNTIL 0x1720
+# define RADEON_WAIT_CRTC_PFLIP (1 << 0)
+# define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
+# define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
+# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
+
+#define RADEON_X_MPLL_REF_FB_DIV 0x000a /* PLL */
+#define RADEON_XCLK_CNTL 0x000d /* PLL */
+#define RADEON_XDLL_CNTL 0x000c /* PLL */
+#define RADEON_XPLL_CNTL 0x000b /* PLL */
+
+
+
+ /* Registers for 3D/TCL */
+#define RADEON_PP_BORDER_COLOR_0 0x1d40
+#define RADEON_PP_BORDER_COLOR_1 0x1d44
+#define RADEON_PP_BORDER_COLOR_2 0x1d48
+#define RADEON_PP_CNTL 0x1c38
+# define RADEON_STIPPLE_ENABLE (1 << 0)
+# define RADEON_SCISSOR_ENABLE (1 << 1)
+# define RADEON_PATTERN_ENABLE (1 << 2)
+# define RADEON_SHADOW_ENABLE (1 << 3)
+# define RADEON_TEX_ENABLE_MASK (0xf << 4)
+# define RADEON_TEX_0_ENABLE (1 << 4)
+# define RADEON_TEX_1_ENABLE (1 << 5)
+# define RADEON_TEX_2_ENABLE (1 << 6)
+# define RADEON_TEX_3_ENABLE (1 << 7)
+# define RADEON_TEX_BLEND_ENABLE_MASK (0xf << 12)
+# define RADEON_TEX_BLEND_0_ENABLE (1 << 12)
+# define RADEON_TEX_BLEND_1_ENABLE (1 << 13)
+# define RADEON_TEX_BLEND_2_ENABLE (1 << 14)
+# define RADEON_TEX_BLEND_3_ENABLE (1 << 15)
+# define RADEON_PLANAR_YUV_ENABLE (1 << 20)
+# define RADEON_SPECULAR_ENABLE (1 << 21)
+# define RADEON_FOG_ENABLE (1 << 22)
+# define RADEON_ALPHA_TEST_ENABLE (1 << 23)
+# define RADEON_ANTI_ALIAS_NONE (0 << 24)
+# define RADEON_ANTI_ALIAS_LINE (1 << 24)
+# define RADEON_ANTI_ALIAS_POLY (2 << 24)
+# define RADEON_ANTI_ALIAS_LINE_POLY (3 << 24)
+# define RADEON_BUMP_MAP_ENABLE (1 << 26)
+# define RADEON_BUMPED_MAP_T0 (0 << 27)
+# define RADEON_BUMPED_MAP_T1 (1 << 27)
+# define RADEON_BUMPED_MAP_T2 (2 << 27)
+# define RADEON_TEX_3D_ENABLE_0 (1 << 29)
+# define RADEON_TEX_3D_ENABLE_1 (1 << 30)
+# define RADEON_MC_ENABLE (1 << 31)
+#define RADEON_PP_FOG_COLOR 0x1c18
+# define RADEON_FOG_COLOR_MASK 0x00ffffff
+# define RADEON_FOG_VERTEX (0 << 24)
+# define RADEON_FOG_TABLE (1 << 24)
+# define RADEON_FOG_USE_DEPTH (0 << 25)
+# define RADEON_FOG_USE_DIFFUSE_ALPHA (2 << 25)
+# define RADEON_FOG_USE_SPEC_ALPHA (3 << 25)
+#define RADEON_PP_LUM_MATRIX 0x1d00
+#define RADEON_PP_MISC 0x1c14
+# define RADEON_REF_ALPHA_MASK 0x000000ff
+# define RADEON_ALPHA_TEST_FAIL (0 << 8)
+# define RADEON_ALPHA_TEST_LESS (1 << 8)
+# define RADEON_ALPHA_TEST_LEQUAL (2 << 8)
+# define RADEON_ALPHA_TEST_EQUAL (3 << 8)
+# define RADEON_ALPHA_TEST_GEQUAL (4 << 8)
+# define RADEON_ALPHA_TEST_GREATER (5 << 8)
+# define RADEON_ALPHA_TEST_NEQUAL (6 << 8)
+# define RADEON_ALPHA_TEST_PASS (7 << 8)
+# define RADEON_ALPHA_TEST_OP_MASK (7 << 8)
+# define RADEON_CHROMA_FUNC_FAIL (0 << 16)
+# define RADEON_CHROMA_FUNC_PASS (1 << 16)
+# define RADEON_CHROMA_FUNC_NEQUAL (2 << 16)
+# define RADEON_CHROMA_FUNC_EQUAL (3 << 16)
+# define RADEON_CHROMA_KEY_NEAREST (0 << 18)
+# define RADEON_CHROMA_KEY_ZERO (1 << 18)
+# define RADEON_SHADOW_ID_AUTO_INC (1 << 20)
+# define RADEON_SHADOW_FUNC_EQUAL (0 << 21)
+# define RADEON_SHADOW_FUNC_NEQUAL (1 << 21)
+# define RADEON_SHADOW_PASS_1 (0 << 22)
+# define RADEON_SHADOW_PASS_2 (1 << 22)
+# define RADEON_RIGHT_HAND_CUBE_D3D (0 << 24)
+# define RADEON_RIGHT_HAND_CUBE_OGL (1 << 24)
+#define RADEON_PP_ROT_MATRIX_0 0x1d58
+#define RADEON_PP_ROT_MATRIX_1 0x1d5c
+#define RADEON_PP_TXFILTER_0 0x1c54
+#define RADEON_PP_TXFILTER_1 0x1c6c
+#define RADEON_PP_TXFILTER_2 0x1c84
+# define RADEON_MAG_FILTER_NEAREST (0 << 0)
+# define RADEON_MAG_FILTER_LINEAR (1 << 0)
+# define RADEON_MAG_FILTER_MASK (1 << 0)
+# define RADEON_MIN_FILTER_NEAREST (0 << 1)
+# define RADEON_MIN_FILTER_LINEAR (1 << 1)
+# define RADEON_MIN_FILTER_NEAREST_MIP_NEAREST (2 << 1)
+# define RADEON_MIN_FILTER_NEAREST_MIP_LINEAR (3 << 1)
+# define RADEON_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 1)
+# define RADEON_MIN_FILTER_LINEAR_MIP_LINEAR (7 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST (8 << 1)
+# define RADEON_MIN_FILTER_ANISO_LINEAR (9 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 << 1)
+# define RADEON_MIN_FILTER_MASK (15 << 1)
+# define RADEON_MAX_ANISO_1_TO_1 (0 << 5)
+# define RADEON_MAX_ANISO_2_TO_1 (1 << 5)
+# define RADEON_MAX_ANISO_4_TO_1 (2 << 5)
+# define RADEON_MAX_ANISO_8_TO_1 (3 << 5)
+# define RADEON_MAX_ANISO_16_TO_1 (4 << 5)
+# define RADEON_MAX_ANISO_MASK (7 << 5)
+# define RADEON_LOD_BIAS_MASK (0xff << 8)
+# define RADEON_LOD_BIAS_SHIFT 8
+# define RADEON_MAX_MIP_LEVEL_MASK (0x0f << 16)
+# define RADEON_MAX_MIP_LEVEL_SHIFT 16
+# define RADEON_YUV_TO_RGB (1 << 20)
+# define RADEON_YUV_TEMPERATURE_COOL (0 << 21)
+# define RADEON_YUV_TEMPERATURE_HOT (1 << 21)
+# define RADEON_YUV_TEMPERATURE_MASK (1 << 21)
+# define RADEON_WRAPEN_S (1 << 22)
+# define RADEON_CLAMP_S_WRAP (0 << 23)
+# define RADEON_CLAMP_S_MIRROR (1 << 23)
+# define RADEON_CLAMP_S_CLAMP_LAST (2 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_LAST (3 << 23)
+# define RADEON_CLAMP_S_CLAMP_BORDER (4 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_BORDER (5 << 23)
+# define RADEON_CLAMP_S_CLAMP_GL (6 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_GL (7 << 23)
+# define RADEON_CLAMP_S_MASK (7 << 23)
+# define RADEON_WRAPEN_T (1 << 26)
+# define RADEON_CLAMP_T_WRAP (0 << 27)
+# define RADEON_CLAMP_T_MIRROR (1 << 27)
+# define RADEON_CLAMP_T_CLAMP_LAST (2 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_LAST (3 << 27)
+# define RADEON_CLAMP_T_CLAMP_BORDER (4 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_BORDER (5 << 27)
+# define RADEON_CLAMP_T_CLAMP_GL (6 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_GL (7 << 27)
+# define RADEON_CLAMP_T_MASK (7 << 27)
+# define RADEON_BORDER_MODE_OGL (0 << 31)
+# define RADEON_BORDER_MODE_D3D (1 << 31)
+#define RADEON_PP_TXFORMAT_0 0x1c58
+#define RADEON_PP_TXFORMAT_1 0x1c70
+#define RADEON_PP_TXFORMAT_2 0x1c88
+# define RADEON_TXFORMAT_I8 (0 << 0)
+# define RADEON_TXFORMAT_AI88 (1 << 0)
+# define RADEON_TXFORMAT_RGB332 (2 << 0)
+# define RADEON_TXFORMAT_ARGB1555 (3 << 0)
+# define RADEON_TXFORMAT_RGB565 (4 << 0)
+# define RADEON_TXFORMAT_ARGB4444 (5 << 0)
+# define RADEON_TXFORMAT_ARGB8888 (6 << 0)
+# define RADEON_TXFORMAT_RGBA8888 (7 << 0)
+# define RADEON_TXFORMAT_Y8 (8 << 0)
+# define RADEON_TXFORMAT_VYUY422 (10 << 0)
+# define RADEON_TXFORMAT_YVYU422 (11 << 0)
+# define RADEON_TXFORMAT_DXT1 (12 << 0)
+# define RADEON_TXFORMAT_DXT23 (14 << 0)
+# define RADEON_TXFORMAT_DXT45 (15 << 0)
+# define RADEON_TXFORMAT_SHADOW16 (16 << 0)
+# define RADEON_TXFORMAT_SHADOW32 (17 << 0)
+# define RADEON_TXFORMAT_DUDV88 (18 << 0)
+# define RADEON_TXFORMAT_LDUDV655 (19 << 0)
+# define RADEON_TXFORMAT_LDUDUV8888 (20 << 0)
+# define RADEON_TXFORMAT_FORMAT_MASK (31 << 0)
+# define RADEON_TXFORMAT_FORMAT_SHIFT 0
+# define RADEON_TXFORMAT_APPLE_YUV_MODE (1 << 5)
+# define RADEON_TXFORMAT_ALPHA_IN_MAP (1 << 6)
+# define RADEON_TXFORMAT_NON_POWER2 (1 << 7)
+# define RADEON_TXFORMAT_WIDTH_MASK (15 << 8)
+# define RADEON_TXFORMAT_WIDTH_SHIFT 8
+# define RADEON_TXFORMAT_HEIGHT_MASK (15 << 12)
+# define RADEON_TXFORMAT_HEIGHT_SHIFT 12
+# define RADEON_TXFORMAT_F5_WIDTH_MASK (15 << 16)
+# define RADEON_TXFORMAT_F5_WIDTH_SHIFT 16
+# define RADEON_TXFORMAT_F5_HEIGHT_MASK (15 << 20)
+# define RADEON_TXFORMAT_F5_HEIGHT_SHIFT 20
+# define RADEON_TXFORMAT_ST_ROUTE_STQ0 (0 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_MASK (3 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_STQ1 (1 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_STQ2 (2 << 24)
+# define RADEON_TXFORMAT_ENDIAN_NO_SWAP (0 << 26)
+# define RADEON_TXFORMAT_ENDIAN_16BPP_SWAP (1 << 26)
+# define RADEON_TXFORMAT_ENDIAN_32BPP_SWAP (2 << 26)
+# define RADEON_TXFORMAT_ENDIAN_HALFDW_SWAP (3 << 26)
+# define RADEON_TXFORMAT_ALPHA_MASK_ENABLE (1 << 28)
+# define RADEON_TXFORMAT_CHROMA_KEY_ENABLE (1 << 29)
+# define RADEON_TXFORMAT_CUBIC_MAP_ENABLE (1 << 30)
+# define RADEON_TXFORMAT_PERSPECTIVE_ENABLE (1 << 31)
+#define RADEON_PP_CUBIC_FACES_0 0x1d24
+#define RADEON_PP_CUBIC_FACES_1 0x1d28
+#define RADEON_PP_CUBIC_FACES_2 0x1d2c
+# define RADEON_FACE_WIDTH_1_SHIFT 0
+# define RADEON_FACE_HEIGHT_1_SHIFT 4
+# define RADEON_FACE_WIDTH_1_MASK (0xf << 0)
+# define RADEON_FACE_HEIGHT_1_MASK (0xf << 4)
+# define RADEON_FACE_WIDTH_2_SHIFT 8
+# define RADEON_FACE_HEIGHT_2_SHIFT 12
+# define RADEON_FACE_WIDTH_2_MASK (0xf << 8)
+# define RADEON_FACE_HEIGHT_2_MASK (0xf << 12)
+# define RADEON_FACE_WIDTH_3_SHIFT 16
+# define RADEON_FACE_HEIGHT_3_SHIFT 20
+# define RADEON_FACE_WIDTH_3_MASK (0xf << 16)
+# define RADEON_FACE_HEIGHT_3_MASK (0xf << 20)
+# define RADEON_FACE_WIDTH_4_SHIFT 24
+# define RADEON_FACE_HEIGHT_4_SHIFT 28
+# define RADEON_FACE_WIDTH_4_MASK (0xf << 24)
+# define RADEON_FACE_HEIGHT_4_MASK (0xf << 28)
+
+#define RADEON_PP_TXOFFSET_0 0x1c5c
+#define RADEON_PP_TXOFFSET_1 0x1c74
+#define RADEON_PP_TXOFFSET_2 0x1c8c
+# define RADEON_TXO_ENDIAN_NO_SWAP (0 << 0)
+# define RADEON_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+# define RADEON_TXO_ENDIAN_WORD_SWAP (2 << 0)
+# define RADEON_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+# define RADEON_TXO_MACRO_LINEAR (0 << 2)
+# define RADEON_TXO_MACRO_TILE (1 << 2)
+# define RADEON_TXO_MICRO_LINEAR (0 << 3)
+# define RADEON_TXO_MICRO_TILE_X2 (1 << 3)
+# define RADEON_TXO_MICRO_TILE_OPT (2 << 3)
+# define RADEON_TXO_OFFSET_MASK 0xffffffe0
+# define RADEON_TXO_OFFSET_SHIFT 5
+
+#define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */
+#define RADEON_PP_CUBIC_OFFSET_T0_1 0x1dd4
+#define RADEON_PP_CUBIC_OFFSET_T0_2 0x1dd8
+#define RADEON_PP_CUBIC_OFFSET_T0_3 0x1ddc
+#define RADEON_PP_CUBIC_OFFSET_T0_4 0x1de0
+#define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00
+#define RADEON_PP_CUBIC_OFFSET_T1_1 0x1e04
+#define RADEON_PP_CUBIC_OFFSET_T1_2 0x1e08
+#define RADEON_PP_CUBIC_OFFSET_T1_3 0x1e0c
+#define RADEON_PP_CUBIC_OFFSET_T1_4 0x1e10
+#define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14
+#define RADEON_PP_CUBIC_OFFSET_T2_1 0x1e18
+#define RADEON_PP_CUBIC_OFFSET_T2_2 0x1e1c
+#define RADEON_PP_CUBIC_OFFSET_T2_3 0x1e20
+#define RADEON_PP_CUBIC_OFFSET_T2_4 0x1e24
+
+#define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */
+#define RADEON_PP_TEX_SIZE_1 0x1d0c
+#define RADEON_PP_TEX_SIZE_2 0x1d14
+# define RADEON_TEX_USIZE_MASK (0x7ff << 0)
+# define RADEON_TEX_USIZE_SHIFT 0
+# define RADEON_TEX_VSIZE_MASK (0x7ff << 16)
+# define RADEON_TEX_VSIZE_SHIFT 16
+# define RADEON_SIGNED_RGB_MASK (1 << 30)
+# define RADEON_SIGNED_RGB_SHIFT 30
+# define RADEON_SIGNED_ALPHA_MASK (1 << 31)
+# define RADEON_SIGNED_ALPHA_SHIFT 31
+#define RADEON_PP_TEX_PITCH_0 0x1d08 /* NPOT */
+#define RADEON_PP_TEX_PITCH_1 0x1d10 /* NPOT */
+#define RADEON_PP_TEX_PITCH_2 0x1d18 /* NPOT */
+/* note: bits 13-5: 32 byte aligned stride of texture map */
+
+#define RADEON_PP_TXCBLEND_0 0x1c60
+#define RADEON_PP_TXCBLEND_1 0x1c78
+#define RADEON_PP_TXCBLEND_2 0x1c90
+# define RADEON_COLOR_ARG_A_SHIFT 0
+# define RADEON_COLOR_ARG_A_MASK (0x1f << 0)
+# define RADEON_COLOR_ARG_A_ZERO (0 << 0)
+# define RADEON_COLOR_ARG_A_CURRENT_COLOR (2 << 0)
+# define RADEON_COLOR_ARG_A_CURRENT_ALPHA (3 << 0)
+# define RADEON_COLOR_ARG_A_DIFFUSE_COLOR (4 << 0)
+# define RADEON_COLOR_ARG_A_DIFFUSE_ALPHA (5 << 0)
+# define RADEON_COLOR_ARG_A_SPECULAR_COLOR (6 << 0)
+# define RADEON_COLOR_ARG_A_SPECULAR_ALPHA (7 << 0)
+# define RADEON_COLOR_ARG_A_TFACTOR_COLOR (8 << 0)
+# define RADEON_COLOR_ARG_A_TFACTOR_ALPHA (9 << 0)
+# define RADEON_COLOR_ARG_A_T0_COLOR (10 << 0)
+# define RADEON_COLOR_ARG_A_T0_ALPHA (11 << 0)
+# define RADEON_COLOR_ARG_A_T1_COLOR (12 << 0)
+# define RADEON_COLOR_ARG_A_T1_ALPHA (13 << 0)
+# define RADEON_COLOR_ARG_A_T2_COLOR (14 << 0)
+# define RADEON_COLOR_ARG_A_T2_ALPHA (15 << 0)
+# define RADEON_COLOR_ARG_A_T3_COLOR (16 << 0)
+# define RADEON_COLOR_ARG_A_T3_ALPHA (17 << 0)
+# define RADEON_COLOR_ARG_B_SHIFT 5
+# define RADEON_COLOR_ARG_B_MASK (0x1f << 5)
+# define RADEON_COLOR_ARG_B_ZERO (0 << 5)
+# define RADEON_COLOR_ARG_B_CURRENT_COLOR (2 << 5)
+# define RADEON_COLOR_ARG_B_CURRENT_ALPHA (3 << 5)
+# define RADEON_COLOR_ARG_B_DIFFUSE_COLOR (4 << 5)
+# define RADEON_COLOR_ARG_B_DIFFUSE_ALPHA (5 << 5)
+# define RADEON_COLOR_ARG_B_SPECULAR_COLOR (6 << 5)
+# define RADEON_COLOR_ARG_B_SPECULAR_ALPHA (7 << 5)
+# define RADEON_COLOR_ARG_B_TFACTOR_COLOR (8 << 5)
+# define RADEON_COLOR_ARG_B_TFACTOR_ALPHA (9 << 5)
+# define RADEON_COLOR_ARG_B_T0_COLOR (10 << 5)
+# define RADEON_COLOR_ARG_B_T0_ALPHA (11 << 5)
+# define RADEON_COLOR_ARG_B_T1_COLOR (12 << 5)
+# define RADEON_COLOR_ARG_B_T1_ALPHA (13 << 5)
+# define RADEON_COLOR_ARG_B_T2_COLOR (14 << 5)
+# define RADEON_COLOR_ARG_B_T2_ALPHA (15 << 5)
+# define RADEON_COLOR_ARG_B_T3_COLOR (16 << 5)
+# define RADEON_COLOR_ARG_B_T3_ALPHA (17 << 5)
+# define RADEON_COLOR_ARG_C_SHIFT 10
+# define RADEON_COLOR_ARG_C_MASK (0x1f << 10)
+# define RADEON_COLOR_ARG_C_ZERO (0 << 10)
+# define RADEON_COLOR_ARG_C_CURRENT_COLOR (2 << 10)
+# define RADEON_COLOR_ARG_C_CURRENT_ALPHA (3 << 10)
+# define RADEON_COLOR_ARG_C_DIFFUSE_COLOR (4 << 10)
+# define RADEON_COLOR_ARG_C_DIFFUSE_ALPHA (5 << 10)
+# define RADEON_COLOR_ARG_C_SPECULAR_COLOR (6 << 10)
+# define RADEON_COLOR_ARG_C_SPECULAR_ALPHA (7 << 10)
+# define RADEON_COLOR_ARG_C_TFACTOR_COLOR (8 << 10)
+# define RADEON_COLOR_ARG_C_TFACTOR_ALPHA (9 << 10)
+# define RADEON_COLOR_ARG_C_T0_COLOR (10 << 10)
+# define RADEON_COLOR_ARG_C_T0_ALPHA (11 << 10)
+# define RADEON_COLOR_ARG_C_T1_COLOR (12 << 10)
+# define RADEON_COLOR_ARG_C_T1_ALPHA (13 << 10)
+# define RADEON_COLOR_ARG_C_T2_COLOR (14 << 10)
+# define RADEON_COLOR_ARG_C_T2_ALPHA (15 << 10)
+# define RADEON_COLOR_ARG_C_T3_COLOR (16 << 10)
+# define RADEON_COLOR_ARG_C_T3_ALPHA (17 << 10)
+# define RADEON_COMP_ARG_A (1 << 15)
+# define RADEON_COMP_ARG_A_SHIFT 15
+# define RADEON_COMP_ARG_B (1 << 16)
+# define RADEON_COMP_ARG_B_SHIFT 16
+# define RADEON_COMP_ARG_C (1 << 17)
+# define RADEON_COMP_ARG_C_SHIFT 17
+# define RADEON_BLEND_CTL_MASK (7 << 18)
+# define RADEON_BLEND_CTL_ADD (0 << 18)
+# define RADEON_BLEND_CTL_SUBTRACT (1 << 18)
+# define RADEON_BLEND_CTL_ADDSIGNED (2 << 18)
+# define RADEON_BLEND_CTL_BLEND (3 << 18)
+# define RADEON_BLEND_CTL_DOT3 (4 << 18)
+# define RADEON_SCALE_SHIFT 21
+# define RADEON_SCALE_MASK (3 << 21)
+# define RADEON_SCALE_1X (0 << 21)
+# define RADEON_SCALE_2X (1 << 21)
+# define RADEON_SCALE_4X (2 << 21)
+# define RADEON_CLAMP_TX (1 << 23)
+# define RADEON_T0_EQ_TCUR (1 << 24)
+# define RADEON_T1_EQ_TCUR (1 << 25)
+# define RADEON_T2_EQ_TCUR (1 << 26)
+# define RADEON_T3_EQ_TCUR (1 << 27)
+# define RADEON_COLOR_ARG_MASK 0x1f
+# define RADEON_COMP_ARG_SHIFT 15
+#define RADEON_PP_TXABLEND_0 0x1c64
+#define RADEON_PP_TXABLEND_1 0x1c7c
+#define RADEON_PP_TXABLEND_2 0x1c94
+# define RADEON_ALPHA_ARG_A_SHIFT 0
+# define RADEON_ALPHA_ARG_A_MASK (0xf << 0)
+# define RADEON_ALPHA_ARG_A_ZERO (0 << 0)
+# define RADEON_ALPHA_ARG_A_CURRENT_ALPHA (1 << 0)
+# define RADEON_ALPHA_ARG_A_DIFFUSE_ALPHA (2 << 0)
+# define RADEON_ALPHA_ARG_A_SPECULAR_ALPHA (3 << 0)
+# define RADEON_ALPHA_ARG_A_TFACTOR_ALPHA (4 << 0)
+# define RADEON_ALPHA_ARG_A_T0_ALPHA (5 << 0)
+# define RADEON_ALPHA_ARG_A_T1_ALPHA (6 << 0)
+# define RADEON_ALPHA_ARG_A_T2_ALPHA (7 << 0)
+# define RADEON_ALPHA_ARG_A_T3_ALPHA (8 << 0)
+# define RADEON_ALPHA_ARG_B_SHIFT 4
+# define RADEON_ALPHA_ARG_B_MASK (0xf << 4)
+# define RADEON_ALPHA_ARG_B_ZERO (0 << 4)
+# define RADEON_ALPHA_ARG_B_CURRENT_ALPHA (1 << 4)
+# define RADEON_ALPHA_ARG_B_DIFFUSE_ALPHA (2 << 4)
+# define RADEON_ALPHA_ARG_B_SPECULAR_ALPHA (3 << 4)
+# define RADEON_ALPHA_ARG_B_TFACTOR_ALPHA (4 << 4)
+# define RADEON_ALPHA_ARG_B_T0_ALPHA (5 << 4)
+# define RADEON_ALPHA_ARG_B_T1_ALPHA (6 << 4)
+# define RADEON_ALPHA_ARG_B_T2_ALPHA (7 << 4)
+# define RADEON_ALPHA_ARG_B_T3_ALPHA (8 << 4)
+# define RADEON_ALPHA_ARG_C_SHIFT 8
+# define RADEON_ALPHA_ARG_C_MASK (0xf << 8)
+# define RADEON_ALPHA_ARG_C_ZERO (0 << 8)
+# define RADEON_ALPHA_ARG_C_CURRENT_ALPHA (1 << 8)
+# define RADEON_ALPHA_ARG_C_DIFFUSE_ALPHA (2 << 8)
+# define RADEON_ALPHA_ARG_C_SPECULAR_ALPHA (3 << 8)
+# define RADEON_ALPHA_ARG_C_TFACTOR_ALPHA (4 << 8)
+# define RADEON_ALPHA_ARG_C_T0_ALPHA (5 << 8)
+# define RADEON_ALPHA_ARG_C_T1_ALPHA (6 << 8)
+# define RADEON_ALPHA_ARG_C_T2_ALPHA (7 << 8)
+# define RADEON_ALPHA_ARG_C_T3_ALPHA (8 << 8)
+# define RADEON_DOT_ALPHA_DONT_REPLICATE (1 << 12)
+# define RADEON_ALPHA_ARG_MASK 0xf
+
+#define RADEON_PP_TFACTOR_0 0x1c68
+#define RADEON_PP_TFACTOR_1 0x1c80
+#define RADEON_PP_TFACTOR_2 0x1c98
+
+#define RADEON_RB3D_BLENDCNTL 0x1c20
+# define RADEON_COMB_FCN_MASK (3 << 12)
+# define RADEON_COMB_FCN_ADD_CLAMP (0 << 12)
+# define RADEON_COMB_FCN_ADD_NOCLAMP (1 << 12)
+# define RADEON_COMB_FCN_SUB_CLAMP (2 << 12)
+# define RADEON_COMB_FCN_SUB_NOCLAMP (3 << 12)
+# define RADEON_SRC_BLEND_GL_ZERO (32 << 16)
+# define RADEON_SRC_BLEND_GL_ONE (33 << 16)
+# define RADEON_SRC_BLEND_GL_SRC_COLOR (34 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_COLOR (35 << 16)
+# define RADEON_SRC_BLEND_GL_DST_COLOR (36 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_DST_COLOR (37 << 16)
+# define RADEON_SRC_BLEND_GL_SRC_ALPHA (38 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_ALPHA (39 << 16)
+# define RADEON_SRC_BLEND_GL_DST_ALPHA (40 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA (41 << 16)
+# define RADEON_SRC_BLEND_GL_SRC_ALPHA_SATURATE (42 << 16)
+# define RADEON_SRC_BLEND_MASK (63 << 16)
+# define RADEON_DST_BLEND_GL_ZERO (32 << 24)
+# define RADEON_DST_BLEND_GL_ONE (33 << 24)
+# define RADEON_DST_BLEND_GL_SRC_COLOR (34 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_SRC_COLOR (35 << 24)
+# define RADEON_DST_BLEND_GL_DST_COLOR (36 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_DST_COLOR (37 << 24)
+# define RADEON_DST_BLEND_GL_SRC_ALPHA (38 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA (39 << 24)
+# define RADEON_DST_BLEND_GL_DST_ALPHA (40 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_DST_ALPHA (41 << 24)
+# define RADEON_DST_BLEND_MASK (63 << 24)
+#define RADEON_RB3D_CNTL 0x1c3c
+# define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
+# define RADEON_PLANE_MASK_ENABLE (1 << 1)
+# define RADEON_DITHER_ENABLE (1 << 2)
+# define RADEON_ROUND_ENABLE (1 << 3)
+# define RADEON_SCALE_DITHER_ENABLE (1 << 4)
+# define RADEON_DITHER_INIT (1 << 5)
+# define RADEON_ROP_ENABLE (1 << 6)
+# define RADEON_STENCIL_ENABLE (1 << 7)
+# define RADEON_Z_ENABLE (1 << 8)
+# define RADEON_DEPTH_XZ_OFFEST_ENABLE (1 << 9)
+# define RADEON_COLOR_FORMAT_ARGB1555 (3 << 10)
+# define RADEON_COLOR_FORMAT_RGB565 (4 << 10)
+# define RADEON_COLOR_FORMAT_ARGB8888 (6 << 10)
+# define RADEON_COLOR_FORMAT_RGB332 (7 << 10)
+# define RADEON_COLOR_FORMAT_Y8 (8 << 10)
+# define RADEON_COLOR_FORMAT_RGB8 (9 << 10)
+# define RADEON_COLOR_FORMAT_YUV422_VYUY (11 << 10)
+# define RADEON_COLOR_FORMAT_YUV422_YVYU (12 << 10)
+# define RADEON_COLOR_FORMAT_aYUV444 (14 << 10)
+# define RADEON_COLOR_FORMAT_ARGB4444 (15 << 10)
+# define RADEON_CLRCMP_FLIP_ENABLE (1 << 14)
+# define RADEON_ZBLOCK16 (1 << 15)
+#define RADEON_RB3D_COLOROFFSET 0x1c40
+# define RADEON_COLOROFFSET_MASK 0xfffffff0
+#define RADEON_RB3D_COLORPITCH 0x1c48
+# define RADEON_COLORPITCH_MASK 0x000001ff8
+# define RADEON_COLOR_TILE_ENABLE (1 << 16)
+# define RADEON_COLOR_MICROTILE_ENABLE (1 << 17)
+# define RADEON_COLOR_ENDIAN_NO_SWAP (0 << 18)
+# define RADEON_COLOR_ENDIAN_WORD_SWAP (1 << 18)
+# define RADEON_COLOR_ENDIAN_DWORD_SWAP (2 << 18)
+#define RADEON_RB3D_DEPTHOFFSET 0x1c24
+#define RADEON_RB3D_DEPTHPITCH 0x1c28
+# define RADEON_DEPTHPITCH_MASK 0x00001ff8
+# define RADEON_DEPTH_HYPERZ (3 << 16)
+# define RADEON_DEPTH_ENDIAN_NO_SWAP (0 << 18)
+# define RADEON_DEPTH_ENDIAN_WORD_SWAP (1 << 18)
+# define RADEON_DEPTH_ENDIAN_DWORD_SWAP (2 << 18)
+#define RADEON_RB3D_PLANEMASK 0x1d84
+#define RADEON_RB3D_ROPCNTL 0x1d80
+# define RADEON_ROP_MASK (15 << 8)
+# define RADEON_ROP_CLEAR (0 << 8)
+# define RADEON_ROP_NOR (1 << 8)
+# define RADEON_ROP_AND_INVERTED (2 << 8)
+# define RADEON_ROP_COPY_INVERTED (3 << 8)
+# define RADEON_ROP_AND_REVERSE (4 << 8)
+# define RADEON_ROP_INVERT (5 << 8)
+# define RADEON_ROP_XOR (6 << 8)
+# define RADEON_ROP_NAND (7 << 8)
+# define RADEON_ROP_AND (8 << 8)
+# define RADEON_ROP_EQUIV (9 << 8)
+# define RADEON_ROP_NOOP (10 << 8)
+# define RADEON_ROP_OR_INVERTED (11 << 8)
+# define RADEON_ROP_COPY (12 << 8)
+# define RADEON_ROP_OR_REVERSE (13 << 8)
+# define RADEON_ROP_OR (14 << 8)
+# define RADEON_ROP_SET (15 << 8)
+#define RADEON_RB3D_STENCILREFMASK 0x1d7c
+# define RADEON_STENCIL_REF_SHIFT 0
+# define RADEON_STENCIL_REF_MASK (0xff << 0)
+# define RADEON_STENCIL_MASK_SHIFT 16
+# define RADEON_STENCIL_VALUE_MASK (0xff << 16)
+# define RADEON_STENCIL_WRITEMASK_SHIFT 24
+# define RADEON_STENCIL_WRITE_MASK (0xff << 24)
+#define RADEON_RB3D_ZPASS_DATA 0x3290
+#define RADEON_RB3D_ZPASS_ADDR 0x3294
+#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
+# define RADEON_DEPTH_FORMAT_MASK (0xf << 0)
+# define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
+# define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
+# define RADEON_DEPTH_FORMAT_24BIT_FLOAT_Z (3 << 0)
+# define RADEON_DEPTH_FORMAT_32BIT_INT_Z (4 << 0)
+# define RADEON_DEPTH_FORMAT_32BIT_FLOAT_Z (5 << 0)
+# define RADEON_DEPTH_FORMAT_16BIT_FLOAT_W (7 << 0)
+# define RADEON_DEPTH_FORMAT_24BIT_FLOAT_W (9 << 0)
+# define RADEON_DEPTH_FORMAT_32BIT_FLOAT_W (11 << 0)
+# define RADEON_Z_TEST_NEVER (0 << 4)
+# define RADEON_Z_TEST_LESS (1 << 4)
+# define RADEON_Z_TEST_LEQUAL (2 << 4)
+# define RADEON_Z_TEST_EQUAL (3 << 4)
+# define RADEON_Z_TEST_GEQUAL (4 << 4)
+# define RADEON_Z_TEST_GREATER (5 << 4)
+# define RADEON_Z_TEST_NEQUAL (6 << 4)
+# define RADEON_Z_TEST_ALWAYS (7 << 4)
+# define RADEON_Z_TEST_MASK (7 << 4)
+# define RADEON_Z_HIERARCHY_ENABLE (1 << 8)
+# define RADEON_STENCIL_TEST_NEVER (0 << 12)
+# define RADEON_STENCIL_TEST_LESS (1 << 12)
+# define RADEON_STENCIL_TEST_LEQUAL (2 << 12)
+# define RADEON_STENCIL_TEST_EQUAL (3 << 12)
+# define RADEON_STENCIL_TEST_GEQUAL (4 << 12)
+# define RADEON_STENCIL_TEST_GREATER (5 << 12)
+# define RADEON_STENCIL_TEST_NEQUAL (6 << 12)
+# define RADEON_STENCIL_TEST_ALWAYS (7 << 12)
+# define RADEON_STENCIL_TEST_MASK (0x7 << 12)
+# define RADEON_STENCIL_FAIL_KEEP (0 << 16)
+# define RADEON_STENCIL_FAIL_ZERO (1 << 16)
+# define RADEON_STENCIL_FAIL_REPLACE (2 << 16)
+# define RADEON_STENCIL_FAIL_INC (3 << 16)
+# define RADEON_STENCIL_FAIL_DEC (4 << 16)
+# define RADEON_STENCIL_FAIL_INVERT (5 << 16)
+# define RADEON_STENCIL_FAIL_INC_WRAP (6 << 16)
+# define RADEON_STENCIL_FAIL_DEC_WRAP (7 << 16)
+# define RADEON_STENCIL_FAIL_MASK (0x7 << 16)
+# define RADEON_STENCIL_ZPASS_KEEP (0 << 20)
+# define RADEON_STENCIL_ZPASS_ZERO (1 << 20)
+# define RADEON_STENCIL_ZPASS_REPLACE (2 << 20)
+# define RADEON_STENCIL_ZPASS_INC (3 << 20)
+# define RADEON_STENCIL_ZPASS_DEC (4 << 20)
+# define RADEON_STENCIL_ZPASS_INVERT (5 << 20)
+# define RADEON_STENCIL_ZPASS_INC_WRAP (6 << 20)
+# define RADEON_STENCIL_ZPASS_DEC_WRAP (7 << 20)
+# define RADEON_STENCIL_ZPASS_MASK (0x7 << 20)
+# define RADEON_STENCIL_ZFAIL_KEEP (0 << 24)
+# define RADEON_STENCIL_ZFAIL_ZERO (1 << 24)
+# define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24)
+# define RADEON_STENCIL_ZFAIL_INC (3 << 24)
+# define RADEON_STENCIL_ZFAIL_DEC (4 << 24)
+# define RADEON_STENCIL_ZFAIL_INVERT (5 << 24)
+# define RADEON_STENCIL_ZFAIL_INC_WRAP (6 << 24)
+# define RADEON_STENCIL_ZFAIL_DEC_WRAP (7 << 24)
+# define RADEON_STENCIL_ZFAIL_MASK (0x7 << 24)
+# define RADEON_Z_COMPRESSION_ENABLE (1 << 28)
+# define RADEON_FORCE_Z_DIRTY (1 << 29)
+# define RADEON_Z_WRITE_ENABLE (1 << 30)
+# define RADEON_Z_DECOMPRESSION_ENABLE (1 << 31)
+
+#define RADEON_RE_STIPPLE_ADDR 0x1cc8
+#define RADEON_RE_STIPPLE_DATA 0x1ccc
+#define RADEON_RE_LINE_PATTERN 0x1cd0
+# define RADEON_LINE_PATTERN_MASK 0x0000ffff
+# define RADEON_LINE_REPEAT_COUNT_SHIFT 16
+# define RADEON_LINE_PATTERN_START_SHIFT 24
+# define RADEON_LINE_PATTERN_LITTLE_BIT_ORDER (0 << 28)
+# define RADEON_LINE_PATTERN_BIG_BIT_ORDER (1 << 28)
+# define RADEON_LINE_PATTERN_AUTO_RESET (1 << 29)
+#define RADEON_RE_LINE_STATE 0x1cd4
+# define RADEON_LINE_CURRENT_PTR_SHIFT 0
+# define RADEON_LINE_CURRENT_COUNT_SHIFT 8
+#define RADEON_RE_MISC 0x26c4
+# define RADEON_STIPPLE_COORD_MASK 0x1f
+# define RADEON_STIPPLE_X_OFFSET_SHIFT 0
+# define RADEON_STIPPLE_X_OFFSET_MASK (0x1f << 0)
+# define RADEON_STIPPLE_Y_OFFSET_SHIFT 8
+# define RADEON_STIPPLE_Y_OFFSET_MASK (0x1f << 8)
+# define RADEON_STIPPLE_LITTLE_BIT_ORDER (0 << 16)
+# define RADEON_STIPPLE_BIG_BIT_ORDER (1 << 16)
+#define RADEON_RE_SOLID_COLOR 0x1c1c
+#define RADEON_RE_TOP_LEFT 0x26c0
+# define RADEON_RE_LEFT_SHIFT 0
+# define RADEON_RE_TOP_SHIFT 16
+#define RADEON_RE_WIDTH_HEIGHT 0x1c44
+# define RADEON_RE_WIDTH_SHIFT 0
+# define RADEON_RE_HEIGHT_SHIFT 16
+
+#define RADEON_SE_CNTL 0x1c4c
+# define RADEON_FFACE_CULL_CW (0 << 0)
+# define RADEON_FFACE_CULL_CCW (1 << 0)
+# define RADEON_FFACE_CULL_DIR_MASK (1 << 0)
+# define RADEON_BFACE_CULL (0 << 1)
+# define RADEON_BFACE_SOLID (3 << 1)
+# define RADEON_FFACE_CULL (0 << 3)
+# define RADEON_FFACE_SOLID (3 << 3)
+# define RADEON_FFACE_CULL_MASK (3 << 3)
+# define RADEON_BADVTX_CULL_DISABLE (1 << 5)
+# define RADEON_FLAT_SHADE_VTX_0 (0 << 6)
+# define RADEON_FLAT_SHADE_VTX_1 (1 << 6)
+# define RADEON_FLAT_SHADE_VTX_2 (2 << 6)
+# define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
+# define RADEON_DIFFUSE_SHADE_SOLID (0 << 8)
+# define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
+# define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
+# define RADEON_DIFFUSE_SHADE_MASK (3 << 8)
+# define RADEON_ALPHA_SHADE_SOLID (0 << 10)
+# define RADEON_ALPHA_SHADE_FLAT (1 << 10)
+# define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
+# define RADEON_ALPHA_SHADE_MASK (3 << 10)
+# define RADEON_SPECULAR_SHADE_SOLID (0 << 12)
+# define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
+# define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
+# define RADEON_SPECULAR_SHADE_MASK (3 << 12)
+# define RADEON_FOG_SHADE_SOLID (0 << 14)
+# define RADEON_FOG_SHADE_FLAT (1 << 14)
+# define RADEON_FOG_SHADE_GOURAUD (2 << 14)
+# define RADEON_FOG_SHADE_MASK (3 << 14)
+# define RADEON_ZBIAS_ENABLE_POINT (1 << 16)
+# define RADEON_ZBIAS_ENABLE_LINE (1 << 17)
+# define RADEON_ZBIAS_ENABLE_TRI (1 << 18)
+# define RADEON_WIDELINE_ENABLE (1 << 20)
+# define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
+# define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
+# define RADEON_VTX_PIX_CENTER_D3D (0 << 27)
+# define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
+# define RADEON_ROUND_MODE_TRUNC (0 << 28)
+# define RADEON_ROUND_MODE_ROUND (1 << 28)
+# define RADEON_ROUND_MODE_ROUND_EVEN (2 << 28)
+# define RADEON_ROUND_MODE_ROUND_ODD (3 << 28)
+# define RADEON_ROUND_PREC_16TH_PIX (0 << 30)
+# define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
+# define RADEON_ROUND_PREC_4TH_PIX (2 << 30)
+# define RADEON_ROUND_PREC_HALF_PIX (3 << 30)
+#define RADEON_SE_CNTL_STATUS 0x2140
+# define RADEON_VC_NO_SWAP (0 << 0)
+# define RADEON_VC_16BIT_SWAP (1 << 0)
+# define RADEON_VC_32BIT_SWAP (2 << 0)
+# define RADEON_VC_HALF_DWORD_SWAP (3 << 0)
+# define RADEON_TCL_BYPASS (1 << 8)
+#define RADEON_SE_COORD_FMT 0x1c50
+# define RADEON_VTX_XY_PRE_MULT_1_OVER_W0 (1 << 0)
+# define RADEON_VTX_Z_PRE_MULT_1_OVER_W0 (1 << 1)
+# define RADEON_VTX_ST0_NONPARAMETRIC (1 << 8)
+# define RADEON_VTX_ST1_NONPARAMETRIC (1 << 9)
+# define RADEON_VTX_ST2_NONPARAMETRIC (1 << 10)
+# define RADEON_VTX_ST3_NONPARAMETRIC (1 << 11)
+# define RADEON_VTX_W0_NORMALIZE (1 << 12)
+# define RADEON_VTX_W0_IS_NOT_1_OVER_W0 (1 << 16)
+# define RADEON_VTX_ST0_PRE_MULT_1_OVER_W0 (1 << 17)
+# define RADEON_VTX_ST1_PRE_MULT_1_OVER_W0 (1 << 19)
+# define RADEON_VTX_ST2_PRE_MULT_1_OVER_W0 (1 << 21)
+# define RADEON_VTX_ST3_PRE_MULT_1_OVER_W0 (1 << 23)
+# define RADEON_TEX1_W_ROUTING_USE_W0 (0 << 26)
+# define RADEON_TEX1_W_ROUTING_USE_Q1 (1 << 26)
+#define RADEON_SE_LINE_WIDTH 0x1db8
+#define RADEON_SE_TCL_LIGHT_MODEL_CTL 0x226c
+# define RADEON_LIGHTING_ENABLE (1 << 0)
+# define RADEON_LIGHT_IN_MODELSPACE (1 << 1)
+# define RADEON_LOCAL_VIEWER (1 << 2)
+# define RADEON_NORMALIZE_NORMALS (1 << 3)
+# define RADEON_RESCALE_NORMALS (1 << 4)
+# define RADEON_SPECULAR_LIGHTS (1 << 5)
+# define RADEON_DIFFUSE_SPECULAR_COMBINE (1 << 6)
+# define RADEON_LIGHT_ALPHA (1 << 7)
+# define RADEON_LOCAL_LIGHT_VEC_GL (1 << 8)
+# define RADEON_LIGHT_NO_NORMAL_AMBIENT_ONLY (1 << 9)
+# define RADEON_LM_SOURCE_STATE_PREMULT 0
+# define RADEON_LM_SOURCE_STATE_MULT 1
+# define RADEON_LM_SOURCE_VERTEX_DIFFUSE 2
+# define RADEON_LM_SOURCE_VERTEX_SPECULAR 3
+# define RADEON_EMISSIVE_SOURCE_SHIFT 16
+# define RADEON_AMBIENT_SOURCE_SHIFT 18
+# define RADEON_DIFFUSE_SOURCE_SHIFT 20
+# define RADEON_SPECULAR_SOURCE_SHIFT 22
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_RED 0x2220
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_GREEN 0x2224
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_BLUE 0x2228
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_ALPHA 0x222c
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_RED 0x2230
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_GREEN 0x2234
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_BLUE 0x2238
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_ALPHA 0x223c
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_GREEN 0x2214
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_BLUE 0x2218
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_ALPHA 0x221c
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_RED 0x2240
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_GREEN 0x2244
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_BLUE 0x2248
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_ALPHA 0x224c
+#define RADEON_SE_TCL_MATRIX_SELECT_0 0x225c
+# define RADEON_MODELVIEW_0_SHIFT 0
+# define RADEON_MODELVIEW_1_SHIFT 4
+# define RADEON_MODELVIEW_2_SHIFT 8
+# define RADEON_MODELVIEW_3_SHIFT 12
+# define RADEON_IT_MODELVIEW_0_SHIFT 16
+# define RADEON_IT_MODELVIEW_1_SHIFT 20
+# define RADEON_IT_MODELVIEW_2_SHIFT 24
+# define RADEON_IT_MODELVIEW_3_SHIFT 28
+#define RADEON_SE_TCL_MATRIX_SELECT_1 0x2260
+# define RADEON_MODELPROJECT_0_SHIFT 0
+# define RADEON_MODELPROJECT_1_SHIFT 4
+# define RADEON_MODELPROJECT_2_SHIFT 8
+# define RADEON_MODELPROJECT_3_SHIFT 12
+# define RADEON_TEXMAT_0_SHIFT 16
+# define RADEON_TEXMAT_1_SHIFT 20
+# define RADEON_TEXMAT_2_SHIFT 24
+# define RADEON_TEXMAT_3_SHIFT 28
+
+
+#define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
+# define RADEON_TCL_VTX_W0 (1 << 0)
+# define RADEON_TCL_VTX_FP_DIFFUSE (1 << 1)
+# define RADEON_TCL_VTX_FP_ALPHA (1 << 2)
+# define RADEON_TCL_VTX_PK_DIFFUSE (1 << 3)
+# define RADEON_TCL_VTX_FP_SPEC (1 << 4)
+# define RADEON_TCL_VTX_FP_FOG (1 << 5)
+# define RADEON_TCL_VTX_PK_SPEC (1 << 6)
+# define RADEON_TCL_VTX_ST0 (1 << 7)
+# define RADEON_TCL_VTX_ST1 (1 << 8)
+# define RADEON_TCL_VTX_Q1 (1 << 9)
+# define RADEON_TCL_VTX_ST2 (1 << 10)
+# define RADEON_TCL_VTX_Q2 (1 << 11)
+# define RADEON_TCL_VTX_ST3 (1 << 12)
+# define RADEON_TCL_VTX_Q3 (1 << 13)
+# define RADEON_TCL_VTX_Q0 (1 << 14)
+# define RADEON_TCL_VTX_WEIGHT_COUNT_SHIFT 15
+# define RADEON_TCL_VTX_NORM0 (1 << 18)
+# define RADEON_TCL_VTX_XY1 (1 << 27)
+# define RADEON_TCL_VTX_Z1 (1 << 28)
+# define RADEON_TCL_VTX_W1 (1 << 29)
+# define RADEON_TCL_VTX_NORM1 (1 << 30)
+# define RADEON_TCL_VTX_Z0 (1 << 31)
+
+#define RADEON_SE_TCL_OUTPUT_VTX_SEL 0x2258
+# define RADEON_TCL_COMPUTE_XYZW (1 << 0)
+# define RADEON_TCL_COMPUTE_DIFFUSE (1 << 1)
+# define RADEON_TCL_COMPUTE_SPECULAR (1 << 2)
+# define RADEON_TCL_FORCE_NAN_IF_COLOR_NAN (1 << 3)
+# define RADEON_TCL_FORCE_INORDER_PROC (1 << 4)
+# define RADEON_TCL_TEX_INPUT_TEX_0 0
+# define RADEON_TCL_TEX_INPUT_TEX_1 1
+# define RADEON_TCL_TEX_INPUT_TEX_2 2
+# define RADEON_TCL_TEX_INPUT_TEX_3 3
+# define RADEON_TCL_TEX_COMPUTED_TEX_0 8
+# define RADEON_TCL_TEX_COMPUTED_TEX_1 9
+# define RADEON_TCL_TEX_COMPUTED_TEX_2 10
+# define RADEON_TCL_TEX_COMPUTED_TEX_3 11
+# define RADEON_TCL_TEX_0_OUTPUT_SHIFT 16
+# define RADEON_TCL_TEX_1_OUTPUT_SHIFT 20
+# define RADEON_TCL_TEX_2_OUTPUT_SHIFT 24
+# define RADEON_TCL_TEX_3_OUTPUT_SHIFT 28
+
+#define RADEON_SE_TCL_PER_LIGHT_CTL_0 0x2270
+# define RADEON_LIGHT_0_ENABLE (1 << 0)
+# define RADEON_LIGHT_0_ENABLE_AMBIENT (1 << 1)
+# define RADEON_LIGHT_0_ENABLE_SPECULAR (1 << 2)
+# define RADEON_LIGHT_0_IS_LOCAL (1 << 3)
+# define RADEON_LIGHT_0_IS_SPOT (1 << 4)
+# define RADEON_LIGHT_0_DUAL_CONE (1 << 5)
+# define RADEON_LIGHT_0_ENABLE_RANGE_ATTEN (1 << 6)
+# define RADEON_LIGHT_0_CONSTANT_RANGE_ATTEN (1 << 7)
+# define RADEON_LIGHT_0_SHIFT 0
+# define RADEON_LIGHT_1_ENABLE (1 << 16)
+# define RADEON_LIGHT_1_ENABLE_AMBIENT (1 << 17)
+# define RADEON_LIGHT_1_ENABLE_SPECULAR (1 << 18)
+# define RADEON_LIGHT_1_IS_LOCAL (1 << 19)
+# define RADEON_LIGHT_1_IS_SPOT (1 << 20)
+# define RADEON_LIGHT_1_DUAL_CONE (1 << 21)
+# define RADEON_LIGHT_1_ENABLE_RANGE_ATTEN (1 << 22)
+# define RADEON_LIGHT_1_CONSTANT_RANGE_ATTEN (1 << 23)
+# define RADEON_LIGHT_1_SHIFT 16
+#define RADEON_SE_TCL_PER_LIGHT_CTL_1 0x2274
+# define RADEON_LIGHT_2_SHIFT 0
+# define RADEON_LIGHT_3_SHIFT 16
+#define RADEON_SE_TCL_PER_LIGHT_CTL_2 0x2278
+# define RADEON_LIGHT_4_SHIFT 0
+# define RADEON_LIGHT_5_SHIFT 16
+#define RADEON_SE_TCL_PER_LIGHT_CTL_3 0x227c
+# define RADEON_LIGHT_6_SHIFT 0
+# define RADEON_LIGHT_7_SHIFT 16
+
+#define RADEON_SE_TCL_STATE_FLUSH 0x2284
+
+#define RADEON_SE_TCL_SHININESS 0x2250
+
+#define RADEON_SE_TCL_TEXTURE_PROC_CTL 0x2268
+# define RADEON_TEXGEN_TEXMAT_0_ENABLE (1 << 0)
+# define RADEON_TEXGEN_TEXMAT_1_ENABLE (1 << 1)
+# define RADEON_TEXGEN_TEXMAT_2_ENABLE (1 << 2)
+# define RADEON_TEXGEN_TEXMAT_3_ENABLE (1 << 3)
+# define RADEON_TEXMAT_0_ENABLE (1 << 4)
+# define RADEON_TEXMAT_1_ENABLE (1 << 5)
+# define RADEON_TEXMAT_2_ENABLE (1 << 6)
+# define RADEON_TEXMAT_3_ENABLE (1 << 7)
+# define RADEON_TEXGEN_INPUT_MASK 0xf
+# define RADEON_TEXGEN_INPUT_TEXCOORD_0 0
+# define RADEON_TEXGEN_INPUT_TEXCOORD_1 1
+# define RADEON_TEXGEN_INPUT_TEXCOORD_2 2
+# define RADEON_TEXGEN_INPUT_TEXCOORD_3 3
+# define RADEON_TEXGEN_INPUT_OBJ 4
+# define RADEON_TEXGEN_INPUT_EYE 5
+# define RADEON_TEXGEN_INPUT_EYE_NORMAL 6
+# define RADEON_TEXGEN_INPUT_EYE_REFLECT 7
+# define RADEON_TEXGEN_INPUT_EYE_NORMALIZED 8
+# define RADEON_TEXGEN_0_INPUT_SHIFT 16
+# define RADEON_TEXGEN_1_INPUT_SHIFT 20
+# define RADEON_TEXGEN_2_INPUT_SHIFT 24
+# define RADEON_TEXGEN_3_INPUT_SHIFT 28
+
+#define RADEON_SE_TCL_UCP_VERT_BLEND_CTL 0x2264
+# define RADEON_UCP_IN_CLIP_SPACE (1 << 0)
+# define RADEON_UCP_IN_MODEL_SPACE (1 << 1)
+# define RADEON_UCP_ENABLE_0 (1 << 2)
+# define RADEON_UCP_ENABLE_1 (1 << 3)
+# define RADEON_UCP_ENABLE_2 (1 << 4)
+# define RADEON_UCP_ENABLE_3 (1 << 5)
+# define RADEON_UCP_ENABLE_4 (1 << 6)
+# define RADEON_UCP_ENABLE_5 (1 << 7)
+# define RADEON_TCL_FOG_MASK (3 << 8)
+# define RADEON_TCL_FOG_DISABLE (0 << 8)
+# define RADEON_TCL_FOG_EXP (1 << 8)
+# define RADEON_TCL_FOG_EXP2 (2 << 8)
+# define RADEON_TCL_FOG_LINEAR (3 << 8)
+# define RADEON_RNG_BASED_FOG (1 << 10)
+# define RADEON_LIGHT_TWOSIDE (1 << 11)
+# define RADEON_BLEND_OP_COUNT_MASK (7 << 12)
+# define RADEON_BLEND_OP_COUNT_SHIFT 12
+# define RADEON_POSITION_BLEND_OP_ENABLE (1 << 16)
+# define RADEON_NORMAL_BLEND_OP_ENABLE (1 << 17)
+# define RADEON_VERTEX_BLEND_SRC_0_PRIMARY (0 << 18)
+# define RADEON_VERTEX_BLEND_SRC_0_SECONDARY (1 << 18)
+# define RADEON_VERTEX_BLEND_SRC_1_PRIMARY (0 << 19)
+# define RADEON_VERTEX_BLEND_SRC_1_SECONDARY (1 << 19)
+# define RADEON_VERTEX_BLEND_SRC_2_PRIMARY (0 << 20)
+# define RADEON_VERTEX_BLEND_SRC_2_SECONDARY (1 << 20)
+# define RADEON_VERTEX_BLEND_SRC_3_PRIMARY (0 << 21)
+# define RADEON_VERTEX_BLEND_SRC_3_SECONDARY (1 << 21)
+# define RADEON_VERTEX_BLEND_WGT_MINUS_ONE (1 << 22)
+# define RADEON_CULL_FRONT_IS_CW (0 << 28)
+# define RADEON_CULL_FRONT_IS_CCW (1 << 28)
+# define RADEON_CULL_FRONT (1 << 29)
+# define RADEON_CULL_BACK (1 << 30)
+# define RADEON_FORCE_W_TO_ONE (1 << 31)
+
+#define RADEON_SE_VPORT_XSCALE 0x1d98
+#define RADEON_SE_VPORT_XOFFSET 0x1d9c
+#define RADEON_SE_VPORT_YSCALE 0x1da0
+#define RADEON_SE_VPORT_YOFFSET 0x1da4
+#define RADEON_SE_VPORT_ZSCALE 0x1da8
+#define RADEON_SE_VPORT_ZOFFSET 0x1dac
+#define RADEON_SE_ZBIAS_FACTOR 0x1db0
+#define RADEON_SE_ZBIAS_CONSTANT 0x1db4
+
+#define RADEON_SE_VTX_FMT 0x2080
+# define RADEON_SE_VTX_FMT_XY 0x00000000
+# define RADEON_SE_VTX_FMT_W0 0x00000001
+# define RADEON_SE_VTX_FMT_FPCOLOR 0x00000002
+# define RADEON_SE_VTX_FMT_FPALPHA 0x00000004
+# define RADEON_SE_VTX_FMT_PKCOLOR 0x00000008
+# define RADEON_SE_VTX_FMT_FPSPEC 0x00000010
+# define RADEON_SE_VTX_FMT_FPFOG 0x00000020
+# define RADEON_SE_VTX_FMT_PKSPEC 0x00000040
+# define RADEON_SE_VTX_FMT_ST0 0x00000080
+# define RADEON_SE_VTX_FMT_ST1 0x00000100
+# define RADEON_SE_VTX_FMT_Q1 0x00000200
+# define RADEON_SE_VTX_FMT_ST2 0x00000400
+# define RADEON_SE_VTX_FMT_Q2 0x00000800
+# define RADEON_SE_VTX_FMT_ST3 0x00001000
+# define RADEON_SE_VTX_FMT_Q3 0x00002000
+# define RADEON_SE_VTX_FMT_Q0 0x00004000
+# define RADEON_SE_VTX_FMT_BLND_WEIGHT_CNT_MASK 0x00038000
+# define RADEON_SE_VTX_FMT_N0 0x00040000
+# define RADEON_SE_VTX_FMT_XY1 0x08000000
+# define RADEON_SE_VTX_FMT_Z1 0x10000000
+# define RADEON_SE_VTX_FMT_W1 0x20000000
+# define RADEON_SE_VTX_FMT_N1 0x40000000
+# define RADEON_SE_VTX_FMT_Z 0x80000000
+
+ /* Registers for CP and Microcode Engine */
+#define RADEON_CP_ME_RAM_ADDR 0x07d4
+#define RADEON_CP_ME_RAM_RADDR 0x07d8
+#define RADEON_CP_ME_RAM_DATAH 0x07dc
+#define RADEON_CP_ME_RAM_DATAL 0x07e0
+
+#define RADEON_CP_RB_BASE 0x0700
+#define RADEON_CP_RB_CNTL 0x0704
+#define RADEON_CP_RB_RPTR_ADDR 0x070c
+#define RADEON_CP_RB_RPTR 0x0710
+#define RADEON_CP_RB_WPTR 0x0714
+
+#define RADEON_CP_IB_BASE 0x0738
+#define RADEON_CP_IB_BUFSZ 0x073c
+
+#define RADEON_CP_CSQ_CNTL 0x0740
+# define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
+# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
+# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
+# define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
+# define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
+# define RADEON_CSQ_PRIBM_INDBM (4 << 28)
+# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
+#define RADEON_CP_CSQ_STAT 0x07f8
+# define RADEON_CSQ_RPTR_PRIMARY_MASK (0xff << 0)
+# define RADEON_CSQ_WPTR_PRIMARY_MASK (0xff << 8)
+# define RADEON_CSQ_RPTR_INDIRECT_MASK (0xff << 16)
+# define RADEON_CSQ_WPTR_INDIRECT_MASK (0xff << 24)
+#define RADEON_CP_CSQ_ADDR 0x07f0
+#define RADEON_CP_CSQ_DATA 0x07f4
+#define RADEON_CP_CSQ_APER_PRIMARY 0x1000
+#define RADEON_CP_CSQ_APER_INDIRECT 0x1300
+
+#define RADEON_CP_RB_WPTR_DELAY 0x0718
+# define RADEON_PRE_WRITE_TIMER_SHIFT 0
+# define RADEON_PRE_WRITE_LIMIT_SHIFT 23
+
+#define RADEON_AIC_CNTL 0x01d0
+# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
+#define RADEON_AIC_LO_ADDR 0x01dc
+
+
+
+ /* Constants */
+#define RADEON_LAST_FRAME_REG RADEON_GUI_SCRATCH_REG0
+#define RADEON_LAST_CLEAR_REG RADEON_GUI_SCRATCH_REG2
+
+
+
+ /* CP packet types */
+#define RADEON_CP_PACKET0 0x00000000
+#define RADEON_CP_PACKET1 0x40000000
+#define RADEON_CP_PACKET2 0x80000000
+#define RADEON_CP_PACKET3 0xC0000000
+# define RADEON_CP_PACKET_MASK 0xC0000000
+# define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000
+# define RADEON_CP_PACKET_MAX_DWORDS (1 << 12)
+# define RADEON_CP_PACKET0_REG_MASK 0x000007ff
+# define RADEON_CP_PACKET1_REG0_MASK 0x000007ff
+# define RADEON_CP_PACKET1_REG1_MASK 0x003ff800
+
+#define RADEON_CP_PACKET0_ONE_REG_WR 0x00008000
+
+#define RADEON_CP_PACKET3_NOP 0xC0001000
+#define RADEON_CP_PACKET3_NEXT_CHAR 0xC0001900
+#define RADEON_CP_PACKET3_PLY_NEXTSCAN 0xC0001D00
+#define RADEON_CP_PACKET3_SET_SCISSORS 0xC0001E00
+#define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
+#define RADEON_CP_PACKET3_LOAD_MICROCODE 0xC0002400
+#define RADEON_CP_PACKET3_WAIT_FOR_IDLE 0xC0002600
+#define RADEON_CP_PACKET3_3D_DRAW_VBUF 0xC0002800
+#define RADEON_CP_PACKET3_3D_DRAW_IMMD 0xC0002900
+#define RADEON_CP_PACKET3_3D_DRAW_INDX 0xC0002A00
+#define RADEON_CP_PACKET3_LOAD_PALETTE 0xC0002C00
+#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
+#define R200_CP_CMD_3D_DRAW_VBUF_2 0xC0003400
+#define R200_CP_CMD_3D_DRAW_IMMD_2 0xC0003500
+#define R200_CP_CMD_3D_DRAW_INDX_2 0xC0003600
+#define RADEON_CP_PACKET3_CNTL_PAINT 0xC0009100
+#define RADEON_CP_PACKET3_CNTL_BITBLT 0xC0009200
+#define RADEON_CP_PACKET3_CNTL_SMALLTEXT 0xC0009300
+#define RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
+#define RADEON_CP_PACKET3_CNTL_POLYLINE 0xC0009500
+#define RADEON_CP_PACKET3_CNTL_POLYSCANLINES 0xC0009800
+#define RADEON_CP_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
+#define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
+#define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
+
+
+#define RADEON_CP_VC_FRMT_XY 0x00000000
+#define RADEON_CP_VC_FRMT_W0 0x00000001
+#define RADEON_CP_VC_FRMT_FPCOLOR 0x00000002
+#define RADEON_CP_VC_FRMT_FPALPHA 0x00000004
+#define RADEON_CP_VC_FRMT_PKCOLOR 0x00000008
+#define RADEON_CP_VC_FRMT_FPSPEC 0x00000010
+#define RADEON_CP_VC_FRMT_FPFOG 0x00000020
+#define RADEON_CP_VC_FRMT_PKSPEC 0x00000040
+#define RADEON_CP_VC_FRMT_ST0 0x00000080
+#define RADEON_CP_VC_FRMT_ST1 0x00000100
+#define RADEON_CP_VC_FRMT_Q1 0x00000200
+#define RADEON_CP_VC_FRMT_ST2 0x00000400
+#define RADEON_CP_VC_FRMT_Q2 0x00000800
+#define RADEON_CP_VC_FRMT_ST3 0x00001000
+#define RADEON_CP_VC_FRMT_Q3 0x00002000
+#define RADEON_CP_VC_FRMT_Q0 0x00004000
+#define RADEON_CP_VC_FRMT_BLND_WEIGHT_CNT_MASK 0x00038000
+#define RADEON_CP_VC_FRMT_N0 0x00040000
+#define RADEON_CP_VC_FRMT_XY1 0x08000000
+#define RADEON_CP_VC_FRMT_Z1 0x10000000
+#define RADEON_CP_VC_FRMT_W1 0x20000000
+#define RADEON_CP_VC_FRMT_N1 0x40000000
+#define RADEON_CP_VC_FRMT_Z 0x80000000
+
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_NONE 0x00000000
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_POINT 0x00000001
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE 0x00000002
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP 0x00000003
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_TYPE_2 0x00000007
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST 0x00000008
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_POINT_LIST 0x00000009
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_LINE_LIST 0x0000000a
+#define RADEON_CP_VC_CNTL_PRIM_WALK_IND 0x00000010
+#define RADEON_CP_VC_CNTL_PRIM_WALK_LIST 0x00000020
+#define RADEON_CP_VC_CNTL_PRIM_WALK_RING 0x00000030
+#define RADEON_CP_VC_CNTL_COLOR_ORDER_BGRA 0x00000000
+#define RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA 0x00000040
+#define RADEON_CP_VC_CNTL_MAOS_ENABLE 0x00000080
+#define RADEON_CP_VC_CNTL_VTX_FMT_NON_RADEON_MODE 0x00000000
+#define RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE 0x00000100
+#define RADEON_CP_VC_CNTL_TCL_DISABLE 0x00000000
+#define RADEON_CP_VC_CNTL_TCL_ENABLE 0x00000200
+#define RADEON_CP_VC_CNTL_NUM_SHIFT 16
+
+#define RADEON_VS_MATRIX_0_ADDR 0
+#define RADEON_VS_MATRIX_1_ADDR 4
+#define RADEON_VS_MATRIX_2_ADDR 8
+#define RADEON_VS_MATRIX_3_ADDR 12
+#define RADEON_VS_MATRIX_4_ADDR 16
+#define RADEON_VS_MATRIX_5_ADDR 20
+#define RADEON_VS_MATRIX_6_ADDR 24
+#define RADEON_VS_MATRIX_7_ADDR 28
+#define RADEON_VS_MATRIX_8_ADDR 32
+#define RADEON_VS_MATRIX_9_ADDR 36
+#define RADEON_VS_MATRIX_10_ADDR 40
+#define RADEON_VS_MATRIX_11_ADDR 44
+#define RADEON_VS_MATRIX_12_ADDR 48
+#define RADEON_VS_MATRIX_13_ADDR 52
+#define RADEON_VS_MATRIX_14_ADDR 56
+#define RADEON_VS_MATRIX_15_ADDR 60
+#define RADEON_VS_LIGHT_AMBIENT_ADDR 64
+#define RADEON_VS_LIGHT_DIFFUSE_ADDR 72
+#define RADEON_VS_LIGHT_SPECULAR_ADDR 80
+#define RADEON_VS_LIGHT_DIRPOS_ADDR 88
+#define RADEON_VS_LIGHT_HWVSPOT_ADDR 96
+#define RADEON_VS_LIGHT_ATTENUATION_ADDR 104
+#define RADEON_VS_MATRIX_EYE2CLIP_ADDR 112
+#define RADEON_VS_UCP_ADDR 116
+#define RADEON_VS_GLOBAL_AMBIENT_ADDR 122
+#define RADEON_VS_FOG_PARAM_ADDR 123
+#define RADEON_VS_EYE_VECTOR_ADDR 124
+
+#define RADEON_SS_LIGHT_DCD_ADDR 0
+#define RADEON_SS_LIGHT_SPOT_EXPONENT_ADDR 8
+#define RADEON_SS_LIGHT_SPOT_CUTOFF_ADDR 16
+#define RADEON_SS_LIGHT_SPECULAR_THRESH_ADDR 24
+#define RADEON_SS_LIGHT_RANGE_CUTOFF_ADDR 32
+#define RADEON_SS_VERT_GUARD_CLIP_ADJ_ADDR 48
+#define RADEON_SS_VERT_GUARD_DISCARD_ADJ_ADDR 49
+#define RADEON_SS_HORZ_GUARD_CLIP_ADJ_ADDR 50
+#define RADEON_SS_HORZ_GUARD_DISCARD_ADJ_ADDR 51
+#define RADEON_SS_SHININESS 60
+
+#define RADEON_TV_MASTER_CNTL 0x0800
+# define RADEON_TVCLK_ALWAYS_ONb (1 << 30)
+#define RADEON_TV_DAC_CNTL 0x088c
+# define RADEON_TV_DAC_CMPOUT (1 << 5)
+#define RADEON_TV_PRE_DAC_MUX_CNTL 0x0888
+# define RADEON_Y_RED_EN (1 << 0)
+# define RADEON_C_GRN_EN (1 << 1)
+# define RADEON_CMP_BLU_EN (1 << 2)
+# define RADEON_RED_MX_FORCE_DAC_DATA (6 << 4)
+# define RADEON_GRN_MX_FORCE_DAC_DATA (6 << 8)
+# define RADEON_BLU_MX_FORCE_DAC_DATA (6 << 12)
+# define RADEON_TV_FORCE_DAC_DATA_SHIFT 16
+#endif
diff --git a/chromium/third_party/minigbm/src/Makefile b/chromium/third_party/minigbm/src/Makefile
index 17584444c41..de4fed18f3f 100644
--- a/chromium/third_party/minigbm/src/Makefile
+++ b/chromium/third_party/minigbm/src/Makefile
@@ -8,9 +8,9 @@ PC_DEPS = libdrm
PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
-CPPFLAGS += -D_GNU_SOURCE=1
-CFLAGS += -std=c99 -Wall -Wsign-compare -Wpointer-arith -Wcast-qual \
- -Wcast-align -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64
+CPPFLAGS += -std=c99 -D_GNU_SOURCE=1
+CFLAGS += -Wall -Wsign-compare -Wpointer-arith -Wcast-qual -Wcast-align \
+ -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64
ifdef DRV_AMDGPU
CFLAGS += $(shell $(PKG_CONFIG) --cflags libdrm_amdgpu)
@@ -21,7 +21,6 @@ ifdef DRV_EXYNOS
endif
ifdef DRV_I915
CFLAGS += $(shell $(PKG_CONFIG) --cflags libdrm_intel)
- LDLIBS += $(shell $(PKG_CONFIG) --libs libdrm_intel)
endif
ifdef DRV_ROCKCHIP
CFLAGS += $(shell $(PKG_CONFIG) --cflags libdrm_rockchip)
diff --git a/chromium/third_party/minigbm/src/amdgpu.c b/chromium/third_party/minigbm/src/amdgpu.c
index 5dcfbeb0f9b..38ea8d685d8 100644
--- a/chromium/third_party/minigbm/src/amdgpu.c
+++ b/chromium/third_party/minigbm/src/amdgpu.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,7 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/mman.h>
#include <xf86drm.h>
#include <amdgpu_drm.h>
#include <amdgpu.h>
@@ -40,16 +39,11 @@ enum {
};
static struct supported_combination combos[5] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XBGR8888, DRM_FORMAT_MOD_NONE,
- BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XBGR8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int amdgpu_set_metadata(int fd, uint32_t handle,
@@ -315,7 +309,6 @@ static int amdgpu_bo_create(struct bo *bo, uint32_t width, uint32_t height,
struct amdgpu_bo_metadata metadata = {0};
ADDR_COMPUTE_SURFACE_INFO_OUTPUT addr_out = {0};
uint32_t tiling_flags = 0;
- uint32_t gem_create_flags = 0;
int ret;
if (amdgpu_addrlib_compute(addrlib, width,
@@ -329,19 +322,13 @@ static int amdgpu_bo_create(struct bo *bo, uint32_t width, uint32_t height,
bo->sizes[0] = addr_out.surfSize;
bo->strides[0] = addr_out.pixelPitch
* DIV_ROUND_UP(addr_out.pixelBits, 8);
- if (usage & (BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_WRITE_RARELY |
- BO_USE_SW_READ_RARELY))
- gem_create_flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
- else
- gem_create_flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
memset(&gem_create, 0, sizeof(gem_create));
gem_create.in.bo_size = bo->sizes[0];
gem_create.in.alignment = addr_out.baseAlign;
/* Set the placement. */
gem_create.in.domains = AMDGPU_GEM_DOMAIN_VRAM;
- gem_create.in.domain_flags = gem_create_flags;
+ gem_create.in.domain_flags = usage;
/* Allocate the buffer with the preferred heap. */
ret = drmCommandWriteRead(drv_get_fd(bo->drv), DRM_AMDGPU_GEM_CREATE,
@@ -360,33 +347,12 @@ static int amdgpu_bo_create(struct bo *bo, uint32_t width, uint32_t height,
return ret;
}
-static void *amdgpu_bo_map(struct bo *bo, struct map_info *data, size_t plane)
-{
- int ret;
- union drm_amdgpu_gem_mmap gem_map;
-
- memset(&gem_map, 0, sizeof(gem_map));
- gem_map.in.handle = bo->handles[0].u32;
-
- ret = drmIoctl(bo->drv->fd, DRM_IOCTL_AMDGPU_GEM_MMAP, &gem_map);
- if (ret) {
- fprintf(stderr, "drv: DRM_IOCTL_AMDGPU_GEM_MMAP failed\n");
- return MAP_FAILED;
- }
- data->length = bo->sizes[0];
-
- return mmap(0, bo->sizes[0], PROT_READ | PROT_WRITE, MAP_SHARED,
- bo->drv->fd, gem_map.out.addr_ptr);
-}
-
struct backend backend_amdgpu = {
.name = "amdgpu",
.init = amdgpu_init,
.close = amdgpu_close,
.bo_create = amdgpu_bo_create,
.bo_destroy = drv_gem_bo_destroy,
- .bo_import = drv_prime_bo_import,
- .bo_map = amdgpu_bo_map,
};
#endif
diff --git a/chromium/third_party/minigbm/src/cirrus.c b/chromium/third_party/minigbm/src/cirrus.c
index f614e8ad08c..91466c96c4d 100644
--- a/chromium/third_party/minigbm/src/cirrus.c
+++ b/chromium/third_party/minigbm/src/cirrus.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,16 +8,12 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[3] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_RGB888, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
- BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[5] = {
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_RGB888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int cirrus_init(struct driver *drv)
@@ -32,6 +28,5 @@ struct backend backend_cirrus =
.init = cirrus_init,
.bo_create = drv_dumb_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/minigbm/src/common.mk b/chromium/third_party/minigbm/src/common.mk
index 3d7e7d4674c..21de50c937e 100644
--- a/chromium/third_party/minigbm/src/common.mk
+++ b/chromium/third_party/minigbm/src/common.mk
@@ -1,4 +1,4 @@
-# Copyright 2012 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
diff --git a/chromium/third_party/minigbm/src/cros_gralloc/cros_alloc_device.cc b/chromium/third_party/minigbm/src/cros_gralloc/cros_alloc_device.cc
index 97c8186f8c6..540574418a0 100644
--- a/chromium/third_party/minigbm/src/cros_gralloc/cros_alloc_device.cc
+++ b/chromium/third_party/minigbm/src/cros_gralloc/cros_alloc_device.cc
@@ -29,14 +29,6 @@ static struct cros_gralloc_bo *cros_gralloc_bo_create(struct driver *drv,
DRM_FORMAT_MOD_NONE);
}
- if (!supported && (drv_usage & BO_USE_RENDERING) &&
- (drv_usage && (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))) {
- drv_usage &= ~BO_USE_RENDERING;
- supported = drv_is_combination_supported(drv, drv_format,
- drv_usage,
- DRM_FORMAT_MOD_NONE);
- }
-
if (!supported) {
cros_gralloc_error("Unsupported combination -- HAL format: %u, "
"HAL flags: %u, drv_format: %u, "
diff --git a/chromium/third_party/minigbm/src/drv.c b/chromium/third_party/minigbm/src/drv.c
index fb79e127e4f..3a9ab4caae6 100644
--- a/chromium/third_party/minigbm/src/drv.c
+++ b/chromium/third_party/minigbm/src/drv.c
@@ -1,10 +1,9 @@
/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <assert.h>
-#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdint.h>
@@ -36,7 +35,6 @@ extern struct backend backend_marvell;
#ifdef DRV_MEDIATEK
extern struct backend backend_mediatek;
#endif
-extern struct backend backend_nouveau;
#ifdef DRV_ROCKCHIP
extern struct backend backend_rockchip;
#endif
@@ -44,9 +42,6 @@ extern struct backend backend_rockchip;
extern struct backend backend_tegra;
#endif
extern struct backend backend_udl;
-#ifdef DRV_VC4
-extern struct backend backend_vc4;
-#endif
extern struct backend backend_vgem;
extern struct backend backend_virtio_gpu;
@@ -79,7 +74,6 @@ static struct backend *drv_get_backend(int fd)
#ifdef DRV_MEDIATEK
&backend_mediatek,
#endif
- &backend_nouveau,
#ifdef DRV_ROCKCHIP
&backend_rockchip,
#endif
@@ -87,9 +81,6 @@ static struct backend *drv_get_backend(int fd)
&backend_tegra,
#endif
&backend_udl,
-#ifdef DRV_VC4
- &backend_vc4,
-#endif
&backend_vgem,
&backend_virtio_gpu,
};
@@ -256,44 +247,6 @@ struct bo *drv_bo_create(struct driver *drv, uint32_t width, uint32_t height,
return bo;
}
-struct bo *drv_bo_create_with_modifiers(struct driver *drv,
- uint32_t width, uint32_t height,
- uint32_t format,
- const uint64_t *modifiers, uint32_t count)
-{
- int ret;
- size_t plane;
- struct bo *bo;
-
- if (!drv->backend->bo_create_with_modifiers) {
- errno = ENOENT;
- return NULL;
- }
-
- bo = drv_bo_new(drv, width, height, format);
-
- if (!bo)
- return NULL;
-
- ret = drv->backend->bo_create_with_modifiers(bo, width, height,
- format, modifiers, count);
-
- if (ret) {
- free(bo);
- return NULL;
- }
-
- pthread_mutex_lock(&drv->driver_lock);
-
- for (plane = 0; plane < bo->num_planes; plane++)
- drv_increment_reference_count(drv, bo, plane);
-
- pthread_mutex_unlock(&drv->driver_lock);
-
- return bo;
-}
-
-
void drv_bo_destroy(struct bo *bo)
{
size_t plane;
@@ -321,24 +274,45 @@ struct bo *drv_bo_import(struct driver *drv, struct drv_import_fd_data *data)
int ret;
size_t plane;
struct bo *bo;
+ struct drm_prime_handle prime_handle;
bo = drv_bo_new(drv, data->width, data->height, data->format);
if (!bo)
return NULL;
- ret = drv->backend->bo_import(bo, data);
- if (ret) {
- free(bo);
- return NULL;
- }
-
for (plane = 0; plane < bo->num_planes; plane++) {
+
+ memset(&prime_handle, 0, sizeof(prime_handle));
+ prime_handle.fd = data->fds[plane];
+
+ ret = drmIoctl(drv->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE,
+ &prime_handle);
+
+ if (ret) {
+ fprintf(stderr, "drv: DRM_IOCTL_PRIME_FD_TO_HANDLE failed "
+ "(fd=%u)\n", prime_handle.fd);
+
+ if (plane > 0) {
+ bo->num_planes = plane;
+ drv_bo_destroy(bo);
+ } else {
+ free(bo);
+ }
+
+ return NULL;
+ }
+
+ bo->handles[plane].u32 = prime_handle.handle;
bo->strides[plane] = data->strides[plane];
bo->offsets[plane] = data->offsets[plane];
bo->sizes[plane] = data->sizes[plane];
bo->format_modifiers[plane] = data->format_modifiers[plane];
bo->total_size += data->sizes[plane];
+
+ pthread_mutex_lock(&drv->driver_lock);
+ drv_increment_reference_count(drv, bo, plane);
+ pthread_mutex_unlock(&drv->driver_lock);
}
return bo;
@@ -402,10 +376,7 @@ int drv_bo_unmap(struct bo *bo, void *map_data)
pthread_mutex_lock(&bo->drv->driver_lock);
if (!--data->refcount) {
- if (bo->drv->backend->bo_unmap)
- ret = bo->drv->backend->bo_unmap(bo, data);
- else
- ret = munmap(data->addr, data->length);
+ ret = munmap(data->addr, data->length);
drmHashDelete(bo->drv->map_table, data->handle);
free(data);
}
diff --git a/chromium/third_party/minigbm/src/drv.h b/chromium/third_party/minigbm/src/drv.h
index 355ea45f03e..83d3b6a4bf5 100644
--- a/chromium/third_party/minigbm/src/drv.h
+++ b/chromium/third_party/minigbm/src/drv.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -92,12 +92,6 @@ struct bo *
drv_bo_create(struct driver *drv, uint32_t width, uint32_t height,
uint32_t format, uint64_t flags);
-struct bo *
-drv_bo_create_with_modifiers(struct driver *drv,
- uint32_t width, uint32_t height,
- uint32_t format,
- const uint64_t *modifiers, uint32_t count);
-
void
drv_bo_destroy(struct bo *bo);
diff --git a/chromium/third_party/minigbm/src/drv_priv.h b/chromium/third_party/minigbm/src/drv_priv.h
index 62492c284cb..837310a70b7 100644
--- a/chromium/third_party/minigbm/src/drv_priv.h
+++ b/chromium/third_party/minigbm/src/drv_priv.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -46,7 +46,6 @@ struct map_info {
size_t length;
uint32_t handle;
int32_t refcount;
- void *priv;
};
struct supported_combination {
@@ -67,15 +66,8 @@ struct backend
void (*close)(struct driver *drv);
int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height,
uint32_t format, uint32_t flags);
- int (*bo_create_with_modifiers)(struct bo *bo,
- uint32_t width, uint32_t height,
- uint32_t format,
- const uint64_t *modifiers,
- uint32_t count);
- int (*bo_destroy)(struct bo *bo);
- int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
void* (*bo_map)(struct bo *bo, struct map_info *data, size_t plane);
- int (*bo_unmap)(struct bo *bo, struct map_info *data);
+ int (*bo_destroy)(struct bo *bo);
uint32_t (*resolve_format)(uint32_t format);
struct list_head combinations;
};
diff --git a/chromium/third_party/minigbm/src/evdi.c b/chromium/third_party/minigbm/src/evdi.c
index 988797b2f8c..97042d1dc78 100644
--- a/chromium/third_party/minigbm/src/evdi.c
+++ b/chromium/third_party/minigbm/src/evdi.c
@@ -8,13 +8,11 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[2] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[4] = {
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int evdi_init(struct driver *drv)
@@ -29,7 +27,6 @@ struct backend backend_evdi =
.init = evdi_init,
.bo_create = drv_dumb_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/minigbm/src/exynos.c b/chromium/third_party/minigbm/src/exynos.c
index 4dcf6043cc1..d6dc7def46f 100644
--- a/chromium/third_party/minigbm/src/exynos.c
+++ b/chromium/third_party/minigbm/src/exynos.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -17,16 +17,12 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[3] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_NV12, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
- BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[5] = {
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_NV12, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int exynos_init(struct driver *drv)
@@ -110,7 +106,6 @@ struct backend backend_exynos =
.init = exynos_init,
.bo_create = exynos_bo_create,
.bo_destroy = drv_gem_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/minigbm/src/gbm.c b/chromium/third_party/minigbm/src/gbm.c
index 6ad32ce6bbe..7389cd8a1b0 100644
--- a/chromium/third_party/minigbm/src/gbm.c
+++ b/chromium/third_party/minigbm/src/gbm.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -137,32 +137,6 @@ PUBLIC struct gbm_bo *gbm_bo_create(struct gbm_device *gbm, uint32_t width,
return bo;
}
-PUBLIC struct gbm_bo *gbm_bo_create_with_modifiers(struct gbm_device *gbm,
- uint32_t width,
- uint32_t height,
- uint32_t format,
- const uint64_t *modifiers,
- uint32_t count)
-{
- struct gbm_bo *bo;
-
- bo = gbm_bo_new(gbm, format);
-
- if (!bo)
- return NULL;
-
- bo->bo = drv_bo_create_with_modifiers(gbm->drv,
- width, height, format,
- modifiers, count);
-
- if (!bo->bo) {
- free(bo);
- return NULL;
- }
-
- return bo;
-}
-
PUBLIC void gbm_bo_destroy(struct gbm_bo *bo)
{
if (bo->destroy_user_data) {
diff --git a/chromium/third_party/minigbm/src/gbm.h b/chromium/third_party/minigbm/src/gbm.h
index 1fb338f98e3..839e2a51c63 100644
--- a/chromium/third_party/minigbm/src/gbm.h
+++ b/chromium/third_party/minigbm/src/gbm.h
@@ -35,7 +35,6 @@ extern "C" {
#define __GBM__ 1
-#include <stddef.h>
#include <stdint.h>
/**
@@ -262,12 +261,6 @@ gbm_bo_create(struct gbm_device *gbm,
uint32_t width, uint32_t height,
uint32_t format, uint32_t flags);
-struct gbm_bo *
-gbm_bo_create_with_modifiers(struct gbm_device *gbm,
- uint32_t width, uint32_t height,
- uint32_t format,
- const uint64_t *modifiers, uint32_t count);
-
#define GBM_BO_IMPORT_WL_BUFFER 0x5501
#define GBM_BO_IMPORT_EGL_IMAGE 0x5502
#define GBM_BO_IMPORT_FD 0x5503
diff --git a/chromium/third_party/minigbm/src/gbm_helpers.c b/chromium/third_party/minigbm/src/gbm_helpers.c
index c60a315b2cc..be18a398e61 100644
--- a/chromium/third_party/minigbm/src/gbm_helpers.c
+++ b/chromium/third_party/minigbm/src/gbm_helpers.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chromium/third_party/minigbm/src/gbm_helpers.h b/chromium/third_party/minigbm/src/gbm_helpers.h
index 48ff3913736..8e0b8b0fd90 100644
--- a/chromium/third_party/minigbm/src/gbm_helpers.h
+++ b/chromium/third_party/minigbm/src/gbm_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chromium/third_party/minigbm/src/gbm_priv.h b/chromium/third_party/minigbm/src/gbm_priv.h
index eb29f1be8a7..379bf01701a 100644
--- a/chromium/third_party/minigbm/src/gbm_priv.h
+++ b/chromium/third_party/minigbm/src/gbm_priv.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chromium/third_party/minigbm/src/gma500.c b/chromium/third_party/minigbm/src/gma500.c
index d8932fb40da..0f78e8546d4 100644
--- a/chromium/third_party/minigbm/src/gma500.c
+++ b/chromium/third_party/minigbm/src/gma500.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,10 +8,9 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[1] = {
- {DRM_FORMAT_RGBX8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[2] = {
+ {DRM_FORMAT_RGBX8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_RGBX8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int gma500_init(struct driver *drv)
@@ -26,6 +25,5 @@ struct backend backend_gma500 =
.init = gma500_init,
.bo_create = drv_dumb_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/minigbm/src/helpers.c b/chromium/third_party/minigbm/src/helpers.c
index 87aad9df17b..f6fd0ec7ec0 100644
--- a/chromium/third_party/minigbm/src/helpers.c
+++ b/chromium/third_party/minigbm/src/helpers.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -210,46 +210,6 @@ int drv_gem_bo_destroy(struct bo *bo)
return error;
}
-int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data)
-{
- int ret;
- size_t plane;
- struct drm_prime_handle prime_handle;
-
- for (plane = 0; plane < bo->num_planes; plane++) {
- memset(&prime_handle, 0, sizeof(prime_handle));
- prime_handle.fd = data->fds[plane];
-
- ret = drmIoctl(bo->drv->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE,
- &prime_handle);
-
- if (ret) {
- fprintf(stderr, "drv: DRM_IOCTL_PRIME_FD_TO_HANDLE "
- "failed (fd=%u)\n", prime_handle.fd);
-
- /*
- * Need to call GEM close on planes that were opened,
- * if any. Adjust the num_planes variable to be the
- * plane that failed, so GEM close will be called on
- * planes before that plane.
- */
- bo->num_planes = plane;
- drv_gem_bo_destroy(bo);
- return ret;
- }
-
- bo->handles[plane].u32 = prime_handle.handle;
- }
-
- for (plane = 0; plane < bo->num_planes; plane++) {
- pthread_mutex_lock(&bo->drv->driver_lock);
- drv_increment_reference_count(bo->drv, bo, plane);
- pthread_mutex_unlock(&bo->drv->driver_lock);
- }
-
- return 0;
-}
-
void *drv_dumb_bo_map(struct bo *bo, struct map_info *data, size_t plane)
{
int ret;
diff --git a/chromium/third_party/minigbm/src/helpers.h b/chromium/third_party/minigbm/src/helpers.h
index 64e8489e391..5b72bacc708 100644
--- a/chromium/third_party/minigbm/src/helpers.h
+++ b/chromium/third_party/minigbm/src/helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -16,7 +16,6 @@ int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height,
uint32_t format, uint32_t flags);
int drv_dumb_bo_destroy(struct bo *bo);
int drv_gem_bo_destroy(struct bo *bo);
-int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data);
void *drv_dumb_bo_map(struct bo *bo, struct map_info *data, size_t plane);
uintptr_t drv_get_reference_count(struct driver *drv, struct bo *bo,
size_t plane);
diff --git a/chromium/third_party/minigbm/src/i915.c b/chromium/third_party/minigbm/src/i915.c
index 2c6645bf2cb..769e6a33c67 100644
--- a/chromium/third_party/minigbm/src/i915.c
+++ b/chromium/third_party/minigbm/src/i915.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,17 +7,17 @@
#ifdef DRV_I915
#include <errno.h>
-#include <i915_drm.h>
-#include <intel_bufmgr.h>
#include <string.h>
+#include <stdio.h>
#include <sys/mman.h>
#include <xf86drm.h>
+#include <i915_drm.h>
#include "drv_priv.h"
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[19] = {
+static struct supported_combination combos[18] = {
{DRM_FORMAT_ARGB1555, DRM_FORMAT_MOD_NONE,
BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_ABGR8888, DRM_FORMAT_MOD_NONE,
@@ -54,20 +54,11 @@ static struct supported_combination combos[19] = {
BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
};
struct i915_device
{
int gen;
- drm_intel_bufmgr *mgr;
- uint32_t count;
-};
-
-struct i915_bo
-{
- drm_intel_bo *ibos[DRV_MAX_PLANES];
};
static int get_gen(int device_id)
@@ -82,10 +73,45 @@ static int get_gen(int device_id)
return 4;
}
+static int i915_init(struct driver *drv)
+{
+ struct i915_device *i915_drv;
+ drm_i915_getparam_t get_param;
+ int device_id;
+ int ret;
+
+ i915_drv = (struct i915_device*)malloc(sizeof(*i915_drv));
+ if (!i915_drv)
+ return -1;
+
+ memset(&get_param, 0, sizeof(get_param));
+ get_param.param = I915_PARAM_CHIPSET_ID;
+ get_param.value = &device_id;
+ ret = drmIoctl(drv->fd, DRM_IOCTL_I915_GETPARAM, &get_param);
+ if (ret) {
+ fprintf(stderr, "drv: DRM_IOCTL_I915_GETPARAM failed\n");
+ free(i915_drv);
+ return -1;
+ }
+
+ i915_drv->gen = get_gen(device_id);
+
+ drv->priv = i915_drv;
+
+ drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
+ return drv_add_kms_flags(drv);
+}
+
+static void i915_close(struct driver *drv)
+{
+ free(drv->priv);
+ drv->priv = NULL;
+}
+
static void i915_align_dimensions(struct driver *drv, uint32_t tiling_mode,
uint32_t *width, uint32_t *height, int bpp)
{
- struct i915_device *i915_dev = (struct i915_device *)drv->priv;
+ struct i915_device *i915_drv = (struct i915_device *)drv->priv;
uint32_t width_alignment = 4, height_alignment = 4;
switch (tiling_mode) {
@@ -100,7 +126,7 @@ static void i915_align_dimensions(struct driver *drv, uint32_t tiling_mode,
break;
case I915_TILING_Y:
- if (i915_dev->gen == 3) {
+ if (i915_drv->gen == 3) {
width_alignment = 512 / bpp;
height_alignment = 8;
} else {
@@ -110,7 +136,7 @@ static void i915_align_dimensions(struct driver *drv, uint32_t tiling_mode,
break;
}
- if (i915_dev->gen > 3) {
+ if (i915_drv->gen > 3) {
*width = ALIGN(*width, width_alignment);
*height = ALIGN(*height, height_alignment);
} else {
@@ -125,69 +151,23 @@ static void i915_align_dimensions(struct driver *drv, uint32_t tiling_mode,
static int i915_verify_dimensions(struct driver *drv, uint32_t stride,
uint32_t height)
{
- struct i915_device *i915_dev = (struct i915_device *)drv->priv;
- if (i915_dev->gen <= 3 && stride > 8192)
+ struct i915_device *i915_drv = (struct i915_device *)drv->priv;
+ if (i915_drv->gen <= 3 && stride > 8192)
return 0;
return 1;
}
-static int i915_init(struct driver *drv)
-{
- struct i915_device *i915_dev;
- drm_i915_getparam_t get_param;
- int device_id;
- int ret;
-
- i915_dev = calloc(1, sizeof(*i915_dev));
- if (!i915_dev)
- return -1;
-
- memset(&get_param, 0, sizeof(get_param));
- get_param.param = I915_PARAM_CHIPSET_ID;
- get_param.value = &device_id;
- ret = drmIoctl(drv->fd, DRM_IOCTL_I915_GETPARAM, &get_param);
- if (ret) {
- fprintf(stderr, "drv: DRM_IOCTL_I915_GETPARAM failed\n");
- free(i915_dev);
- return -EINVAL;
- }
-
- i915_dev->gen = get_gen(device_id);
- i915_dev->count = 0;
-
- i915_dev->mgr = drm_intel_bufmgr_gem_init(drv->fd, 16 * 1024);
- if (!i915_dev->mgr) {
- fprintf(stderr, "drv: drm_intel_bufmgr_gem_init failed\n");
- free(i915_dev);
- return -EINVAL;
- }
-
- drv->priv = i915_dev;
-
- drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
- return drv_add_kms_flags(drv);
-}
-
-static void i915_close(struct driver *drv)
-{
- struct i915_device *i915_dev = drv->priv;
- drm_intel_bufmgr_destroy(i915_dev->mgr);
- free(i915_dev);
- drv->priv = NULL;
-}
-
static int i915_bo_create(struct bo *bo, uint32_t width, uint32_t height,
uint32_t format, uint32_t flags)
{
- int ret;
- size_t plane;
- char name[20];
- uint32_t tiling_mode;
- struct i915_bo *i915_bo;
-
+ struct driver *drv = bo->drv;
int bpp = drv_stride_from_format(format, 1, 0);
- struct i915_device *i915_dev = (struct i915_device *)bo->drv->priv;
+ struct drm_i915_gem_create gem_create;
+ struct drm_i915_gem_set_tiling gem_set_tiling;
+ uint32_t tiling_mode = I915_TILING_NONE;
+ size_t plane;
+ int ret;
if (flags & (BO_USE_CURSOR | BO_USE_LINEAR |
BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))
@@ -197,114 +177,46 @@ static int i915_bo_create(struct bo *bo, uint32_t width, uint32_t height,
else
tiling_mode = I915_TILING_Y;
- i915_align_dimensions(bo->drv, tiling_mode, &width, &height, bpp);
- drv_bo_from_format(bo, width, height, format);
-
- if (!i915_verify_dimensions(bo->drv, bo->strides[0], height))
- return -EINVAL;
-
- snprintf(name, sizeof(name), "i915-buffer-%u", i915_dev->count);
- i915_dev->count++;
-
- i915_bo = calloc(1, sizeof(*i915_bo));
- if (!i915_bo)
- return -ENOMEM;
-
- bo->priv = i915_bo;
+ i915_align_dimensions(drv, tiling_mode, &width, &height, bpp);
- i915_bo->ibos[0] = drm_intel_bo_alloc(i915_dev->mgr, name,
- bo->total_size, 0);
- if (!i915_bo->ibos[0]) {
- fprintf(stderr, "drv: drm_intel_bo_alloc failed");
- free(i915_bo);
- bo->priv = NULL;
- return -ENOMEM;
- }
-
- for (plane = 0; plane < bo->num_planes; plane++) {
- if (plane > 0)
- drm_intel_bo_reference(i915_bo->ibos[0]);
-
- bo->handles[plane].u32 = i915_bo->ibos[0]->handle;
- i915_bo->ibos[plane] = i915_bo->ibos[0];
- }
+ drv_bo_from_format(bo, width, height, format);
- bo->tiling = tiling_mode;
+ if (!i915_verify_dimensions(drv, bo->strides[0], height))
+ return EINVAL;
- ret = drm_intel_bo_set_tiling(i915_bo->ibos[0], &bo->tiling,
- bo->strides[0]);
+ memset(&gem_create, 0, sizeof(gem_create));
+ gem_create.size = bo->total_size;
- if (ret || bo->tiling != tiling_mode) {
- fprintf(stderr, "drv: drm_intel_gem_bo_set_tiling failed "
- "errno=%x, stride=%x\n", errno, bo->strides[0]);
- /* Calls i915 bo destroy. */
- bo->drv->backend->bo_destroy(bo);
- return -errno;
+ ret = drmIoctl(drv->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
+ if (ret) {
+ fprintf(stderr, "drv: DRM_IOCTL_I915_GEM_CREATE failed "
+ "(size=%llu)\n", gem_create.size);
+ return ret;
}
- return 0;
-}
-
-static int i915_bo_destroy(struct bo *bo)
-{
- size_t plane;
- struct i915_bo *i915_bo = bo->priv;
-
for (plane = 0; plane < bo->num_planes; plane++)
- drm_intel_bo_unreference(i915_bo->ibos[plane]);
-
- free(i915_bo);
- bo->priv = NULL;
-
- return 0;
-}
-
-static int i915_bo_import(struct bo *bo, struct drv_import_fd_data *data)
-{
- size_t plane;
- uint32_t swizzling;
- struct i915_bo *i915_bo;
- struct i915_device *i915_dev = bo->drv->priv;
-
- i915_bo = calloc(1, sizeof(*i915_bo));
- if (!i915_bo)
- return -ENOMEM;
-
- bo->priv = i915_bo;
-
- /*
- * When self-importing, libdrm_intel increments the reference count
- * on the drm_intel_bo. It also returns the same drm_intel_bo per GEM
- * handle. Thus, we don't need to increase the reference count
- * (i.e, drv_increment_reference_count) when importing with this
- * backend.
- */
- for (plane = 0; plane < bo->num_planes; plane++) {
-
- i915_bo->ibos[plane] = drm_intel_bo_gem_create_from_prime(i915_dev->mgr,
- data->fds[plane], data->sizes[plane]);
-
- if (!i915_bo->ibos[plane]) {
- /*
- * Need to call GEM close on planes that were opened,
- * if any. Adjust the num_planes variable to be the
- * plane that failed, so GEM close will be called on
- * planes before that plane.
- */
- bo->num_planes = plane;
- i915_bo_destroy(bo);
- fprintf(stderr, "drv: i915: failed to import failed");
- return -EINVAL;
- }
-
- bo->handles[plane].u32 = i915_bo->ibos[plane]->handle;
- }
-
- if (drm_intel_bo_get_tiling(i915_bo->ibos[0], &bo->tiling,
- &swizzling)) {
- fprintf(stderr, "drv: drm_intel_bo_get_tiling failed");
- i915_bo_destroy(bo);
- return -EINVAL;
+ bo->handles[plane].u32 = gem_create.handle;
+
+ memset(&gem_set_tiling, 0, sizeof(gem_set_tiling));
+ do {
+ gem_set_tiling.handle = bo->handles[0].u32;
+ gem_set_tiling.tiling_mode = tiling_mode;
+ gem_set_tiling.stride = bo->strides[0];
+ ret = drmIoctl(drv->fd, DRM_IOCTL_I915_GEM_SET_TILING,
+ &gem_set_tiling);
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+
+ if (ret == -1) {
+ struct drm_gem_close gem_close;
+ gem_close.handle = bo->handles[0].u32;
+ fprintf(stderr, "drv: DRM_IOCTL_I915_GEM_SET_TILING failed "
+ "errno=%x (handle=%x, tiling=%x, stride=%x)\n",
+ errno,
+ gem_set_tiling.handle,
+ gem_set_tiling.tiling_mode,
+ gem_set_tiling.stride);
+ drmIoctl(drv->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
+ return -errno;
}
return 0;
@@ -313,35 +225,21 @@ static int i915_bo_import(struct bo *bo, struct drv_import_fd_data *data)
static void *i915_bo_map(struct bo *bo, struct map_info *data, size_t plane)
{
int ret;
- struct i915_bo *i915_bo = bo->priv;
+ struct drm_i915_gem_mmap_gtt gem_map;
- if (bo->tiling == I915_TILING_NONE)
- /* TODO(gsingh): use bo_map flags to determine if we should
- * enable writing.
- */
- ret = drm_intel_bo_map(i915_bo->ibos[0], 1);
- else
- ret = drm_intel_gem_bo_map_gtt(i915_bo->ibos[0]);
+ memset(&gem_map, 0, sizeof(gem_map));
+ gem_map.handle = bo->handles[0].u32;
+ ret = drmIoctl(bo->drv->fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &gem_map);
if (ret) {
- fprintf(stderr, "drv: i915_bo_map failed.");
+ fprintf(stderr, "drv: DRM_IOCTL_I915_GEM_MMAP_GTT failed\n");
return MAP_FAILED;
}
- return i915_bo->ibos[0]->virtual;
-}
-
-static int i915_bo_unmap(struct bo *bo, struct map_info *data)
-{
- int ret;
- struct i915_bo *i915_bo = bo->priv;
-
- if (bo->tiling == I915_TILING_NONE)
- ret = drm_intel_bo_unmap(i915_bo->ibos[0]);
- else
- ret = drm_intel_gem_bo_unmap_gtt(i915_bo->ibos[0]);
+ data->length = bo->total_size;
- return ret;
+ return mmap(0, bo->total_size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ bo->drv->fd, gem_map.offset);
}
static uint32_t i915_resolve_format(uint32_t format)
@@ -363,10 +261,8 @@ struct backend backend_i915 =
.init = i915_init,
.close = i915_close,
.bo_create = i915_bo_create,
- .bo_destroy = i915_bo_destroy,
- .bo_import = i915_bo_import,
+ .bo_destroy = drv_gem_bo_destroy,
.bo_map = i915_bo_map,
- .bo_unmap = i915_bo_unmap,
.resolve_format = i915_resolve_format,
};
diff --git a/chromium/third_party/minigbm/src/marvell.c b/chromium/third_party/minigbm/src/marvell.c
index ae3dc4570dc..e088db6e496 100644
--- a/chromium/third_party/minigbm/src/marvell.c
+++ b/chromium/third_party/minigbm/src/marvell.c
@@ -10,13 +10,11 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[2] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[4] = {
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
}
static int marvell_init(struct driver *drv)
@@ -31,7 +29,6 @@ struct backend backend_marvell =
.init = marvell_init,
.bo_create = drv_dumb_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/minigbm/src/mediatek.c b/chromium/third_party/minigbm/src/mediatek.c
index 7e85f63409a..d4206be55fb 100644
--- a/chromium/third_party/minigbm/src/mediatek.c
+++ b/chromium/third_party/minigbm/src/mediatek.c
@@ -16,24 +16,25 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[6] = {
+static struct supported_combination combos[8] = {
{DRM_FORMAT_ABGR8888, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
+ BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
+ BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_RGB565, DRM_FORMAT_MOD_NONE,
- BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
- BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
+ BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
{DRM_FORMAT_XBGR8888, DRM_FORMAT_MOD_NONE,
BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
+ BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
};
@@ -107,7 +108,6 @@ struct backend backend_mediatek =
.init = mediatek_init,
.bo_create = mediatek_bo_create,
.bo_destroy = drv_gem_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = mediatek_bo_map,
.resolve_format = mediatek_resolve_format,
};
diff --git a/chromium/third_party/minigbm/src/nouveau.c b/chromium/third_party/minigbm/src/nouveau.c
deleted file mode 100644
index e0d5954db72..00000000000
--- a/chromium/third_party/minigbm/src/nouveau.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "drv_priv.h"
-#include "helpers.h"
-#include "util.h"
-
-static struct supported_combination combos[2] = {
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_RENDERING},
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_RENDERING},
-};
-
-static int nouveau_init(struct driver *drv)
-{
- drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
- return drv_add_kms_flags(drv);
-}
-
-struct backend backend_nouveau =
-{
- .name = "nouveau",
- .init = nouveau_init,
- .bo_create = drv_dumb_bo_create,
- .bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
- .bo_map = drv_dumb_bo_map,
-};
diff --git a/chromium/third_party/minigbm/src/rockchip.c b/chromium/third_party/minigbm/src/rockchip.c
index a64a42f682f..02a5c473f87 100644
--- a/chromium/third_party/minigbm/src/rockchip.c
+++ b/chromium/third_party/minigbm/src/rockchip.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -17,7 +17,7 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[12] = {
+static struct supported_combination combos[11] = {
{DRM_FORMAT_ABGR8888, DRM_FORMAT_MOD_NONE,
BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
@@ -42,79 +42,16 @@ static struct supported_combination combos[12] = {
BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
};
-static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height,
- uint32_t format)
-{
- /* We've restricted ourselves to four bytes per pixel. */
- const uint32_t pixel_size = 4;
-
- const uint32_t clump_width = 4;
- const uint32_t clump_height = 4;
-
-#define AFBC_NARROW 1
-#if AFBC_NARROW == 1
- const uint32_t block_width = 4 * clump_width;
- const uint32_t block_height = 4 * clump_height;
-#else
- const uint32_t block_width = 8 * clump_width;
- const uint32_t block_height = 2 * clump_height;
-#endif
-
- const uint32_t header_block_size = 16;
- const uint32_t body_block_size = block_width * block_height * pixel_size;
- const uint32_t width_in_blocks = DIV_ROUND_UP(width, block_width);
- const uint32_t height_in_blocks = DIV_ROUND_UP(height, block_height);
- const uint32_t total_blocks = width_in_blocks * height_in_blocks;
-
- const uint32_t header_plane_size = total_blocks * header_block_size;
- const uint32_t body_plane_size = total_blocks * body_block_size;
-
- /* GPU requires 64 bytes, but EGL import code expects 1024 byte
- * alignement for the body plane. */
- const uint32_t body_plane_alignment = 1024;
-
- const uint32_t body_plane_offset =
- ALIGN(header_plane_size, body_plane_alignment);
- const uint32_t total_size =
- body_plane_offset + body_plane_size;
-
- bo->strides[0] = width_in_blocks * block_width * pixel_size;
- bo->sizes[0] = total_size;
- bo->offsets[0] = 0;
-
- bo->total_size = total_size;
-
- bo->format_modifiers[0] = DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC;
-
- return 0;
-}
-
static int rockchip_init(struct driver *drv)
{
drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
return drv_add_kms_flags(drv);
}
-static bool has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier)
-{
- uint32_t i;
-
- for (i = 0; i < count; i++)
- if (list[i] == modifier)
- return true;
-
- return false;
-}
-
-static int rockchip_bo_create_with_modifiers(struct bo *bo,
- uint32_t width, uint32_t height,
- uint32_t format,
- const uint64_t *modifiers,
- uint32_t count)
+static int rockchip_bo_create(struct bo *bo, uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
int ret;
size_t plane;
@@ -130,18 +67,7 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo,
drv_bo_from_format(bo, aligned_width, height, format);
bo->total_size = bo->strides[0] * aligned_height
+ w_mbs * h_mbs * 128;
- } else if (width <= 2560 &&
- has_modifier(modifiers, count,
- DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC)) {
- /* If the caller has decided they can use AFBC, always
- * pick that */
- afbc_bo_from_format(bo, width, height, format);
} else {
- if (!has_modifier(modifiers, count, DRM_FORMAT_MOD_NONE)) {
- errno = EINVAL;
- fprintf(stderr, "no usable modifier found\n");
- return -1;
- }
drv_bo_from_format(bo, width, height, format);
}
@@ -163,25 +89,11 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo,
return 0;
}
-static int rockchip_bo_create(struct bo *bo, uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
-{
- uint64_t modifiers[] = { DRM_FORMAT_MOD_NONE };
-
- return rockchip_bo_create_with_modifiers(bo, width, height, format,
- modifiers, ARRAY_SIZE(modifiers));
-}
-
static void *rockchip_bo_map(struct bo *bo, struct map_info *data, size_t plane)
{
int ret;
struct drm_rockchip_gem_map_off gem_map;
- /* We can only map buffers created with SW access flags, which should
- * have no modifiers (ie, not AFBC). */
- if (bo->format_modifiers[0] == DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC)
- return MAP_FAILED;
-
memset(&gem_map, 0, sizeof(gem_map));
gem_map.handle = bo->handles[0].u32;
@@ -217,9 +129,7 @@ struct backend backend_rockchip =
.name = "rockchip",
.init = rockchip_init,
.bo_create = rockchip_bo_create,
- .bo_create_with_modifiers = rockchip_bo_create_with_modifiers,
.bo_destroy = drv_gem_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = rockchip_bo_map,
.resolve_format = rockchip_resolve_format,
};
diff --git a/chromium/third_party/minigbm/src/tegra.c b/chromium/third_party/minigbm/src/tegra.c
index f48352e615d..49f3c6aeb47 100644
--- a/chromium/third_party/minigbm/src/tegra.c
+++ b/chromium/third_party/minigbm/src/tegra.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -33,16 +33,6 @@ enum nv_mem_kind
NV_MEM_KIND_GENERIC_16Bx2 = 0xfe,
};
-enum tegra_map_type {
- TEGRA_READ_TILED_BUFFER = 0,
- TEGRA_WRITE_TILED_BUFFER = 1,
-};
-
-struct tegra_private_map_data {
- void *tiled;
- void *untiled;
-};
-
static struct supported_combination combos[4] = {
{DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
@@ -104,80 +94,10 @@ static void compute_layout_blocklinear(int width, int height, int format,
static void compute_layout_linear(int width, int height, int format,
uint32_t *stride, uint32_t *size)
{
- *stride = ALIGN(drv_stride_from_format(format, width, 0), 64);
+ *stride = drv_stride_from_format(format, width, 0);
*size = *stride * height;
}
-static void transfer_tile(struct bo *bo, uint8_t *tiled, uint8_t *untiled,
- enum tegra_map_type type, uint32_t bytes_per_pixel,
- uint32_t gob_top, uint32_t gob_left,
- uint32_t gob_size_pixels)
-{
- uint8_t *tmp;
- uint32_t x, y, k;
- for (k = 0; k < gob_size_pixels; k++) {
- /*
- * Given the kth pixel starting from the tile specified by
- * gob_top and gob_left, unswizzle to get the standard (x, y)
- * representation.
- */
- x = gob_left + (((k >> 3) & 8) | ((k >> 1) & 4) | (k & 3));
- y = gob_top + ((k >> 7 << 3) | ((k >> 3) & 6) | ((k >> 2) & 1));
-
- tmp = untiled + (y * bo->strides[0]) + (x * bytes_per_pixel);
-
- if (type == TEGRA_READ_TILED_BUFFER)
- memcpy(tmp, tiled, bytes_per_pixel);
- else if (type == TEGRA_WRITE_TILED_BUFFER)
- memcpy(tiled, tmp, bytes_per_pixel);
-
- /* Move on to next pixel. */
- tiled += bytes_per_pixel;
- }
-}
-
-static void transfer_tiled_memory(struct bo *bo, uint8_t *tiled,
- uint8_t *untiled, enum tegra_map_type type)
-{
- uint32_t gob_width, gob_height, gob_size_bytes, gob_size_pixels,
- gob_count_x, gob_count_y, gob_top, gob_left;
- uint32_t i, j, offset;
- uint8_t *tmp;
- uint32_t bytes_per_pixel = drv_stride_from_format(bo->format, 1, 0);
-
- /*
- * The blocklinear format consists of 8*(2^n) x 64 byte sized tiles,
- * where 0 <= n <= 4.
- */
- gob_width = DIV_ROUND_UP(NV_BLOCKLINEAR_GOB_WIDTH, bytes_per_pixel);
- gob_height = NV_BLOCKLINEAR_GOB_HEIGHT *
- (1 << NV_DEFAULT_BLOCK_HEIGHT_LOG2);
- /* Calculate the height from maximum possible gob height */
- while (gob_height > NV_BLOCKLINEAR_GOB_HEIGHT
- && gob_height >= 2 * bo->height)
- gob_height /= 2;
-
- gob_size_bytes = gob_height * NV_BLOCKLINEAR_GOB_WIDTH;
- gob_size_pixels = gob_height * gob_width;
-
- gob_count_x = DIV_ROUND_UP(bo->strides[0], NV_BLOCKLINEAR_GOB_WIDTH);
- gob_count_y = DIV_ROUND_UP(bo->height, gob_height);
-
- offset = 0;
- for (j = 0; j < gob_count_y; j++) {
- gob_top = j * gob_height;
- for (i = 0; i < gob_count_x; i++) {
- tmp = tiled + offset;
- gob_left = i * gob_width;
-
- transfer_tile(bo, tmp, untiled, type, bytes_per_pixel,
- gob_top, gob_left, gob_size_pixels);
-
- offset += gob_size_bytes;
- }
- }
-}
-
static int tegra_init(struct driver *drv)
{
drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
@@ -242,7 +162,6 @@ static void *tegra_bo_map(struct bo *bo, struct map_info *data, size_t plane)
{
int ret;
struct drm_tegra_gem_mmap gem_map;
- struct tegra_private_map_data *priv;
memset(&gem_map, 0, sizeof(gem_map));
gem_map.handle = bo->handles[0].u32;
@@ -254,37 +173,10 @@ static void *tegra_bo_map(struct bo *bo, struct map_info *data, size_t plane)
return MAP_FAILED;
}
- void *addr = mmap(0, bo->total_size, PROT_READ | PROT_WRITE, MAP_SHARED,
- bo->drv->fd, gem_map.offset);
-
data->length = bo->total_size;
- if ((bo->tiling & 0xFF) == NV_MEM_KIND_C32_2CRA && addr != MAP_FAILED) {
- priv = calloc(1, sizeof(*priv));
- priv->untiled = calloc(1, bo->total_size);
- priv->tiled = addr;
- data->priv = priv;
- transfer_tiled_memory(bo, priv->tiled, priv->untiled,
- TEGRA_READ_TILED_BUFFER);
- addr = priv->untiled;
- }
-
- return addr;
-}
-
-static int tegra_bo_unmap(struct bo *bo, struct map_info *data)
-{
- if (data->priv) {
- struct tegra_private_map_data *priv = data->priv;
- transfer_tiled_memory(bo, priv->tiled, priv->untiled,
- TEGRA_WRITE_TILED_BUFFER);
- data->addr = priv->tiled;
- free(priv->untiled);
- free(priv);
- data->priv = NULL;
- }
-
- return munmap(data->addr, data->length);
+ return mmap(0, bo->total_size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ bo->drv->fd, gem_map.offset);
}
struct backend backend_tegra =
@@ -293,9 +185,7 @@ struct backend backend_tegra =
.init = tegra_init,
.bo_create = tegra_bo_create,
.bo_destroy = drv_gem_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = tegra_bo_map,
- .bo_unmap = tegra_bo_unmap,
};
#endif
diff --git a/chromium/third_party/minigbm/src/udl.c b/chromium/third_party/minigbm/src/udl.c
index c607772b736..a4fb07b5b47 100644
--- a/chromium/third_party/minigbm/src/udl.c
+++ b/chromium/third_party/minigbm/src/udl.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,13 +8,11 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[2] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[4] = {
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int udl_init(struct driver *drv)
@@ -29,6 +27,5 @@ struct backend backend_udl =
.init = udl_init,
.bo_create = drv_dumb_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/minigbm/src/util.h b/chromium/third_party/minigbm/src/util.h
index 696b996b9af..9606336fdc4 100644
--- a/chromium/third_party/minigbm/src/util.h
+++ b/chromium/third_party/minigbm/src/util.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chromium/third_party/minigbm/src/vc4.c b/chromium/third_party/minigbm/src/vc4.c
deleted file mode 100644
index 7e5351f2775..00000000000
--- a/chromium/third_party/minigbm/src/vc4.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2017 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifdef DRV_VC4
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <vc4_drm.h>
-#include <xf86drm.h>
-
-#include "drv_priv.h"
-#include "helpers.h"
-#include "util.h"
-
-static struct supported_combination combos[3] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_RGB565, DRM_FORMAT_MOD_NONE,
- BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
- BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
-};
-
-static int vc4_init(struct driver *drv)
-{
- drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
- return drv_add_kms_flags(drv);
-}
-
-static int vc4_bo_create(struct bo *bo, uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
-{
- int ret;
- size_t plane;
- struct drm_vc4_create_bo bo_create;
-
- drv_bo_from_format(bo, width, height, format);
-
- memset(&bo_create, 0, sizeof(bo_create));
- bo_create.size = bo->total_size;
-
- ret = drmIoctl(bo->drv->fd, DRM_IOCTL_VC4_CREATE_BO, &bo_create);
- if (ret) {
- fprintf(stderr, "drv: DRM_IOCTL_VC4_GEM_CREATE failed "
- "(size=%zu)\n", bo->total_size);
- return ret;
- }
-
- for (plane = 0; plane < bo->num_planes; plane++)
- bo->handles[plane].u32 = bo_create.handle;
-
- return 0;
-}
-
-static void *vc4_bo_map(struct bo *bo, struct map_info *data, size_t plane)
-{
- int ret;
- struct drm_vc4_mmap_bo bo_map;
-
- memset(&bo_map, 0, sizeof(bo_map));
- bo_map.handle = bo->handles[0].u32;
-
- ret = drmCommandWriteRead(bo->drv->fd, DRM_VC4_MMAP_BO, &bo_map,
- sizeof(bo_map));
- if (ret) {
- fprintf(stderr, "drv: DRM_VC4_MMAP_BO failed\n");
- return MAP_FAILED;
- }
-
- data->length = bo->total_size;
-
- return mmap(0, bo->total_size, PROT_READ | PROT_WRITE, MAP_SHARED,
- bo->drv->fd, bo_map.offset);
-}
-
-struct backend backend_vc4 =
-{
- .name = "vc4",
- .init = vc4_init,
- .bo_create = vc4_bo_create,
- .bo_import = drv_prime_bo_import,
- .bo_destroy = drv_gem_bo_destroy,
- .bo_map = vc4_bo_map,
-};
-
-#endif
diff --git a/chromium/third_party/minigbm/src/vgem.c b/chromium/third_party/minigbm/src/vgem.c
index 0f3d2e3e0e3..815f73c9051 100644
--- a/chromium/third_party/minigbm/src/vgem.c
+++ b/chromium/third_party/minigbm/src/vgem.c
@@ -13,17 +13,14 @@
static struct supported_combination combos[4] = {
{DRM_FORMAT_ABGR8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
{DRM_FORMAT_RGB565, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
- BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
{DRM_FORMAT_XBGR8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
- BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
+ BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+ {DRM_FORMAT_YVU420, DRM_FORMAT_MOD_NONE,
+ BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
};
static int vgem_init(struct driver *drv)
@@ -63,7 +60,6 @@ struct backend backend_vgem =
.init = vgem_init,
.bo_create = vgem_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
.resolve_format = vgem_resolve_format,
};
diff --git a/chromium/third_party/minigbm/src/virtio_gpu.c b/chromium/third_party/minigbm/src/virtio_gpu.c
index 5ac0e314aa0..f169101be27 100644
--- a/chromium/third_party/minigbm/src/virtio_gpu.c
+++ b/chromium/third_party/minigbm/src/virtio_gpu.c
@@ -8,13 +8,11 @@
#include "helpers.h"
#include "util.h"
-static struct supported_combination combos[2] = {
- {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
- {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
- BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN |
- BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+static struct supported_combination combos[4] = {
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_CURSOR | BO_USE_LINEAR},
+ {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, BO_USE_RENDERING},
};
static int virtio_gpu_init(struct driver *drv)
@@ -29,7 +27,6 @@ struct backend backend_virtio_gpu =
.init = virtio_gpu_init,
.bo_create = drv_dumb_bo_create,
.bo_destroy = drv_dumb_bo_destroy,
- .bo_import = drv_prime_bo_import,
.bo_map = drv_dumb_bo_map,
};
diff --git a/chromium/third_party/pyelftools/.hgignore b/chromium/third_party/pyelftools/.hgignore
new file mode 100644
index 00000000000..b5fbddea2f8
--- /dev/null
+++ b/chromium/third_party/pyelftools/.hgignore
@@ -0,0 +1,12 @@
+syntax: glob
+
+*.pyc
+.coverage
+.tox
+htmlcov
+tags
+build
+dist
+MANIFEST
+
+
diff --git a/chromium/third_party/pyelftools/.travis.yml b/chromium/third_party/pyelftools/.travis.yml
deleted file mode 100644
index c2eaf2356ed..00000000000
--- a/chromium/third_party/pyelftools/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-language: python
-python:
- - "2.7"
- - "3.2"
- - "3.3"
- - "3.4"
-script: python test/all_tests.py
-
diff --git a/chromium/third_party/pyelftools/CHANGES b/chromium/third_party/pyelftools/CHANGES
index 926dbe07c39..dc64e660e85 100644
--- a/chromium/third_party/pyelftools/CHANGES
+++ b/chromium/third_party/pyelftools/CHANGES
@@ -1,31 +1,10 @@
Changelog
=========
-+ Version 0.22 (30.03.2014)
-
- - pyelftools repository moved to https://github.com/eliben/pyelftools
- - Support for version sections - contributed by Yann Rouillard.
- - Better ARM support (including AArch64) - contributed by Dobromir Stefanov.
- - Added some initial support for parsing Solaris OpenCSW ELF files
- (contributed by Yann Rouillard).
- - Added some initial support for DWARF4 (as generated by gcc 4.8)
- and DWARF generated by recent versions of Clang (3.3).
- - Added the get_full_path utility method to DIEs that have an associated
- file name / path (based on pull request #16 by Shaheed Haque).
- - Set up Travis CI integration.
-
-+ Version 0.21 (17.04.2013)
++ Version 0.21 (??)
- Added new example: dwarf_decode_address - decode function name and
file & line information from an address.
- - Issue #7: parsing incorrect DWARF was made a bit more forgiving for cases
- where serialized DIE trees have extra NULLs at the end.
- - Very initial support for ARM ELF files (Matthew Fernandez - pull
- request #6).
- - Support support for dumping the dynamic section (Mike Frysinger - pull
- request #7).
- - Output of scripts/readelf.py now matches that of binutils 2.23.52.
- - Added more machine EM_ values to ENUM_E_TYPE.
+ Version 0.20 (27.01.2012)
@@ -35,3 +14,4 @@ Changelog
on Windows.
+ Version 0.10 - Initial public release (06.01.2012)
+
diff --git a/chromium/third_party/pyelftools/MANIFEST.in b/chromium/third_party/pyelftools/MANIFEST.in
index 872e667abca..1f3af68ba39 100644
--- a/chromium/third_party/pyelftools/MANIFEST.in
+++ b/chromium/third_party/pyelftools/MANIFEST.in
@@ -1,8 +1,11 @@
-recursive-include elftools *.py
+recursive-include elftools *.py
recursive-include scripts *.py
recursive-include examples *.py *.elf *.out
-recursive-include test *.py *.elf *.arm
+recursive-include test *.py *.elf
include README
include LICENSE
include CHANGES
include tox.ini
+
+
+
diff --git a/chromium/third_party/pyelftools/README b/chromium/third_party/pyelftools/README
new file mode 100644
index 00000000000..836c1f28926
--- /dev/null
+++ b/chromium/third_party/pyelftools/README
@@ -0,0 +1,43 @@
+Introduction: what is pyelftools?
+---------------------------------
+
+**pyelftools** is a pure-Python library for parsing and analyzing ELF files
+and DWARF debugging information. See the
+`User's guide <https://bitbucket.org/eliben/pyelftools/wiki/Userguide>`_ for more details.
+
+Pre-requisites
+--------------
+
+As a user of **pyelftools**, one only needs Python to run. It works with
+Python versions 2.6, 2.7 and 3.2. For hacking on **pyelftools** the
+requirements are a bit more strict, please see the
+`hacking guide <https://bitbucket.org/eliben/pyelftools/wiki/Hacking>`_.
+
+Installing
+----------
+
+When you unzip the source distribution, run::
+
+ > python setup.py install
+
+Alternatively, **pyelftools** can be installed from PyPI (Python package
+index)::
+
+ > pip install pyelftools
+
+How to use it?
+--------------
+
+**pyelftools** is a regular Python library: you import and invoke it from your
+own code. For a detailed usage guide and links to examples, please consult the
+`user's guide <https://bitbucket.org/eliben/pyelftools/wiki/Userguide>`_.
+
+License
+-------
+
+**pyelftools** is open source software. Its code is in the public domain. See
+the ``LICENSE`` file for more details.
+
+
+
+
diff --git a/chromium/third_party/pyelftools/README.rst b/chromium/third_party/pyelftools/README.rst
deleted file mode 100644
index d668f3b35f9..00000000000
--- a/chromium/third_party/pyelftools/README.rst
+++ /dev/null
@@ -1,57 +0,0 @@
-Introduction: what is pyelftools?
----------------------------------
-
-**pyelftools** is a pure-Python library for parsing and analyzing ELF files
-and DWARF debugging information. See the
-`User's guide <https://github.com/eliben/pyelftools/wiki/User's-guide>`_
-for more details.
-
-Pre-requisites
---------------
-
-As a user of **pyelftools**, one only needs Python to run. It works with
-Python versions 2.6, 2.7 and 3.x (x >= 2). For hacking on **pyelftools** the
-requirements are a bit more strict, please see the
-`hacking guide <https://github.com/eliben/pyelftools/wiki/Hacking-guide>`_.
-
-Installing
-----------
-
-**pyelftools** can be installed from PyPI (Python package index)::
-
- > pip install pyelftools
-
-Alternatively, you can download the source distribution for the most recent and
-historic versions from the *Downloads* tab on the `pyelftools project page
-<https://github.com/eliben/pyelftools>`_ (by going to *Tags*). Then, you can
-install from source, as usual::
-
- > python setup.py install
-
-Since **pyelftools** is a work in progress, it's recommended to have the most
-recent version of the code. This can be done by downloading the `master zip
-file <https://github.com/eliben/pyelftools/archive/master.zip>`_ or just
-cloning the Git repository.
-
-How to use it?
---------------
-
-**pyelftools** is a regular Python library: you import and invoke it from your
-own code. For a detailed usage guide and links to examples, please consult the
-`user's guide <https://github.com/eliben/pyelftools/wiki/User's-guide>`_.
-
-License
--------
-
-**pyelftools** is open source software. Its code is in the public domain. See
-the ``LICENSE`` file for more details.
-
-CI Status
----------
-
-**pyelftools** has automatic testing enabled through the convenient
-`Travis CI project <https://travis-ci.org>`_. Here is the latest build status:
-
-.. image:: https://travis-ci.org/eliben/pyelftools.png?branch=master
- :align: center
- :target: https://travis-ci.org/eliben/pyelftools
diff --git a/chromium/third_party/pyelftools/TODO b/chromium/third_party/pyelftools/TODO
index 90280447160..1f8d11d1d7c 100644
--- a/chromium/third_party/pyelftools/TODO
+++ b/chromium/third_party/pyelftools/TODO
@@ -4,15 +4,7 @@ New version
* Update elftools/__init__.py
* Update setup.py
* Update CHANGES
-* Tag in git (v0.xx)
-
-construct
----------
-
-The construct seems to be maintained again - they also backported my Python 3
-fixes. Theoretically, I can remove construct from pyelftools and use it as a
-dependency instead. I don't really have time to play with this now, but may
-do so in the future.
+* Tag in hg
Distribution
------------
@@ -22,11 +14,15 @@ python setup.py build sdist upload
Preparing a new release
-----------------------
-* Run 'tox' tests (with '-r' to create new venvs)
+* Run all tests with Python 2.7 before packaging, on Linux
* Make sure new version was updated everywhere appropriate
+* Packaging done on Linux
* Run ``python setup.py build sdist`` (no 'upload' yet)
* Untar the created ``dist/pyelftools-x.y.tar.gz`` and make sure
everything looks ok
+* Runt 'tox' tests (with '-r' to create new venvs)
* Now build with upload to send it to PyPi
* Test with pip install from some new virtualenv
+* If everything is OK, upload the distribution to BitBucket as well
* The older download can be kept alive for a couple of days
+
diff --git a/chromium/third_party/pyelftools/elftools/__init__.py b/chromium/third_party/pyelftools/elftools/__init__.py
index 8a3e56cdffc..0f14043bf4b 100644
--- a/chromium/third_party/pyelftools/elftools/__init__.py
+++ b/chromium/third_party/pyelftools/elftools/__init__.py
@@ -1,7 +1,3 @@
-#-------------------------------------------------------------------------------
-# elftools
-#
-# Eli Bendersky (eliben@gmail.com)
-# This code is in the public domain
-#-------------------------------------------------------------------------------
-__version__ = '0.22'
+__version__ = '0.20'
+
+
diff --git a/chromium/third_party/pyelftools/elftools/common/ordereddict.py b/chromium/third_party/pyelftools/elftools/common/ordereddict.py
index 18ee0458fe7..43356435eab 100644
--- a/chromium/third_party/pyelftools/elftools/common/ordereddict.py
+++ b/chromium/third_party/pyelftools/elftools/common/ordereddict.py
@@ -1,9 +1,11 @@
-#-------------------------------------------------------------------------------
-# elftools: port of OrderedDict to work on Python < 2.7
+# http://code.activestate.com/recipes/576693/ (r9)
+# Created by Raymond Hettinger on Wed, 18 Mar 2009 (MIT)
#
-# Taken from http://code.activestate.com/recipes/576693/ , revision 9
-# Code by Raymond Hettinger. License: MIT
-#-------------------------------------------------------------------------------
+# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7
+# and pypy.
+# Passes Python2.7's test suite and incorporates all the latest updates.
+#
+
try:
from thread import get_ident as _get_ident
except ImportError:
diff --git a/chromium/third_party/pyelftools/elftools/common/utils.py b/chromium/third_party/pyelftools/elftools/common/utils.py
index a2c9edbe356..2daed04c51c 100644
--- a/chromium/third_party/pyelftools/elftools/common/utils.py
+++ b/chromium/third_party/pyelftools/elftools/common/utils.py
@@ -31,8 +31,8 @@ def struct_parse(struct, stream, stream_pos=None):
stream.seek(stream_pos)
return struct.parse_stream(stream)
except ConstructError as e:
- raise ELFParseError(str(e))
-
+ raise ELFParseError(e.message)
+
def parse_cstring_from_stream(stream, stream_pos=None):
""" Parse a C-string from the given stream. The string is returned without
@@ -41,8 +41,6 @@ def parse_cstring_from_stream(stream, stream_pos=None):
If stream_pos is provided, the stream is seeked to this position before
the parsing is done. Otherwise, the current position of the stream is
used.
- Note: a bytes object is returned here, because this is what's read from
- the binary file.
"""
if stream_pos is not None:
stream.seek(stream_pos)
@@ -78,10 +76,11 @@ def dwarf_assert(cond, msg=''):
@contextmanager
def preserve_stream_pos(stream):
""" Usage:
- # stream has some position FOO (return value of stream.tell())
- with preserve_stream_pos(stream):
- # do stuff that manipulates the stream
- # stream still has position FOO
+
+ # stream has some position FOO (return value of stream.tell())
+ with preserve_stream_pos(stream):
+ # do stuff that manipulates the stream
+ # stream still has position FOO
"""
saved_pos = stream.tell()
yield
diff --git a/chromium/third_party/pyelftools/elftools/construct/README b/chromium/third_party/pyelftools/elftools/construct/README
index 7f9e1418c76..2c1b79852fb 100644
--- a/chromium/third_party/pyelftools/elftools/construct/README
+++ b/chromium/third_party/pyelftools/elftools/construct/README
@@ -1,10 +1,8 @@
-construct is a Python library for declarative parsing and building of binary
-data. This is my fork of construct 2, with some modifications for Python 3
-and bug fixes. The construct website is http://construct.readthedocs.org
+'construct' is the actual library, with my modifications for Python 3
+compatibility and various bug fixes.
-pyelftools carries construct around because construct has been abandoned for
-a long time and didn't get bugfixes; it also didn't work with Python 3.
+Taken from my fork: https://github.com/eliben/construct
-LICENSE is the original license.
+Take a look at LICENSE for the original license
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/callframe.py b/chromium/third_party/pyelftools/elftools/dwarf/callframe.py
index 264adb8dc31..de67a43eaca 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/callframe.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/callframe.py
@@ -11,12 +11,12 @@ from collections import namedtuple
from ..common.utils import (struct_parse, dwarf_assert, preserve_stream_pos)
from ..common.py3compat import iterkeys
from .structs import DWARFStructs
-from .constants import *
+from .constants import *
class CallFrameInfo(object):
""" DWARF CFI (Call Frame Info)
-
+
stream, size:
A stream holding the .debug_frame section, and the size of the
section in it.
@@ -26,13 +26,14 @@ class CallFrameInfo(object):
Eventually, each entry gets its own structs based on the initial
length field it starts with. The address_size, however, is taken
from base_structs. This appears to be a limitation of the DWARFv3
- standard, fixed in v4.
- A discussion I had on dwarf-discuss confirms this.
- So for DWARFv4 we'll take the address size from the CIE header,
- but for earlier versions will use the elfclass of the containing
- file; more sophisticated methods are used by libdwarf and others,
- such as guessing which CU contains which FDEs (based on their
- address ranges) and taking the address_size from those CUs.
+ standard, fixed in v4 (where an address_size field exists for each
+ CFI. I had a discussion about this on dwarf-discuss that confirms
+ this.
+ Currently for base_structs I simply use the elfclass of the
+ containing file, but more sophisticated methods are used by
+ libdwarf and others, such as guessing which CU contains which FDEs
+ (based on their address ranges) and taking the address_size from
+ those CUs.
"""
def __init__(self, stream, size, base_structs):
self.stream = stream
@@ -86,7 +87,7 @@ class CallFrameInfo(object):
entry_structs.Dwarf_offset(''), self.stream)
is_CIE = (
- (dwarf_format == 32 and CIE_id == 0xFFFFFFFF) or
+ (dwarf_format == 32 and CIE_id == 0xFFFFFFFF) or
CIE_id == 0xFFFFFFFFFFFFFFFF)
if is_CIE:
@@ -99,14 +100,6 @@ class CallFrameInfo(object):
header = struct_parse(
header_struct, self.stream, offset)
- # If this is DWARF version 4 or later, we can have a more precise
- # address size, read from the CIE header.
- if entry_structs.dwarf_version >= 4:
- entry_structs = DWARFStructs(
- little_endian=entry_structs.little_endian,
- dwarf_format=entry_structs.dwarf_format,
- address_size=header.address_size)
-
# For convenience, compute the end offset for this entry
end_offset = (
offset + header.length +
@@ -258,7 +251,7 @@ class CFIEntry(object):
reg_order = []
else: # FDE
# For a FDE, we need to decode the attached CIE first, because its
- # decoded table is needed. Its "initial instructions" describe a
+ # decoded table is needed. Its "initial instructions" describe a
# line that serves as the base (first) line in the FDE's table.
cie = self.cie
cie_decoded_table = cie.get_decoded()
@@ -266,7 +259,7 @@ class CFIEntry(object):
cur_line = last_line_in_CIE
cur_line['pc'] = self['initial_location']
reg_order = copy.copy(cie_decoded_table.reg_order)
-
+
table = []
# Keeps a stack for the use of DW_CFA_{remember|restore}_state
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/compileunit.py b/chromium/third_party/pyelftools/elftools/dwarf/compileunit.py
index f5011dde835..fbe4a8b3022 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/compileunit.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/compileunit.py
@@ -10,36 +10,36 @@ from .die import DIE
class CompileUnit(object):
- """ A DWARF compilation unit (CU).
-
+ """ A DWARF compilation unit (CU).
+
A normal compilation unit typically represents the text and data
contributed to an executable by a single relocatable object file.
- It may be derived from several source files,
+ It may be derived from several source files,
including pre-processed "include files"
-
+
Serves as a container and context to DIEs that describe objects and code
belonging to a compilation unit.
-
+
CU header entries can be accessed as dict keys from this object, i.e.
cu = CompileUnit(...)
cu['version'] # version field of the CU header
-
- To get the top-level DIE describing the compilation unit, call the
+
+ To get the top-level DIE describing the compilation unit, call the
get_top_DIE method.
"""
def __init__(self, header, dwarfinfo, structs, cu_offset, cu_die_offset):
""" header:
CU header for this compile unit
-
+
dwarfinfo:
The DWARFInfo context object which created this one
-
+
structs:
A DWARFStructs instance suitable for this compile unit
-
+
cu_offset:
Offset in the stream to the beginning of this CU (its header)
-
+
cu_die_offset:
Offset in the stream of the top DIE of this CU
"""
@@ -48,19 +48,19 @@ class CompileUnit(object):
self.structs = structs
self.cu_offset = cu_offset
self.cu_die_offset = cu_die_offset
-
- # The abbreviation table for this CU. Filled lazily when DIEs are
+
+ # The abbreviation table for this CU. Filled lazily when DIEs are
# requested.
self._abbrev_table = None
-
+
# A list of DIEs belonging to this CU. Lazily parsed.
self._dielist = []
-
+
def dwarf_format(self):
""" Get the DWARF format (32 or 64) for this CU
"""
return self.structs.dwarf_format
-
+
def get_abbrev_table(self):
""" Get the abbreviation table (AbbrevTable object) for this CU
"""
@@ -70,31 +70,31 @@ class CompileUnit(object):
return self._abbrev_table
def get_top_DIE(self):
- """ Get the top DIE (which is either a DW_TAG_compile_unit or
+ """ Get the top DIE (which is either a DW_TAG_compile_unit or
DW_TAG_partial_unit) of this CU
"""
return self._get_DIE(0)
-
+
def iter_DIEs(self):
""" Iterate over all the DIEs in the CU, in order of their appearance.
Note that null DIEs will also be returned.
"""
self._parse_DIEs()
return iter(self._dielist)
-
+
#------ PRIVATE ------#
-
+
def __getitem__(self, name):
""" Implement dict-like access to header entries
"""
return self.header[name]
def _get_DIE(self, index):
- """ Get the DIE at the given index
+ """ Get the DIE at the given index
"""
self._parse_DIEs()
return self._dielist[index]
-
+
def _parse_DIEs(self):
""" Parse all the DIEs pertaining to this CU from the stream and shove
them sequentially into self._dielist.
@@ -103,13 +103,13 @@ class CompileUnit(object):
"""
if len(self._dielist) > 0:
return
-
- # Compute the boundary (one byte past the bounds) of this CU in the
+
+ # Compute the boundary (one byte past the bounds) of this CU in the
# stream
- cu_boundary = ( self.cu_offset +
- self['unit_length'] +
+ cu_boundary = ( self.cu_offset +
+ self['unit_length'] +
self.structs.initial_length_field_size())
-
+
# First pass: parse all DIEs and place them into self._dielist
die_offset = self.cu_die_offset
while die_offset < cu_boundary:
@@ -122,18 +122,18 @@ class CompileUnit(object):
# Second pass - unflatten the DIE tree
self._unflatten_tree()
-
+
def _unflatten_tree(self):
""" "Unflatten" the DIE tree from it serial representation, by setting
the child/sibling/parent links of DIEs.
-
+
Assumes self._dielist was already populated by a linear list of DIEs
read from the stream section
"""
# the first DIE in the list is the root node
root = self._dielist[0]
parentstack = [root]
-
+
for die in self._dielist[1:]:
if not die.is_null():
cur_parent = parentstack[-1]
@@ -143,11 +143,6 @@ class CompileUnit(object):
if die.has_children:
parentstack.append(die)
else:
- # parentstack should not be really empty here. However, some
- # compilers generate DWARF that has extra NULLs in the end and
- # we don't want pyelftools to fail parsing them just because of
- # this.
- if len(parentstack) > 0:
- # end of children for the current parent
- parentstack.pop()
+ # end of children for the current parent
+ parentstack.pop()
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/descriptions.py b/chromium/third_party/pyelftools/elftools/dwarf/descriptions.py
index ca00cd1ee7c..721c97a5172 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/descriptions.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/descriptions.py
@@ -24,7 +24,7 @@ def set_global_machine_arch(machine_arch):
def describe_attr_value(attr, die, section_offset):
""" Given an attribute attr, return the textual representation of its
value, suitable for tools like readelf.
-
+
To cover all cases, this function needs some extra arguments:
die: the DIE this attribute was extracted from
@@ -32,11 +32,11 @@ def describe_attr_value(attr, die, section_offset):
"""
descr_func = _ATTR_DESCRIPTION_MAP[attr.form]
val_description = descr_func(attr, die, section_offset)
-
+
# For some attributes we can display further information
extra_info_func = _EXTRA_INFO_DESCRIPTION_MAP[attr.name]
extra_info = extra_info_func(attr, die, section_offset)
- return str(val_description) + '\t' + extra_info
+ return str(val_description) + '\t' + extra_info
def describe_CFI_instructions(entry):
@@ -45,7 +45,7 @@ def describe_CFI_instructions(entry):
"""
def _assert_FDE_instruction(instr):
dwarf_assert(
- isinstance(entry, FDE),
+ isinstance(entry, FDE),
'Unexpected instruction "%s" for a CIE' % instr)
def _full_reg_name(regnum):
@@ -82,7 +82,7 @@ def describe_CFI_instructions(entry):
'DW_CFA_advance_loc4', 'DW_CFA_advance_loc'):
_assert_FDE_instruction(instr)
factored_offset = instr.args[0] * cie['code_alignment_factor']
- s += ' %s: %s to %016x\n' % (
+ s += ' %s: %s to %08x\n' % (
name, factored_offset, factored_offset + pc)
pc += factored_offset
elif name in ( 'DW_CFA_remember_state', 'DW_CFA_restore_state',
@@ -126,7 +126,7 @@ def describe_CFI_CFA_rule(rule):
return 'exp'
else:
return '%s%+d' % (describe_reg_name(rule.reg), rule.offset)
-
+
def describe_DWARF_expr(expr, structs):
""" Textual description of a DWARF expression encoded in 'expr'.
@@ -197,29 +197,23 @@ def _describe_attr_debool(attr, die, section_offset):
"""
return '1' if attr.value else '0'
-def _describe_attr_present(attr, die, section_offset):
- """ Some forms may simply mean that an attribute is present,
- without providing any value.
- """
- return '1'
-
def _describe_attr_block(attr, die, section_offset):
s = '%s byte block: ' % len(attr.value)
- s += ' '.join('%x' % item for item in attr.value) + ' '
+ s += ' '.join('%x' % item for item in attr.value)
return s
-
+
_ATTR_DESCRIPTION_MAP = defaultdict(
lambda: _describe_attr_value_passthrough, # default_factory
-
+
DW_FORM_ref1=_describe_attr_ref,
DW_FORM_ref2=_describe_attr_ref,
DW_FORM_ref4=_describe_attr_ref,
DW_FORM_ref8=_describe_attr_split_64bit,
- DW_FORM_ref_udata=_describe_attr_ref,
+ DW_FORM_ref_udata=_describe_attr_ref,
DW_FORM_ref_addr=_describe_attr_hex_addr,
DW_FORM_data4=_describe_attr_hex,
- DW_FORM_data8=_describe_attr_hex,
+ DW_FORM_data8=_describe_attr_split_64bit,
DW_FORM_addr=_describe_attr_hex,
DW_FORM_sec_offset=_describe_attr_hex,
DW_FORM_flag=_describe_attr_debool,
@@ -233,9 +227,6 @@ _ATTR_DESCRIPTION_MAP = defaultdict(
DW_FORM_block2=_describe_attr_block,
DW_FORM_block4=_describe_attr_block,
DW_FORM_block=_describe_attr_block,
- DW_FORM_flag_present=_describe_attr_present,
- DW_FORM_exprloc=_describe_attr_block,
- DW_FORM_ref_sig8=_describe_attr_ref,
)
@@ -411,7 +402,7 @@ def _import_extra(attr, die, section_offset):
_EXTRA_INFO_DESCRIPTION_MAP = defaultdict(
lambda: _make_extra_string(''), # default_factory
-
+
DW_AT_inline=_make_extra_mapper(
_DESCR_DW_INL, '(Unknown inline attribute value: %x',
default_interpolate_value=True),
@@ -472,7 +463,7 @@ _REG_NAMES_x64 = [
class ExprDumper(GenericExprVisitor):
""" A concrete visitor for DWARF expressions that dumps a textual
representation of the complete expression.
-
+
Usage: after creation, call process_expr, and then get_str for a
semicolon-delimited string representation of the decoded expression.
"""
@@ -494,10 +485,10 @@ class ExprDumper(GenericExprVisitor):
'DW_OP_pick', 'DW_OP_plus_uconst', 'DW_OP_bra', 'DW_OP_skip',
'DW_OP_fbreg', 'DW_OP_piece', 'DW_OP_deref_size',
'DW_OP_xderef_size', 'DW_OP_regx',])
-
+
for n in range(0, 32):
self._ops_with_decimal_arg.add('DW_OP_breg%s' % n)
-
+
self._ops_with_two_decimal_args = set([
'DW_OP_const8u', 'DW_OP_const8s', 'DW_OP_bregx', 'DW_OP_bit_piece'])
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/die.py b/chromium/third_party/pyelftools/elftools/dwarf/die.py
index 86830fc3bed..f0b5eb8dd48 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/die.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/die.py
@@ -7,20 +7,17 @@
# This code is in the public domain
#-------------------------------------------------------------------------------
from collections import namedtuple
-import os
-from ..common.exceptions import DWARFError
-from ..common.py3compat import OrderedDict, bytes2str, iteritems
+from ..common.py3compat import OrderedDict
from ..common.utils import struct_parse, preserve_stream_pos
-from .enums import DW_FORM_raw2name
-# AttributeValue - describes an attribute value in the DIE:
+# AttributeValue - describes an attribute value in the DIE:
#
# name:
# The name (DW_AT_*) of this attribute
-#
-# form:
+#
+# form:
# The DW_FORM_* name of this attribute
#
# value:
@@ -42,37 +39,37 @@ AttributeValue = namedtuple(
class DIE(object):
""" A DWARF debugging information entry. On creation, parses itself from
the stream. Each DIE is held by a CU.
-
+
Accessible attributes:
-
+
tag:
The DIE tag
-
+
size:
The size this DIE occupies in the section
-
+
offset:
The offset of this DIE in the stream
-
+
attributes:
- An ordered dictionary mapping attribute names to values. It's
+ An ordered dictionary mapping attribute names to values. It's
ordered to preserve the order of attributes in the section
-
+
has_children:
Specifies whether this DIE has children
-
+
abbrev_code:
- The abbreviation code pointing to an abbreviation entry (note
- that this is for informational pusposes only - this object
+ The abbreviation code pointing to an abbreviation entry (not
+ that this is for informational pusposes only - this object
interacts with its abbreviation table transparently).
-
+
See also the public methods.
"""
def __init__(self, cu, stream, offset):
""" cu:
CompileUnit object this DIE belongs to. Used to obtain context
information (structs, abbrev table, etc.)
-
+
stream, offset:
The stream and offset into it where this DIE's data is located
"""
@@ -80,7 +77,7 @@ class DIE(object):
self.dwarfinfo = self.cu.dwarfinfo # get DWARFInfo context
self.stream = stream
self.offset = offset
-
+
self.attributes = OrderedDict()
self.tag = None
self.has_children = None
@@ -88,39 +85,25 @@ class DIE(object):
self.size = 0
self._children = []
self._parent = None
-
- self._parse_DIE()
-
+
+ self._parse_DIE()
+
def is_null(self):
""" Is this a null entry?
"""
return self.tag is None
-
+
def get_parent(self):
- """ The parent DIE of this DIE. None if the DIE has no parent (i.e. a
+ """ The parent DIE of this DIE. None if the DIE has no parent (i.e. a
top-level DIE).
"""
return self._parent
-
- def get_full_path(self):
- """ Return the full path filename for the DIE.
-
- The filename is the join of 'DW_AT_comp_dir' and 'DW_AT_name',
- either of which may be missing in practice. Note that its value is
- usually a string taken from the .debug_string section and the
- returned value will be a string.
- """
- comp_dir_attr = self.attributes.get('DW_AT_comp_dir', None)
- comp_dir = bytes2str(comp_dir_attr.value) if comp_dir_attr else ''
- fname_attr = self.attributes.get('DW_AT_name', None)
- fname = bytes2str(fname_attr.value) if fname_attr else ''
- return os.path.join(comp_dir, fname)
-
+
def iter_children(self):
""" Yield all children of this DIE
"""
return iter(self._children)
-
+
def iter_siblings(self):
""" Yield all siblings of this DIE
"""
@@ -136,41 +119,41 @@ class DIE(object):
#
def add_child(self, die):
self._children.append(die)
-
+
def set_parent(self, die):
self._parent = die
#------ PRIVATE ------#
-
+
def __repr__(self):
s = 'DIE %s, size=%s, has_chidren=%s\n' % (
self.tag, self.size, self.has_children)
- for attrname, attrval in iteritems(self.attributes):
+ for attrname, attrval in self.attributes.iteritems():
s += ' |%-18s: %s\n' % (attrname, attrval)
return s
-
+
def __str__(self):
return self.__repr__()
-
+
def _parse_DIE(self):
""" Parses the DIE info from the section, based on the abbreviation
table of the CU
"""
structs = self.cu.structs
-
- # A DIE begins with the abbreviation code. Read it and use it to
+
+ # A DIE begins with the abbreviation code. Read it and use it to
# obtain the abbrev declaration for this DIE.
# Note: here and elsewhere, preserve_stream_pos is used on operations
# that manipulate the stream by reading data from it.
#
self.abbrev_code = struct_parse(
structs.Dwarf_uleb128(''), self.stream, self.offset)
-
+
# This may be a null entry
if self.abbrev_code == 0:
self.size = self.stream.tell() - self.offset
return
-
+
with preserve_stream_pos(self.stream):
abbrev_decl = self.cu.get_abbrev_table().get_abbrev(
self.abbrev_code)
@@ -184,14 +167,14 @@ class DIE(object):
attr_offset = self.stream.tell()
raw_value = struct_parse(structs.Dwarf_dw_form[form], self.stream)
- value = self._translate_attr_value(form, raw_value)
+ value = self._translate_attr_value(form, raw_value)
self.attributes[name] = AttributeValue(
name=name,
form=form,
value=value,
raw_value=raw_value,
offset=attr_offset)
-
+
self.size = self.stream.tell() - self.offset
def _translate_attr_value(self, form, raw_value):
@@ -204,17 +187,13 @@ class DIE(object):
elif form == 'DW_FORM_flag':
value = not raw_value == 0
elif form == 'DW_FORM_indirect':
- try:
- form = DW_FORM_raw2name[raw_value]
- except KeyError as err:
- raise DWARFError(
- 'Found DW_FORM_indirect with unknown raw_value=' +
- str(raw_value))
-
+ form = raw_value
raw_value = struct_parse(
- self.cu.structs.Dwarf_dw_form[form], self.stream)
+ structs.Dwarf_dw_form[form], self.stream)
# Let's hope this doesn't get too deep :-)
return self._translate_attr_value(form, raw_value)
else:
value = raw_value
return value
+
+
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/dwarfinfo.py b/chromium/third_party/pyelftools/elftools/dwarf/dwarfinfo.py
index 1995fc88f77..9aa2f520e6d 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/dwarfinfo.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/dwarfinfo.py
@@ -21,7 +21,7 @@ from .ranges import RangeLists
# Describes a debug section
-#
+#
# stream: a stream object containing the data of this section
# name: section name in the container file
# global_offset: the global offset of the section in its container file
@@ -30,7 +30,7 @@ from .ranges import RangeLists
# 'name' and 'global_offset' are for descriptional purposes only and
# aren't strictly required for the DWARF parsing to work.
#
-DebugSectionDescriptor = namedtuple('DebugSectionDescriptor',
+DebugSectionDescriptor = namedtuple('DebugSectionDescriptor',
'stream name global_offset size')
@@ -51,7 +51,7 @@ DwarfConfig = namedtuple('DwarfConfig',
class DWARFInfo(object):
- """ Acts also as a "context" to other major objects, bridging between
+ """ Acts also as a "context" to other major objects, bridging between
various parts of the debug infromation.
"""
def __init__(self,
@@ -59,7 +59,6 @@ class DWARFInfo(object):
debug_info_sec,
debug_abbrev_sec,
debug_frame_sec,
- eh_frame_sec,
debug_str_sec,
debug_loc_sec,
debug_ranges_sec,
@@ -69,20 +68,19 @@ class DWARFInfo(object):
debug_*_sec:
DebugSectionDescriptor for a section. Pass None for sections
- that don't exist. These arguments are best given with
+ that don't exist. These arguments are best given with
keyword syntax.
"""
self.config = config
self.debug_info_sec = debug_info_sec
self.debug_abbrev_sec = debug_abbrev_sec
self.debug_frame_sec = debug_frame_sec
- self.eh_frame_sec = eh_frame_sec
self.debug_str_sec = debug_str_sec
self.debug_loc_sec = debug_loc_sec
self.debug_ranges_sec = debug_ranges_sec
self.debug_line_sec = debug_line_sec
- # This is the DWARFStructs the context uses, so it doesn't depend on
+ # This is the DWARFStructs the context uses, so it doesn't depend on
# DWARF format and address_size (these are determined per CU) - set them
# to default values.
self.structs = DWARFStructs(
@@ -121,7 +119,7 @@ class DWARFInfo(object):
return self._abbrevtable_cache[offset]
def get_string_from_table(self, offset):
- """ Obtain a string from the string table section, given an offset
+ """ Obtain a string from the string table section, given an offset
relative to the section.
"""
return parse_cstring_from_stream(self.debug_str_sec.stream, offset)
@@ -141,12 +139,12 @@ class DWARFInfo(object):
return None
def has_CFI(self):
- """ Does this dwarf info have a dwarf_frame CFI section?
+ """ Does this dwarf info has a CFI section?
"""
return self.debug_frame_sec is not None
def CFI_entries(self):
- """ Get a list of dwarf_frame CFI entries from the .debug_frame section.
+ """ Get a list of CFI entries from the .debug_frame section.
"""
cfi = CallFrameInfo(
stream=self.debug_frame_sec.stream,
@@ -154,37 +152,17 @@ class DWARFInfo(object):
base_structs=self.structs)
return cfi.get_entries()
- def has_EH_CFI(self):
- """ Does this dwarf info have a eh_frame CFI section?
- """
- return self.eh_frame_sec is not None
-
- def EH_CFI_entries(self):
- """ Get a list of eh_frame CFI entries from the .eh_frame section.
- """
- cfi = CallFrameInfo(
- stream=self.eh_frame_sec.stream,
- size=self.eh_frame_sec.size,
- base_structs=self.structs)
- return cfi.get_entries()
-
def location_lists(self):
""" Get a LocationLists object representing the .debug_loc section of
the DWARF data, or None if this section doesn't exist.
"""
- if self.debug_loc_sec:
- return LocationLists(self.debug_loc_sec.stream, self.structs)
- else:
- return None
+ return LocationLists(self.debug_loc_sec.stream, self.structs)
def range_lists(self):
""" Get a RangeLists object representing the .debug_ranges section of
the DWARF data, or None if this section doesn't exist.
"""
- if self.debug_ranges_sec:
- return RangeLists(self.debug_ranges_sec.stream, self.structs)
- else:
- return None
+ return RangeLists(self.debug_ranges_sec.stream, self.structs)
#------ PRIVATE ------#
@@ -197,18 +175,18 @@ class DWARFInfo(object):
# Compute the offset of the next CU in the section. The unit_length
# field of the CU header contains its size not including the length
# field itself.
- offset = ( offset +
- cu['unit_length'] +
+ offset = ( offset +
+ cu['unit_length'] +
cu.structs.initial_length_field_size())
yield cu
-
+
def _parse_CU_at_offset(self, offset):
""" Parse and return a CU at the given offset in the debug_info stream.
"""
# Section 7.4 (32-bit and 64-bit DWARF Formats) of the DWARF spec v3
- # states that the first 32-bit word of the CU header determines
+ # states that the first 32-bit word of the CU header determines
# whether the CU is represented with 32-bit or 64-bit DWARF format.
- #
+ #
# So we peek at the first word in the CU header to determine its
# dwarf format. Based on it, we then create a new DWARFStructs
# instance suitable for this CU and use it to parse the rest.
@@ -227,15 +205,15 @@ class DWARFInfo(object):
little_endian=self.config.little_endian,
dwarf_format=dwarf_format,
address_size=4)
-
+
cu_header = struct_parse(
cu_structs.Dwarf_CU_header, self.debug_info_sec.stream, offset)
if cu_header['address_size'] == 8:
cu_structs = DWARFStructs(
little_endian=self.config.little_endian,
dwarf_format=dwarf_format,
- address_size=8)
-
+ address_size=8)
+
cu_die_offset = self.debug_info_sec.stream.tell()
dwarf_assert(
self._is_supported_version(cu_header['version']),
@@ -246,11 +224,11 @@ class DWARFInfo(object):
structs=cu_structs,
cu_offset=offset,
cu_die_offset=cu_die_offset)
-
+
def _is_supported_version(self, version):
""" DWARF version supported by this parser
"""
- return 2 <= version <= 4
+ return 2 <= version <= 3
def _parse_line_program_at_offset(self, debug_line_offset, structs):
""" Given an offset to the .debug_line section, parse the line program
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/enums.py b/chromium/third_party/pyelftools/elftools/dwarf/enums.py
index d576dffb505..1338725701d 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/enums.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/enums.py
@@ -7,7 +7,6 @@
# This code is in the public domain
#-------------------------------------------------------------------------------
from ..construct import Pass
-from ..common.py3compat import iteritems
ENUM_DW_TAG = dict(
@@ -53,12 +52,10 @@ ENUM_DW_TAG = dict(
DW_TAG_namelist_items = 0x2c,
DW_TAG_packed_type = 0x2d,
DW_TAG_subprogram = 0x2e,
-
- # The DWARF standard defines these as _parameter, not _param, but we
- # maintain compatibility with readelf.
+ DW_TAG_template_type_parameter = 0x2f,
DW_TAG_template_type_param = 0x2f,
+ DW_TAG_template_value_parameter = 0x30,
DW_TAG_template_value_param = 0x30,
-
DW_TAG_thrown_type = 0x31,
DW_TAG_try_block = 0x32,
DW_TAG_variant_part = 0x33,
@@ -188,9 +185,7 @@ ENUM_DW_AT = dict(
DW_AT_main_subprogram = 0x6a,
DW_AT_data_bit_offset = 0x6b,
DW_AT_const_expr = 0x6c,
- DW_AT_enum_class = 0x6d,
- DW_AT_linkage_name = 0x6e,
-
+
DW_AT_MIPS_fde = 0x2001,
DW_AT_MIPS_loop_begin = 0x2002,
DW_AT_MIPS_tail_loop_begin = 0x2003,
@@ -202,46 +197,8 @@ ENUM_DW_AT = dict(
DW_AT_MIPS_abstract_name = 0x2009,
DW_AT_MIPS_clone_origin = 0x200a,
DW_AT_MIPS_has_inlines = 0x200b,
- DW_AT_MIPS_stride_byte = 0x200c,
- DW_AT_MIPS_stride_elem = 0x200d,
- DW_AT_MIPS_ptr_dopetype = 0x200e,
- DW_AT_MIPS_allocatable_dopetype = 0x200f,
- DW_AT_MIPS_assumed_shape_dopetype = 0x2010,
- DW_AT_MIPS_assumed_size = 0x2011,
-
- DW_AT_sf_names = 0x2101,
- DW_AT_src_info = 0x2102,
- DW_AT_mac_info = 0x2103,
- DW_AT_src_coords = 0x2104,
- DW_AT_body_begin = 0x2105,
- DW_AT_body_end = 0x2106,
- DW_AT_GNU_vector = 0x2107,
- DW_AT_GNU_template_name = 0x2110,
- DW_AT_GNU_call_site_value = 0x2111,
- DW_AT_GNU_call_site_data_value = 0x2112,
- DW_AT_GNU_call_site_target = 0x2113,
- DW_AT_GNU_call_site_target_clobbered = 0x2114,
- DW_AT_GNU_tail_call = 0x2115,
- DW_AT_GNU_all_tail_call_sites = 0x2116,
- DW_AT_GNU_all_call_sites = 0x2117,
- DW_AT_GNU_all_source_call_sites = 0x2118,
-
- DW_AT_APPLE_optimized = 0x3fe1,
- DW_AT_APPLE_flags = 0x3fe2,
- DW_AT_APPLE_isa = 0x3fe3,
- DW_AT_APPLE_block = 0x3fe4,
- DW_AT_APPLE_major_runtime_vers = 0x3fe5,
- DW_AT_APPLE_runtime_class = 0x3fe6,
- DW_AT_APPLE_omit_frame_ptr = 0x3fe7,
- DW_AT_APPLE_property_name = 0x3fe8,
- DW_AT_APPLE_property_getter = 0x3fe9,
- DW_AT_APPLE_property_setter = 0x3fea,
- DW_AT_APPLE_property_attribute = 0x3feb,
- DW_AT_APPLE_objc_complete_type = 0x3fec,
- DW_AT_APPLE_property = 0x3fed,
-
- _default_ = Pass,
+ _default_ = Pass,
)
@@ -268,16 +225,7 @@ ENUM_DW_FORM = dict(
DW_FORM_ref8 = 0x14,
DW_FORM_ref_udata = 0x15,
DW_FORM_indirect = 0x16,
- DW_FORM_sec_offset = 0x17,
- DW_FORM_exprloc = 0x18,
- DW_FORM_flag_present = 0x19,
- DW_FORM_ref_sig8 = 0x20,
- DW_FORM_GNU_strp_alt = 0x1f21,
- DW_FORM_GNU_ref_alt = 0x1f20,
_default_ = Pass,
)
-# Inverse mapping for ENUM_DW_FORM
-DW_FORM_raw2name = dict((v, k) for k, v in iteritems(ENUM_DW_FORM))
-
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/lineprogram.py b/chromium/third_party/pyelftools/elftools/dwarf/lineprogram.py
index 810e60398cb..ee5193ee868 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/lineprogram.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/lineprogram.py
@@ -215,10 +215,10 @@ class LineProgram(object):
add_entry_old_state(opcode, [operand])
elif opcode == DW_LNS_negate_stmt:
state.is_stmt = not state.is_stmt
- add_entry_old_state(opcode, [])
+ add_entry_old_state(opcode, [operand])
elif opcode == DW_LNS_set_basic_block:
state.basic_block = True
- add_entry_old_state(opcode, [])
+ add_entry_old_state(opcode, [operand])
elif opcode == DW_LNS_const_add_pc:
adjusted_opcode = 255 - self['opcode_base']
address_addend = ((adjusted_opcode // self['line_range']) *
diff --git a/chromium/third_party/pyelftools/elftools/dwarf/structs.py b/chromium/third_party/pyelftools/elftools/dwarf/structs.py
index 39e4815b2f4..cfb2515a0ab 100644
--- a/chromium/third_party/pyelftools/elftools/dwarf/structs.py
+++ b/chromium/third_party/pyelftools/elftools/dwarf/structs.py
@@ -11,7 +11,7 @@ from ..construct import (
UBInt8, UBInt16, UBInt32, UBInt64, ULInt8, ULInt16, ULInt32, ULInt64,
SBInt8, SBInt16, SBInt32, SBInt64, SLInt8, SLInt16, SLInt32, SLInt64,
Adapter, Struct, ConstructError, If, RepeatUntil, Field, Rename, Enum,
- Array, PrefixedArray, CString, Embed, StaticField
+ Array, PrefixedArray, CString, Embed,
)
from ..common.construct_utils import RepeatUntilExcluding
@@ -19,39 +19,39 @@ from .enums import *
class DWARFStructs(object):
- """ Exposes Construct structs suitable for parsing information from DWARF
+ """ Exposes Construct structs suitable for parsing information from DWARF
sections. Each compile unit in DWARF info can have its own structs
- object. Keep in mind that these structs have to be given a name (by
+ object. Keep in mind that these structs have to be given a name (by
calling them with a name) before being used for parsing (like other
Construct structs). Those that should be used without a name are marked
by (+).
-
+
Accessible attributes (mostly as described in chapter 7 of the DWARF
spec v3):
-
+
Dwarf_[u]int{8,16,32,64):
Data chunks of the common sizes
-
+
Dwarf_offset:
32-bit or 64-bit word, depending on dwarf_format
-
+
Dwarf_target_addr:
32-bit or 64-bit word, depending on address size
-
+
Dwarf_initial_length:
"Initial length field" encoding
section 7.4
-
+
Dwarf_{u,s}leb128:
ULEB128 and SLEB128 variable-length encoding
-
+
Dwarf_CU_header (+):
Compilation unit header
-
+
Dwarf_abbrev_declaration (+):
Abbreviation table declaration - doesn't include the initial
code, only the contents.
-
+
Dwarf_dw_form (+):
A dictionary mapping 'DW_FORM_*' keys into construct Structs
that parse such forms. These Structs have already been given
@@ -62,7 +62,7 @@ class DWARFStructs(object):
Dwarf_lineprog_file_entry (+):
A single file entry in a line program header or instruction
-
+
Dwarf_CIE_header (+):
A call-frame CIE
@@ -71,27 +71,22 @@ class DWARFStructs(object):
See also the documentation of public methods.
"""
- def __init__(self,
- little_endian, dwarf_format, address_size, dwarf_version=2):
- """ dwarf_version:
- Numeric DWARF version
-
- little_endian:
+ def __init__(self, little_endian, dwarf_format, address_size):
+ """ little_endian:
True if the file is little endian, False if big
-
+
dwarf_format:
DWARF Format: 32 or 64-bit (see spec section 7.4)
-
+
address_size:
- Target machine address size, in bytes (4 or 8). (See spec
+ Target machine address size, in bytes (4 or 8). (See spec
section 7.5.1)
"""
assert dwarf_format == 32 or dwarf_format == 64
assert address_size == 8 or address_size == 4
self.little_endian = little_endian
- self.dwarf_format = dwarf_format
+ self.dwarf_format = dwarf_format
self.address_size = address_size
- self.dwarf_version = dwarf_version
self._create_structs()
def initial_length_field_size(self):
@@ -136,7 +131,7 @@ class DWARFStructs(object):
def _create_initial_length(self):
def _InitialLength(name):
# Adapts a Struct that parses forward a full initial length field.
- # Only if the first word is the continuation value, the second
+ # Only if the first word is the continuation value, the second
# word is parsed from the stream.
#
return _InitialLengthAdapter(
@@ -157,13 +152,13 @@ class DWARFStructs(object):
self.Dwarf_uint16('version'),
self.Dwarf_offset('debug_abbrev_offset'),
self.Dwarf_uint8('address_size'))
-
+
def _create_abbrev_declaration(self):
self.Dwarf_abbrev_declaration = Struct('Dwarf_abbrev_entry',
Enum(self.Dwarf_uleb128('tag'), **ENUM_DW_TAG),
Enum(self.Dwarf_uint8('children_flag'), **ENUM_DW_CHILDREN),
RepeatUntilExcluding(
- lambda obj, ctx:
+ lambda obj, ctx:
obj.name == 'DW_AT_null' and obj.form == 'DW_FORM_null',
Struct('attr_spec',
Enum(self.Dwarf_uleb128('name'), **ENUM_DW_AT),
@@ -172,12 +167,12 @@ class DWARFStructs(object):
def _create_dw_form(self):
self.Dwarf_dw_form = dict(
DW_FORM_addr=self.Dwarf_target_addr(''),
-
+
DW_FORM_block1=self._make_block_struct(self.Dwarf_uint8),
DW_FORM_block2=self._make_block_struct(self.Dwarf_uint16),
DW_FORM_block4=self._make_block_struct(self.Dwarf_uint32),
DW_FORM_block=self._make_block_struct(self.Dwarf_uleb128),
-
+
# All DW_FORM_data<n> forms are assumed to be unsigned
DW_FORM_data1=self.Dwarf_uint8(''),
DW_FORM_data2=self.Dwarf_uint16(''),
@@ -185,29 +180,19 @@ class DWARFStructs(object):
DW_FORM_data8=self.Dwarf_uint64(''),
DW_FORM_sdata=self.Dwarf_sleb128(''),
DW_FORM_udata=self.Dwarf_uleb128(''),
-
+
DW_FORM_string=CString(''),
DW_FORM_strp=self.Dwarf_offset(''),
DW_FORM_flag=self.Dwarf_uint8(''),
-
+
DW_FORM_ref1=self.Dwarf_uint8(''),
DW_FORM_ref2=self.Dwarf_uint16(''),
DW_FORM_ref4=self.Dwarf_uint32(''),
DW_FORM_ref8=self.Dwarf_uint64(''),
DW_FORM_ref_udata=self.Dwarf_uleb128(''),
DW_FORM_ref_addr=self.Dwarf_offset(''),
-
+
DW_FORM_indirect=self.Dwarf_uleb128(''),
-
- # New forms in DWARFv4
- DW_FORM_flag_present = StaticField('', 0),
- DW_FORM_sec_offset = self.Dwarf_offset(''),
- DW_FORM_exprloc = self._make_block_struct(self.Dwarf_uleb128),
- DW_FORM_ref_sig8 = self.Dwarf_offset(''),
-
- DW_FORM_GNU_strp_alt=self.Dwarf_offset(''),
- DW_FORM_GNU_ref_alt=self.Dwarf_offset(''),
- DW_AT_GNU_all_call_sites=self.Dwarf_uleb128(''),
)
def _create_lineprog_header(self):
@@ -230,7 +215,7 @@ class DWARFStructs(object):
self.Dwarf_int8('line_base'),
self.Dwarf_uint8('line_range'),
self.Dwarf_uint8('opcode_base'),
- Array(lambda ctx: ctx['opcode_base'] - 1,
+ Array(lambda ctx: ctx['opcode_base'] - 1,
self.Dwarf_uint8('standard_opcode_lengths')),
RepeatUntilExcluding(
lambda obj, ctx: obj == b'',
@@ -241,27 +226,14 @@ class DWARFStructs(object):
)
def _create_callframe_entry_headers(self):
- # The CIE header was modified in DWARFv4.
- if self.dwarf_version == 4:
- self.Dwarf_CIE_header = Struct('Dwarf_CIE_header',
- self.Dwarf_initial_length('length'),
- self.Dwarf_offset('CIE_id'),
- self.Dwarf_uint8('version'),
- CString('augmentation'),
- self.Dwarf_uint8('address_size'),
- self.Dwarf_uint8('segment_size'),
- self.Dwarf_uleb128('code_alignment_factor'),
- self.Dwarf_sleb128('data_alignment_factor'),
- self.Dwarf_uleb128('return_address_register'))
- else:
- self.Dwarf_CIE_header = Struct('Dwarf_CIE_header',
- self.Dwarf_initial_length('length'),
- self.Dwarf_offset('CIE_id'),
- self.Dwarf_uint8('version'),
- CString('augmentation'),
- self.Dwarf_uleb128('code_alignment_factor'),
- self.Dwarf_sleb128('data_alignment_factor'),
- self.Dwarf_uleb128('return_address_register'))
+ self.Dwarf_CIE_header = Struct('Dwarf_CIE_header',
+ self.Dwarf_initial_length('length'),
+ self.Dwarf_offset('CIE_id'),
+ self.Dwarf_uint8('version'),
+ CString('augmentation'),
+ self.Dwarf_uleb128('code_alignment_factor'),
+ self.Dwarf_sleb128('data_alignment_factor'),
+ self.Dwarf_uleb128('return_address_register'))
self.Dwarf_FDE_header = Struct('Dwarf_FDE_header',
self.Dwarf_initial_length('length'),
@@ -270,7 +242,7 @@ class DWARFStructs(object):
self.Dwarf_target_addr('address_range'))
def _make_block_struct(self, length_field):
- """ Create a struct for DW_FORM_block<size>
+ """ Create a struct for DW_FORM_block<size>
"""
return PrefixedArray(
subcon=self.Dwarf_uint8('elem'),
diff --git a/chromium/third_party/pyelftools/elftools/elf/constants.py b/chromium/third_party/pyelftools/elftools/elf/constants.py
index b41f35a96f4..df75e16fe0e 100644
--- a/chromium/third_party/pyelftools/elftools/elf/constants.py
+++ b/chromium/third_party/pyelftools/elftools/elf/constants.py
@@ -6,26 +6,6 @@
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
-
-class E_FLAGS(object):
- """ Flag values for the e_flags field of the ELF header
- """
- EF_ARM_EABIMASK=0xFF000000
- EF_ARM_EABI_VER1=0x01000000
- EF_ARM_EABI_VER2=0x02000000
- EF_ARM_EABI_VER3=0x03000000
- EF_ARM_EABI_VER4=0x04000000
- EF_ARM_EABI_VER5=0x05000000
- EF_ARM_GCCMASK=0x00400FFF
- EF_ARM_HASENTRY=0x02
- EF_ARM_SYMSARESORTED=0x04
- EF_ARM_DYNSYMSUSESEGIDX=0x8
- EF_ARM_MAPSYMSFIRST=0x10
- EF_ARM_LE8=0x00400000
- EF_ARM_BE8=0x00800000
- EF_ARM_ABI_FLOAT_SOFT=0x00000200
- EF_ARM_ABI_FLOAT_HARD=0x00000400
-
class SHN_INDICES(object):
""" Special section indices
"""
@@ -65,25 +45,3 @@ class P_FLAGS(object):
PF_MASKOS=0x00FF0000
PF_MASKPROC=0xFF000000
-
-# symbol info flags for entries
-# in the .SUNW_syminfo section
-class SUNW_SYMINFO_FLAGS(object):
- """ Flags for the si_flags field of entries
- in the .SUNW_syminfo section
- """
- SYMINFO_FLG_DIRECT=0x1
- SYMINFO_FLG_FILTER=0x2
- SYMINFO_FLG_COPY=0x4
- SYMINFO_FLG_LAZYLOAD=0x8
- SYMINFO_FLG_DIRECTBIND=0x10
- SYMINFO_FLG_NOEXTDIRECT=0x20
- SYMINFO_FLG_AUXILIARY=0x40
- SYMINFO_FLG_INTERPOSE=0x80
- SYMINFO_FLG_CAP=0x100
- SYMINFO_FLG_DEFERRED=0x200
-
-class VER_FLAGS(object):
- VER_FLG_BASE=0x1
- VER_FLG_WEAK=0x2
- VER_FLG_INFO=0x4
diff --git a/chromium/third_party/pyelftools/elftools/elf/descriptions.py b/chromium/third_party/pyelftools/elftools/elf/descriptions.py
index 6d108c2a340..2cde281b21e 100644
--- a/chromium/third_party/pyelftools/elftools/elf/descriptions.py
+++ b/chromium/third_party/pyelftools/elftools/elf/descriptions.py
@@ -6,10 +6,8 @@
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
-from .enums import (
- ENUM_D_TAG, ENUM_E_VERSION, ENUM_RELOC_TYPE_i386, ENUM_RELOC_TYPE_x64,
- ENUM_RELOC_TYPE_ARM, ENUM_RELOC_TYPE_AARCH64)
-from .constants import P_FLAGS, SH_FLAGS, SUNW_SYMINFO_FLAGS, VER_FLAGS
+from .enums import ENUM_E_VERSION, ENUM_RELOC_TYPE_i386, ENUM_RELOC_TYPE_x64
+from .constants import P_FLAGS, SH_FLAGS
from ..common.py3compat import iteritems
@@ -24,7 +22,7 @@ def describe_ei_version(x):
if x == 'EV_CURRENT':
s += ' (current)'
return s
-
+
def describe_ei_osabi(x):
return _DESCR_EI_OSABI.get(x, _unknown)
@@ -43,7 +41,7 @@ def describe_p_type(x):
def describe_p_flags(x):
s = ''
for flag in (P_FLAGS.PF_R, P_FLAGS.PF_W, P_FLAGS.PF_X):
- s += _DESCR_P_FLAGS[flag] if (x & flag) else ' '
+ s += _DESCR_P_FLAGS[flag] if (x & flag) else ' '
return s
def describe_sh_type(x):
@@ -77,43 +75,14 @@ def describe_reloc_type(x, elffile):
return _DESCR_RELOC_TYPE_i386.get(x, _unknown)
elif arch == 'x64':
return _DESCR_RELOC_TYPE_x64.get(x, _unknown)
- elif arch == 'ARM':
- return _DESCR_RELOC_TYPE_ARM.get(x, _unknown)
- elif arch == 'AArch64':
- return _DESCR_RELOC_TYPE_AARCH64.get(x, _unknown)
else:
return 'unrecognized: %-7x' % (x & 0xFFFFFFFF)
-def describe_dyn_tag(x):
- return _DESCR_D_TAG.get(x, _unknown)
-
-
-def describe_syminfo_flags(x):
- return ''.join(_DESCR_SYMINFO_FLAGS[flag] for flag in (
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_CAP,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECT,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_FILTER,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_AUXILIARY,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECTBIND,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_COPY,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_LAZYLOAD,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_NOEXTDIRECT,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_INTERPOSE,
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DEFERRED) if x & flag)
-
-def describe_symbol_boundto(x):
- return _DESCR_SYMINFO_BOUNDTO.get(x, '%3s' % x)
-
-def describe_ver_flags(x):
- return ' | '.join(_DESCR_VER_FLAGS[flag] for flag in (
- VER_FLAGS.VER_FLG_WEAK,
- VER_FLAGS.VER_FLG_BASE,
- VER_FLAGS.VER_FLG_INFO) if x & flag)
#-------------------------------------------------------------------------------
_unknown = '<unknown>'
-
+
_DESCR_EI_CLASS = dict(
ELFCLASSNONE='none',
ELFCLASS32='ELF32',
@@ -169,9 +138,6 @@ _DESCR_E_MACHINE = dict(
EM_IA_64='Intel IA-64',
EM_X86_64='Advanced Micro Devices X86-64',
EM_AVR='Atmel AVR 8-bit microcontroller',
- EM_ARM='ARM',
- EM_AARCH64='AArch64',
- EM_BLAFKIN='Analog Devices Blackfin',
RESERVED='RESERVED',
)
@@ -186,11 +152,6 @@ _DESCR_P_TYPE = dict(
PT_GNU_EH_FRAME='GNU_EH_FRAME',
PT_GNU_STACK='GNU_STACK',
PT_GNU_RELRO='GNU_RELRO',
- PT_ARM_ARCHEXT='ARM_ARCHEXT',
- PT_ARM_EXIDX='ARM_EXIDX',
- PT_ARM_UNWIND='ARM_UNWIND',
- PT_AARCH64_ARCHEXT='AARCH64_ARCHEXT',
- PT_AARCH64_UNWIND='AARCH64_UNWIND',
)
_DESCR_P_FLAGS = {
@@ -222,10 +183,6 @@ _DESCR_SH_TYPE = dict(
SHT_GNU_verneed='VERNEED',
SHT_GNU_versym='VERSYM',
SHT_GNU_LIBLIST='GNU_LIBLIST',
- SHT_ARM_EXIDX='ARM_EXIDX',
- SHT_ARM_PREEMPTMAP='ARM_PREEMPTMAP',
- SHT_ARM_ATTRIBUTES='ARM_ATTRIBUTES',
- SHT_ARM_DEBUGOVERLAY='ARM_DEBUGOVERLAY',
)
_DESCR_SH_FLAGS = {
@@ -265,10 +222,7 @@ _DESCR_ST_VISIBILITY = dict(
STV_DEFAULT='DEFAULT',
STV_INTERNAL='INTERNAL',
STV_HIDDEN='HIDDEN',
- STV_PROTECTED='PROTECTED',
- STV_EXPORTED='EXPORTED',
- STV_SINGLETON='SINGLETON',
- STV_ELIMINATE='ELIMINATE',
+ STD_PROTECTED='PROTECTED',
)
_DESCR_ST_SHNDX = dict(
@@ -277,44 +231,10 @@ _DESCR_ST_SHNDX = dict(
SHN_COMMON='COM',
)
-_DESCR_SYMINFO_FLAGS = {
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECT: 'D',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECTBIND: 'B',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_COPY: 'C',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_LAZYLOAD: 'L',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_NOEXTDIRECT: 'N',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_AUXILIARY: 'A',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_FILTER: 'F',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_INTERPOSE: 'I',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_CAP: 'S',
- SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DEFERRED: 'P',
-}
-
-_DESCR_SYMINFO_BOUNDTO = dict(
- SYMINFO_BT_SELF='<self>',
- SYMINFO_BT_PARENT='<parent>',
- SYMINFO_BT_NONE='',
- SYMINFO_BT_EXTERN='<extern>',
-)
-
-_DESCR_VER_FLAGS = {
- 0: '',
- VER_FLAGS.VER_FLG_BASE: 'BASE',
- VER_FLAGS.VER_FLG_WEAK: 'WEAK',
- VER_FLAGS.VER_FLG_INFO: 'INFO',
-}
-
_DESCR_RELOC_TYPE_i386 = dict(
(v, k) for k, v in iteritems(ENUM_RELOC_TYPE_i386))
_DESCR_RELOC_TYPE_x64 = dict(
(v, k) for k, v in iteritems(ENUM_RELOC_TYPE_x64))
-_DESCR_RELOC_TYPE_ARM = dict(
- (v, k) for k, v in iteritems(ENUM_RELOC_TYPE_ARM))
-
-_DESCR_RELOC_TYPE_AARCH64 = dict(
- (v, k) for k, v in iteritems(ENUM_RELOC_TYPE_AARCH64))
-_DESCR_D_TAG = dict(
- (v, k) for k, v in iteritems(ENUM_D_TAG))
diff --git a/chromium/third_party/pyelftools/elftools/elf/dynamic.py b/chromium/third_party/pyelftools/elftools/elf/dynamic.py
index 9f985c20037..2292470baa9 100644
--- a/chromium/third_party/pyelftools/elftools/elf/dynamic.py
+++ b/chromium/third_party/pyelftools/elftools/elf/dynamic.py
@@ -10,45 +10,26 @@ import itertools
from .sections import Section
from .segments import Segment
-from ..common.exceptions import ELFError
-from ..common.utils import struct_parse, parse_cstring_from_stream
+from ..common.utils import struct_parse
-
-class _DynamicStringTable(object):
- """ Bare string table based on values found via ELF dynamic tags and
- loadable segments only. Good enough for get_string() only.
- """
- def __init__(self, stream, table_offset):
- self._stream = stream
- self._table_offset = table_offset
-
- def get_string(self, offset):
- """ Get the string stored at the given offset in this string table.
- """
- return parse_cstring_from_stream(self._stream,
- self._table_offset + offset)
+from enums import ENUM_D_TAG
class DynamicTag(object):
""" Dynamic Tag object - representing a single dynamic tag entry from a
dynamic section.
- Allows dictionary-like access to the dynamic structure. For special
- tags (those listed in the _HANDLED_TAGS set below), creates additional
- attributes for convenience. For example, .soname will contain the actual
- value of DT_SONAME (fetched from the dynamic symbol table).
+ Similarly to Section objects, allows dictionary-like access to the
+ dynamic tag.
"""
- _HANDLED_TAGS = frozenset(
- ['DT_NEEDED', 'DT_RPATH', 'DT_RUNPATH', 'DT_SONAME',
- 'DT_SUNW_FILTER'])
- def __init__(self, entry, stringtable):
- if stringtable is None:
- raise ELFError('Creating DynamicTag without string table')
+ _HANDLED_TAGS = frozenset(['DT_NEEDED', 'DT_RPATH', 'DT_RUNPATH'])
+
+ def __init__(self, entry, elffile):
self.entry = entry
if entry.d_tag in self._HANDLED_TAGS:
- setattr(self, entry.d_tag[3:].lower(),
- stringtable.get_string(self.entry.d_val))
+ dynstr = elffile.get_section_by_name('.dynstr')
+ setattr(self, entry.d_tag[3:].lower(), dynstr.get_string(self.entry.d_val))
def __getitem__(self, name):
""" Implement dict-like access to entries
@@ -67,78 +48,35 @@ class DynamicTag(object):
class Dynamic(object):
- """ Shared functionality between dynamic sections and segments.
- """
- def __init__(self, stream, elffile, stringtable, position):
+ def __init__(self, stream, elffile, position):
self._stream = stream
self._elffile = elffile
self._elfstructs = elffile.structs
- self._num_tags = -1
+ self._num_tags = -1;
self._offset = position
self._tagsize = self._elfstructs.Elf_Dyn.sizeof()
- # Do not access this directly yourself; use _get_stringtable() instead.
- self._stringtable = stringtable
-
- def _get_stringtable(self):
- """ Return a string table for looking up dynamic tag related strings.
-
- This won't be a "full" string table object, but will at least
- support the get_string() function.
- """
- if self._stringtable:
- return self._stringtable
-
- # If the ELF has stripped its section table (which is unusual, but
- # perfectly valid), we need to use the dynamic tags to locate the
- # dynamic string table.
- strtab = None
- for tag in self._iter_tags(type='DT_STRTAB'):
- strtab = tag['d_val']
- break
- # If we found a dynamic string table, locate the offset in the file
- # by using the program headers.
- if strtab:
- table_offset = next(self._elffile.address_offsets(strtab), None)
- if table_offset is not None:
- self._stringtable = _DynamicStringTable(self._stream, table_offset)
- return self._stringtable
-
- # That didn't work for some reason. Let's use the section header
- # even though this ELF is super weird.
- self._stringtable = self._elffile.get_section_by_name(b'.dynstr')
- return self._stringtable
-
- def _iter_tags(self, type=None):
- """ Yield all raw tags (limit to |type| if specified)
+ def iter_tags(self, type=None):
+ """ Yield all tags (limit to |type| if specified)
"""
for n in itertools.count():
- tag = self._get_tag(n)
- if type is None or tag['d_tag'] == type:
+ tag = self.get_tag(n)
+ if type is None or tag.entry.d_tag == type:
yield tag
- if tag['d_tag'] == 'DT_NULL':
+ if tag.entry.d_tag == 'DT_NULL':
break
- def iter_tags(self, type=None):
- """ Yield all tags (limit to |type| if specified)
- """
- for tag in self._iter_tags(type=type):
- yield DynamicTag(tag, self._get_stringtable())
-
- def _get_tag(self, n):
- """ Get the raw tag at index #n from the file
+ def get_tag(self, n):
+ """ Get the tag at index #n from the file (DynamicTag object)
"""
offset = self._offset + n * self._tagsize
- return struct_parse(
+ entry = struct_parse(
self._elfstructs.Elf_Dyn,
self._stream,
stream_pos=offset)
+ return DynamicTag(entry, self._elffile)
- def get_tag(self, n):
- """ Get the tag at index #n from the file (DynamicTag object)
- """
- return DynamicTag(self._get_tag(n), self._get_stringtable())
-
+ @property
def num_tags(self):
""" Number of dynamic tags in the file
"""
@@ -148,8 +86,8 @@ class Dynamic(object):
for n in itertools.count():
tag = self.get_tag(n)
if tag.entry.d_tag == 'DT_NULL':
- self._num_tags = n + 1
- return self._num_tags
+ self._num_tags = n
+ return n
class DynamicSection(Section, Dynamic):
@@ -157,25 +95,12 @@ class DynamicSection(Section, Dynamic):
"""
def __init__(self, header, name, stream, elffile):
Section.__init__(self, header, name, stream)
- stringtable = elffile.get_section(header['sh_link'])
- Dynamic.__init__(self, stream, elffile, stringtable, self['sh_offset'])
+ Dynamic.__init__(self, stream, elffile, self['sh_offset'])
class DynamicSegment(Segment, Dynamic):
""" ELF dynamic table segment. Knows how to process the list of tags.
"""
def __init__(self, header, stream, elffile):
- # The string table section to be used to resolve string names in
- # the dynamic tag array is the one pointed at by the sh_link field
- # of the dynamic section header.
- # So we must look for the dynamic section contained in the dynamic
- # segment, we do so by searching for the dynamic section whose content
- # is located at the same offset as the dynamic segment
- stringtable = None
- for section in elffile.iter_sections():
- if (isinstance(section, DynamicSection) and
- section['sh_offset'] == header['p_offset']):
- stringtable = elffile.get_section(section['sh_link'])
- break
Segment.__init__(self, header, stream)
- Dynamic.__init__(self, stream, elffile, stringtable, self['p_offset'])
+ Dynamic.__init__(self, stream, elffile, self['p_offset'])
diff --git a/chromium/third_party/pyelftools/elftools/elf/elffile.py b/chromium/third_party/pyelftools/elftools/elf/elffile.py
index 15aa07e7f95..e2bd904c26f 100644
--- a/chromium/third_party/pyelftools/elftools/elf/elffile.py
+++ b/chromium/third_party/pyelftools/elftools/elf/elffile.py
@@ -12,32 +12,29 @@ from ..common.utils import struct_parse, elf_assert
from ..construct import ConstructError
from .structs import ELFStructs
from .sections import (
- Section, StringTableSection, SymbolTableSection,
- SUNWSyminfoTableSection, NullSection)
+ Section, StringTableSection, SymbolTableSection, NullSection)
from .dynamic import DynamicSection, DynamicSegment
from .relocation import RelocationSection, RelocationHandler
-from .gnuversions import (
- GNUVerNeedSection, GNUVerDefSection,
- GNUVerSymSection)
from .segments import Segment, InterpSegment
+from .enums import ENUM_RELOC_TYPE_i386, ENUM_RELOC_TYPE_x64
from ..dwarf.dwarfinfo import DWARFInfo, DebugSectionDescriptor, DwarfConfig
class ELFFile(object):
""" Creation: the constructor accepts a stream (file-like object) with the
contents of an ELF file.
-
+
Accessible attributes:
stream:
The stream holding the data of the file - must be a binary
stream (bytes, not string).
- elfclass:
+ elfclass:
32 or 64 - specifies the word size of the target machine
-
+
little_endian:
- boolean - specifies the target machine's endianness
+ boolean - specifies the target machine's endianness
header:
the complete ELF file header
@@ -55,24 +52,24 @@ class ELFFile(object):
self.stream.seek(0)
self.e_ident_raw = self.stream.read(16)
-
+
self._file_stringtable_section = self._get_file_stringtable()
self._section_name_map = None
-
+
def num_sections(self):
""" Number of sections in the file
"""
return self['e_shnum']
-
+
def get_section(self, n):
""" Get the section at index #n from the file (Section object or a
subclass)
"""
section_header = self._get_section_header(n)
return self._make_section(section_header)
-
+
def get_section_by_name(self, name):
- """ Get a section from the file, by name. Return None if no such
+ """ Get a section from the file, by name. Return None if no such
section exists.
"""
# The first time this method is called, construct a name to number
@@ -84,18 +81,18 @@ class ELFFile(object):
self._section_name_map[sec.name] = i
secnum = self._section_name_map.get(name, None)
return None if secnum is None else self.get_section(secnum)
-
+
def iter_sections(self):
""" Yield all the sections in the file
"""
for i in range(self.num_sections()):
yield self.get_section(i)
-
+
def num_segments(self):
""" Number of segments in the file
"""
return self['e_phnum']
-
+
def get_segment(self, n):
""" Get the segment at index #n from the file (Segment object)
"""
@@ -108,20 +105,8 @@ class ELFFile(object):
for i in range(self.num_segments()):
yield self.get_segment(i)
- def address_offsets(self, start, size=1):
- """ Yield a file offset for each ELF segment containing a memory region.
-
- A memory region is defined by the range [start...start+size). The
- offset of the region is yielded.
- """
- end = start + size
- for seg in self.iter_segments():
- if (start >= seg['p_vaddr'] and
- end <= seg['p_vaddr'] + seg['p_filesz']):
- yield start - seg['p_vaddr'] + seg['p_offset']
-
def has_dwarf_info(self):
- """ Check whether this file appears to have debugging information.
+ """ Check whether this file appears to have debugging information.
We assume that if it has the debug_info section, it has all theother
required sections as well.
"""
@@ -134,32 +119,30 @@ class ELFFile(object):
If relocate_dwarf_sections is True, relocations for DWARF sections
are looked up and applied.
"""
- # Expect that has_dwarf_info was called, so at least .debug_info is
- # present.
+ # Expect that has_dwarf_info was called, so at least .debug_info is
+ # present.
# Sections that aren't found will be passed as None to DWARFInfo.
#
debug_sections = {}
- for secname in (b'.debug_info', b'.debug_abbrev', b'.debug_str',
- b'.debug_line', b'.debug_frame',
- b'.debug_loc', b'.debug_ranges'):
+ for secname in (b'.debug_info', b'.debug_abbrev', b'.debug_str',
+ b'.debug_line', b'.debug_frame', b'.debug_loc',
+ b'.debug_ranges'):
section = self.get_section_by_name(secname)
if section is None:
debug_sections[secname] = None
else:
debug_sections[secname] = self._read_dwarf_section(
- section,
- relocate_dwarf_sections)
+ section,
+ relocate_dwarf_sections)
return DWARFInfo(
config=DwarfConfig(
little_endian=self.little_endian,
- default_address_size=self.elfclass // 8,
+ default_address_size=self.elfclass / 8,
machine_arch=self.get_machine_arch()),
debug_info_sec=debug_sections[b'.debug_info'],
debug_abbrev_sec=debug_sections[b'.debug_abbrev'],
debug_frame_sec=debug_sections[b'.debug_frame'],
- # TODO(eliben): reading of eh_frame is not hooked up yet
- eh_frame_sec=None,
debug_str_sec=debug_sections[b'.debug_str'],
debug_loc_sec=debug_sections[b'.debug_loc'],
debug_ranges_sec=debug_sections[b'.debug_ranges'],
@@ -167,16 +150,12 @@ class ELFFile(object):
def get_machine_arch(self):
""" Return the machine architecture, as detected from the ELF header.
- Not all architectures are supported at the moment.
+ At the moment the only supported architectures are x86 and x64.
"""
if self['e_machine'] == 'EM_X86_64':
return 'x64'
elif self['e_machine'] in ('EM_386', 'EM_486'):
return 'x86'
- elif self['e_machine'] == 'EM_ARM':
- return 'ARM'
- elif self['e_machine'] == 'EM_AARCH64':
- return 'AArch64'
else:
return '<unknown>'
@@ -191,7 +170,7 @@ class ELFFile(object):
""" Verify the ELF file and identify its class and endianness.
"""
# Note: this code reads the stream directly, without using ELFStructs,
- # since we don't yet know its exact format. ELF was designed to be
+ # since we don't yet know its exact format. ELF was designed to be
# read like this - its e_ident field is word-size and endian agnostic.
#
self.stream.seek(0)
@@ -213,17 +192,17 @@ class ELFFile(object):
self.little_endian = False
else:
raise ELFError('Invalid EI_DATA %s' % repr(ei_data))
-
+
def _section_offset(self, n):
""" Compute the offset of section #n in the file
"""
return self['e_shoff'] + n * self['e_shentsize']
-
+
def _segment_offset(self, n):
""" Compute the offset of segment #n in the file
"""
return self['e_phoff'] + n * self['e_phentsize']
-
+
def _make_segment(self, segment_header):
""" Create a Segment object of the appropriate type
"""
@@ -236,13 +215,13 @@ class ELFFile(object):
return Segment(segment_header, self.stream)
def _get_section_header(self, n):
- """ Find the header of section #n, parse it and return the struct
+ """ Find the header of section #n, parse it and return the struct
"""
return struct_parse(
self.structs.Elf_Shdr,
self.stream,
stream_pos=self._section_offset(n))
-
+
def _get_section_name(self, section_header):
""" Given a section header, find this section's name in the file's
string table
@@ -255,21 +234,13 @@ class ELFFile(object):
"""
name = self._get_section_name(section_header)
sectype = section_header['sh_type']
-
+
if sectype == 'SHT_STRTAB':
return StringTableSection(section_header, name, self.stream)
elif sectype == 'SHT_NULL':
return NullSection(section_header, name, self.stream)
- elif sectype in ('SHT_SYMTAB', 'SHT_DYNSYM', 'SHT_SUNW_LDYNSYM'):
+ elif sectype in ('SHT_SYMTAB', 'SHT_DYNSYM'):
return self._make_symbol_table_section(section_header, name)
- elif sectype == 'SHT_SUNW_syminfo':
- return self._make_sunwsyminfo_table_section(section_header, name)
- elif sectype == 'SHT_GNU_verneed':
- return self._make_gnu_verneed_section(section_header, name)
- elif sectype == 'SHT_GNU_verdef':
- return self._make_gnu_verdef_section(section_header, name)
- elif sectype == 'SHT_GNU_versym':
- return self._make_gnu_versym_section(section_header, name)
elif sectype in ('SHT_REL', 'SHT_RELA'):
return RelocationSection(
section_header, name, self.stream, self)
@@ -288,46 +259,6 @@ class ELFFile(object):
elffile=self,
stringtable=strtab_section)
- def _make_sunwsyminfo_table_section(self, section_header, name):
- """ Create a SUNWSyminfoTableSection
- """
- linked_strtab_index = section_header['sh_link']
- strtab_section = self.get_section(linked_strtab_index)
- return SUNWSyminfoTableSection(
- section_header, name, self.stream,
- elffile=self,
- symboltable=strtab_section)
-
- def _make_gnu_verneed_section(self, section_header, name):
- """ Create a GNUVerNeedSection
- """
- linked_strtab_index = section_header['sh_link']
- strtab_section = self.get_section(linked_strtab_index)
- return GNUVerNeedSection(
- section_header, name, self.stream,
- elffile=self,
- stringtable=strtab_section)
-
- def _make_gnu_verdef_section(self, section_header, name):
- """ Create a GNUVerDefSection
- """
- linked_strtab_index = section_header['sh_link']
- strtab_section = self.get_section(linked_strtab_index)
- return GNUVerDefSection(
- section_header, name, self.stream,
- elffile=self,
- stringtable=strtab_section)
-
- def _make_gnu_versym_section(self, section_header, name):
- """ Create a GNUVerSymSection
- """
- linked_strtab_index = section_header['sh_link']
- strtab_section = self.get_section(linked_strtab_index)
- return GNUVerSymSection(
- section_header, name, self.stream,
- elffile=self,
- symboltable=strtab_section)
-
def _get_segment_header(self, n):
""" Find the header of segment #n, parse it and return the struct
"""
@@ -335,7 +266,7 @@ class ELFFile(object):
self.structs.Elf_Phdr,
self.stream,
stream_pos=self._segment_offset(n))
-
+
def _get_file_stringtable(self):
""" Find the file's string table section
"""
diff --git a/chromium/third_party/pyelftools/elftools/elf/enums.py b/chromium/third_party/pyelftools/elftools/elf/enums.py
index 4aa449a8fe5..804fc45c806 100644
--- a/chromium/third_party/pyelftools/elftools/elf/enums.py
+++ b/chromium/third_party/pyelftools/elftools/elf/enums.py
@@ -47,7 +47,6 @@ ENUM_EI_OSABI = dict(
ELFOSABI_OPENVMS=13,
ELFOSABI_NSK=14,
ELFOSABI_AROS=15,
- ELFOSABI_ARM_AEABI=64,
ELFOSABI_ARM=97,
ELFOSABI_STANDALONE=255,
_default_=Pass,
@@ -66,6 +65,7 @@ ENUM_E_TYPE = dict(
)
# e_machine in the ELF header
+# (this list is currently somewhat partial...)
ENUM_E_MACHINE = dict(
EM_NONE=0,
EM_M32=1,
@@ -73,94 +73,15 @@ ENUM_E_MACHINE = dict(
EM_386=3,
EM_68K=4,
EM_88K=5,
+ EM_486=6,
EM_860=7,
EM_MIPS=8,
EM_S370=9,
- EM_MIPS_RS3_LE=10,
- EM_PARISC=15,
- EM_VPP500=17,
- EM_SPARC32PLUS=18,
- EM_960=19,
- EM_PPC=20,
- EM_PPC64=21,
- EM_S390=22,
- EM_V800=36,
- EM_FR20=37,
- EM_RH32=38,
- EM_RCE=39,
- EM_ARM=40,
- EM_ALPHA=41,
- EM_SH=42,
- EM_SPARCV9=43,
- EM_TRICORE=44,
- EM_ARC=45,
- EM_H8_300=46,
- EM_H8_300H=47,
- EM_H8S=48,
- EM_H8_500=49,
+ EM_MIPS_RS4_BE=10,
EM_IA_64=50,
- EM_MIPS_X=51,
- EM_COLDFIRE=52,
- EM_68HC12=53,
- EM_MMA=54,
- EM_PCP=55,
- EM_NCPU=56,
- EM_NDR1=57,
- EM_STARCORE=58,
- EM_ME16=59,
- EM_ST100=60,
- EM_TINYJ=61,
EM_X86_64=62,
- EM_PDSP=63,
- EM_PDP10=64,
- EM_PDP11=65,
- EM_FX66=66,
- EM_ST9PLUS=67,
- EM_ST7=68,
- EM_68HC16=69,
- EM_68HC11=70,
- EM_68HC08=71,
- EM_68HC05=72,
- EM_SVX=73,
- EM_ST19=74,
- EM_VAX=75,
- EM_CRIS=76,
- EM_JAVELIN=77,
- EM_FIREPATH=78,
- EM_ZSP=79,
- EM_MMIX=80,
- EM_HUANY=81,
- EM_PRISM=82,
EM_AVR=83,
- EM_FR30=84,
- EM_D10V=85,
- EM_D30V=86,
- EM_V850=87,
- EM_M32R=88,
- EM_MN10300=89,
- EM_MN10200=90,
- EM_PJ=91,
- EM_OPENRISC=92,
- EM_ARC_A5=93,
- EM_XTENSA=94,
- EM_VIDEOCORE=95,
- EM_TMM_GPP=96,
- EM_NS32K=97,
- EM_TPC=98,
- EM_SNP1K=99,
- EM_ST200=100,
- EM_IP2K=101,
- EM_MAX=102,
- EM_CR=103,
- EM_F2MC16=104,
- EM_MSP430=105,
- EM_BLACKFIN=106,
- EM_SE_C33=107,
- EM_SEP=108,
- EM_ARCA=109,
- EM_UNICORE=110,
EM_L10M=180,
- EM_AARCH64=183,
_default_=Pass,
)
@@ -186,20 +107,14 @@ ENUM_SH_TYPE = dict(
SHT_NUM=19,
SHT_LOOS=0x60000000,
SHT_GNU_HASH=0x6ffffff6,
- SHT_GNU_verdef=0x6ffffffd, # also SHT_SUNW_verdef
- SHT_GNU_verneed=0x6ffffffe, # also SHT_SUNW_verneed
- SHT_GNU_versym=0x6fffffff, # also SHT_SUNW_versym
+ SHT_GNU_verdef=0x6ffffffd,
+ SHT_GNU_verneed=0x6ffffffe,
+ SHT_GNU_versym=0x6fffffff,
SHT_LOPROC=0x70000000,
SHT_HIPROC=0x7fffffff,
SHT_LOUSER=0x80000000,
SHT_HIUSER=0xffffffff,
SHT_AMD64_UNWIND=0x70000001,
- SHT_SUNW_LDYNSYM=0x6ffffff3,
- SHT_SUNW_syminfo=0x6ffffffc,
- SHT_ARM_EXIDX=0x70000001,
- SHT_ARM_PREEMPTMAP=0x70000002,
- SHT_ARM_ATTRIBUTES=0x70000003,
- SHT_ARM_DEBUGOVERLAY=0x70000004,
_default_=Pass,
)
@@ -219,11 +134,6 @@ ENUM_P_TYPE = dict(
PT_GNU_EH_FRAME=0x6474e550,
PT_GNU_STACK=0x6474e551,
PT_GNU_RELRO=0x6474e552,
- PT_ARM_ARCHEXT=0x70000000,
- PT_ARM_EXIDX=0x70000001,
- PT_ARM_UNWIND=0x70000001,
- PT_AARCH64_ARCHEXT=0x70000000,
- PT_AARCH64_UNWIND=0x70000001,
_default_=Pass,
)
@@ -265,9 +175,6 @@ ENUM_ST_VISIBILITY = dict(
STV_INTERNAL=1,
STV_HIDDEN=2,
STV_PROTECTED=3,
- STV_EXPORTED=4,
- STV_SINGLETON=5,
- STV_ELIMINATE=6,
_default_=Pass,
)
@@ -317,24 +224,6 @@ ENUM_D_TAG = dict(
DT_PREINIT_ARRAYSZ=33,
DT_NUM=34,
DT_LOOS=0x6000000d,
- DT_SUNW_AUXILIARY=0x6000000d,
- DT_SUNW_RTLDINF=0x6000000e,
- DT_SUNW_FILTER=0x6000000f,
- DT_SUNW_CAP=0x60000010,
- DT_SUNW_SYMTAB=0x60000011,
- DT_SUNW_SYMSZ=0x60000012,
- DT_SUNW_ENCODING=0x60000013,
- DT_SUNW_SORTENT=0x60000013,
- DT_SUNW_SYMSORT=0x60000014,
- DT_SUNW_SYMSORTSZ=0x60000015,
- DT_SUNW_TLSSORT=0x60000016,
- DT_SUNW_TLSSORTSZ=0x60000017,
- DT_SUNW_CAPINFO=0x60000018,
- DT_SUNW_STRPAD=0x60000019,
- DT_SUNW_CAPCHAIN=0x6000001a,
- DT_SUNW_LDMACH=0x6000001b,
- DT_SUNW_CAPCHAINENT=0x6000001d,
- DT_SUNW_CAPCHAINSZ=0x6000001f,
DT_HIOS=0x6ffff000,
DT_LOPROC=0x70000000,
DT_HIPROC=0x7fffffff,
@@ -462,271 +351,3 @@ ENUM_RELOC_TYPE_x64 = dict(
_default_=Pass,
)
-# Sunw Syminfo Bound To special values
-ENUM_SUNW_SYMINFO_BOUNDTO = dict(
- SYMINFO_BT_SELF=0xffff,
- SYMINFO_BT_PARENT=0xfffe,
- SYMINFO_BT_NONE=0xfffd,
- SYMINFO_BT_EXTERN=0xfffc,
- _default_=Pass,
-)
-
-# Versym section, version dependency index
-ENUM_VERSYM = dict(
- VER_NDX_LOCAL=0,
- VER_NDX_GLOBAL=1,
- VER_NDX_LORESERVE=0xff00,
- VER_NDX_ELIMINATE=0xff01,
- _default_=Pass,
-)
-# Sunw Syminfo Bound To special values
-ENUM_SUNW_SYMINFO_BOUNDTO = dict(
- SYMINFO_BT_SELF=0xffff,
- SYMINFO_BT_PARENT=0xfffe,
- SYMINFO_BT_NONE=0xfffd,
- SYMINFO_BT_EXTERN=0xfffc,
- _default_=Pass,
-)
-
-ENUM_RELOC_TYPE_ARM = dict(
- R_ARM_NONE=0,
- R_ARM_PC24=1,
- R_ARM_ABS32=2,
- R_ARM_REL32=3,
- R_ARM_LDR_PC_G0=4,
- R_ARM_ABS16=5,
- R_ARM_ABS12=6,
- R_ARM_THM_ABS5=7,
- R_ARM_ABS8=8,
- R_ARM_SBREL32=9,
- R_ARM_THM_CALL=10,
- R_ARM_THM_PC8=11,
- R_ARM_BREL_ADJ=12,
- R_ARM_SWI24=13,
- R_ARM_THM_SWI8=14,
- R_ARM_XPC25=15,
- R_ARM_THM_XPC22=16,
- R_ARM_TLS_DTPMOD32=17,
- R_ARM_TLS_DTPOFF32=18,
- R_ARM_TLS_TPOFF32=19,
- R_ARM_COPY=20,
- R_ARM_GLOB_DAT=21,
- R_ARM_JUMP_SLOT=22,
- R_ARM_RELATIVE=23,
- R_ARM_GOTOFF32=24,
- R_ARM_BASE_PREL=25,
- R_ARM_GOT_BREL=26,
- R_ARM_PLT32=27,
- R_ARM_CALL=28,
- R_ARM_JUMP24=29,
- R_ARM_THM_JUMP24=30,
- R_ARM_BASE_ABS=31,
- R_ARM_ALU_PCREL_7_0=32,
- R_ARM_ALU_PCREL_15_8=33,
- R_ARM_ALU_PCREL_23_15=34,
- R_ARM_LDR_SBREL_11_0_NC=35,
- R_ARM_ALU_SBREL_19_12_NC=36,
- R_ARM_ALU_SBREL_27_20_CK=37,
- R_ARM_TARGET1=38,
- R_ARM_SBREL31=39,
- R_ARM_V4BX=40,
- R_ARM_TARGET2=41,
- R_ARM_PREL31=42,
- R_ARM_MOVW_ABS_NC=43,
- R_ARM_MOVT_ABS=44,
- R_ARM_MOVW_PREL_NC=45,
- R_ARM_MOVT_PREL=46,
- R_ARM_THM_MOVW_ABS_NC=47,
- R_ARM_THM_MOVT_ABS=48,
- R_ARM_THM_MOVW_PREL_NC=49,
- R_ARM_THM_MOVT_PREL=50,
- R_ARM_THM_JUMP19=51,
- R_ARM_THM_JUMP6=52,
- R_ARM_THM_ALU_PREL_11_0=53,
- R_ARM_THM_PC12=54,
- R_ARM_ABS32_NOI=55,
- R_ARM_REL32_NOI=56,
- R_ARM_ALU_PC_G0_NC=57,
- R_ARM_ALU_PC_G0=58,
- R_ARM_ALU_PC_G1_NC=59,
- R_ARM_ALU_PC_G1=60,
- R_ARM_ALU_PC_G2=61,
- R_ARM_LDR_PC_G1=62,
- R_ARM_LDR_PC_G2=63,
- R_ARM_LDRS_PC_G0=64,
- R_ARM_LDRS_PC_G1=65,
- R_ARM_LDRS_PC_G2=66,
- R_ARM_LDC_PC_G0=67,
- R_ARM_LDC_PC_G1=68,
- R_ARM_LDC_PC_G2=69,
- R_ARM_ALU_SB_G0_NC=70,
- R_ARM_ALU_SB_G0=71,
- R_ARM_ALU_SB_G1_NC=72,
- R_ARM_ALU_SB_G1=73,
- R_ARM_ALU_SB_G2=74,
- R_ARM_LDR_SB_G0=75,
- R_ARM_LDR_SB_G1=76,
- R_ARM_LDR_SB_G2=77,
- R_ARM_LDRS_SB_G0=78,
- R_ARM_LDRS_SB_G1=79,
- R_ARM_LDRS_SB_G2=80,
- R_ARM_LDC_SB_G0=81,
- R_ARM_LDC_SB_G1=82,
- R_ARM_LDC_SB_G2=83,
- R_ARM_MOVW_BREL_NC=84,
- R_ARM_MOVT_BREL=85,
- R_ARM_MOVW_BREL=86,
- R_ARM_THM_MOVW_BREL_NC=87,
- R_ARM_THM_MOVT_BREL=88,
- R_ARM_THM_MOVW_BREL=89,
- R_ARM_PLT32_ABS=94,
- R_ARM_GOT_ABS=95,
- R_ARM_GOT_PREL=96,
- R_ARM_GOT_BREL12=97,
- R_ARM_GOTOFF12=98,
- R_ARM_GOTRELAX=99,
- R_ARM_GNU_VTENTRY=100,
- R_ARM_GNU_VTINHERIT=101,
- R_ARM_THM_JUMP11=102,
- R_ARM_THM_JUMP8=103,
- R_ARM_TLS_GD32=104,
- R_ARM_TLS_LDM32=105,
- R_ARM_TLS_LDO32=106,
- R_ARM_TLS_IE32=107,
- R_ARM_TLS_LE32=108,
- R_ARM_TLS_LDO12=109,
- R_ARM_TLS_LE12=110,
- R_ARM_TLS_IE12GP=111,
- R_ARM_PRIVATE_0=112,
- R_ARM_PRIVATE_1=113,
- R_ARM_PRIVATE_2=114,
- R_ARM_PRIVATE_3=115,
- R_ARM_PRIVATE_4=116,
- R_ARM_PRIVATE_5=117,
- R_ARM_PRIVATE_6=118,
- R_ARM_PRIVATE_7=119,
- R_ARM_PRIVATE_8=120,
- R_ARM_PRIVATE_9=121,
- R_ARM_PRIVATE_10=122,
- R_ARM_PRIVATE_11=123,
- R_ARM_PRIVATE_12=124,
- R_ARM_PRIVATE_13=125,
- R_ARM_PRIVATE_14=126,
- R_ARM_PRIVATE_15=127,
- R_ARM_ME_TOO=128,
- R_ARM_THM_TLS_DESCSEQ16=129,
- R_ARM_THM_TLS_DESCSEQ32=130,
- R_ARM_THM_GOT_BREL12=131,
- R_ARM_IRELATIVE=140,
-)
-
-ENUM_RELOC_TYPE_AARCH64 = dict(
- R_AARCH64_NONE=256,
- R_AARCH64_ABS64=257,
- R_AARCH64_ABS32=258,
- R_AARCH64_ABS16=259,
- R_AARCH64_PREL64=260,
- R_AARCH64_PREL32=261,
- R_AARCH64_PREL16=262,
- R_AARCH64_MOVW_UABS_G0=263,
- R_AARCH64_MOVW_UABS_G0_NC=264,
- R_AARCH64_MOVW_UABS_G1=265,
- R_AARCH64_MOVW_UABS_G1_NC=266,
- R_AARCH64_MOVW_UABS_G2=267,
- R_AARCH64_MOVW_UABS_G2_NC=268,
- R_AARCH64_MOVW_UABS_G3=269,
- R_AARCH64_MOVW_SABS_G0=270,
- R_AARCH64_MOVW_SABS_G1=271,
- R_AARCH64_MOVW_SABS_G2=272,
- R_AARCH64_LD_PREL_LO19=273,
- R_AARCH64_ADR_PREL_LO21=274,
- R_AARCH64_ADR_PREL_PG_HI21=275,
- R_AARCH64_ADR_PREL_PG_HI21_NC=276,
- R_AARCH64_ADD_ABS_LO12_NC=277,
- R_AARCH64_LDST8_ABS_LO12_NC=278,
- R_AARCH64_TSTBR14=279,
- R_AARCH64_CONDBR19=280,
- R_AARCH64_JUMP26=282,
- R_AARCH64_CALL26=283,
- R_AARCH64_LDST16_ABS_LO12_NC=284,
- R_AARCH64_LDST32_ABS_LO12_NC=285,
- R_AARCH64_LDST64_ABS_LO12_NC=286,
- R_AARCH64_MOVW_PREL_G0=287,
- R_AARCH64_MOVW_PREL_G0_NC=288,
- R_AARCH64_MOVW_PREL_G1=289,
- R_AARCH64_MOVW_PREL_G1_NC=290,
- R_AARCH64_MOVW_PREL_G2=291,
- R_AARCH64_MOVW_PREL_G2_NC=292,
- R_AARCH64_MOVW_PREL_G3=293,
- R_AARCH64_MOVW_GOTOFF_G0=300,
- R_AARCH64_MOVW_GOTOFF_G0_NC=301,
- R_AARCH64_MOVW_GOTOFF_G1=302,
- R_AARCH64_MOVW_GOTOFF_G1_NC=303,
- R_AARCH64_MOVW_GOTOFF_G2=304,
- R_AARCH64_MOVW_GOTOFF_G2_NC=305,
- R_AARCH64_MOVW_GOTOFF_G3=306,
- R_AARCH64_GOTREL64=307,
- R_AARCH64_GOTREL32=308,
- R_AARCH64_GOT_LD_PREL19=309,
- R_AARCH64_LD64_GOTOFF_LO15=310,
- R_AARCH64_ADR_GOT_PAGE=311,
- R_AARCH64_LD64_GOT_LO12_NC=312,
- R_AARCH64_TLSGD_ADR_PREL21=512,
- R_AARCH64_TLSGD_ADR_PAGE21=513,
- R_AARCH64_TLSGD_ADD_LO12_NC=514,
- R_AARCH64_TLSGD_MOVW_G1=515,
- R_AARCH64_TLSGD_MOVW_G0_NC=516,
- R_AARCH64_TLSLD_ADR_PREL21=517,
- R_AARCH64_TLSLD_ADR_PAGE21=518,
- R_AARCH64_TLSLD_ADD_LO12_NC=519,
- R_AARCH64_TLSLD_MOVW_G1=520,
- R_AARCH64_TLSLD_MOVW_G0_NC=521,
- R_AARCH64_TLSLD_LD_PREL19=522,
- R_AARCH64_TLSLD_MOVW_DTPREL_G2=523,
- R_AARCH64_TLSLD_MOVW_DTPREL_G1=524,
- R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC=525,
- R_AARCH64_TLSLD_MOVW_DTPREL_G0=526,
- R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC=527,
- R_AARCH64_TLSLD_ADD_DTPREL_HI12=528,
- R_AARCH64_TLSLD_ADD_DTPREL_LO12=529,
- R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC=530,
- R_AARCH64_TLSLD_LDST8_DTPREL_LO12=531,
- R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC=532,
- R_AARCH64_TLSLD_LDST16_DTPREL_LO12=533,
- R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC=534,
- R_AARCH64_TLSLD_LDST32_DTPREL_LO12=535,
- R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC=536,
- R_AARCH64_TLSLD_LDST64_DTPREL_LO12=537,
- R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC=538,
- R_AARCH64_TLSIE_MOVW_GOTTPREL_G1=539,
- R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC=540,
- R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21=541,
- R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC=542,
- R_AARCH64_TLSIE_LD_GOTTPREL_PREL19=543,
- R_AARCH64_TLSLE_MOVW_TPREL_G2=544,
- R_AARCH64_TLSLE_MOVW_TPREL_G1=545,
- R_AARCH64_TLSLE_MOVW_TPREL_G1_NC=546,
- R_AARCH64_TLSLE_MOVW_TPREL_G0=547,
- R_AARCH64_TLSLE_MOVW_TPREL_G0_NC=548,
- R_AARCH64_TLSLE_ADD_TPREL_HI12=549,
- R_AARCH64_TLSLE_ADD_TPREL_LO12=550,
- R_AARCH64_TLSLE_ADD_TPREL_LO12_NC=551,
- R_AARCH64_TLSLE_LDST8_TPREL_LO12=552,
- R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC=553,
- R_AARCH64_TLSLE_LDST16_TPREL_LO12=554,
- R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC=555,
- R_AARCH64_TLSLE_LDST32_TPREL_LO12=556,
- R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC=557,
- R_AARCH64_TLSLE_LDST64_TPREL_LO12=558,
- R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC=559,
- R_AARCH64_COPY=1024,
- R_AARCH64_GLOB_DAT=1025,
- R_AARCH64_JUMP_SLOT=1026,
- R_AARCH64_RELATIVE=1027,
- R_AARCH64_TLS_DTPREL64=1028,
- R_AARCH64_TLS_DTPMOD64=1029,
- R_AARCH64_TLS_TPREL64=1030,
- R_AARCH64_TLS_DTPREL32=1031,
- R_AARCH64_TLS_DTPMOD32=1032,
- R_AARCH64_TLS_TPREL32=1033,
-)
diff --git a/chromium/third_party/pyelftools/elftools/elf/gnuversions.py b/chromium/third_party/pyelftools/elftools/elf/gnuversions.py
deleted file mode 100644
index 4a4473f3fae..00000000000
--- a/chromium/third_party/pyelftools/elftools/elf/gnuversions.py
+++ /dev/null
@@ -1,228 +0,0 @@
-#------------------------------------------------------------------------------
-# elftools: elf/gnuversions.py
-#
-# ELF sections
-#
-# Yann Rouillard (yann@pleiades.fr.eu.org)
-# This code is in the public domain
-#------------------------------------------------------------------------------
-from ..construct import CString
-from ..common.utils import struct_parse, elf_assert
-from .sections import Section, Symbol
-
-
-class Version(object):
- """ Version object - representing a version definition or dependency
- entry from a "Version Needed" or a "Version Dependency" table section.
-
- This kind of entry contains a pointer to an array of auxiliary entries
- that store the information about version names or dependencies.
- These entries are not stored in this object and should be accessed
- through the appropriate method of a section object which will return
- an iterator of VersionAuxiliary objects.
-
- Similarly to Section objects, allows dictionary-like access to
- verdef/verneed entry
- """
- def __init__(self, entry, name=None):
- self.entry = entry
- self.name = name
-
- def __getitem__(self, name):
- """ Implement dict-like access to entry
- """
- return self.entry[name]
-
-
-class VersionAuxiliary(object):
- """ Version Auxiliary object - representing an auxiliary entry of a version
- definition or dependency entry
-
- Similarly to Section objects, allows dictionary-like access to the
- verdaux/vernaux entry
- """
- def __init__(self, entry, name):
- self.entry = entry
- self.name = name
-
- def __getitem__(self, name):
- """ Implement dict-like access to entries
- """
- return self.entry[name]
-
-
-class GNUVersionSection(Section):
- """ Common ancestor class for ELF SUNW|GNU Version Needed/Dependency
- sections class which contains shareable code
- """
-
- def __init__(self, header, name, stream, elffile, stringtable,
- field_prefix, version_struct, version_auxiliaries_struct):
- super(GNUVersionSection, self).__init__(header, name, stream)
- self.elffile = elffile
- self.stringtable = stringtable
- self.field_prefix = field_prefix
- self.version_struct = version_struct
- self.version_auxiliaries_struct = version_auxiliaries_struct
-
- def num_versions(self):
- """ Number of version entries in the section
- """
- return self['sh_info']
-
- def _field_name(self, name, auxiliary=False):
- """ Return the real field's name of version or a version auxiliary
- entry
- """
- middle = 'a_' if auxiliary else '_'
- return self.field_prefix + middle + name
-
- def _iter_version_auxiliaries(self, entry_offset, count):
- """ Yield all auxiliary entries of a version entry
- """
- name_field = self._field_name('name', auxiliary=True)
- next_field = self._field_name('next', auxiliary=True)
-
- for _ in range(count):
- entry = struct_parse(
- self.version_auxiliaries_struct,
- self.stream,
- stream_pos=entry_offset)
-
- name = self.stringtable.get_string(entry[name_field])
- version_aux = VersionAuxiliary(entry, name)
- yield version_aux
-
- entry_offset += entry[next_field]
-
- def iter_versions(self):
- """ Yield all the version entries in the section
- Each time it returns the main version structure
- and an iterator to walk through its auxiliaries entries
- """
- aux_field = self._field_name('aux')
- count_field = self._field_name('cnt')
- next_field = self._field_name('next')
-
- entry_offset = self['sh_offset']
- for _ in range(self.num_versions()):
- entry = struct_parse(
- self.version_struct,
- self.stream,
- stream_pos=entry_offset)
-
- elf_assert(entry[count_field] > 0,
- 'Expected number of version auxiliary entries (%s) to be > 0'
- 'for the following version entry: %s' % (
- count_field, str(entry)))
-
- version = Version(entry)
- aux_entries_offset = entry_offset + entry[aux_field]
- version_auxiliaries_iter = self._iter_version_auxiliaries(
- aux_entries_offset, entry[count_field])
-
- yield version, version_auxiliaries_iter
-
- entry_offset += entry[next_field]
-
-
-class GNUVerNeedSection(GNUVersionSection):
- """ ELF SUNW or GNU Version Needed table section.
- Has an associated StringTableSection that's passed in the constructor.
- """
- def __init__(self, header, name, stream, elffile, stringtable):
- super(GNUVerNeedSection, self).__init__(
- header, name, stream, elffile, stringtable, 'vn',
- elffile.structs.Elf_Verneed, elffile.structs.Elf_Vernaux)
- self._has_indexes = None
-
- def has_indexes(self):
- """ Return True if at least one version definition entry has an index
- that is stored in the vna_other field.
- This information is used for symbol versioning
- """
- if self._has_indexes is None:
- self._has_indexes = False
- for _, vernaux_iter in self.iter_versions():
- for vernaux in vernaux_iter:
- if vernaux['vna_other']:
- self._has_indexes = True
- break
-
- return self._has_indexes
-
- def iter_versions(self):
- for verneed, vernaux in super(GNUVerNeedSection, self).iter_versions():
- verneed.name = self.stringtable.get_string(verneed['vn_file'])
- yield verneed, vernaux
-
- def get_version(self, index):
- """ Get the version information located at index #n in the table
- Return boths the verneed structure and the vernaux structure
- that contains the name of the version
- """
- for verneed, vernaux_iter in self.iter_versions():
- for vernaux in vernaux_iter:
- if vernaux['vna_other'] == index:
- return verneed, vernaux
-
- return None
-
-
-class GNUVerDefSection(GNUVersionSection):
- """ ELF SUNW or GNU Version Definition table section.
- Has an associated StringTableSection that's passed in the constructor.
- """
- def __init__(self, header, name, stream, elffile, stringtable):
- super(GNUVerDefSection, self).__init__(
- header, name, stream, elffile, stringtable, 'vd',
- elffile.structs.Elf_Verdef, elffile.structs.Elf_Verdaux)
-
- def get_version(self, index):
- """ Get the version information located at index #n in the table
- Return boths the verdef structure and an iterator to retrieve
- both the version names and dependencies in the form of
- verdaux entries
- """
- for verdef, verdaux_iter in self.iter_versions():
- if verdef['vd_ndx'] == index:
- return verdef, verdaux_iter
-
- return None
-
-
-class GNUVerSymSection(Section):
- """ ELF SUNW or GNU Versym table section.
- Has an associated SymbolTableSection that's passed in the constructor.
- """
- def __init__(self, header, name, stream, elffile, symboltable):
- super(GNUVerSymSection, self).__init__(header, name, stream)
- self.elffile = elffile
- self.elfstructs = self.elffile.structs
- self.symboltable = symboltable
-
- def num_symbols(self):
- """ Number of symbols in the table
- """
- return self['sh_size'] // self['sh_entsize']
-
- def get_symbol(self, n):
- """ Get the symbol at index #n from the table (Symbol object)
- It begins at 1 and not 0 since the first entry is used to
- store the current version of the syminfo table
- """
- # Grab the symbol's entry from the stream
- entry_offset = self['sh_offset'] + n * self['sh_entsize']
- entry = struct_parse(
- self.elfstructs.Elf_Versym,
- self.stream,
- stream_pos=entry_offset)
- # Find the symbol name in the associated symbol table
- name = self.symboltable.get_symbol(n).name
- return Symbol(entry, name)
-
- def iter_symbols(self):
- """ Yield all the symbols in the table
- """
- for i in range(self.num_symbols()):
- yield self.get_symbol(i)
diff --git a/chromium/third_party/pyelftools/elftools/elf/relocation.py b/chromium/third_party/pyelftools/elftools/elf/relocation.py
index 176f7c5404a..5ff853beda9 100644
--- a/chromium/third_party/pyelftools/elftools/elf/relocation.py
+++ b/chromium/third_party/pyelftools/elftools/elf/relocation.py
@@ -23,12 +23,12 @@ class Relocation(object):
def __init__(self, entry, elffile):
self.entry = entry
self.elffile = elffile
-
+
def is_RELA(self):
""" Is this a RELA relocation? If not, it's REL.
"""
return 'r_addend' in self.entry
-
+
def __getitem__(self, name):
""" Dict-like access to entries
"""
@@ -112,7 +112,7 @@ class RelocationHandler(object):
relsection.name in reloc_section_names):
return relsection
return None
-
+
def apply_section_relocations(self, stream, reloc_section):
""" Apply all relocations in reloc_section (a RelocationSection object)
to the given stream, that contains the data of the section that is
@@ -162,7 +162,7 @@ class RelocationHandler(object):
elif recipe.bytesize == 8:
value_struct = self.elffile.structs.Elf_word64('')
else:
- raise ELFRelocationError('Invalid bytesize %s for relocation' %
+ raise ELFRelocationError('Invalid bytesize %s for relocation' %
recipe_bytesize)
# 1. Read the value from the stream (with correct size and endianness)
@@ -178,11 +178,6 @@ class RelocationHandler(object):
addend=reloc['r_addend'] if recipe.has_addend else 0)
# 3. Write the relocated value back into the stream
stream.seek(reloc['r_offset'])
-
- # Make sure the relocated value fits back by wrapping it around. This
- # looks like a problem, but it seems to be the way this is done in
- # binutils too.
- relocated_value = relocated_value % (2 ** (recipe.bytesize * 8))
value_struct.build_stream(relocated_value, stream)
# Relocations are represented by "recipes". Each recipe specifies:
@@ -203,13 +198,10 @@ class RelocationHandler(object):
def _reloc_calc_sym_plus_value_pcrel(value, sym_value, offset, addend=0):
return sym_value + value - offset
-
+
def _reloc_calc_sym_plus_addend(value, sym_value, offset, addend=0):
return sym_value + addend
-
- def _reloc_calc_sym_plus_addend_pcrel(value, sym_value, offset, addend=0):
- return sym_value + addend - offset
-
+
_RELOCATION_RECIPES_X86 = {
ENUM_RELOC_TYPE_i386['R_386_NONE']: _RELOCATION_RECIPE_TYPE(
bytesize=4, has_addend=False, calc_func=_reloc_calc_identity),
@@ -220,15 +212,12 @@ class RelocationHandler(object):
bytesize=4, has_addend=False,
calc_func=_reloc_calc_sym_plus_value_pcrel),
}
-
+
_RELOCATION_RECIPES_X64 = {
ENUM_RELOC_TYPE_x64['R_X86_64_NONE']: _RELOCATION_RECIPE_TYPE(
bytesize=8, has_addend=True, calc_func=_reloc_calc_identity),
ENUM_RELOC_TYPE_x64['R_X86_64_64']: _RELOCATION_RECIPE_TYPE(
bytesize=8, has_addend=True, calc_func=_reloc_calc_sym_plus_addend),
- ENUM_RELOC_TYPE_x64['R_X86_64_PC32']: _RELOCATION_RECIPE_TYPE(
- bytesize=8, has_addend=True,
- calc_func=_reloc_calc_sym_plus_addend_pcrel),
ENUM_RELOC_TYPE_x64['R_X86_64_32']: _RELOCATION_RECIPE_TYPE(
bytesize=4, has_addend=True, calc_func=_reloc_calc_sym_plus_addend),
ENUM_RELOC_TYPE_x64['R_X86_64_32S']: _RELOCATION_RECIPE_TYPE(
diff --git a/chromium/third_party/pyelftools/elftools/elf/sections.py b/chromium/third_party/pyelftools/elftools/elf/sections.py
index 1380d6b8e0c..518c857aa92 100644
--- a/chromium/third_party/pyelftools/elftools/elf/sections.py
+++ b/chromium/third_party/pyelftools/elftools/elf/sections.py
@@ -6,13 +6,14 @@
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
+from ..construct import CString
from ..common.utils import struct_parse, elf_assert, parse_cstring_from_stream
class Section(object):
""" Base class for ELF sections. Also used for all sections types that have
no special functionality.
-
+
Allows dictionary-like access to the section header. For example:
> sec = Section(...)
> sec['sh_type'] # section type
@@ -21,7 +22,7 @@ class Section(object):
self.header = header
self.name = name
self.stream = stream
-
+
def data(self):
""" The section data from the file.
"""
@@ -32,7 +33,7 @@ class Section(object):
""" Is this a null section?
"""
return False
-
+
def __getitem__(self, name):
""" Implement dict-like access to header entries
"""
@@ -40,8 +41,6 @@ class Section(object):
def __eq__(self, other):
return self.header == other.header
- def __hash__(self):
- return hash(self.header)
class NullSection(Section):
@@ -52,14 +51,14 @@ class NullSection(Section):
def is_null(self):
return True
-
+
class StringTableSection(Section):
""" ELF string table section.
"""
def __init__(self, header, name, stream):
super(StringTableSection, self).__init__(header, name, stream)
-
+
def get_string(self, offset):
""" Get the string stored at the given offset in this string table.
"""
@@ -78,15 +77,15 @@ class SymbolTableSection(Section):
self.elfstructs = self.elffile.structs
self.stringtable = stringtable
elf_assert(self['sh_entsize'] > 0,
- 'Expected entry size of section %r to be > 0' % name)
+ 'Expected entry size of section %s to be > 0' % name)
elf_assert(self['sh_size'] % self['sh_entsize'] == 0,
- 'Expected section size to be a multiple of entry size in section %r' % name)
+ 'Expected section size to be a multiple of entry size in section %s' % name)
def num_symbols(self):
""" Number of symbols in the table
"""
return self['sh_size'] // self['sh_entsize']
-
+
def get_symbol(self, n):
""" Get the symbol at index #n from the table (Symbol object)
"""
@@ -124,38 +123,3 @@ class Symbol(object):
return self.entry[name]
-class SUNWSyminfoTableSection(Section):
- """ ELF .SUNW Syminfo table section.
- Has an associated SymbolTableSection that's passed in the constructor.
- """
- def __init__(self, header, name, stream, elffile, symboltable):
- super(SUNWSyminfoTableSection, self).__init__(header, name, stream)
- self.elffile = elffile
- self.elfstructs = self.elffile.structs
- self.symboltable = symboltable
-
- def num_symbols(self):
- """ Number of symbols in the table
- """
- return self['sh_size'] // self['sh_entsize'] - 1
-
- def get_symbol(self, n):
- """ Get the symbol at index #n from the table (Symbol object).
- It begins at 1 and not 0 since the first entry is used to
- store the current version of the syminfo table.
- """
- # Grab the symbol's entry from the stream
- entry_offset = self['sh_offset'] + n * self['sh_entsize']
- entry = struct_parse(
- self.elfstructs.Elf_Sunw_Syminfo,
- self.stream,
- stream_pos=entry_offset)
- # Find the symbol name in the associated symbol table
- name = self.symboltable.get_symbol(n).name
- return Symbol(entry, name)
-
- def iter_symbols(self):
- """ Yield all the symbols in the table
- """
- for i in range(1, self.num_symbols() + 1):
- yield self.get_symbol(i)
diff --git a/chromium/third_party/pyelftools/elftools/elf/segments.py b/chromium/third_party/pyelftools/elftools/elf/segments.py
index bc54da2c056..217ba085db6 100644
--- a/chromium/third_party/pyelftools/elftools/elf/segments.py
+++ b/chromium/third_party/pyelftools/elftools/elf/segments.py
@@ -15,7 +15,7 @@ class Segment(object):
def __init__(self, header, stream):
self.header = header
self.stream = stream
-
+
def data(self):
""" The segment data from the file.
"""
@@ -30,8 +30,8 @@ class Segment(object):
def section_in_segment(self, section):
""" Is the given section contained in this segment?
- Note: this tries to reproduce the intricate rules of the
- ELF_SECTION_IN_SEGMENT_STRICT macro of the header
+ Note: this tries to reproduce the intricate rules of the
+ ELF_SECTION_IN_SEGMENT_STRICT macro of the header
elf/include/internal.h in the source of binutils.
"""
# Only the 'strict' checks from ELF_SECTION_IN_SEGMENT_1 are included
@@ -41,7 +41,7 @@ class Segment(object):
# Only PT_LOAD, PT_GNU_RELR0 and PT_TLS segments can contain SHF_TLS
# sections
- if ( secflags & SH_FLAGS.SHF_TLS and
+ if ( secflags & SH_FLAGS.SHF_TLS and
segtype in ('PT_TLS', 'PT_GNU_RELR0', 'PT_LOAD')):
return False
# PT_TLS segment contains only SHF_TLS sections, PT_PHDR no sections
@@ -61,7 +61,7 @@ class Segment(object):
# not match at the very end of the segment (unless the segment is
# also zero size, which is handled by the second condition).
if not (secaddr >= vaddr and
- secaddr - vaddr + section['sh_size'] <= self['p_memsz'] and
+ secaddr - vaddr + section['sh_size'] <= self['p_memsz'] and
secaddr - vaddr <= self['p_memsz'] - 1):
return False
@@ -74,7 +74,7 @@ class Segment(object):
# Same logic as with secaddr vs. vaddr checks above, just on offsets in
# the file
- return (secoffset >= poffset and
+ return (secoffset >= poffset and
secoffset - poffset + section['sh_size'] <= self['p_filesz'] and
secoffset - poffset <= self['p_filesz'] - 1)
diff --git a/chromium/third_party/pyelftools/elftools/elf/structs.py b/chromium/third_party/pyelftools/elftools/elf/structs.py
index 0862400faeb..08567de4fbe 100644
--- a/chromium/third_party/pyelftools/elftools/elf/structs.py
+++ b/chromium/third_party/pyelftools/elftools/elf/structs.py
@@ -19,20 +19,20 @@ from .enums import *
class ELFStructs(object):
""" Accessible attributes:
-
+
Elf_{byte|half|word|word64|addr|offset|sword|xword|xsword}:
- Data chunks, as specified by the ELF standard, adjusted for
+ Data chunks, as specified by the ELF standard, adjusted for
correct endianness and word-size.
Elf_Ehdr:
ELF file header
-
+
Elf_Phdr:
Program header
-
+
Elf_Shdr:
Section header
-
+
Elf_Sym:
Symbol table entry
@@ -42,9 +42,9 @@ class ELFStructs(object):
def __init__(self, little_endian=True, elfclass=32):
assert elfclass == 32 or elfclass == 64
self.little_endian = little_endian
- self.elfclass = elfclass
+ self.elfclass = elfclass
self._create_structs()
-
+
def _create_structs(self):
if self.little_endian:
self.Elf_byte = ULInt8
@@ -66,18 +66,14 @@ class ELFStructs(object):
self.Elf_sword = SBInt32
self.Elf_xword = UBInt32 if self.elfclass == 32 else UBInt64
self.Elf_sxword = SBInt32 if self.elfclass == 32 else SBInt64
-
+
self._create_ehdr()
self._create_phdr()
self._create_shdr()
self._create_sym()
self._create_rel()
self._create_dyn()
- self._create_sunw_syminfo()
- self._create_gnu_verneed()
- self._create_gnu_verdef()
- self._create_gnu_versym()
-
+
def _create_ehdr(self):
self.Elf_Ehdr = Struct('Elf_Ehdr',
Struct('e_ident',
@@ -103,7 +99,7 @@ class ELFStructs(object):
self.Elf_half('e_shnum'),
self.Elf_half('e_shstrndx'),
)
-
+
def _create_phdr(self):
if self.elfclass == 32:
self.Elf_Phdr = Struct('Elf_Phdr',
@@ -126,8 +122,8 @@ class ELFStructs(object):
self.Elf_xword('p_filesz'),
self.Elf_xword('p_memsz'),
self.Elf_xword('p_align'),
- )
-
+ )
+
def _create_shdr(self):
self.Elf_Shdr = Struct('Elf_Shdr',
self.Elf_word('sh_name'),
@@ -141,7 +137,7 @@ class ELFStructs(object):
self.Elf_xword('sh_addralign'),
self.Elf_xword('sh_entsize'),
)
-
+
def _create_rel(self):
# r_info is also taken apart into r_info_sym and r_info_type.
# This is done in Value to avoid endianity issues while parsing.
@@ -207,50 +203,5 @@ class ELFStructs(object):
self.Elf_xword('st_size'),
)
- def _create_sunw_syminfo(self):
- self.Elf_Sunw_Syminfo = Struct('Elf_Sunw_Syminfo',
- Enum(self.Elf_half('si_boundto'), **ENUM_SUNW_SYMINFO_BOUNDTO),
- self.Elf_half('si_flags'),
- )
- def _create_gnu_verneed(self):
- # Structure of "version needed" entries is documented in
- # Oracle "Linker and Libraries Guide", Chapter 7 Object File Format
- self.Elf_Verneed = Struct('Elf_Verneed',
- self.Elf_half('vn_version'),
- self.Elf_half('vn_cnt'),
- self.Elf_word('vn_file'),
- self.Elf_word('vn_aux'),
- self.Elf_word('vn_next'),
- )
- self.Elf_Vernaux = Struct('Elf_Vernaux',
- self.Elf_word('vna_hash'),
- self.Elf_half('vna_flags'),
- self.Elf_half('vna_other'),
- self.Elf_word('vna_name'),
- self.Elf_word('vna_next'),
- )
- def _create_gnu_verdef(self):
- # Structure off "version definition" entries are documented in
- # Oracle "Linker and Libraries Guide", Chapter 7 Object File Format
- self.Elf_Verdef = Struct('Elf_Verdef',
- self.Elf_half('vd_version'),
- self.Elf_half('vd_flags'),
- self.Elf_half('vd_ndx'),
- self.Elf_half('vd_cnt'),
- self.Elf_word('vd_hash'),
- self.Elf_word('vd_aux'),
- self.Elf_word('vd_next'),
- )
- self.Elf_Verdaux = Struct('Elf_Verdaux',
- self.Elf_word('vda_name'),
- self.Elf_word('vda_next'),
- )
-
- def _create_gnu_versym(self):
- # Structure off "version symbol" entries are documented in
- # Oracle "Linker and Libraries Guide", Chapter 7 Object File Format
- self.Elf_Versym = Struct('Elf_Versym',
- Enum(self.Elf_half('ndx'), **ENUM_VERSYM),
- )
diff --git a/chromium/third_party/pyelftools/examples/dwarf_decode_address.py b/chromium/third_party/pyelftools/examples/dwarf_decode_address.py
index 80b53eefc89..831b4fc3110 100644
--- a/chromium/third_party/pyelftools/examples/dwarf_decode_address.py
+++ b/chromium/third_party/pyelftools/examples/dwarf_decode_address.py
@@ -10,9 +10,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import maxint, bytes2str
from elftools.elf.elffile import ELFFile
@@ -42,7 +45,7 @@ def process_file(filename, address):
def decode_funcname(dwarfinfo, address):
# Go over all DIEs in the DWARF information, looking for a subprogram
# entry with an address range that includes the given address. Note that
- # this simplifies things by disregarding subprograms that may have
+ # this simplifies things by disregarding subprograms that may have
# split address ranges.
for CU in dwarfinfo.iter_CUs():
for DIE in CU.iter_DIEs():
@@ -63,18 +66,16 @@ def decode_file_line(dwarfinfo, address):
for CU in dwarfinfo.iter_CUs():
# First, look at line programs to find the file/line for the address
lineprog = dwarfinfo.line_program_for_CU(CU)
- prevstate = None
+ prevaddr = maxint
for entry in lineprog.get_entries():
# We're interested in those entries where a new state is assigned
- if entry.state is None or entry.state.end_sequence:
- continue
- # Looking for a range of addresses in two consecutive states that
- # contain the required address.
- if prevstate and prevstate.address <= address < entry.state.address:
- filename = lineprog['file_entry'][prevstate.file - 1].name
- line = prevstate.line
- return filename, line
- prevstate = entry.state
+ state = entry.state
+ if state is not None and not state.end_sequence:
+ if prevaddr <= address <= state.address:
+ filename = lineprog['file_entry'][state.file - 1].name
+ line = state.line
+ return filename, line
+ prevaddr = state.address
return None, None
diff --git a/chromium/third_party/pyelftools/examples/dwarf_die_tree.py b/chromium/third_party/pyelftools/examples/dwarf_die_tree.py
index ef108c35adf..7eb07ff3a3b 100644
--- a/chromium/third_party/pyelftools/examples/dwarf_die_tree.py
+++ b/chromium/third_party/pyelftools/examples/dwarf_die_tree.py
@@ -10,10 +10,14 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
-
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
+
+from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
@@ -43,8 +47,15 @@ def process_file(filename):
top_DIE = CU.get_top_DIE()
print(' Top DIE with tag=%s' % top_DIE.tag)
- # We're interested in the filename...
- print(' name=%s' % top_DIE.get_full_path())
+ # Each DIE holds an OrderedDict of attributes, mapping names to
+ # values. Values are represented by AttributeValue objects in
+ # elftools/dwarf/die.py
+ # We're interested in the DW_AT_name attribute. Note that its value
+ # is usually a string taken from the .debug_string section. This
+ # is done transparently by the library, and such a value will be
+ # simply given as a string.
+ name_attr = top_DIE.attributes['DW_AT_name']
+ print(' name=%s' % bytes2str(name_attr.value))
# Display DIEs recursively starting with top_DIE
die_info_rec(top_DIE)
diff --git a/chromium/third_party/pyelftools/examples/dwarf_location_lists.py b/chromium/third_party/pyelftools/examples/dwarf_location_lists.py
index d8ee1e97ea5..62896189c1e 100644
--- a/chromium/third_party/pyelftools/examples/dwarf_location_lists.py
+++ b/chromium/third_party/pyelftools/examples/dwarf_location_lists.py
@@ -10,10 +10,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
-
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import itervalues
from elftools.elf.elffile import ELFFile
@@ -84,7 +86,7 @@ def show_loclist(loclist, dwarfinfo, indent):
else:
d.append(str(loc_entity))
return '\n'.join(indent + s for s in d)
-
+
def attribute_has_location_list(attr):
""" Only some attributes can have location list values, if they have the
diff --git a/chromium/third_party/pyelftools/examples/dwarf_range_lists.py b/chromium/third_party/pyelftools/examples/dwarf_range_lists.py
index 6e8998dfca4..c310e584f12 100644
--- a/chromium/third_party/pyelftools/examples/dwarf_range_lists.py
+++ b/chromium/third_party/pyelftools/examples/dwarf_range_lists.py
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# elftools example: dwarf_range_lists.py
#
-# Examine DIE entries which have range list values, and decode these range
+# Examine DIE entries which have range list values, and decode these range
# lists.
#
# Eli Bendersky (eliben@gmail.com)
@@ -10,9 +10,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import itervalues
from elftools.elf.elffile import ELFFile
@@ -37,9 +40,6 @@ def process_file(filename):
# The range lists are extracted by DWARFInfo from the .debug_ranges
# section, and returned here as a RangeLists object.
range_lists = dwarfinfo.range_lists()
- if range_lists is None:
- print(' file has no .debug_ranges section')
- return
for CU in dwarfinfo.iter_CUs():
# DWARFInfo allows to iterate over the compile units contained in
diff --git a/chromium/third_party/pyelftools/examples/elf_low_high_api.py b/chromium/third_party/pyelftools/examples/elf_low_high_api.py
index e2d7f495bd7..05d75642ac8 100644
--- a/chromium/third_party/pyelftools/examples/elf_low_high_api.py
+++ b/chromium/third_party/pyelftools/examples/elf_low_high_api.py
@@ -11,9 +11,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
diff --git a/chromium/third_party/pyelftools/examples/elf_relocations.py b/chromium/third_party/pyelftools/examples/elf_relocations.py
index 008626619f5..fd65541954c 100644
--- a/chromium/third_party/pyelftools/examples/elf_relocations.py
+++ b/chromium/third_party/pyelftools/examples/elf_relocations.py
@@ -10,10 +10,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
-
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
diff --git a/chromium/third_party/pyelftools/examples/elf_show_debug_sections.py b/chromium/third_party/pyelftools/examples/elf_show_debug_sections.py
index 4e4da61e259..96e1dd9df88 100644
--- a/chromium/third_party/pyelftools/examples/elf_show_debug_sections.py
+++ b/chromium/third_party/pyelftools/examples/elf_show_debug_sections.py
@@ -9,9 +9,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
diff --git a/chromium/third_party/pyelftools/examples/elfclass_address_size.py b/chromium/third_party/pyelftools/examples/elfclass_address_size.py
index ac2bfaadcc3..d6b19d3d40e 100644
--- a/chromium/third_party/pyelftools/examples/elfclass_address_size.py
+++ b/chromium/third_party/pyelftools/examples/elfclass_address_size.py
@@ -10,9 +10,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.elf.elffile import ELFFile
diff --git a/chromium/third_party/pyelftools/examples/examine_dwarf_info.py b/chromium/third_party/pyelftools/examples/examine_dwarf_info.py
index 0e1619e9f7a..35ce35bbc40 100644
--- a/chromium/third_party/pyelftools/examples/examine_dwarf_info.py
+++ b/chromium/third_party/pyelftools/examples/examine_dwarf_info.py
@@ -9,10 +9,14 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
+from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
@@ -42,8 +46,15 @@ def process_file(filename):
top_DIE = CU.get_top_DIE()
print(' Top DIE with tag=%s' % top_DIE.tag)
- # We're interested in the filename...
- print(' name=%s' % top_DIE.get_full_path())
+ # Each DIE holds an OrderedDict of attributes, mapping names to
+ # values. Values are represented by AttributeValue objects in
+ # elftools/dwarf/die.py
+ # We're interested in the DW_AT_name attribute. Note that its value
+ # is usually a string taken from the .debug_str section. This
+ # is done transparently by the library, and such a value will be
+ # simply given as a string.
+ name_attr = top_DIE.attributes['DW_AT_name']
+ print(' name=%s' % bytes2str(name_attr.value))
if __name__ == '__main__':
for filename in sys.argv[1:]:
diff --git a/chromium/third_party/pyelftools/examples/reference_output/dwarf_decode_address.out b/chromium/third_party/pyelftools/examples/reference_output/dwarf_decode_address.out
index e14d84a77db..73ca9eeaab9 100644
--- a/chromium/third_party/pyelftools/examples/reference_output/dwarf_decode_address.out
+++ b/chromium/third_party/pyelftools/examples/reference_output/dwarf_decode_address.out
@@ -1,4 +1,4 @@
Processing file: ./examples/sample_exe64.elf
Function: main
File: z.c
-Line: 3
+Line: 4
diff --git a/chromium/third_party/pyelftools/examples/reference_output/dwarf_die_tree.out b/chromium/third_party/pyelftools/examples/reference_output/dwarf_die_tree.out
index 4a81a8ee177..143cbbb42b2 100644
--- a/chromium/third_party/pyelftools/examples/reference_output/dwarf_die_tree.out
+++ b/chromium/third_party/pyelftools/examples/reference_output/dwarf_die_tree.out
@@ -1,11 +1,11 @@
Processing file: ./examples/sample_exe64.elf
Found a compile unit at offset 0, length 115
Top DIE with tag=DW_TAG_compile_unit
- name=/usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S
+ name=../sysdeps/x86_64/elf/start.S
DIE tag=DW_TAG_compile_unit
Found a compile unit at offset 119, length 135
Top DIE with tag=DW_TAG_compile_unit
- name=/usr/src/packages/BUILD/glibc-2.11.1/csu/init.c
+ name=init.c
DIE tag=DW_TAG_compile_unit
DIE tag=DW_TAG_base_type
DIE tag=DW_TAG_base_type
@@ -21,7 +21,7 @@ Processing file: ./examples/sample_exe64.elf
DIE tag=DW_TAG_const_type
Found a compile unit at offset 258, length 156
Top DIE with tag=DW_TAG_compile_unit
- name=/tmp/ebenders/z.c
+ name=z.c
DIE tag=DW_TAG_compile_unit
DIE tag=DW_TAG_subprogram
DIE tag=DW_TAG_formal_parameter
@@ -33,7 +33,7 @@ Processing file: ./examples/sample_exe64.elf
DIE tag=DW_TAG_variable
Found a compile unit at offset 418, length 300
Top DIE with tag=DW_TAG_compile_unit
- name=/usr/src/packages/BUILD/glibc-2.11.1/csu/elf-init.c
+ name=elf-init.c
DIE tag=DW_TAG_compile_unit
DIE tag=DW_TAG_base_type
DIE tag=DW_TAG_typedef
diff --git a/chromium/third_party/pyelftools/examples/reference_output/examine_dwarf_info.out b/chromium/third_party/pyelftools/examples/reference_output/examine_dwarf_info.out
index 51146264cc9..968be294a67 100644
--- a/chromium/third_party/pyelftools/examples/reference_output/examine_dwarf_info.out
+++ b/chromium/third_party/pyelftools/examples/reference_output/examine_dwarf_info.out
@@ -1,13 +1,13 @@
Processing file: ./examples/sample_exe64.elf
Found a compile unit at offset 0, length 115
Top DIE with tag=DW_TAG_compile_unit
- name=/usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S
+ name=../sysdeps/x86_64/elf/start.S
Found a compile unit at offset 119, length 135
Top DIE with tag=DW_TAG_compile_unit
- name=/usr/src/packages/BUILD/glibc-2.11.1/csu/init.c
+ name=init.c
Found a compile unit at offset 258, length 156
Top DIE with tag=DW_TAG_compile_unit
- name=/tmp/ebenders/z.c
+ name=z.c
Found a compile unit at offset 418, length 300
Top DIE with tag=DW_TAG_compile_unit
- name=/usr/src/packages/BUILD/glibc-2.11.1/csu/elf-init.c
+ name=elf-init.c
diff --git a/chromium/third_party/pyelftools/pyelftools.sublime-project b/chromium/third_party/pyelftools/pyelftools.sublime-project
deleted file mode 100644
index a92140cdf39..00000000000
--- a/chromium/third_party/pyelftools/pyelftools.sublime-project
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "folders":
- [
- {
- "path": ".",
- "folder_exclude_patterns": ["build", "dist", ".tox", ".hg"]
- }
- ]
-}
diff --git a/chromium/third_party/pyelftools/scripts/readelf.py b/chromium/third_party/pyelftools/scripts/readelf.py
index 8179c013a54..04c75bafca3 100755
--- a/chromium/third_party/pyelftools/scripts/readelf.py
+++ b/chromium/third_party/pyelftools/scripts/readelf.py
@@ -11,24 +11,20 @@ import os, sys
from optparse import OptionParser
import string
-# For running from development directory. It should take precedence over the
-# installed pyelftools.
-sys.path.insert(0, '.')
-
+# If elftools is not installed, maybe we're running from the root or scripts
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools import __version__
from elftools.common.exceptions import ELFError
from elftools.common.py3compat import (
ifilter, byte2int, bytes2str, itervalues, str2bytes)
from elftools.elf.elffile import ELFFile
-from elftools.elf.dynamic import DynamicSection, DynamicSegment
-from elftools.elf.enums import ENUM_D_TAG
from elftools.elf.segments import InterpSegment
from elftools.elf.sections import SymbolTableSection
-from elftools.elf.gnuversions import (
- GNUVerSymSection, GNUVerDefSection,
- GNUVerNeedSection,
- )
from elftools.elf.relocation import RelocationSection
from elftools.elf.descriptions import (
describe_ei_class, describe_ei_data, describe_ei_version,
@@ -36,10 +32,8 @@ from elftools.elf.descriptions import (
describe_e_version_numeric, describe_p_type, describe_p_flags,
describe_sh_type, describe_sh_flags,
describe_symbol_type, describe_symbol_bind, describe_symbol_visibility,
- describe_symbol_shndx, describe_reloc_type, describe_dyn_tag,
- describe_ver_flags,
+ describe_symbol_shndx, describe_reloc_type,
)
-from elftools.elf.constants import E_FLAGS
from elftools.dwarf.dwarfinfo import DWARFInfo
from elftools.dwarf.descriptions import (
describe_reg_name, describe_attr_value, set_global_machine_arch,
@@ -55,20 +49,18 @@ class ReadElf(object):
""" display_* methods are used to emit output into the output stream
"""
def __init__(self, file, output):
- """ file:
+ """ file:
stream object with the ELF file to read
-
+
output:
output stream to write to
"""
self.elffile = ELFFile(file)
self.output = output
-
+
# Lazily initialized if a debug dump is requested
self._dwarfinfo = None
- self._versioninfo = None
-
def display_file_header(self):
""" Display the ELF file header
"""
@@ -78,33 +70,32 @@ class ReadElf(object):
for b in self.elffile.e_ident_raw))
header = self.elffile.header
e_ident = header['e_ident']
- self._emitline(' Class: %s' %
+ self._emitline(' Class: %s' %
describe_ei_class(e_ident['EI_CLASS']))
- self._emitline(' Data: %s' %
+ self._emitline(' Data: %s' %
describe_ei_data(e_ident['EI_DATA']))
- self._emitline(' Version: %s' %
+ self._emitline(' Version: %s' %
describe_ei_version(e_ident['EI_VERSION']))
self._emitline(' OS/ABI: %s' %
describe_ei_osabi(e_ident['EI_OSABI']))
- self._emitline(' ABI Version: %d' %
+ self._emitline(' ABI Version: %d' %
e_ident['EI_ABIVERSION'])
self._emitline(' Type: %s' %
describe_e_type(header['e_type']))
- self._emitline(' Machine: %s' %
+ self._emitline(' Machine: %s' %
describe_e_machine(header['e_machine']))
self._emitline(' Version: %s' %
describe_e_version_numeric(header['e_version']))
- self._emitline(' Entry point address: %s' %
+ self._emitline(' Entry point address: %s' %
self._format_hex(header['e_entry']))
- self._emit(' Start of program headers: %s' %
+ self._emit(' Start of program headers: %s' %
header['e_phoff'])
self._emitline(' (bytes into file)')
- self._emit(' Start of section headers: %s' %
+ self._emit(' Start of section headers: %s' %
header['e_shoff'])
self._emitline(' (bytes into file)')
- self._emitline(' Flags: %s%s' %
- (self._format_hex(header['e_flags']),
- self.decode_flags(header['e_flags'])))
+ self._emitline(' Flags: %s' %
+ self._format_hex(header['e_flags']))
self._emitline(' Size of this header: %s (bytes)' %
header['e_ehsize'])
self._emitline(' Size of program headers: %s (bytes)' %
@@ -118,17 +109,6 @@ class ReadElf(object):
self._emitline(' Section header string table index: %s' %
header['e_shstrndx'])
- def decode_flags(self, flags):
- description = ""
- if self.elffile['e_machine'] == "EM_ARM":
- if flags & E_FLAGS.EF_ARM_HASENTRY:
- description += ", has entry point"
-
- version = flags & E_FLAGS.EF_ARM_EABIMASK
- if version == E_FLAGS.EF_ARM_EABI_VER5:
- description += ", Version5 EABI"
- return description
-
def display_program_headers(self, show_heading=True):
""" Display the ELF program headers.
If show_heading is True, displays the heading for this information
@@ -193,14 +173,14 @@ class ReadElf(object):
self._format_hex(segment['p_align'], lead0x=False)))
if isinstance(segment, InterpSegment):
- self._emitline(' [Requesting program interpreter: %s]' %
+ self._emitline(' [Requesting program interpreter: %s]' %
bytes2str(segment.get_interp_name()))
# Sections to segments mapping
#
if self.elffile.num_sections() == 0:
# No sections? We're done
- return
+ return
self._emitline('\n Section to Segment mapping:')
self._emitline(' Segment Sections...')
@@ -209,7 +189,7 @@ class ReadElf(object):
self._emit(' %2.2d ' % nseg)
for section in self.elffile.iter_sections():
- if ( not section.is_null() and
+ if ( not section.is_null() and
segment.section_in_segment(section)):
self._emit('%s ' % bytes2str(section.name))
@@ -274,8 +254,6 @@ class ReadElf(object):
def display_symbol_tables(self):
""" Display the symbol tables contained in the file
"""
- self._init_versioninfo()
-
for section in self.elffile.iter_sections():
if not isinstance(section, SymbolTableSection):
continue
@@ -294,85 +272,17 @@ class ReadElf(object):
self._emitline(' Num: Value Size Type Bind Vis Ndx Name')
for nsym, symbol in enumerate(section.iter_symbols()):
-
- version_info = ''
- # readelf doesn't display version info for Solaris versioning
- if (section['sh_type'] == 'SHT_DYNSYM' and
- self._versioninfo['type'] == 'GNU'):
- version = self._symbol_version(nsym)
- if (version['name'] != bytes2str(symbol.name) and
- version['index'] not in ('VER_NDX_LOCAL',
- 'VER_NDX_GLOBAL')):
- if version['filename']:
- # external symbol
- version_info = '@%(name)s (%(index)i)' % version
- else:
- # internal symbol
- if version['hidden']:
- version_info = '@%(name)s' % version
- else:
- version_info = '@@%(name)s' % version
-
# symbol names are truncated to 25 chars, similarly to readelf
- self._emitline('%6d: %s %5d %-7s %-6s %-7s %4s %.25s%s' % (
+ self._emitline('%6d: %s %5d %-7s %-6s %-7s %4s %.25s' % (
nsym,
- self._format_hex(
- symbol['st_value'], fullhex=True, lead0x=False),
+ self._format_hex(symbol['st_value'], fullhex=True, lead0x=False),
symbol['st_size'],
describe_symbol_type(symbol['st_info']['type']),
describe_symbol_bind(symbol['st_info']['bind']),
describe_symbol_visibility(symbol['st_other']['visibility']),
describe_symbol_shndx(symbol['st_shndx']),
- bytes2str(symbol.name),
- version_info))
-
- def display_dynamic_tags(self):
- """ Display the dynamic tags contained in the file
- """
- has_dynamic_sections = False
- for section in self.elffile.iter_sections():
- if not isinstance(section, DynamicSection):
- continue
-
- has_dynamic_sections = True
- self._emitline("\nDynamic section at offset %s contains %s entries:" % (
- self._format_hex(section['sh_offset']),
- section.num_tags()))
- self._emitline(" Tag Type Name/Value")
-
- padding = 20 + (8 if self.elffile.elfclass == 32 else 0)
- for tag in section.iter_tags():
- if tag.entry.d_tag == 'DT_NEEDED':
- parsed = 'Shared library: [%s]' % bytes2str(tag.needed)
- elif tag.entry.d_tag == 'DT_RPATH':
- parsed = 'Library rpath: [%s]' % bytes2str(tag.rpath)
- elif tag.entry.d_tag == 'DT_RUNPATH':
- parsed = 'Library runpath: [%s]' % bytes2str(tag.runpath)
- elif tag.entry.d_tag == 'DT_SONAME':
- parsed = 'Library soname: [%s]' % bytes2str(tag.soname)
- elif tag.entry.d_tag.endswith(('SZ', 'ENT')):
- parsed = '%i (bytes)' % tag['d_val']
- elif tag.entry.d_tag.endswith(('NUM', 'COUNT')):
- parsed = '%i' % tag['d_val']
- elif tag.entry.d_tag == 'DT_PLTREL':
- s = describe_dyn_tag(tag.entry.d_val)
- if s.startswith('DT_'):
- s = s[3:]
- parsed = '%s' % s
- else:
- parsed = '%#x' % tag['d_val']
-
- self._emitline(" %s %-*s %s" % (
- self._format_hex(ENUM_D_TAG.get(tag.entry.d_tag, tag.entry.d_tag),
- fullhex=True, lead0x=True),
- padding,
- '(%s)' % (tag.entry.d_tag[3:],),
- parsed))
- if not has_dynamic_sections:
- # readelf only prints this if there is at least one segment
- if self.elffile.num_segments():
- self._emitline("\nThere is no dynamic section in this file.")
-
+ bytes2str(symbol.name)))
+
def display_relocations(self):
""" Display the relocations contained in the file
"""
@@ -397,9 +307,9 @@ class ReadElf(object):
for rel in section.iter_relocations():
hexwidth = 8 if self.elffile.elfclass == 32 else 12
self._emit('%s %s %-17.17s' % (
- self._format_hex(rel['r_offset'],
+ self._format_hex(rel['r_offset'],
fieldsize=hexwidth, lead0x=False),
- self._format_hex(rel['r_info'],
+ self._format_hex(rel['r_info'],
fieldsize=hexwidth, lead0x=False),
describe_reloc_type(
rel['r_info_type'], self.elffile)))
@@ -430,112 +340,7 @@ class ReadElf(object):
if not has_relocation_sections:
self._emitline('\nThere are no relocations in this file.')
-
- def display_version_info(self):
- """ Display the version info contained in the file
- """
- self._init_versioninfo()
-
- if not self._versioninfo['type']:
- self._emitline("\nNo version information found in this file.")
- return
-
- for section in self.elffile.iter_sections():
- if isinstance(section, GNUVerSymSection):
- self._print_version_section_header(
- section, 'Version symbols', lead0x=False)
-
- num_symbols = section.num_symbols()
-
- # Symbol version info are printed four by four entries
- for idx_by_4 in range(0, num_symbols, 4):
-
- self._emit(' %03x:' % idx_by_4)
-
- for idx in range(idx_by_4, min(idx_by_4 + 4, num_symbols)):
-
- symbol_version = self._symbol_version(idx)
- if symbol_version['index'] == 'VER_NDX_LOCAL':
- version_index = 0
- version_name = '(*local*)'
- elif symbol_version['index'] == 'VER_NDX_GLOBAL':
- version_index = 1
- version_name = '(*global*)'
- else:
- version_index = symbol_version['index']
- version_name = '(%(name)s)' % symbol_version
-
- visibility = 'h' if symbol_version['hidden'] else ' '
-
- self._emit('%4x%s%-13s' % (
- version_index, visibility, version_name))
-
- self._emitline()
-
- elif isinstance(section, GNUVerDefSection):
- self._print_version_section_header(
- section, 'Version definition', indent=2)
-
- offset = 0
- for verdef, verdaux_iter in section.iter_versions():
- verdaux = next(verdaux_iter)
-
- name = verdaux.name
- if verdef['vd_flags']:
- flags = describe_ver_flags(verdef['vd_flags'])
- # Mimic exactly the readelf output
- flags += ' '
- else:
- flags = 'none'
-
- self._emitline(' %s: Rev: %i Flags: %s Index: %i'
- ' Cnt: %i Name: %s' % (
- self._format_hex(offset, fieldsize=6,
- alternate=True),
- verdef['vd_version'], flags, verdef['vd_ndx'],
- verdef['vd_cnt'], bytes2str(name)))
-
- verdaux_offset = (
- offset + verdef['vd_aux'] + verdaux['vda_next'])
- for idx, verdaux in enumerate(verdaux_iter, start=1):
- self._emitline(' %s: Parent %i: %s' %
- (self._format_hex(verdaux_offset, fieldsize=4),
- idx, bytes2str(verdaux.name)))
- verdaux_offset += verdaux['vda_next']
-
- offset += verdef['vd_next']
-
- elif isinstance(section, GNUVerNeedSection):
- self._print_version_section_header(section, 'Version needs')
-
- offset = 0
- for verneed, verneed_iter in section.iter_versions():
-
- self._emitline(' %s: Version: %i File: %s Cnt: %i' % (
- self._format_hex(offset, fieldsize=6,
- alternate=True),
- verneed['vn_version'], bytes2str(verneed.name),
- verneed['vn_cnt']))
-
- vernaux_offset = offset + verneed['vn_aux']
- for idx, vernaux in enumerate(verneed_iter, start=1):
- if vernaux['vna_flags']:
- flags = describe_ver_flags(vernaux['vna_flags'])
- # Mimic exactly the readelf output
- flags += ' '
- else:
- flags = 'none'
-
- self._emitline(
- ' %s: Name: %s Flags: %s Version: %i' % (
- self._format_hex(vernaux_offset, fieldsize=4),
- bytes2str(vernaux.name), flags,
- vernaux['vna_other']))
-
- vernaux_offset += vernaux['vna_next']
-
- offset += verneed['vn_next']
-
+
def display_hex_dump(self, section_spec):
""" Display a hex dump of a section. section_spec is either a section
number or a name.
@@ -596,7 +401,7 @@ class ReadElf(object):
dataptr = 0
while dataptr < len(data):
- while ( dataptr < len(data) and
+ while ( dataptr < len(data) and
not (32 <= byte2int(data[dataptr]) <= 127)):
dataptr += 1
@@ -624,7 +429,7 @@ class ReadElf(object):
self._init_dwarfinfo()
if self._dwarfinfo is None:
return
-
+
set_global_machine_arch(self.elffile.get_machine_arch())
if dump_what == 'info':
@@ -638,8 +443,7 @@ class ReadElf(object):
else:
self._emitline('debug dump not yet supported for "%s"' % dump_what)
- def _format_hex(self, addr, fieldsize=None, fullhex=False, lead0x=True,
- alternate=False):
+ def _format_hex(self, addr, fieldsize=None, fullhex=False, lead0x=True):
""" Format an address into a hexadecimal string.
fieldsize:
@@ -649,25 +453,12 @@ class ReadElf(object):
If None, the minimal required field size will be used.
fullhex:
- If True, override fieldsize to set it to the maximal size
+ If True, override fieldsize to set it to the maximal size
needed for the elfclass
lead0x:
If True, leading 0x is added
-
- alternate:
- If True, override lead0x to emulate the alternate
- hexadecimal form specified in format string with the #
- character: only non-zero values are prefixed with 0x.
- This form is used by readelf.
"""
- if alternate:
- if addr == 0:
- lead0x = False
- else:
- lead0x = True
- fieldsize -= 2
-
s = '0x' if lead0x else ''
if fullhex:
fieldsize = 8 if self.elffile.elfclass == 32 else 16
@@ -676,98 +467,7 @@ class ReadElf(object):
else:
field = '%' + '0%sx' % fieldsize
return s + field % addr
-
- def _print_version_section_header(self, version_section, name, lead0x=True,
- indent=1):
- """ Print a section header of one version related section (versym,
- verneed or verdef) with some options to accomodate readelf
- little differences between each header (e.g. indentation
- and 0x prefixing).
- """
- if hasattr(version_section, 'num_versions'):
- num_entries = version_section.num_versions()
- else:
- num_entries = version_section.num_symbols()
-
- self._emitline("\n%s section '%s' contains %s entries:" %
- (name, bytes2str(version_section.name), num_entries))
- self._emitline('%sAddr: %s Offset: %s Link: %i (%s)' % (
- ' ' * indent,
- self._format_hex(
- version_section['sh_addr'], fieldsize=16, lead0x=lead0x),
- self._format_hex(
- version_section['sh_offset'], fieldsize=6, lead0x=True),
- version_section['sh_link'],
- bytes2str(
- self.elffile.get_section(version_section['sh_link']).name)
- )
- )
-
- def _init_versioninfo(self):
- """ Search and initialize informations about version related sections
- and the kind of versioning used (GNU or Solaris).
- """
- if self._versioninfo is not None:
- return
-
- self._versioninfo = {'versym': None, 'verdef': None,
- 'verneed': None, 'type': None}
-
- for section in self.elffile.iter_sections():
- if isinstance(section, GNUVerSymSection):
- self._versioninfo['versym'] = section
- elif isinstance(section, GNUVerDefSection):
- self._versioninfo['verdef'] = section
- elif isinstance(section, GNUVerNeedSection):
- self._versioninfo['verneed'] = section
- elif isinstance(section, DynamicSection):
- for tag in section.iter_tags():
- if tag['d_tag'] == 'DT_VERSYM':
- self._versioninfo['type'] = 'GNU'
- break
-
- if not self._versioninfo['type'] and (
- self._versioninfo['verneed'] or self._versioninfo['verdef']):
- self._versioninfo['type'] = 'Solaris'
-
- def _symbol_version(self, nsym):
- """ Return a dict containing information on the
- or None if no version information is available
- """
- self._init_versioninfo()
-
- symbol_version = dict.fromkeys(('index', 'name', 'filename', 'hidden'))
-
- if (not self._versioninfo['versym'] or
- nsym >= self._versioninfo['versym'].num_symbols()):
- return None
-
- symbol = self._versioninfo['versym'].get_symbol(nsym)
- index = symbol.entry['ndx']
- if not index in ('VER_NDX_LOCAL', 'VER_NDX_GLOBAL'):
- index = int(index)
-
- if self._versioninfo['type'] == 'GNU':
- # In GNU versioning mode, the highest bit is used to
- # store wether the symbol is hidden or not
- if index & 0x8000:
- index &= ~0x8000
- symbol_version['hidden'] = True
-
- if (self._versioninfo['verdef'] and
- index <= self._versioninfo['verdef'].num_versions()):
- _, verdaux_iter = \
- self._versioninfo['verdef'].get_version(index)
- symbol_version['name'] = bytes2str(next(verdaux_iter).name)
- else:
- verneed, vernaux = \
- self._versioninfo['verneed'].get_version(index)
- symbol_version['name'] = bytes2str(vernaux.name)
- symbol_version['filename'] = bytes2str(verneed.name)
-
- symbol_version['index'] = index
- return symbol_version
-
+
def _section_from_spec(self, spec):
""" Retrieve a section given a "spec" (either number or name).
Return None if no such section exists in the file.
@@ -775,7 +475,7 @@ class ReadElf(object):
try:
num = int(spec)
if num < self.elffile.num_sections():
- return self.elffile.get_section(num)
+ return self.elffile.get_section(num)
else:
return None
except ValueError:
@@ -800,7 +500,7 @@ class ReadElf(object):
"""
if self._dwarfinfo is not None:
return
-
+
if self.elffile.has_dwarf_info():
self._dwarfinfo = self.elffile.get_dwarf_info()
else:
@@ -810,7 +510,7 @@ class ReadElf(object):
""" Dump the debugging info section.
"""
self._emitline('Contents of the .debug_info section:\n')
-
+
# Offset of the .debug_info section in the stream
section_offset = self._dwarfinfo.debug_info_sec.global_offset
@@ -821,11 +521,10 @@ class ReadElf(object):
self._format_hex(cu['unit_length']),
'%s-bit' % cu.dwarf_format()))
self._emitline(' Version: %s' % cu['version']),
- self._emitline(' Abbrev Offset: %s' % (
- self._format_hex(cu['debug_abbrev_offset']))),
+ self._emitline(' Abbrev Offset: %s' % cu['debug_abbrev_offset']),
self._emitline(' Pointer Size: %s' % cu['address_size'])
-
- # The nesting depth of each DIE within the tree of DIEs must be
+
+ # The nesting depth of each DIE within the tree of DIEs must be
# displayed. To implement this, a counter is incremented each time
# the current DIE has children, and decremented when a null die is
# encountered. Due to the way the DIE tree is serialized, this will
@@ -833,15 +532,15 @@ class ReadElf(object):
#
die_depth = 0
for die in cu.iter_DIEs():
- self._emitline(' <%s><%x>: Abbrev Number: %s%s' % (
- die_depth,
- die.offset,
- die.abbrev_code,
- (' (%s)' % die.tag) if not die.is_null() else ''))
if die.is_null():
die_depth -= 1
continue
-
+ self._emitline(' <%s><%x>: Abbrev Number: %s (%s)' % (
+ die_depth,
+ die.offset,
+ die.abbrev_code,
+ die.tag))
+
for attr in itervalues(die.attributes):
name = attr.name
# Unknown attribute values are passed-through as integers
@@ -852,10 +551,10 @@ class ReadElf(object):
name,
describe_attr_value(
attr, die, section_offset)))
-
+
if die.has_children:
die_depth += 1
-
+
self._emitline()
def _dump_debug_line_programs(self):
@@ -867,14 +566,13 @@ class ReadElf(object):
for cu in self._dwarfinfo.iter_CUs():
lineprogram = self._dwarfinfo.line_program_for_CU(cu)
- cu_filename = bytes2str(lineprogram['file_entry'][0].name)
+ cu_filename = ''
if len(lineprogram['include_directory']) > 0:
- dir_index = lineprogram['file_entry'][0].dir_index
- if dir_index > 0:
- dir = lineprogram['include_directory'][dir_index - 1]
- else:
- dir = b'.'
- cu_filename = '%s/%s' % (bytes2str(dir), cu_filename)
+ cu_filename = '%s/%s' % (
+ bytes2str(lineprogram['include_directory'][0]),
+ bytes2str(lineprogram['file_entry'][0].name))
+ else:
+ cu_filename = bytes2str(lineprogram['file_entry'][0].name)
self._emitline('CU: %s:' % cu_filename)
self._emitline('File name Line number Starting address')
@@ -906,7 +604,7 @@ class ReadElf(object):
self._emitline('%-35s %11d %18s' % (
bytes2str(lineprogram['file_entry'][state.file - 1].name),
state.line,
- '0' if state.address == 0 else
+ '0' if state.address == 0 else
self._format_hex(state.address)))
if entry.command == DW_LNS_copy:
# Another readelf oddity...
@@ -921,10 +619,8 @@ class ReadElf(object):
for entry in self._dwarfinfo.CFI_entries():
if isinstance(entry, CIE):
- self._emitline('\n%08x %s %s CIE' % (
- entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_id'], fullhex=True, lead0x=False)))
+ self._emitline('\n%08x %08x %08x CIE' % (
+ entry.offset, entry['length'], entry['CIE_id']))
self._emitline(' Version: %d' % entry['version'])
self._emitline(' Augmentation: "%s"' % bytes2str(entry['augmentation']))
self._emitline(' Code alignment factor: %u' % entry['code_alignment_factor'])
@@ -932,15 +628,13 @@ class ReadElf(object):
self._emitline(' Return address column: %d' % entry['return_address_register'])
self._emitline()
else: # FDE
- self._emitline('\n%08x %s %s FDE cie=%08x pc=%s..%s' % (
+ self._emitline('\n%08x %08x %08x FDE cie=%08x pc=%08x..%08x' % (
entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_pointer'], fullhex=True, lead0x=False),
+ entry['length'],
+ entry['CIE_pointer'],
entry.cie.offset,
- self._format_hex(entry['initial_location'], fullhex=True, lead0x=False),
- self._format_hex(
- entry['initial_location'] + entry['address_range'],
- fullhex=True, lead0x=False)))
+ entry['initial_location'],
+ entry['initial_location'] + entry['address_range']))
self._emit(describe_CFI_instructions(entry))
self._emitline()
@@ -955,24 +649,23 @@ class ReadElf(object):
for entry in self._dwarfinfo.CFI_entries():
if isinstance(entry, CIE):
- self._emitline('\n%08x %s %s CIE "%s" cf=%d df=%d ra=%d' % (
+ self._emitline('\n%08x %08x %08x CIE "%s" cf=%d df=%d ra=%d' % (
entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_id'], fullhex=True, lead0x=False),
+ entry['length'],
+ entry['CIE_id'],
bytes2str(entry['augmentation']),
entry['code_alignment_factor'],
entry['data_alignment_factor'],
entry['return_address_register']))
ra_regnum = entry['return_address_register']
else: # FDE
- self._emitline('\n%08x %s %s FDE cie=%08x pc=%s..%s' % (
+ self._emitline('\n%08x %08x %08x FDE cie=%08x pc=%08x..%08x' % (
entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_pointer'], fullhex=True, lead0x=False),
+ entry['length'],
+ entry['CIE_pointer'],
entry.cie.offset,
- self._format_hex(entry['initial_location'], fullhex=True, lead0x=False),
- self._format_hex(entry['initial_location'] + entry['address_range'],
- fullhex=True, lead0x=False)))
+ entry['initial_location'],
+ entry['initial_location'] + entry['address_range']))
ra_regnum = entry.cie['return_address_register']
# Print the heading row for the decoded table
@@ -986,14 +679,14 @@ class ReadElf(object):
# ra_regnum is always listed last with a special heading.
decoded_table = entry.get_decoded()
reg_order = sorted(ifilter(
- lambda r: r != ra_regnum,
+ lambda r: r != ra_regnum,
decoded_table.reg_order))
# Headings for the registers
for regnum in reg_order:
self._emit('%-6s' % describe_reg_name(regnum))
self._emitline('ra ')
-
+
# Now include ra_regnum in reg_order to print its values similarly
# to the other registers.
reg_order.append(ra_regnum)
@@ -1034,9 +727,6 @@ def main(stream=None):
add_help_option=False, # -h is a real option of readelf
prog='readelf.py',
version=VERSION_STRING)
- optparser.add_option('-d', '--dynamic',
- action='store_true', dest='show_dynamic_tags',
- help='Display the dynamic section')
optparser.add_option('-H', '--help',
action='store_true', dest='help',
help='Display this information')
@@ -1064,9 +754,6 @@ def main(stream=None):
optparser.add_option('-p', '--string-dump',
action='store', dest='show_string_dump', metavar='<number|name>',
help='Dump the contents of section <number|name> as strings')
- optparser.add_option('-V', '--version-info',
- action='store_true', dest='show_version_info',
- help='Display the version sections (if present)')
optparser.add_option('--debug-dump',
action='store', dest='debug_dump_what', metavar='<what>',
help=(
@@ -1097,14 +784,10 @@ def main(stream=None):
if do_program_header:
readelf.display_program_headers(
show_heading=not do_file_header)
- if options.show_dynamic_tags:
- readelf.display_dynamic_tags()
if options.show_symbols:
readelf.display_symbol_tables()
if options.show_relocs:
readelf.display_relocations()
- if options.show_version_info:
- readelf.display_version_info()
if options.show_hex_dump:
readelf.display_hex_dump(options.show_hex_dump)
if options.show_string_dump:
diff --git a/chromium/third_party/pyelftools/setup.py b/chromium/third_party/pyelftools/setup.py
index c6beb1682f0..3103e19892e 100644
--- a/chromium/third_party/pyelftools/setup.py
+++ b/chromium/third_party/pyelftools/setup.py
@@ -24,11 +24,11 @@ setup(
description='Library for analyzing ELF files and DWARF debugging information',
long_description=description,
license='Public domain',
- version='0.22',
+ version='0.20',
author='Eli Bendersky',
maintainer='Eli Bendersky',
author_email='eliben@gmail.com',
- url='https://github.com/eliben/pyelftools',
+ url='https://bitbucket.org/eliben/pyelftools',
platforms='Cross Platform',
classifiers = [
'Programming Language :: Python :: 2',
@@ -44,5 +44,7 @@ setup(
'elftools.construct', 'elftools.construct.lib',
],
- scripts=['scripts/readelf.py']
+ scripts=['scripts/readelf.py'],
)
+
+
diff --git a/chromium/third_party/pyelftools/tox.ini b/chromium/third_party/pyelftools/tox.ini
index 600ca1c9a60..73fbb848535 100644
--- a/chromium/third_party/pyelftools/tox.ini
+++ b/chromium/third_party/pyelftools/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,py33
+envlist = py27,py26,py32
[testenv]
commands =
@@ -10,3 +10,4 @@ commands =
[testenv:py26]
deps =
unittest2
+
diff --git a/chromium/third_party/pyelftools/z.py b/chromium/third_party/pyelftools/z.py
index 18f7d35b844..d30feb3e106 100644
--- a/chromium/third_party/pyelftools/z.py
+++ b/chromium/third_party/pyelftools/z.py
@@ -1,10 +1,3 @@
-#-------------------------------------------------------------------------------
-# elftools
-#
-# Eli Bendersky (eliben@gmail.com)
-# This code is in the public domain
-#-------------------------------------------------------------------------------
-
# Just a script for playing around with pyelftools during testing
# please ignore it!
#
diff --git a/chromium/third_party/skia/src/core/SkPathRef.cpp b/chromium/third_party/skia/src/core/SkPathRef.cpp
index f0fda2703b5..33382253917 100644
--- a/chromium/third_party/skia/src/core/SkPathRef.cpp
+++ b/chromium/third_party/skia/src/core/SkPathRef.cpp
@@ -190,6 +190,11 @@ void SkPathRef::CreateTransformedCopy(sk_sp<SkPathRef>* dst,
// or if an invalid verb is encountered, return false.
static bool deduce_pts_conics(const uint8_t verbs[], int vCount, int* ptCountPtr,
int* conicCountPtr) {
+ // When there is at least one verb, the first is required to be kMove_Verb.
+ if (0 < vCount && verbs[vCount-1] != SkPath::kMove_Verb) {
+ return false;
+ }
+
int ptCount = 0;
int conicCount = 0;
for (int i = 0; i < vCount; ++i) {
diff --git a/chromium/third_party/skia/tools/gyp b/chromium/third_party/skia/tools/gyp
deleted file mode 120000
index d871f5b0075..00000000000
--- a/chromium/third_party/skia/tools/gyp
+++ /dev/null
@@ -1 +0,0 @@
-../third_party/externals/gyp/ \ No newline at end of file
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.c b/chromium/third_party/sqlite/amalgamation/sqlite3.c
index f0075cfb318..68fd260459c 100644
--- a/chromium/third_party/sqlite/amalgamation/sqlite3.c
+++ b/chromium/third_party/sqlite/amalgamation/sqlite3.c
@@ -4065,6 +4065,15 @@ typedef struct sqlite3_context sqlite3_context;
** [sqlite3_blob_open | incremental BLOB I/O] routines.
** ^A negative value for the zeroblob results in a zero-length BLOB.
**
+** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
+** [prepared statement] S to have an SQL value of NULL, but to also be
+** associated with the pointer P.
+** ^The sqlite3_bind_pointer() routine can be used to pass
+** host-language pointers into [application-defined SQL functions].
+** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
+** to be an ordinary SQL NULL value to everything other than
+** [sqlite3_value_pointer()].
+**
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
** for the [prepared statement] or with a prepared statement for which
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
@@ -4098,6 +4107,7 @@ SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
@@ -4867,6 +4877,11 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
** extract UTF-16 strings as big-endian and little-endian respectively.
**
+** ^If [sqlite3_value] object V was initialized
+** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
+** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
+** sqlite3_value_pointer(V) returns a NULL.
+**
** ^(The sqlite3_value_numeric_type() interface attempts to apply
** numeric affinity to the value. This means that an attempt is
** made to convert the value to an integer or floating point. If
@@ -4894,6 +4909,7 @@ SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
SQLITE_API int sqlite3_value_type(sqlite3_value*);
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
@@ -4906,10 +4922,6 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
-**
-** SQLite makes no use of subtype itself. It merely passes the subtype
-** from the result of one [application-defined SQL function] into the
-** input of another.
*/
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
@@ -5187,6 +5199,14 @@ typedef void (*sqlite3_destructor_type)(void*);
** [unprotected sqlite3_value] object is required, so either
** kind of [sqlite3_value] object can be used with this interface.
**
+** ^The sqlite3_result_pointer(C,P) interface sets the result to an
+** SQL NULL value, just like [sqlite3_result_null(C)], except that it
+** also associates the host-language pointer P with that NULL value such
+** that the pointer can be retrieved within an
+** [application-defined SQL function] using [sqlite3_value_pointer()].
+** This mechanism can be used to pass non-SQL values between
+** application-defined functions.
+**
** If these routines are called from within the different thread
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
@@ -5210,6 +5230,7 @@ SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
@@ -18089,6 +18110,7 @@ struct Mem {
double r; /* Real value used when MEM_Real is set in flags */
i64 i; /* Integer value used when MEM_Int is set in flags */
int nZero; /* Used when bit MEM_Zero is set in flags */
+ void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */
FuncDef *pDef; /* Used only when flags==MEM_Agg */
RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
@@ -18374,6 +18396,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
#else
SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
#endif
+SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*);
SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
@@ -70280,6 +70303,17 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
}
}
+/*
+** Set the value stored in *pMem should already be a NULL.
+** Also store a pointer to go with it.
+*/
+SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
+ assert( pMem->flags==MEM_Null );
+ pMem->flags = MEM_Null|MEM_Subtype;
+ pMem->u.pPtr = pPtr;
+ pMem->eSubtype = 'p';
+}
+
#ifndef SQLITE_OMIT_FLOATING_POINT
/*
** Delete any previous value and set the value stored in *pMem to val,
@@ -76159,6 +76193,14 @@ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
Mem *pMem = (Mem*)pVal;
return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
}
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){
+ Mem *p = (Mem*)pVal;
+ if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
+ return p->u.pPtr;
+ }else{
+ return 0;
+ }
+}
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
}
@@ -76337,6 +76379,12 @@ SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetNull(pCtx->pOut);
}
+SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
+ Mem *pOut = pCtx->pOut;
+ assert( sqlite3_mutex_held(pOut->db->mutex) );
+ sqlite3VdbeMemSetNull(pOut);
+ sqlite3VdbeMemSetPointer(pOut, pPtr);
+}
SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
Mem *pOut = pCtx->pOut;
assert( sqlite3_mutex_held(pOut->db->mutex) );
@@ -77322,6 +77370,16 @@ SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
}
return rc;
}
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
+ int rc;
+ Vdbe *p = (Vdbe*)pStmt;
+ rc = vdbeUnbind(p, i);
+ if( rc==SQLITE_OK ){
+ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
+ sqlite3_mutex_leave(p->db->mutex);
+ }
+ return rc;
+}
SQLITE_API int sqlite3_bind_text(
sqlite3_stmt *pStmt,
int i,
@@ -148237,9 +148295,8 @@ static int fts3ColumnMethod(
sqlite3_result_int64(pCtx, pCsr->iPrevId);
}else if( iCol==p->nColumn ){
/* The extra column whose name is the same as the table.
- ** Return a blob which is a pointer to the cursor. */
- sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
- sqlite3_result_subtype(pCtx, '3');
+ ** Return a pointer to the cursor. */
+ sqlite3_result_pointer(pCtx, pCsr);
}else if( iCol==p->nColumn+2 && pCsr->pExpr ){
sqlite3_result_int64(pCtx, pCsr->iLangid);
}else{
@@ -148451,17 +148508,13 @@ static int fts3FunctionArg(
sqlite3_value *pVal, /* argv[0] passed to function */
Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
){
- Fts3Cursor *pRet;
- if( sqlite3_value_type(pVal)!=SQLITE_BLOB
- || sqlite3_value_subtype(pVal)!='3'
- || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)
- ){
+ Fts3Cursor *pRet = (Fts3Cursor*)sqlite3_value_pointer(pVal);
+ if( pRet==0 ){
char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
sqlite3_result_error(pContext, zErr, -1);
sqlite3_free(zErr);
return SQLITE_ERROR;
}
- memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));
*ppCsr = pRet;
return SQLITE_OK;
}
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.h b/chromium/third_party/sqlite/amalgamation/sqlite3.h
index 8e4e11e0ce7..a476a98f528 100644
--- a/chromium/third_party/sqlite/amalgamation/sqlite3.h
+++ b/chromium/third_party/sqlite/amalgamation/sqlite3.h
@@ -3786,6 +3786,15 @@ typedef struct sqlite3_context sqlite3_context;
** [sqlite3_blob_open | incremental BLOB I/O] routines.
** ^A negative value for the zeroblob results in a zero-length BLOB.
**
+** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
+** [prepared statement] S to have an SQL value of NULL, but to also be
+** associated with the pointer P.
+** ^The sqlite3_bind_pointer() routine can be used to pass
+** host-language pointers into [application-defined SQL functions].
+** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
+** to be an ordinary SQL NULL value to everything other than
+** [sqlite3_value_pointer()].
+**
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
** for the [prepared statement] or with a prepared statement for which
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
@@ -3819,6 +3828,7 @@ SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
@@ -4588,6 +4598,11 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
** extract UTF-16 strings as big-endian and little-endian respectively.
**
+** ^If [sqlite3_value] object V was initialized
+** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
+** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
+** sqlite3_value_pointer(V) returns a NULL.
+**
** ^(The sqlite3_value_numeric_type() interface attempts to apply
** numeric affinity to the value. This means that an attempt is
** made to convert the value to an integer or floating point. If
@@ -4615,6 +4630,7 @@ SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
SQLITE_API int sqlite3_value_type(sqlite3_value*);
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
@@ -4627,10 +4643,6 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
-**
-** SQLite makes no use of subtype itself. It merely passes the subtype
-** from the result of one [application-defined SQL function] into the
-** input of another.
*/
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
@@ -4908,6 +4920,14 @@ typedef void (*sqlite3_destructor_type)(void*);
** [unprotected sqlite3_value] object is required, so either
** kind of [sqlite3_value] object can be used with this interface.
**
+** ^The sqlite3_result_pointer(C,P) interface sets the result to an
+** SQL NULL value, just like [sqlite3_result_null(C)], except that it
+** also associates the host-language pointer P with that NULL value such
+** that the pointer can be retrieved within an
+** [application-defined SQL function] using [sqlite3_value_pointer()].
+** This mechanism can be used to pass non-SQL values between
+** application-defined functions.
+**
** If these routines are called from within the different thread
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
@@ -4931,6 +4951,7 @@ SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
diff --git a/chromium/third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch b/chromium/third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch
new file mode 100644
index 00000000000..e65e75f9d60
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch
@@ -0,0 +1,420 @@
+From 3dac6f0ce5313f60acc6b7abca1d431001ad0187 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 15 Jul 2017 12:30:42 -0700
+Subject: [PATCH 13/13] Add new interfaces sqlite3_bind_pointer(),
+ sqlite3_result_pointer(), and sqlite3_value_pointer() used to safely move
+ pointer values through SQL without exposing underlying memory address
+ information.
+
+---
+ third_party/sqlite/src/ext/fts3/fts3.c | 13 +++------
+ third_party/sqlite/src/ext/misc/carray.c | 46 ++++++++++++++++++++++++++----
+ third_party/sqlite/src/ext/misc/remember.c | 6 ++--
+ third_party/sqlite/src/src/sqlite.h.in | 29 ++++++++++++++++---
+ third_party/sqlite/src/src/vdbeInt.h | 2 ++
+ third_party/sqlite/src/src/vdbeapi.c | 24 ++++++++++++++++
+ third_party/sqlite/src/src/vdbemem.c | 11 +++++++
+ third_party/sqlite/src/test/tabfunc01.test | 25 ++++++++--------
+ 8 files changed, 122 insertions(+), 34 deletions(-)
+
+diff --git a/third_party/sqlite/src/ext/fts3/fts3.c b/third_party/sqlite/src/ext/fts3/fts3.c
+index 827769881616..5d2f21d2937f 100644
+--- a/third_party/sqlite/src/ext/fts3/fts3.c
++++ b/third_party/sqlite/src/ext/fts3/fts3.c
+@@ -3347,9 +3347,8 @@ static int fts3ColumnMethod(
+ sqlite3_result_int64(pCtx, pCsr->iPrevId);
+ }else if( iCol==p->nColumn ){
+ /* The extra column whose name is the same as the table.
+- ** Return a blob which is a pointer to the cursor. */
+- sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
+- sqlite3_result_subtype(pCtx, '3');
++ ** Return a pointer to the cursor. */
++ sqlite3_result_pointer(pCtx, pCsr);
+ }else if( iCol==p->nColumn+2 && pCsr->pExpr ){
+ sqlite3_result_int64(pCtx, pCsr->iLangid);
+ }else{
+@@ -3561,17 +3560,13 @@ static int fts3FunctionArg(
+ sqlite3_value *pVal, /* argv[0] passed to function */
+ Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
+ ){
+- Fts3Cursor *pRet;
+- if( sqlite3_value_type(pVal)!=SQLITE_BLOB
+- || sqlite3_value_subtype(pVal)!='3'
+- || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)
+- ){
++ Fts3Cursor *pRet = (Fts3Cursor*)sqlite3_value_pointer(pVal);
++ if( pRet==0 ){
+ char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
+ sqlite3_result_error(pContext, zErr, -1);
+ sqlite3_free(zErr);
+ return SQLITE_ERROR;
+ }
+- memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));
+ *ppCsr = pRet;
+ return SQLITE_OK;
+ }
+diff --git a/third_party/sqlite/src/ext/misc/carray.c b/third_party/sqlite/src/ext/misc/carray.c
+index 025eb5db2c0e..2fdff0cd3afc 100644
+--- a/third_party/sqlite/src/ext/misc/carray.c
++++ b/third_party/sqlite/src/ext/misc/carray.c
+@@ -73,7 +73,7 @@ typedef struct carray_cursor carray_cursor;
+ struct carray_cursor {
+ sqlite3_vtab_cursor base; /* Base class - must be first */
+ sqlite3_int64 iRowid; /* The rowid */
+- sqlite3_int64 iPtr; /* Pointer to array of values */
++ void* pPtr; /* Pointer to the array of values */
+ sqlite3_int64 iCnt; /* Number of integers in the array */
+ unsigned char eType; /* One of the CARRAY_type values */
+ };
+@@ -167,7 +167,7 @@ static int carrayColumn(
+ carray_cursor *pCur = (carray_cursor*)cur;
+ sqlite3_int64 x = 0;
+ switch( i ){
+- case CARRAY_COLUMN_POINTER: x = pCur->iPtr; break;
++ case CARRAY_COLUMN_POINTER: return SQLITE_OK;
+ case CARRAY_COLUMN_COUNT: x = pCur->iCnt; break;
+ case CARRAY_COLUMN_CTYPE: {
+ sqlite3_result_text(ctx, azType[pCur->eType], -1, SQLITE_STATIC);
+@@ -232,8 +232,8 @@ static int carrayFilter(
+ ){
+ carray_cursor *pCur = (carray_cursor *)pVtabCursor;
+ if( idxNum ){
+- pCur->iPtr = sqlite3_value_int64(argv[0]);
+- pCur->iCnt = sqlite3_value_int64(argv[1]);
++ pCur->pPtr = sqlite3_value_pointer(argv[0]);
++ pCur->iCnt = pCur->pPtr ? sqlite3_value_int64(argv[1]) : 0;
+ if( idxNum<3 ){
+ pCur->eType = CARRAY_INT32;
+ }else{
+@@ -251,7 +251,7 @@ static int carrayFilter(
+ }
+ }
+ }else{
+- pCur->iPtr = 0;
++ pCur->pPtr = 0;
+ pCur->iCnt = 0;
+ }
+ pCur->iRowid = 1;
+@@ -345,6 +345,34 @@ static sqlite3_module carrayModule = {
+ 0, /* xRename */
+ };
+
++/*
++** For testing purpose in the TCL test harness, we need a method for
++** setting the pointer value. The inttoptr(X) SQL function accomplishes
++** this. Tcl script will bind an integer to X and the inttoptr() SQL
++** function will use sqlite3_result_pointer() to convert that integer into
++** a pointer.
++**
++** This is for testing on TCL only.
++*/
++#ifdef SQLITE_TEST
++static void inttoptrFunc(
++ sqlite3_context *context,
++ int argc,
++ sqlite3_value **argv
++){
++ void *p;
++ sqlite3_int64 i64;
++ i64 = sqlite3_value_int64(argv[0]);
++ if( sizeof(i64)==sizeof(p) ){
++ memcpy(&p, &i64, sizeof(p));
++ }else{
++ int i32 = i64 & 0xffffffff;
++ memcpy(&p, &i32, sizeof(p));
++ }
++ sqlite3_result_pointer(context, p);
++}
++#endif /* SQLITE_TEST */
++
+ #endif /* SQLITE_OMIT_VIRTUALTABLE */
+
+ #ifdef _WIN32
+@@ -359,6 +387,12 @@ int sqlite3_carray_init(
+ SQLITE_EXTENSION_INIT2(pApi);
+ #ifndef SQLITE_OMIT_VIRTUALTABLE
+ rc = sqlite3_create_module(db, "carray", &carrayModule, 0);
+-#endif
++#ifdef SQLITE_TEST
++ if( rc==SQLITE_OK ){
++ rc = sqlite3_create_function(db, "inttoptr", 1, SQLITE_UTF8, 0,
++ inttoptrFunc, 0, 0);
++ }
++#endif /* SQLITE_TEST */
++#endif /* SQLITE_OMIT_VIRTUALTABLE */
+ return rc;
+ }
+diff --git a/third_party/sqlite/src/ext/misc/remember.c b/third_party/sqlite/src/ext/misc/remember.c
+index aa3eff8a3f8b..587d44a12cdc 100644
+--- a/third_party/sqlite/src/ext/misc/remember.c
++++ b/third_party/sqlite/src/ext/misc/remember.c
+@@ -44,11 +44,11 @@ static void rememberFunc(
+ sqlite3_value **argv
+ ){
+ sqlite3_int64 v;
+- sqlite3_int64 ptr;
++ sqlite3_int64 *ptr;
+ assert( argc==2 );
+ v = sqlite3_value_int64(argv[0]);
+- ptr = sqlite3_value_int64(argv[1]);
+- *((sqlite3_int64*)ptr) = v;
++ ptr = sqlite3_value_pointer(argv[1]);
++ if( ptr ) *ptr = v;
+ sqlite3_result_int64(pCtx, v);
+ }
+
+diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src/sqlite.h.in
+index fbbf4b9f2db3..371ae5848bbc 100644
+--- a/third_party/sqlite/src/src/sqlite.h.in
++++ b/third_party/sqlite/src/src/sqlite.h.in
+@@ -3786,6 +3786,15 @@ typedef struct sqlite3_context sqlite3_context;
+ ** [sqlite3_blob_open | incremental BLOB I/O] routines.
+ ** ^A negative value for the zeroblob results in a zero-length BLOB.
+ **
++** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
++** [prepared statement] S to have an SQL value of NULL, but to also be
++** associated with the pointer P.
++** ^The sqlite3_bind_pointer() routine can be used to pass
++** host-language pointers into [application-defined SQL functions].
++** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
++** to be an ordinary SQL NULL value to everything other than
++** [sqlite3_value_pointer()].
++**
+ ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
+ ** for the [prepared statement] or with a prepared statement for which
+ ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
+@@ -3819,6 +3828,7 @@ int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
+ int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
+ void(*)(void*), unsigned char encoding);
+ int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
++int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
+ int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
+ int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
+
+@@ -4588,6 +4598,11 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
+ ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
+ ** extract UTF-16 strings as big-endian and little-endian respectively.
+ **
++** ^If [sqlite3_value] object V was initialized
++** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
++** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
++** sqlite3_value_pointer(V) returns a NULL.
++**
+ ** ^(The sqlite3_value_numeric_type() interface attempts to apply
+ ** numeric affinity to the value. This means that an attempt is
+ ** made to convert the value to an integer or floating point. If
+@@ -4615,6 +4630,7 @@ const unsigned char *sqlite3_value_text(sqlite3_value*);
+ const void *sqlite3_value_text16(sqlite3_value*);
+ const void *sqlite3_value_text16le(sqlite3_value*);
+ const void *sqlite3_value_text16be(sqlite3_value*);
++void *sqlite3_value_pointer(sqlite3_value*);
+ int sqlite3_value_type(sqlite3_value*);
+ int sqlite3_value_numeric_type(sqlite3_value*);
+
+@@ -4627,10 +4643,6 @@ int sqlite3_value_numeric_type(sqlite3_value*);
+ ** information can be used to pass a limited amount of context from
+ ** one SQL function to another. Use the [sqlite3_result_subtype()]
+ ** routine to set the subtype for the return value of an SQL function.
+-**
+-** SQLite makes no use of subtype itself. It merely passes the subtype
+-** from the result of one [application-defined SQL function] into the
+-** input of another.
+ */
+ unsigned int sqlite3_value_subtype(sqlite3_value*);
+
+@@ -4908,6 +4920,14 @@ typedef void (*sqlite3_destructor_type)(void*);
+ ** [unprotected sqlite3_value] object is required, so either
+ ** kind of [sqlite3_value] object can be used with this interface.
+ **
++** ^The sqlite3_result_pointer(C,P) interface sets the result to an
++** SQL NULL value, just like [sqlite3_result_null(C)], except that it
++** also associates the host-language pointer P with that NULL value such
++** that the pointer can be retrieved within an
++** [application-defined SQL function] using [sqlite3_value_pointer()].
++** This mechanism can be used to pass non-SQL values between
++** application-defined functions.
++**
+ ** If these routines are called from within the different thread
+ ** than the one containing the application-defined function that received
+ ** the [sqlite3_context] pointer, the results are undefined.
+@@ -4931,6 +4951,7 @@ void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
+ void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
+ void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
+ void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
++void sqlite3_result_pointer(sqlite3_context*, void*);
+ void sqlite3_result_zeroblob(sqlite3_context*, int n);
+ int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
+
+diff --git a/third_party/sqlite/src/src/vdbeInt.h b/third_party/sqlite/src/src/vdbeInt.h
+index 989cdfd34617..69eab56bc578 100644
+--- a/third_party/sqlite/src/src/vdbeInt.h
++++ b/third_party/sqlite/src/src/vdbeInt.h
+@@ -189,6 +189,7 @@ struct Mem {
+ double r; /* Real value used when MEM_Real is set in flags */
+ i64 i; /* Integer value used when MEM_Int is set in flags */
+ int nZero; /* Used when bit MEM_Zero is set in flags */
++ void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */
+ FuncDef *pDef; /* Used only when flags==MEM_Agg */
+ RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
+ VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
+@@ -474,6 +475,7 @@ void sqlite3VdbeMemSetInt64(Mem*, i64);
+ #else
+ void sqlite3VdbeMemSetDouble(Mem*, double);
+ #endif
++void sqlite3VdbeMemSetPointer(Mem*, void*);
+ void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
+ void sqlite3VdbeMemSetNull(Mem*);
+ void sqlite3VdbeMemSetZeroBlob(Mem*,int);
+diff --git a/third_party/sqlite/src/src/vdbeapi.c b/third_party/sqlite/src/src/vdbeapi.c
+index 6eb97f1d1ddb..c54490c077cd 100644
+--- a/third_party/sqlite/src/src/vdbeapi.c
++++ b/third_party/sqlite/src/src/vdbeapi.c
+@@ -198,6 +198,14 @@ unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
+ Mem *pMem = (Mem*)pVal;
+ return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
+ }
++void *sqlite3_value_pointer(sqlite3_value *pVal){
++ Mem *p = (Mem*)pVal;
++ if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
++ return p->u.pPtr;
++ }else{
++ return 0;
++ }
++}
+ const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
+ return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
+ }
+@@ -376,6 +384,12 @@ void sqlite3_result_null(sqlite3_context *pCtx){
+ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
+ sqlite3VdbeMemSetNull(pCtx->pOut);
+ }
++void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
++ Mem *pOut = pCtx->pOut;
++ assert( sqlite3_mutex_held(pOut->db->mutex) );
++ sqlite3VdbeMemSetNull(pOut);
++ sqlite3VdbeMemSetPointer(pOut, pPtr);
++}
+ void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
+ Mem *pOut = pCtx->pOut;
+ assert( sqlite3_mutex_held(pOut->db->mutex) );
+@@ -1361,6 +1375,16 @@ int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
+ }
+ return rc;
+ }
++int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
++ int rc;
++ Vdbe *p = (Vdbe*)pStmt;
++ rc = vdbeUnbind(p, i);
++ if( rc==SQLITE_OK ){
++ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
++ sqlite3_mutex_leave(p->db->mutex);
++ }
++ return rc;
++}
+ int sqlite3_bind_text(
+ sqlite3_stmt *pStmt,
+ int i,
+diff --git a/third_party/sqlite/src/src/vdbemem.c b/third_party/sqlite/src/src/vdbemem.c
+index 656e19bfa890..2f7aedb32171 100644
+--- a/third_party/sqlite/src/src/vdbemem.c
++++ b/third_party/sqlite/src/src/vdbemem.c
+@@ -697,6 +697,17 @@ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
+ }
+ }
+
++/*
++** Set the value stored in *pMem should already be a NULL.
++** Also store a pointer to go with it.
++*/
++void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
++ assert( pMem->flags==MEM_Null );
++ pMem->flags = MEM_Null|MEM_Subtype;
++ pMem->u.pPtr = pPtr;
++ pMem->eSubtype = 'p';
++}
++
+ #ifndef SQLITE_OMIT_FLOATING_POINT
+ /*
+ ** Delete any previous value and set the value stored in *pMem to val,
+diff --git a/third_party/sqlite/src/test/tabfunc01.test b/third_party/sqlite/src/test/tabfunc01.test
+index dcaafa420c25..bb89aec1e706 100644
+--- a/third_party/sqlite/src/test/tabfunc01.test
++++ b/third_party/sqlite/src/test/tabfunc01.test
+@@ -150,62 +150,63 @@ do_execsql_test tabfunc01-600 {
+ do_test tabfunc01-700 {
+ set PTR1 [intarray_addr 5 7 13 17 23]
+ db eval {
+- SELECT b FROM t600, carray($PTR1,5) WHERE a=value;
++ SELECT b FROM t600, carray(inttoptr($PTR1),5) WHERE a=value;
+ }
+ } {(005) (007) (013) (017) (023)}
+ do_test tabfunc01-701 {
+ db eval {
+- SELECT b FROM t600 WHERE a IN carray($PTR1,5,'int32');
++ SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),5,'int32');
+ }
+ } {(005) (007) (013) (017) (023)}
+ do_test tabfunc01-702 {
+ db eval {
+- SELECT b FROM t600 WHERE a IN carray($PTR1,4,'int32');
++ SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),4,'int32');
+ }
+ } {(005) (007) (013) (017)}
+ do_catchsql_test tabfunc01-710 {
+- SELECT b FROM t600 WHERE a IN carray($PTR1,5,'int33');
++ SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),5,'int33');
+ } {1 {unknown datatype: 'int33'}}
+
+ do_test tabfunc01-720 {
+ set PTR2 [int64array_addr 5 7 13 17 23]
+ db eval {
+- SELECT b FROM t600, carray($PTR2,5,'int64') WHERE a=value;
++ SELECT b FROM t600, carray(inttoptr($PTR2),5,'int64') WHERE a=value;
+ }
+ } {(005) (007) (013) (017) (023)}
+ do_test tabfunc01-721 {
+ db eval {
+ SELECT remember(123,$PTR2);
+- SELECT value FROM carray($PTR2,5,'int64');
++ SELECT value FROM carray(inttoptr($PTR2),5,'int64');
+ }
+ } {123 123 7 13 17 23}
+ do_test tabfunc01-722 {
+ set PTR3 [expr {$PTR2+16}]
+ db eval {
+- SELECT remember(987,$PTR3);
+- SELECT value FROM carray($PTR2,5,'int64');
++ SELECT remember(987,inttoptr($PTR3));
++ SELECT value FROM carray(inttoptr($PTR2),5,'int64');
+ }
+ } {987 123 7 987 17 23}
+
+ do_test tabfunc01-730 {
+ set PTR4 [doublearray_addr 5.0 7.0 13.0 17.0 23.0]
+ db eval {
+- SELECT b FROM t600, carray($PTR4,5,'double') WHERE a=value;
++ SELECT b FROM t600, carray(inttoptr($PTR4),5,'double') WHERE a=value;
+ }
+ } {(005) (007) (013) (017) (023)}
+
+ do_test tabfunc01-740 {
+ set PTR5 [textarray_addr x5 x7 x13 x17 x23]
+ db eval {
+- SELECT b FROM t600, carray($PTR5,5,'char*') WHERE a=trim(value,'x');
++ SELECT b FROM t600, carray(inttoptr($PTR5),5,'char*')
++ WHERE a=trim(value,'x');
+ }
+ } {(005) (007) (013) (017) (023)}
+
+ do_test tabfunc01-750 {
+ db eval {
+ SELECT aa.value, bb.value, '|'
+- FROM carray($PTR4,5,'double') AS aa
+- JOIN carray($PTR5,5,'char*') AS bb ON aa.rowid=bb.rowid;
++ FROM carray(inttoptr($PTR4),5,'double') AS aa
++ JOIN carray(inttoptr($PTR5),5,'char*') AS bb ON aa.rowid=bb.rowid;
+ }
+ } {5.0 x5 | 7.0 x7 | 13.0 x13 | 17.0 x17 | 23.0 x23 |}
+
+--
+2.11
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3.c b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
index 82776988161..5d2f21d2937 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
@@ -3347,9 +3347,8 @@ static int fts3ColumnMethod(
sqlite3_result_int64(pCtx, pCsr->iPrevId);
}else if( iCol==p->nColumn ){
/* The extra column whose name is the same as the table.
- ** Return a blob which is a pointer to the cursor. */
- sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
- sqlite3_result_subtype(pCtx, '3');
+ ** Return a pointer to the cursor. */
+ sqlite3_result_pointer(pCtx, pCsr);
}else if( iCol==p->nColumn+2 && pCsr->pExpr ){
sqlite3_result_int64(pCtx, pCsr->iLangid);
}else{
@@ -3561,17 +3560,13 @@ static int fts3FunctionArg(
sqlite3_value *pVal, /* argv[0] passed to function */
Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
){
- Fts3Cursor *pRet;
- if( sqlite3_value_type(pVal)!=SQLITE_BLOB
- || sqlite3_value_subtype(pVal)!='3'
- || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)
- ){
+ Fts3Cursor *pRet = (Fts3Cursor*)sqlite3_value_pointer(pVal);
+ if( pRet==0 ){
char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
sqlite3_result_error(pContext, zErr, -1);
sqlite3_free(zErr);
return SQLITE_ERROR;
}
- memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));
*ppCsr = pRet;
return SQLITE_OK;
}
diff --git a/chromium/third_party/sqlite/src/ext/misc/carray.c b/chromium/third_party/sqlite/src/ext/misc/carray.c
index 025eb5db2c0..2fdff0cd3af 100644
--- a/chromium/third_party/sqlite/src/ext/misc/carray.c
+++ b/chromium/third_party/sqlite/src/ext/misc/carray.c
@@ -73,7 +73,7 @@ typedef struct carray_cursor carray_cursor;
struct carray_cursor {
sqlite3_vtab_cursor base; /* Base class - must be first */
sqlite3_int64 iRowid; /* The rowid */
- sqlite3_int64 iPtr; /* Pointer to array of values */
+ void* pPtr; /* Pointer to the array of values */
sqlite3_int64 iCnt; /* Number of integers in the array */
unsigned char eType; /* One of the CARRAY_type values */
};
@@ -167,7 +167,7 @@ static int carrayColumn(
carray_cursor *pCur = (carray_cursor*)cur;
sqlite3_int64 x = 0;
switch( i ){
- case CARRAY_COLUMN_POINTER: x = pCur->iPtr; break;
+ case CARRAY_COLUMN_POINTER: return SQLITE_OK;
case CARRAY_COLUMN_COUNT: x = pCur->iCnt; break;
case CARRAY_COLUMN_CTYPE: {
sqlite3_result_text(ctx, azType[pCur->eType], -1, SQLITE_STATIC);
@@ -232,8 +232,8 @@ static int carrayFilter(
){
carray_cursor *pCur = (carray_cursor *)pVtabCursor;
if( idxNum ){
- pCur->iPtr = sqlite3_value_int64(argv[0]);
- pCur->iCnt = sqlite3_value_int64(argv[1]);
+ pCur->pPtr = sqlite3_value_pointer(argv[0]);
+ pCur->iCnt = pCur->pPtr ? sqlite3_value_int64(argv[1]) : 0;
if( idxNum<3 ){
pCur->eType = CARRAY_INT32;
}else{
@@ -251,7 +251,7 @@ static int carrayFilter(
}
}
}else{
- pCur->iPtr = 0;
+ pCur->pPtr = 0;
pCur->iCnt = 0;
}
pCur->iRowid = 1;
@@ -345,6 +345,34 @@ static sqlite3_module carrayModule = {
0, /* xRename */
};
+/*
+** For testing purpose in the TCL test harness, we need a method for
+** setting the pointer value. The inttoptr(X) SQL function accomplishes
+** this. Tcl script will bind an integer to X and the inttoptr() SQL
+** function will use sqlite3_result_pointer() to convert that integer into
+** a pointer.
+**
+** This is for testing on TCL only.
+*/
+#ifdef SQLITE_TEST
+static void inttoptrFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ void *p;
+ sqlite3_int64 i64;
+ i64 = sqlite3_value_int64(argv[0]);
+ if( sizeof(i64)==sizeof(p) ){
+ memcpy(&p, &i64, sizeof(p));
+ }else{
+ int i32 = i64 & 0xffffffff;
+ memcpy(&p, &i32, sizeof(p));
+ }
+ sqlite3_result_pointer(context, p);
+}
+#endif /* SQLITE_TEST */
+
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifdef _WIN32
@@ -359,6 +387,12 @@ int sqlite3_carray_init(
SQLITE_EXTENSION_INIT2(pApi);
#ifndef SQLITE_OMIT_VIRTUALTABLE
rc = sqlite3_create_module(db, "carray", &carrayModule, 0);
-#endif
+#ifdef SQLITE_TEST
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_function(db, "inttoptr", 1, SQLITE_UTF8, 0,
+ inttoptrFunc, 0, 0);
+ }
+#endif /* SQLITE_TEST */
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
return rc;
}
diff --git a/chromium/third_party/sqlite/src/ext/misc/remember.c b/chromium/third_party/sqlite/src/ext/misc/remember.c
index aa3eff8a3f8..587d44a12cd 100644
--- a/chromium/third_party/sqlite/src/ext/misc/remember.c
+++ b/chromium/third_party/sqlite/src/ext/misc/remember.c
@@ -44,11 +44,11 @@ static void rememberFunc(
sqlite3_value **argv
){
sqlite3_int64 v;
- sqlite3_int64 ptr;
+ sqlite3_int64 *ptr;
assert( argc==2 );
v = sqlite3_value_int64(argv[0]);
- ptr = sqlite3_value_int64(argv[1]);
- *((sqlite3_int64*)ptr) = v;
+ ptr = sqlite3_value_pointer(argv[1]);
+ if( ptr ) *ptr = v;
sqlite3_result_int64(pCtx, v);
}
diff --git a/chromium/third_party/sqlite/src/src/sqlite.h.in b/chromium/third_party/sqlite/src/src/sqlite.h.in
index fbbf4b9f2db..371ae5848bb 100644
--- a/chromium/third_party/sqlite/src/src/sqlite.h.in
+++ b/chromium/third_party/sqlite/src/src/sqlite.h.in
@@ -3786,6 +3786,15 @@ typedef struct sqlite3_context sqlite3_context;
** [sqlite3_blob_open | incremental BLOB I/O] routines.
** ^A negative value for the zeroblob results in a zero-length BLOB.
**
+** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
+** [prepared statement] S to have an SQL value of NULL, but to also be
+** associated with the pointer P.
+** ^The sqlite3_bind_pointer() routine can be used to pass
+** host-language pointers into [application-defined SQL functions].
+** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
+** to be an ordinary SQL NULL value to everything other than
+** [sqlite3_value_pointer()].
+**
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
** for the [prepared statement] or with a prepared statement for which
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
@@ -3819,6 +3828,7 @@ int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
@@ -4588,6 +4598,11 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
** extract UTF-16 strings as big-endian and little-endian respectively.
**
+** ^If [sqlite3_value] object V was initialized
+** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
+** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
+** sqlite3_value_pointer(V) returns a NULL.
+**
** ^(The sqlite3_value_numeric_type() interface attempts to apply
** numeric affinity to the value. This means that an attempt is
** made to convert the value to an integer or floating point. If
@@ -4615,6 +4630,7 @@ const unsigned char *sqlite3_value_text(sqlite3_value*);
const void *sqlite3_value_text16(sqlite3_value*);
const void *sqlite3_value_text16le(sqlite3_value*);
const void *sqlite3_value_text16be(sqlite3_value*);
+void *sqlite3_value_pointer(sqlite3_value*);
int sqlite3_value_type(sqlite3_value*);
int sqlite3_value_numeric_type(sqlite3_value*);
@@ -4627,10 +4643,6 @@ int sqlite3_value_numeric_type(sqlite3_value*);
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
-**
-** SQLite makes no use of subtype itself. It merely passes the subtype
-** from the result of one [application-defined SQL function] into the
-** input of another.
*/
unsigned int sqlite3_value_subtype(sqlite3_value*);
@@ -4908,6 +4920,14 @@ typedef void (*sqlite3_destructor_type)(void*);
** [unprotected sqlite3_value] object is required, so either
** kind of [sqlite3_value] object can be used with this interface.
**
+** ^The sqlite3_result_pointer(C,P) interface sets the result to an
+** SQL NULL value, just like [sqlite3_result_null(C)], except that it
+** also associates the host-language pointer P with that NULL value such
+** that the pointer can be retrieved within an
+** [application-defined SQL function] using [sqlite3_value_pointer()].
+** This mechanism can be used to pass non-SQL values between
+** application-defined functions.
+**
** If these routines are called from within the different thread
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
@@ -4931,6 +4951,7 @@ void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+void sqlite3_result_pointer(sqlite3_context*, void*);
void sqlite3_result_zeroblob(sqlite3_context*, int n);
int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
diff --git a/chromium/third_party/sqlite/src/src/vdbeInt.h b/chromium/third_party/sqlite/src/src/vdbeInt.h
index 989cdfd3461..69eab56bc57 100644
--- a/chromium/third_party/sqlite/src/src/vdbeInt.h
+++ b/chromium/third_party/sqlite/src/src/vdbeInt.h
@@ -189,6 +189,7 @@ struct Mem {
double r; /* Real value used when MEM_Real is set in flags */
i64 i; /* Integer value used when MEM_Int is set in flags */
int nZero; /* Used when bit MEM_Zero is set in flags */
+ void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */
FuncDef *pDef; /* Used only when flags==MEM_Agg */
RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
@@ -474,6 +475,7 @@ void sqlite3VdbeMemSetInt64(Mem*, i64);
#else
void sqlite3VdbeMemSetDouble(Mem*, double);
#endif
+void sqlite3VdbeMemSetPointer(Mem*, void*);
void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
void sqlite3VdbeMemSetNull(Mem*);
void sqlite3VdbeMemSetZeroBlob(Mem*,int);
diff --git a/chromium/third_party/sqlite/src/src/vdbeapi.c b/chromium/third_party/sqlite/src/src/vdbeapi.c
index 6eb97f1d1dd..c54490c077c 100644
--- a/chromium/third_party/sqlite/src/src/vdbeapi.c
+++ b/chromium/third_party/sqlite/src/src/vdbeapi.c
@@ -198,6 +198,14 @@ unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
Mem *pMem = (Mem*)pVal;
return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
}
+void *sqlite3_value_pointer(sqlite3_value *pVal){
+ Mem *p = (Mem*)pVal;
+ if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
+ return p->u.pPtr;
+ }else{
+ return 0;
+ }
+}
const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
}
@@ -376,6 +384,12 @@ void sqlite3_result_null(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetNull(pCtx->pOut);
}
+void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
+ Mem *pOut = pCtx->pOut;
+ assert( sqlite3_mutex_held(pOut->db->mutex) );
+ sqlite3VdbeMemSetNull(pOut);
+ sqlite3VdbeMemSetPointer(pOut, pPtr);
+}
void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
Mem *pOut = pCtx->pOut;
assert( sqlite3_mutex_held(pOut->db->mutex) );
@@ -1361,6 +1375,16 @@ int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
}
return rc;
}
+int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
+ int rc;
+ Vdbe *p = (Vdbe*)pStmt;
+ rc = vdbeUnbind(p, i);
+ if( rc==SQLITE_OK ){
+ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
+ sqlite3_mutex_leave(p->db->mutex);
+ }
+ return rc;
+}
int sqlite3_bind_text(
sqlite3_stmt *pStmt,
int i,
diff --git a/chromium/third_party/sqlite/src/src/vdbemem.c b/chromium/third_party/sqlite/src/src/vdbemem.c
index 656e19bfa89..2f7aedb3217 100644
--- a/chromium/third_party/sqlite/src/src/vdbemem.c
+++ b/chromium/third_party/sqlite/src/src/vdbemem.c
@@ -697,6 +697,17 @@ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
}
}
+/*
+** Set the value stored in *pMem should already be a NULL.
+** Also store a pointer to go with it.
+*/
+void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
+ assert( pMem->flags==MEM_Null );
+ pMem->flags = MEM_Null|MEM_Subtype;
+ pMem->u.pPtr = pPtr;
+ pMem->eSubtype = 'p';
+}
+
#ifndef SQLITE_OMIT_FLOATING_POINT
/*
** Delete any previous value and set the value stored in *pMem to val,
diff --git a/chromium/third_party/swiftshader/third_party/subzero/DESIGN.rst b/chromium/third_party/swiftshader/third_party/subzero/DESIGN.rst
index d0f71625a6c..363c19c6178 120000..100644
--- a/chromium/third_party/swiftshader/third_party/subzero/DESIGN.rst
+++ b/chromium/third_party/swiftshader/third_party/subzero/DESIGN.rst
@@ -1 +1,1593 @@
-docs/DESIGN.rst \ No newline at end of file
+Design of the Subzero fast code generator
+=========================================
+
+Introduction
+------------
+
+The `Portable Native Client (PNaCl) <http://gonacl.com>`_ project includes
+compiler technology based on `LLVM <http://llvm.org/>`_. The developer uses the
+PNaCl toolchain to compile their application to architecture-neutral PNaCl
+bitcode (a ``.pexe`` file), using as much architecture-neutral optimization as
+possible. The ``.pexe`` file is downloaded to the user's browser where the
+PNaCl translator (a component of Chrome) compiles the ``.pexe`` file to
+`sandboxed
+<https://developer.chrome.com/native-client/reference/sandbox_internals/index>`_
+native code. The translator uses architecture-specific optimizations as much as
+practical to generate good native code.
+
+The native code can be cached by the browser to avoid repeating translation on
+future page loads. However, first-time user experience is hampered by long
+translation times. The LLVM-based PNaCl translator is pretty slow, even when
+using ``-O0`` to minimize optimizations, so delays are especially noticeable on
+slow browser platforms such as ARM-based Chromebooks.
+
+Translator slowness can be mitigated or hidden in a number of ways.
+
+- Parallel translation. However, slow machines where this matters most, e.g.
+ ARM-based Chromebooks, are likely to have fewer cores to parallelize across,
+ and are likely to less memory available for multiple translation threads to
+ use.
+
+- Streaming translation, i.e. start translating as soon as the download starts.
+ This doesn't help much when translation speed is 10× slower than download
+ speed, or the ``.pexe`` file is already cached while the translated binary was
+ flushed from the cache.
+
+- Arrange the web page such that translation is done in parallel with
+ downloading large assets.
+
+- Arrange the web page to distract the user with `cat videos
+ <https://www.youtube.com/watch?v=tLt5rBfNucc>`_ while translation is in
+ progress.
+
+Or, improve translator performance to something more reasonable.
+
+This document describes Subzero's attempt to improve translation speed by an
+order of magnitude while rivaling LLVM's code quality. Subzero does this
+through minimal IR layering, lean data structures and passes, and a careful
+selection of fast optimization passes. It has two optimization recipes: full
+optimizations (``O2``) and minimal optimizations (``Om1``). The recipes are the
+following (described in more detail below):
+
++----------------------------------------+-----------------------------+
+| O2 recipe | Om1 recipe |
++========================================+=============================+
+| Parse .pexe file | Parse .pexe file |
++----------------------------------------+-----------------------------+
+| Loop nest analysis | |
++----------------------------------------+-----------------------------+
+| Local common subexpression elimination | |
++----------------------------------------+-----------------------------+
+| Address mode inference | |
++----------------------------------------+-----------------------------+
+| Read-modify-write (RMW) transform | |
++----------------------------------------+-----------------------------+
+| Basic liveness analysis | |
++----------------------------------------+-----------------------------+
+| Load optimization | |
++----------------------------------------+-----------------------------+
+| | Phi lowering (simple) |
++----------------------------------------+-----------------------------+
+| Target lowering | Target lowering |
++----------------------------------------+-----------------------------+
+| Full liveness analysis | |
++----------------------------------------+-----------------------------+
+| Register allocation | Minimal register allocation |
++----------------------------------------+-----------------------------+
+| Phi lowering (advanced) | |
++----------------------------------------+-----------------------------+
+| Post-phi register allocation | |
++----------------------------------------+-----------------------------+
+| Branch optimization | |
++----------------------------------------+-----------------------------+
+| Code emission | Code emission |
++----------------------------------------+-----------------------------+
+
+Goals
+=====
+
+Translation speed
+-----------------
+
+We'd like to be able to translate a ``.pexe`` file as fast as download speed.
+Any faster is in a sense wasted effort. Download speed varies greatly, but
+we'll arbitrarily say 1 MB/sec. We'll pick the ARM A15 CPU as the example of a
+slow machine. We observe a 3× single-thread performance difference between A15
+and a high-end x86 Xeon E5-2690 based workstation, and aggressively assume a
+``.pexe`` file could be compressed to 50% on the web server using gzip transport
+compression, so we set the translation speed goal to 6 MB/sec on the high-end
+Xeon workstation.
+
+Currently, at the ``-O0`` level, the LLVM-based PNaCl translation translates at
+⅒ the target rate. The ``-O2`` mode takes 3× as long as the ``-O0`` mode.
+
+In other words, Subzero's goal is to improve over LLVM's translation speed by
+10×.
+
+Code quality
+------------
+
+Subzero's initial goal is to produce code that meets or exceeds LLVM's ``-O0``
+code quality. The stretch goal is to approach LLVM ``-O2`` code quality. On
+average, LLVM ``-O2`` performs twice as well as LLVM ``-O0``.
+
+It's important to note that the quality of Subzero-generated code depends on
+target-neutral optimizations and simplifications being run beforehand in the
+developer environment. The ``.pexe`` file reflects these optimizations. For
+example, Subzero assumes that the basic blocks are ordered topologically where
+possible (which makes liveness analysis converge fastest), and Subzero does not
+do any function inlining because it should already have been done.
+
+Translator size
+---------------
+
+The current LLVM-based translator binary (``pnacl-llc``) is about 10 MB in size.
+We think 1 MB is a more reasonable size -- especially for such a component that
+is distributed to a billion Chrome users. Thus we target a 10× reduction in
+binary size.
+
+For development, Subzero can be built for all target architectures, and all
+debugging and diagnostic options enabled. For a smaller translator, we restrict
+to a single target architecture, and define a ``MINIMAL`` build where
+unnecessary features are compiled out.
+
+Subzero leverages some data structures from LLVM's ``ADT`` and ``Support``
+include directories, which have little impact on translator size. It also uses
+some of LLVM's bitcode decoding code (for binary-format ``.pexe`` files), again
+with little size impact. In non-``MINIMAL`` builds, the translator size is much
+larger due to including code for parsing text-format bitcode files and forming
+LLVM IR.
+
+Memory footprint
+----------------
+
+The current LLVM-based translator suffers from an issue in which some
+function-specific data has to be retained in memory until all translation
+completes, and therefore the memory footprint grows without bound. Large
+``.pexe`` files can lead to the translator process holding hundreds of MB of
+memory by the end. The translator runs in a separate process, so this memory
+growth doesn't *directly* affect other processes, but it does dirty the physical
+memory and contributes to a perception of bloat and sometimes a reality of
+out-of-memory tab killing, especially noticeable on weaker systems.
+
+Subzero should maintain a stable memory footprint throughout translation. It's
+not really practical to set a specific limit, because there is not really a
+practical limit on a single function's size, but the footprint should be
+"reasonable" and be proportional to the largest input function size, not the
+total ``.pexe`` file size. Simply put, Subzero should not have memory leaks or
+inexorable memory growth. (We use ASAN builds to test for leaks.)
+
+Multithreaded translation
+-------------------------
+
+It should be practical to translate different functions concurrently and see
+good scalability. Some locking may be needed, such as accessing output buffers
+or constant pools, but that should be fairly minimal. In contrast, LLVM was
+only designed for module-level parallelism, and as such, the PNaCl translator
+internally splits a ``.pexe`` file into several modules for concurrent
+translation. All output needs to be deterministic regardless of the level of
+multithreading, i.e. functions and data should always be output in the same
+order.
+
+Target architectures
+--------------------
+
+Initial target architectures are x86-32, x86-64, ARM32, and MIPS32. Future
+targets include ARM64 and MIPS64, though these targets lack NaCl support
+including a sandbox model or a validator.
+
+The first implementation is for x86-32, because it was expected to be
+particularly challenging, and thus more likely to draw out any design problems
+early:
+
+- There are a number of special cases, asymmetries, and warts in the x86
+ instruction set.
+
+- Complex addressing modes may be leveraged for better code quality.
+
+- 64-bit integer operations have to be lowered into longer sequences of 32-bit
+ operations.
+
+- Paucity of physical registers may reveal code quality issues early in the
+ design.
+
+Detailed design
+===============
+
+Intermediate representation - ICE
+---------------------------------
+
+Subzero's IR is called ICE. It is designed to be reasonably similar to LLVM's
+IR, which is reflected in the ``.pexe`` file's bitcode structure. It has a
+representation of global variables and initializers, and a set of functions.
+Each function contains a list of basic blocks, and each basic block constains a
+list of instructions. Instructions that operate on stack and register variables
+do so using static single assignment (SSA) form.
+
+The ``.pexe`` file is translated one function at a time (or in parallel by
+multiple translation threads). The recipe for optimization passes depends on
+the specific target and optimization level, and is described in detail below.
+Global variables (types and initializers) are simply and directly translated to
+object code, without any meaningful attempts at optimization.
+
+A function's control flow graph (CFG) is represented by the ``Ice::Cfg`` class.
+Its key contents include:
+
+- A list of ``CfgNode`` pointers, generally held in topological order.
+
+- A list of ``Variable`` pointers corresponding to local variables used in the
+ function plus compiler-generated temporaries.
+
+A basic block is represented by the ``Ice::CfgNode`` class. Its key contents
+include:
+
+- A linear list of instructions, in the same style as LLVM. The last
+ instruction of the list is always a terminator instruction: branch, switch,
+ return, unreachable.
+
+- A list of Phi instructions, also in the same style as LLVM. They are held as
+ a linear list for convenience, though per Phi semantics, they are executed "in
+ parallel" without dependencies on each other.
+
+- An unordered list of ``CfgNode`` pointers corresponding to incoming edges, and
+ another list for outgoing edges.
+
+- The node's unique, 0-based index into the CFG's node list.
+
+An instruction is represented by the ``Ice::Inst`` class. Its key contents
+include:
+
+- A list of source operands.
+
+- Its destination variable, if the instruction produces a result in an
+ ``Ice::Variable``.
+
+- A bitvector indicating which variables' live ranges this instruction ends.
+ This is computed during liveness analysis.
+
+Instructions kinds are divided into high-level ICE instructions and low-level
+ICE instructions. High-level instructions consist of the PNaCl/LLVM bitcode
+instruction kinds. Each target architecture implementation extends the
+instruction space with its own set of low-level instructions. Generally,
+low-level instructions correspond to individual machine instructions. The
+high-level ICE instruction space includes a few additional instruction kinds
+that are not part of LLVM but are generally useful (e.g., an Assignment
+instruction), or are useful across targets (e.g., BundleLock and BundleUnlock
+instructions for sandboxing).
+
+Specifically, high-level ICE instructions that derive from LLVM (but with PNaCl
+ABI restrictions as documented in the `PNaCl Bitcode Reference Manual
+<https://developer.chrome.com/native-client/reference/pnacl-bitcode-abi>`_) are
+the following:
+
+- Alloca: allocate data on the stack
+
+- Arithmetic: binary operations of the form ``A = B op C``
+
+- Br: conditional or unconditional branch
+
+- Call: function call
+
+- Cast: unary type-conversion operations
+
+- ExtractElement: extract a scalar element from a vector-type value
+
+- Fcmp: floating-point comparison
+
+- Icmp: integer comparison
+
+- IntrinsicCall: call a known intrinsic
+
+- InsertElement: insert a scalar element into a vector-type value
+
+- Load: load a value from memory
+
+- Phi: implement the SSA phi node
+
+- Ret: return from the function
+
+- Select: essentially the C language operation of the form ``X = C ? Y : Z``
+
+- Store: store a value into memory
+
+- Switch: generalized branch to multiple possible locations
+
+- Unreachable: indicate that this portion of the code is unreachable
+
+The additional high-level ICE instructions are the following:
+
+- Assign: a simple ``A=B`` assignment. This is useful for e.g. lowering Phi
+ instructions to non-SSA assignments, before lowering to machine code.
+
+- BundleLock, BundleUnlock. These are markers used for sandboxing, but are
+ common across all targets and so they are elevated to the high-level
+ instruction set.
+
+- FakeDef, FakeUse, FakeKill. These are tools used to preserve consistency in
+ liveness analysis, elevated to the high-level because they are used by all
+ targets. They are described in more detail at the end of this section.
+
+- JumpTable: this represents the result of switch optimization analysis, where
+ some switch instructions may use jump tables instead of cascading
+ compare/branches.
+
+An operand is represented by the ``Ice::Operand`` class. In high-level ICE, an
+operand is either an ``Ice::Constant`` or an ``Ice::Variable``. Constants
+include scalar integer constants, scalar floating point constants, Undef (an
+unspecified constant of a particular scalar or vector type), and symbol
+constants (essentially addresses of globals). Note that the PNaCl ABI does not
+include vector-type constants besides Undef, and as such, Subzero (so far) has
+no reason to represent vector-type constants internally. A variable represents
+a value allocated on the stack (though not including alloca-derived storage).
+Among other things, a variable holds its unique, 0-based index into the CFG's
+variable list.
+
+Each target can extend the ``Constant`` and ``Variable`` classes for its own
+needs. In addition, the ``Operand`` class may be extended, e.g. to define an
+x86 ``MemOperand`` that encodes a base register, an index register, an index
+register shift amount, and a constant offset.
+
+Register allocation and liveness analysis are restricted to Variable operands.
+Because of the importance of register allocation to code quality, and the
+translation-time cost of liveness analysis, Variable operands get some special
+treatment in ICE. Most notably, a frequent pattern in Subzero is to iterate
+across all the Variables of an instruction. An instruction holds a list of
+operands, but an operand may contain 0, 1, or more Variables. As such, the
+``Operand`` class specially holds a list of Variables contained within, for
+quick access.
+
+A Subzero transformation pass may work by deleting an existing instruction and
+replacing it with zero or more new instructions. Instead of actually deleting
+the existing instruction, we generally mark it as deleted and insert the new
+instructions right after the deleted instruction. When printing the IR for
+debugging, this is a big help because it makes it much more clear how the
+non-deleted instructions came about.
+
+Subzero has a few special instructions to help with liveness analysis
+consistency.
+
+- The FakeDef instruction gives a fake definition of some variable. For
+ example, on x86-32, a divide instruction defines both ``%eax`` and ``%edx``
+ but an ICE instruction can represent only one destination variable. This is
+ similar for multiply instructions, and for function calls that return a 64-bit
+ integer result in the ``%edx:%eax`` pair. Also, using the ``xor %eax, %eax``
+ trick to set ``%eax`` to 0 requires an initial FakeDef of ``%eax``.
+
+- The FakeUse instruction registers a use of a variable, typically to prevent an
+ earlier assignment to that variable from being dead-code eliminated. For
+ example, lowering an operation like ``x=cc?y:z`` may be done using x86's
+ conditional move (cmov) instruction: ``mov z, x; cmov_cc y, x``. Without a
+ FakeUse of ``x`` between the two instructions, the liveness analysis pass may
+ dead-code eliminate the first instruction.
+
+- The FakeKill instruction is added after a call instruction, and is a quick way
+ of indicating that caller-save registers are invalidated.
+
+Pexe parsing
+------------
+
+Subzero includes an integrated PNaCl bitcode parser for ``.pexe`` files. It
+parses the ``.pexe`` file function by function, ultimately constructing an ICE
+CFG for each function. After a function is parsed, its CFG is handed off to the
+translation phase. The bitcode parser also parses global initializer data and
+hands it off to be translated to data sections in the object file.
+
+Subzero has another parsing strategy for testing/debugging. LLVM libraries can
+be used to parse a module into LLVM IR (though very slowly relative to Subzero
+native parsing). Then we iterate across the LLVM IR and construct high-level
+ICE, handing off each CFG to the translation phase.
+
+Overview of lowering
+--------------------
+
+In general, translation goes like this:
+
+- Parse the next function from the ``.pexe`` file and construct a CFG consisting
+ of high-level ICE.
+
+- Do analysis passes and transformation passes on the high-level ICE, as
+ desired.
+
+- Lower each high-level ICE instruction into a sequence of zero or more
+ low-level ICE instructions. Each high-level instruction is generally lowered
+ independently, though the target lowering is allowed to look ahead in the
+ CfgNode's instruction list if desired.
+
+- Do more analysis and transformation passes on the low-level ICE, as desired.
+
+- Assemble the low-level CFG into an ELF object file (alternatively, a textual
+ assembly file that is later assembled by some external tool).
+
+- Repeat for all functions, and also produce object code for data such as global
+ initializers and internal constant pools.
+
+Currently there are two optimization levels: ``O2`` and ``Om1``. For ``O2``,
+the intention is to apply all available optimizations to get the best code
+quality (though the initial code quality goal is measured against LLVM's ``O0``
+code quality). For ``Om1``, the intention is to apply as few optimizations as
+possible and produce code as quickly as possible, accepting poor code quality.
+``Om1`` is short for "O-minus-one", i.e. "worse than O0", or in other words,
+"sub-zero".
+
+High-level debuggability of generated code is so far not a design requirement.
+Subzero doesn't really do transformations that would obfuscate debugging; the
+main thing might be that register allocation (including stack slot coalescing
+for stack-allocated variables whose live ranges don't overlap) may render a
+variable's value unobtainable after its live range ends. This would not be an
+issue for ``Om1`` since it doesn't register-allocate program-level variables,
+nor does it coalesce stack slots. That said, fully supporting debuggability
+would require a few additions:
+
+- DWARF support would need to be added to Subzero's ELF file emitter. Subzero
+ propagates global symbol names, local variable names, and function-internal
+ label names that are present in the ``.pexe`` file. This would allow a
+ debugger to map addresses back to symbols in the ``.pexe`` file.
+
+- To map ``.pexe`` file symbols back to meaningful source-level symbol names,
+ file names, line numbers, etc., Subzero would need to handle `LLVM bitcode
+ metadata <http://llvm.org/docs/LangRef.html#metadata>`_ and ``llvm.dbg``
+ `instrinsics<http://llvm.org/docs/LangRef.html#dbg-intrinsics>`_.
+
+- The PNaCl toolchain explicitly strips all this from the ``.pexe`` file, and so
+ the toolchain would need to be modified to preserve it.
+
+Our experience so far is that ``Om1`` translates twice as fast as ``O2``, but
+produces code with one third the code quality. ``Om1`` is good for testing and
+debugging -- during translation, it tends to expose errors in the basic lowering
+that might otherwise have been hidden by the register allocator or other
+optimization passes. It also helps determine whether a code correctness problem
+is a fundamental problem in the basic lowering, or an error in another
+optimization pass.
+
+The implementation of target lowering also controls the recipe of passes used
+for ``Om1`` and ``O2`` translation. For example, address mode inference may
+only be relevant for x86.
+
+Lowering strategy
+-----------------
+
+The core of Subzero's lowering from high-level ICE to low-level ICE is to lower
+each high-level instruction down to a sequence of low-level target-specific
+instructions, in a largely context-free setting. That is, each high-level
+instruction conceptually has a simple template expansion into low-level
+instructions, and lowering can in theory be done in any order. This may sound
+like a small effort, but quite a large number of templates may be needed because
+of the number of PNaCl types and instruction variants. Furthermore, there may
+be optimized templates, e.g. to take advantage of operator commutativity (for
+example, ``x=x+1`` might allow a bettern lowering than ``x=1+x``). This is
+similar to other template-based approaches in fast code generation or
+interpretation, though some decisions are deferred until after some global
+analysis passes, mostly related to register allocation, stack slot assignment,
+and specific choice of instruction variant and addressing mode.
+
+The key idea for a lowering template is to produce valid low-level instructions
+that are guaranteed to meet address mode and other structural requirements of
+the instruction set. For example, on x86, the source operand of an integer
+store instruction must be an immediate or a physical register; a shift
+instruction's shift amount must be an immediate or in register ``%cl``; a
+function's integer return value is in ``%eax``; most x86 instructions are
+two-operand, in contrast to corresponding three-operand high-level instructions;
+etc.
+
+Because target lowering runs before register allocation, there is no way to know
+whether a given ``Ice::Variable`` operand lives on the stack or in a physical
+register. When the low-level instruction calls for a physical register operand,
+the target lowering can create an infinite-weight Variable. This tells the
+register allocator to assign infinite weight when making decisions, effectively
+guaranteeing some physical register. Variables can also be pre-colored to a
+specific physical register (``cl`` in the shift example above), which also gives
+infinite weight.
+
+To illustrate, consider a high-level arithmetic instruction on 32-bit integer
+operands::
+
+ A = B + C
+
+X86 target lowering might produce the following::
+
+ T.inf = B // mov instruction
+ T.inf += C // add instruction
+ A = T.inf // mov instruction
+
+Here, ``T.inf`` is an infinite-weight temporary. As long as ``T.inf`` has a
+physical register, the three lowered instructions are all encodable regardless
+of whether ``B`` and ``C`` are physical registers, memory, or immediates, and
+whether ``A`` is a physical register or in memory.
+
+In this example, ``A`` must be a Variable and one may be tempted to simplify the
+lowering sequence by setting ``A`` as infinite-weight and using::
+
+ A = B // mov instruction
+ A += C // add instruction
+
+This has two problems. First, if the original instruction was actually ``A =
+B + A``, the result would be incorrect. Second, assigning ``A`` a physical
+register applies throughout ``A``'s entire live range. This is probably not
+what is intended, and may ultimately lead to a failure to allocate a register
+for an infinite-weight variable.
+
+This style of lowering leads to many temporaries being generated, so in ``O2``
+mode, we rely on the register allocator to clean things up. For example, in the
+example above, if ``B`` ends up getting a physical register and its live range
+ends at this instruction, the register allocator is likely to reuse that
+register for ``T.inf``. This leads to ``T.inf=B`` being a redundant register
+copy, which is removed as an emission-time peephole optimization.
+
+O2 lowering
+-----------
+
+Currently, the ``O2`` lowering recipe is the following:
+
+- Loop nest analysis
+
+- Local common subexpression elimination
+
+- Address mode inference
+
+- Read-modify-write (RMW) transformation
+
+- Basic liveness analysis
+
+- Load optimization
+
+- Target lowering
+
+- Full liveness analysis
+
+- Register allocation
+
+- Phi instruction lowering (advanced)
+
+- Post-phi lowering register allocation
+
+- Branch optimization
+
+These passes are described in more detail below.
+
+Om1 lowering
+------------
+
+Currently, the ``Om1`` lowering recipe is the following:
+
+- Phi instruction lowering (simple)
+
+- Target lowering
+
+- Register allocation (infinite-weight and pre-colored only)
+
+Optimization passes
+-------------------
+
+Liveness analysis
+^^^^^^^^^^^^^^^^^
+
+Liveness analysis is a standard dataflow optimization, implemented as follows.
+For each node (basic block), its live-out set is computed as the union of the
+live-in sets of its successor nodes. Then the node's instructions are processed
+in reverse order, updating the live set, until the beginning of the node is
+reached, and the node's live-in set is recorded. If this iteration has changed
+the node's live-in set, the node's predecessors are marked for reprocessing.
+This continues until no more nodes need reprocessing. If nodes are processed in
+reverse topological order, the number of iterations over the CFG is generally
+equal to the maximum loop nest depth.
+
+To implement this, each node records its live-in and live-out sets, initialized
+to the empty set. Each instruction records which of its Variables' live ranges
+end in that instruction, initialized to the empty set. A side effect of
+liveness analysis is dead instruction elimination. Each instruction can be
+marked as tentatively dead, and after the algorithm converges, the tentatively
+dead instructions are permanently deleted.
+
+Optionally, after this liveness analysis completes, we can do live range
+construction, in which we calculate the live range of each variable in terms of
+instruction numbers. A live range is represented as a union of segments, where
+the segment endpoints are instruction numbers. Instruction numbers are required
+to be unique across the CFG, and monotonically increasing within a basic block.
+As a union of segments, live ranges can contain "gaps" and are therefore
+precise. Because of SSA properties, a variable's live range can start at most
+once in a basic block, and can end at most once in a basic block. Liveness
+analysis keeps track of which variable/instruction tuples begin live ranges and
+end live ranges, and combined with live-in and live-out sets, we can efficiently
+build up live ranges of all variables across all basic blocks.
+
+A lot of care is taken to try to make liveness analysis fast and efficient.
+Because of the lowering strategy, the number of variables is generally
+proportional to the number of instructions, leading to an O(N^2) complexity
+algorithm if implemented naively. To improve things based on sparsity, we note
+that most variables are "local" and referenced in at most one basic block (in
+contrast to the "global" variables with multi-block usage), and therefore cannot
+be live across basic blocks. Therefore, the live-in and live-out sets,
+typically represented as bit vectors, can be limited to the set of global
+variables, and the intra-block liveness bit vector can be compacted to hold the
+global variables plus the local variables for that block.
+
+Register allocation
+^^^^^^^^^^^^^^^^^^^
+
+Subzero implements a simple linear-scan register allocator, based on the
+allocator described by Hanspeter Mössenböck and Michael Pfeiffer in `Linear Scan
+Register Allocation in the Context of SSA Form and Register Constraints
+<ftp://ftp.ssw.uni-linz.ac.at/pub/Papers/Moe02.PDF>`_. This allocator has
+several nice features:
+
+- Live ranges are represented as unions of segments, as described above, rather
+ than a single start/end tuple.
+
+- It allows pre-coloring of variables with specific physical registers.
+
+- It applies equally well to pre-lowered Phi instructions.
+
+The paper suggests an approach of aggressively coalescing variables across Phi
+instructions (i.e., trying to force Phi source and destination variables to have
+the same register assignment), but we reject that in favor of the more natural
+preference mechanism described below.
+
+We enhance the algorithm in the paper with the capability of automatic inference
+of register preference, and with the capability of allowing overlapping live
+ranges to safely share the same register in certain circumstances. If we are
+considering register allocation for variable ``A``, and ``A`` has a single
+defining instruction ``A=B+C``, then the preferred register for ``A``, if
+available, would be the register assigned to ``B`` or ``C``, if any, provided
+that ``B`` or ``C``'s live range does not overlap ``A``'s live range. In this
+way we infer a good register preference for ``A``.
+
+We allow overlapping live ranges to get the same register in certain cases.
+Suppose a high-level instruction like::
+
+ A = unary_op(B)
+
+has been target-lowered like::
+
+ T.inf = B
+ A = unary_op(T.inf)
+
+Further, assume that ``B``'s live range continues beyond this instruction
+sequence, and that ``B`` has already been assigned some register. Normally, we
+might want to infer ``B``'s register as a good candidate for ``T.inf``, but it
+turns out that ``T.inf`` and ``B``'s live ranges overlap, requiring them to have
+different registers. But ``T.inf`` is just a read-only copy of ``B`` that is
+guaranteed to be in a register, so in theory these overlapping live ranges could
+safely have the same register. Our implementation allows this overlap as long
+as ``T.inf`` is never modified within ``B``'s live range, and ``B`` is never
+modified within ``T.inf``'s live range.
+
+Subzero's register allocator can be run in 3 configurations.
+
+- Normal mode. All Variables are considered for register allocation. It
+ requires full liveness analysis and live range construction as a prerequisite.
+ This is used by ``O2`` lowering.
+
+- Minimal mode. Only infinite-weight or pre-colored Variables are considered.
+ All other Variables are stack-allocated. It does not require liveness
+ analysis; instead, it quickly scans the instructions and records first
+ definitions and last uses of all relevant Variables, using that to construct a
+ single-segment live range. Although this includes most of the Variables, the
+ live ranges are mostly simple, short, and rarely overlapping, which the
+ register allocator handles efficiently. This is used by ``Om1`` lowering.
+
+- Post-phi lowering mode. Advanced phi lowering is done after normal-mode
+ register allocation, and may result in new infinite-weight Variables that need
+ registers. One would like to just run something like minimal mode to assign
+ registers to the new Variables while respecting existing register allocation
+ decisions. However, it sometimes happens that there are no free registers.
+ In this case, some register needs to be forcibly spilled to the stack and
+ temporarily reassigned to the new Variable, and reloaded at the end of the new
+ Variable's live range. The register must be one that has no explicit
+ references during the Variable's live range. Since Subzero currently doesn't
+ track def/use chains (though it does record the CfgNode where a Variable is
+ defined), we just do a brute-force search across the CfgNode's instruction
+ list for the instruction numbers of interest. This situation happens very
+ rarely, so there's little point for now in improving its performance.
+
+The basic linear-scan algorithm may, as it proceeds, rescind an early register
+allocation decision, leaving that Variable to be stack-allocated. Some of these
+times, it turns out that the Variable could have been given a different register
+without conflict, but by this time it's too late. The literature recognizes
+this situation and describes "second-chance bin-packing", which Subzero can do.
+We can rerun the register allocator in a mode that respects existing register
+allocation decisions, and sometimes it finds new non-conflicting opportunities.
+In fact, we can repeatedly run the register allocator until convergence.
+Unfortunately, in the current implementation, these subsequent register
+allocation passes end up being extremely expensive. This is because of the
+treatment of the "unhandled pre-colored" Variable set, which is normally very
+small but ends up being quite large on subsequent passes. Its performance can
+probably be made acceptable with a better choice of data structures, but for now
+this second-chance mechanism is disabled.
+
+Future work is to implement LLVM's `Greedy
+<http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html>`_
+register allocator as a replacement for the basic linear-scan algorithm, given
+LLVM's experience with its improvement in code quality. (The blog post claims
+that the Greedy allocator also improved maintainability because a lot of hacks
+could be removed, but Subzero is probably not yet to that level of hacks, and is
+less likely to see that particular benefit.)
+
+Local common subexpression elimination
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The Local CSE implementation goes through each instruction and records a portion
+of each ``Seen`` instruction in a hashset-like container. That portion consists
+of the entire instruction except for any dest variable. That means ``A = X + Y``
+and ``B = X + Y`` will be considered to be 'equal' for this purpose. This allows
+us to detect common subexpressions.
+
+Whenever a repetition is detected, the redundant variables are stored in a
+container mapping the replacee to the replacement. In the case above, it would
+be ``MAP[B] = A`` assuming ``B = X + Y`` comes after ``A = X + Y``.
+
+At any point if a variable that has an entry in the replacement table is
+encountered, it is replaced with the variable it is mapped to. This ensures that
+the redundant variables will not have any uses in the basic block, allowing
+dead code elimination to clean up the redundant instruction.
+
+With SSA, the information stored is never invalidated. However, non-SSA input is
+supported with the ``-lcse=no-ssa`` option. This has to maintain some extra
+dependency information to ensure proper invalidation on variable assignment.
+This is not rigorously tested because this pass is run at an early stage where
+it is safe to assume variables have a single definition. This is not enabled by
+default because it bumps the compile time overhead from 2% to 6%.
+
+Loop-invariant code motion
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This pass utilizes the loop analysis information to hoist invariant instructions
+to loop pre-headers. A loop must have a single entry node (header) and that node
+must have a single external predecessor for this optimization to work, as it is
+currently implemented.
+
+The pass works by iterating over all instructions in the loop until the set of
+invariant instructions converges. In each iteration, a non-invariant instruction
+involving only constants or a variable known to be invariant is added to the
+result set. The destination variable of that instruction is added to the set of
+variables known to be invariant (which is initialized with the constant args).
+
+Improving the loop-analysis infrastructure is likely to have significant impact
+on this optimization. Inserting an extra node to act as the pre-header when the
+header has multiple incoming edges from outside could also be a good idea.
+Expanding the initial invariant variable set to contain all variables that do
+not have definitions inside the loop does not seem to improve anything.
+
+Short circuit evaluation
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Short circuit evaluation splits nodes and introduces early jumps when the result
+of a logical operation can be determined early and there are no observable side
+effects of skipping the rest of the computation. The instructions considered
+backwards from the end of the basic blocks. When a definition of a variable
+involved in a conditional jump is found, an extra jump can be inserted in that
+location, moving the rest of the instructions in the node to a newly inserted
+node. Consider this example::
+
+ __N :
+ a = <something>
+ Instruction 1 without side effect
+ ... b = <something> ...
+ Instruction N without side effect
+ t1 = or a b
+ br t1 __X __Y
+
+is transformed to::
+
+ __N :
+ a = <something>
+ br a __X __N_ext
+
+ __N_ext :
+ Instruction 1 without side effect
+ ... b = <something> ...
+ Instruction N without side effect
+ br b __X __Y
+
+The logic for AND is analogous, the only difference is that the early jump is
+facilitated by a ``false`` value instead of ``true``.
+
+Global Variable Splitting
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Global variable splitting (``-split-global-vars``) is run after register
+allocation. It works on the variables that did not manage to get registers (but
+are allowed to) and decomposes their live ranges into the individual segments
+(which span a single node at most). New variables are created (but not yet used)
+with these smaller live ranges and the register allocator is run again. This is
+not inefficient as the old variables that already had registers are now
+considered pre-colored.
+
+The new variables that get registers replace their parent variables for their
+portion of its (parent's) live range. A copy from the old variable to the new
+is introduced before the first use and the reverse after the last def in the
+live range.
+
+Basic phi lowering
+^^^^^^^^^^^^^^^^^^
+
+The simplest phi lowering strategy works as follows (this is how LLVM ``-O0``
+implements it). Consider this example::
+
+ L1:
+ ...
+ br L3
+ L2:
+ ...
+ br L3
+ L3:
+ A = phi [B, L1], [C, L2]
+ X = phi [Y, L1], [Z, L2]
+
+For each destination of a phi instruction, we can create a temporary and insert
+the temporary's assignment at the end of the predecessor block::
+
+ L1:
+ ...
+ A' = B
+ X' = Y
+ br L3
+ L2:
+ ...
+ A' = C
+ X' = Z
+ br L3
+ L2:
+ A = A'
+ X = X'
+
+This transformation is very simple and reliable. It can be done before target
+lowering and register allocation, and it easily avoids the classic lost-copy and
+related problems. ``Om1`` lowering uses this strategy.
+
+However, it has the disadvantage of initializing temporaries even for branches
+not taken, though that could be mitigated by splitting non-critical edges and
+putting assignments in the edge-split nodes. Another problem is that without
+extra machinery, the assignments to ``A``, ``A'``, ``X``, and ``X'`` are given a
+specific ordering even though phi semantics are that the assignments are
+parallel or unordered. This sometimes imposes false live range overlaps and
+leads to poorer register allocation.
+
+Advanced phi lowering
+^^^^^^^^^^^^^^^^^^^^^
+
+``O2`` lowering defers phi lowering until after register allocation to avoid the
+problem of false live range overlaps. It works as follows. We split each
+incoming edge and move the (parallel) phi assignments into the split nodes. We
+linearize each set of assignments by finding a safe, topological ordering of the
+assignments, respecting register assignments as well. For example::
+
+ A = B
+ X = Y
+
+Normally these assignments could be executed in either order, but if ``B`` and
+``X`` are assigned the same physical register, we would want to use the above
+ordering. Dependency cycles are broken by introducing a temporary. For
+example::
+
+ A = B
+ B = A
+
+Here, a temporary breaks the cycle::
+
+ t = A
+ A = B
+ B = t
+
+Finally, we use the existing target lowering to lower the assignments in this
+basic block, and once that is done for all basic blocks, we run the post-phi
+variant of register allocation on the edge-split basic blocks.
+
+When computing a topological order, we try to first schedule assignments whose
+source has a physical register, and last schedule assignments whose destination
+has a physical register. This helps reduce register pressure.
+
+X86 address mode inference
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+We try to take advantage of the x86 addressing mode that includes a base
+register, an index register, an index register scale amount, and an immediate
+offset. We do this through simple pattern matching. Starting with a load or
+store instruction where the address is a variable, we initialize the base
+register to that variable, and look up the instruction where that variable is
+defined. If that is an add instruction of two variables and the index register
+hasn't been set, we replace the base and index register with those two
+variables. If instead it is an add instruction of a variable and a constant, we
+replace the base register with the variable and add the constant to the
+immediate offset.
+
+There are several more patterns that can be matched. This pattern matching
+continues on the load or store instruction until no more matches are found.
+Because a program typically has few load and store instructions (not to be
+confused with instructions that manipulate stack variables), this address mode
+inference pass is fast.
+
+X86 read-modify-write inference
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A reasonably common bitcode pattern is a non-atomic update of a memory
+location::
+
+ x = load addr
+ y = add x, 1
+ store y, addr
+
+On x86, with good register allocation, the Subzero passes described above
+generate code with only this quality::
+
+ mov [%ebx], %eax
+ add $1, %eax
+ mov %eax, [%ebx]
+
+However, x86 allows for this kind of code::
+
+ add $1, [%ebx]
+
+which requires fewer instructions, but perhaps more importantly, requires fewer
+physical registers.
+
+It's also important to note that this transformation only makes sense if the
+store instruction ends ``x``'s live range.
+
+Subzero's ``O2`` recipe includes an early pass to find read-modify-write (RMW)
+opportunities via simple pattern matching. The only problem is that it is run
+before liveness analysis, which is needed to determine whether ``x``'s live
+range ends after the RMW. Since liveness analysis is one of the most expensive
+passes, it's not attractive to run it an extra time just for RMW analysis.
+Instead, we essentially generate both the RMW and the non-RMW versions, and then
+during lowering, the RMW version deletes itself if it finds x still live.
+
+X86 compare-branch inference
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In the LLVM instruction set, the compare/branch pattern works like this::
+
+ cond = icmp eq a, b
+ br cond, target
+
+The result of the icmp instruction is a single bit, and a conditional branch
+tests that bit. By contrast, most target architectures use this pattern::
+
+ cmp a, b // implicitly sets various bits of FLAGS register
+ br eq, target // branch on a particular FLAGS bit
+
+A naive lowering sequence conditionally sets ``cond`` to 0 or 1, then tests
+``cond`` and conditionally branches. Subzero has a pass that identifies
+boolean-based operations like this and folds them into a single
+compare/branch-like operation. It is set up for more than just cmp/br though.
+Boolean producers include icmp (integer compare), fcmp (floating-point compare),
+and trunc (integer truncation when the destination has bool type). Boolean
+consumers include branch, select (the ternary operator from the C language), and
+sign-extend and zero-extend when the source has bool type.
+
+Sandboxing
+^^^^^^^^^^
+
+Native Client's sandbox model uses software fault isolation (SFI) to provide
+safety when running untrusted code in a browser or other environment. Subzero
+implements Native Client's `sandboxing
+<https://developer.chrome.com/native-client/reference/sandbox_internals/index>`_
+to enable Subzero-translated executables to be run inside Chrome. Subzero also
+provides a fairly simple framework for investigating alternative sandbox models
+or other restrictions on the sandbox model.
+
+Sandboxing in Subzero is not actually implemented as a separate pass, but is
+integrated into lowering and assembly.
+
+- Indirect branches, including the ret instruction, are masked to a bundle
+ boundary and bundle-locked.
+
+- Call instructions are aligned to the end of the bundle so that the return
+ address is bundle-aligned.
+
+- Indirect branch targets, including function entry and targets in a switch
+ statement jump table, are bundle-aligned.
+
+- The intrinsic for reading the thread pointer is inlined appropriately.
+
+- For x86-64, non-stack memory accesses are with respect to the reserved sandbox
+ base register. We reduce the aggressiveness of address mode inference to
+ leave room for the sandbox base register during lowering. There are no memory
+ sandboxing changes for x86-32.
+
+Code emission
+-------------
+
+Subzero's integrated assembler is derived from Dart's `assembler code
+<https://github.com/dart-lang/sdk/tree/master/runtime/vm>'_. There is a pass
+that iterates through the low-level ICE instructions and invokes the relevant
+assembler functions. Placeholders are added for later fixup of branch target
+offsets. (Backward branches use short offsets if possible; forward branches
+generally use long offsets unless it is an intra-block branch of "known" short
+length.) The assembler emits into a staging buffer. Once emission into the
+staging buffer for a function is complete, the data is emitted to the output
+file as an ELF object file, and metadata such as relocations, symbol table, and
+string table, are accumulated for emission at the end. Global data initializers
+are emitted similarly. A key point is that at this point, the staging buffer
+can be deallocated, and only a minimum of data needs to held until the end.
+
+As a debugging alternative, Subzero can emit textual assembly code which can
+then be run through an external assembler. This is of course super slow, but
+quite valuable when bringing up a new target.
+
+As another debugging option, the staging buffer can be emitted as textual
+assembly, primarily in the form of ".byte" lines. This allows the assembler to
+be tested separately from the ELF related code.
+
+Memory management
+-----------------
+
+Where possible, we allocate from a ``CfgLocalAllocator`` which derives from
+LLVM's ``BumpPtrAllocator``. This is an arena-style allocator where objects
+allocated from the arena are never actually freed; instead, when the CFG
+translation completes and the CFG is deleted, the entire arena memory is
+reclaimed at once. This style of allocation works well in an environment like a
+compiler where there are distinct phases with only easily-identifiable objects
+living across phases. It frees the developer from having to manage object
+deletion, and it amortizes deletion costs across just a single arena deletion at
+the end of the phase. Furthermore, it helps scalability by allocating entirely
+from thread-local memory pools, and minimizing global locking of the heap.
+
+Instructions are probably the most heavily allocated complex class in Subzero.
+We represent an instruction list as an intrusive doubly linked list, allocate
+all instructions from the ``CfgLocalAllocator``, and we make sure each
+instruction subclass is basically `POD
+<http://en.cppreference.com/w/cpp/concept/PODType>`_ (Plain Old Data) with a
+trivial destructor. This way, when the CFG is finished, we don't need to
+individually deallocate every instruction. We do similar for Variables, which
+is probably the second most popular complex class.
+
+There are some situations where passes need to use some `STL container class
+<http://en.cppreference.com/w/cpp/container>`_. Subzero has a way of using the
+``CfgLocalAllocator`` as the container allocator if this is needed.
+
+Multithreaded translation
+-------------------------
+
+Subzero is designed to be able to translate functions in parallel. With the
+``-threads=N`` command-line option, there is a 3-stage producer-consumer
+pipeline:
+
+- A single thread parses the ``.pexe`` file and produces a sequence of work
+ units. A work unit can be either a fully constructed CFG, or a set of global
+ initializers. The work unit includes its sequence number denoting its parse
+ order. Each work unit is added to the translation queue.
+
+- There are N translation threads that draw work units from the translation
+ queue and lower them into assembler buffers. Each assembler buffer is added
+ to the emitter queue, tagged with its sequence number. The CFG and its
+ ``CfgLocalAllocator`` are disposed of at this point.
+
+- A single thread draws assembler buffers from the emitter queue and appends to
+ the output file. It uses the sequence numbers to reintegrate the assembler
+ buffers according to the original parse order, such that output order is
+ always deterministic.
+
+This means that with ``-threads=N``, there are actually ``N+1`` spawned threads
+for a total of ``N+2`` execution threads, taking the parser and emitter threads
+into account. For the special case of ``N=0``, execution is entirely sequential
+-- the same thread parses, translates, and emits, one function at a time. This
+is useful for performance measurements.
+
+Ideally, we would like to get near-linear scalability as the number of
+translation threads increases. We expect that ``-threads=1`` should be slightly
+faster than ``-threads=0`` as the small amount of time spent parsing and
+emitting is done largely in parallel with translation. With perfect
+scalability, we see ``-threads=N`` translating ``N`` times as fast as
+``-threads=1``, up until the point where parsing or emitting becomes the
+bottleneck, or ``N+2`` exceeds the number of CPU cores. In reality, memory
+performance would become a bottleneck and efficiency might peak at, say, 75%.
+
+Currently, parsing takes about 11% of total sequential time. If translation
+scalability ever gets so fast and awesomely scalable that parsing becomes a
+bottleneck, it should be possible to make parsing multithreaded as well.
+
+Internally, all shared, mutable data is held in the GlobalContext object, and
+access to each field is guarded by a mutex.
+
+Security
+--------
+
+Subzero includes a number of security features in the generated code, as well as
+in the Subzero translator itself, which run on top of the existing Native Client
+sandbox as well as Chrome's OS-level sandbox.
+
+Sandboxed translator
+^^^^^^^^^^^^^^^^^^^^
+
+When running inside the browser, the Subzero translator executes as sandboxed,
+untrusted code that is initially checked by the validator, just like the
+LLVM-based ``pnacl-llc`` translator. As such, the Subzero binary should be no
+more or less secure than the translator it replaces, from the point of view of
+the Chrome sandbox. That said, Subzero is much smaller than ``pnacl-llc`` and
+was designed from the start with security in mind, so one expects fewer attacker
+opportunities here.
+
+Code diversification
+^^^^^^^^^^^^^^^^^^^^
+
+`Return-oriented programming
+<https://en.wikipedia.org/wiki/Return-oriented_programming>`_ (ROP) is a
+now-common technique for starting with e.g. a known buffer overflow situation
+and launching it into a deeper exploit. The attacker scans the executable
+looking for ROP gadgets, which are short sequences of code that happen to load
+known values into known registers and then return. An attacker who manages to
+overwrite parts of the stack can overwrite it with carefully chosen return
+addresses such that certain ROP gadgets are effectively chained together to set
+up the register state as desired, finally returning to some code that manages to
+do something nasty based on those register values.
+
+If there is a popular ``.pexe`` with a large install base, the attacker could
+run Subzero on it and scan the executable for suitable ROP gadgets to use as
+part of a potential exploit. Note that if the trusted validator is working
+correctly, these ROP gadgets are limited to starting at a bundle boundary and
+cannot use the trick of finding a gadget that happens to begin inside another
+instruction. All the same, gadgets with these constraints still exist and the
+attacker has access to them. This is the attack model we focus most on --
+protecting the user against misuse of a "trusted" developer's application, as
+opposed to mischief from a malicious ``.pexe`` file.
+
+Subzero can mitigate these attacks to some degree through code diversification.
+Specifically, we can apply some randomness to the code generation that makes ROP
+gadgets less predictable. This randomness can have some compile-time cost, and
+it can affect the code quality; and some diversifications may be more effective
+than others. A more detailed treatment of hardening techniques may be found in
+the Matasano report "`Attacking Clientside JIT Compilers
+<https://www.nccgroup.trust/globalassets/resources/us/presentations/documents/attacking_clientside_jit_compilers_paper.pdf>`_".
+
+To evaluate diversification effectiveness, we use a third-party ROP gadget
+finder and limit its results to bundle-aligned addresses. For a given
+diversification technique, we run it with a number of different random seeds,
+find ROP gadgets for each version, and determine how persistent each ROP gadget
+is across the different versions. A gadget is persistent if the same gadget is
+found at the same code address. The best diversifications are ones with low
+gadget persistence rates.
+
+Subzero implements 7 different diversification techniques. Below is a
+discussion of each technique, its effectiveness, and its cost. The discussions
+of cost and effectiveness are for a single diversification technique; the
+translation-time costs for multiple techniques are additive, but the effects of
+multiple techniques on code quality and effectiveness are not yet known.
+
+In Subzero's implementation, each randomization is "repeatable" in a sense.
+Each pass that includes a randomization option gets its own private instance of
+a random number generator (RNG). The RNG is seeded with a combination of a
+global seed, the pass ID, and the function's sequence number. The global seed
+is designed to be different across runs (perhaps based on the current time), but
+for debugging, the global seed can be set to a specific value and the results
+will be repeatable.
+
+Subzero-generated code is subject to diversification once per translation, and
+then Chrome caches the diversified binary for subsequent executions. An
+attacker may attempt to run the binary multiple times hoping for
+higher-probability combinations of ROP gadgets. When the attacker guesses
+wrong, a likely outcome is an application crash. Chrome throttles creation of
+crashy processes which reduces the likelihood of the attacker eventually gaining
+a foothold.
+
+Constant blinding
+~~~~~~~~~~~~~~~~~
+
+Here, we prevent attackers from controlling large immediates in the text
+(executable) section. A random cookie is generated for each function, and if
+the constant exceeds a specified threshold, the constant is obfuscated with the
+cookie and equivalent code is generated. For example, instead of this x86
+instruction::
+
+ mov $0x11223344, <%Reg/Mem>
+
+the following code might be generated::
+
+ mov $(0x11223344+Cookie), %temp
+ lea -Cookie(%temp), %temp
+ mov %temp, <%Reg/Mem>
+
+The ``lea`` instruction is used rather than e.g. ``add``/``sub`` or ``xor``, to
+prevent unintended effects on the flags register.
+
+This transformation has almost no effect on translation time, and about 1%
+impact on code quality, depending on the threshold chosen. It does little to
+reduce gadget persistence, but it does remove a lot of potential opportunities
+to construct intra-instruction ROP gadgets (which an attacker could use only if
+a validator bug were discovered, since the Native Client sandbox and associated
+validator force returns and other indirect branches to be to bundle-aligned
+addresses).
+
+Constant pooling
+~~~~~~~~~~~~~~~~
+
+This is similar to constant blinding, in that large immediates are removed from
+the text section. In this case, each unique constant above the threshold is
+stored in a read-only data section and the constant is accessed via a memory
+load. For the above example, the following code might be generated::
+
+ mov $Label$1, %temp
+ mov %temp, <%Reg/Mem>
+
+This has a similarly small impact on translation time and ROP gadget
+persistence, and a smaller (better) impact on code quality. This is because it
+uses fewer instructions, and in some cases good register allocation leads to no
+increase in instruction count. Note that this still gives an attacker some
+limited amount of control over some text section values, unless we randomize the
+constant pool layout.
+
+Static data reordering
+~~~~~~~~~~~~~~~~~~~~~~
+
+This transformation limits the attacker's ability to control bits in global data
+address references. It simply permutes the order in memory of global variables
+and internal constant pool entries. For the constant pool, we only permute
+within a type (i.e., emit a randomized list of ints, followed by a randomized
+list of floats, etc.) to maintain good packing in the face of alignment
+constraints.
+
+As might be expected, this has no impact on code quality, translation time, or
+ROP gadget persistence (though as above, it limits opportunities for
+intra-instruction ROP gadgets with a broken validator).
+
+Basic block reordering
+~~~~~~~~~~~~~~~~~~~~~~
+
+Here, we randomize the order of basic blocks within a function, with the
+constraint that we still want to maintain a topological order as much as
+possible, to avoid making the code too branchy.
+
+This has no impact on code quality, and about 1% impact on translation time, due
+to a separate pass to recompute layout. It ends up having a huge effect on ROP
+gadget persistence, tied for best with nop insertion, reducing ROP gadget
+persistence to less than 5%.
+
+Function reordering
+~~~~~~~~~~~~~~~~~~~
+
+Here, we permute the order that functions are emitted, primarily to shift ROP
+gadgets around to less predictable locations. It may also change call address
+offsets in case the attacker was trying to control that offset in the code.
+
+To control latency and memory footprint, we don't arbitrarily permute functions.
+Instead, for some relatively small value of N, we queue up N assembler buffers,
+and then emit the N functions in random order, and repeat until all functions
+are emitted.
+
+Function reordering has no impact on translation time or code quality.
+Measurements indicate that it reduces ROP gadget persistence to about 15%.
+
+Nop insertion
+~~~~~~~~~~~~~
+
+This diversification randomly adds a nop instruction after each regular
+instruction, with some probability. Nop instructions of different lengths may
+be selected. Nop instructions are never added inside a bundle_lock region.
+Note that when sandboxing is enabled, nop instructions are already being added
+for bundle alignment, so the diversification nop instructions may simply be
+taking the place of alignment nop instructions, though distributed differently
+through the bundle.
+
+In Subzero's currently implementation, nop insertion adds 3-5% to the
+translation time, but this is probably because it is implemented as a separate
+pass that adds actual nop instructions to the IR. The overhead would probably
+be a lot less if it were integrated into the assembler pass. The code quality
+is also reduced by 3-5%, making nop insertion the most expensive of the
+diversification techniques.
+
+Nop insertion is very effective in reducing ROP gadget persistence, at the same
+level as basic block randomization (less than 5%). But given nop insertion's
+impact on translation time and code quality, one would most likely prefer to use
+basic block randomization instead (though the combined effects of the different
+diversification techniques have not yet been studied).
+
+Register allocation randomization
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In this diversification, the register allocator tries to make different but
+mostly functionally equivalent choices, while maintaining stable code quality.
+
+A naive approach would be the following. Whenever the allocator has more than
+one choice for assigning a register, choose randomly among those options. And
+whenever there are no registers available and there is a tie for the
+lowest-weight variable, randomly select one of the lowest-weight variables to
+evict. Because of the one-pass nature of the linear-scan algorithm, this
+randomization strategy can have a large impact on which variables are ultimately
+assigned registers, with a corresponding large impact on code quality.
+
+Instead, we choose an approach that tries to keep code quality stable regardless
+of the random seed. We partition the set of physical registers into equivalence
+classes. If a register is pre-colored in the function (i.e., referenced
+explicitly by name), it forms its own equivalence class. The remaining
+registers are partitioned according to their combination of attributes such as
+integer versus floating-point, 8-bit versus 32-bit, caller-save versus
+callee-saved, etc. Each equivalence class is randomly permuted, and the
+complete permutation is applied to the final register assignments.
+
+Register randomization reduces ROP gadget persistence to about 10% on average,
+though there tends to be fairly high variance across functions and applications.
+This probably has to do with the set of restrictions in the x86-32 instruction
+set and ABI, such as few general-purpose registers, ``%eax`` used for return
+values, ``%edx`` used for division, ``%cl`` used for shifting, etc. As
+intended, register randomization has no impact on code quality, and a slight
+(0.5%) impact on translation time due to an extra scan over the variables to
+identify pre-colored registers.
+
+Fuzzing
+^^^^^^^
+
+We have started fuzz-testing the ``.pexe`` files input to Subzero, using a
+combination of `afl-fuzz <http://lcamtuf.coredump.cx/afl/>`_, LLVM's `libFuzzer
+<http://llvm.org/docs/LibFuzzer.html>`_, and custom tooling. The purpose is to
+find and fix cases where Subzero crashes or otherwise ungracefully fails on
+unexpected inputs, and to do so automatically over a large range of unexpected
+inputs. By fixing bugs that arise from fuzz testing, we reduce the possibility
+of an attacker exploiting these bugs.
+
+Most of the problems found so far are ones most appropriately handled in the
+parser. However, there have been a couple that have identified problems in the
+lowering, or otherwise inappropriately triggered assertion failures and fatal
+errors. We continue to dig into this area.
+
+Future security work
+^^^^^^^^^^^^^^^^^^^^
+
+Subzero is well-positioned to explore other future security enhancements, e.g.:
+
+- Tightening the Native Client sandbox. ABI changes, such as the previous work
+ on `hiding the sandbox base address
+ <https://docs.google.com/document/d/1eskaI4353XdsJQFJLRnZzb_YIESQx4gNRzf31dqXVG8>`_
+ in x86-64, are easy to experiment with in Subzero.
+
+- Making the executable code section read-only. This would prevent a PNaCl
+ application from inspecting its own binary and trying to find ROP gadgets even
+ after code diversification has been performed. It may still be susceptible to
+ `blind ROP <http://www.scs.stanford.edu/brop/bittau-brop.pdf>`_ attacks,
+ security is still overall improved.
+
+- Instruction selection diversification. It may be possible to lower a given
+ instruction in several largely equivalent ways, which gives more opportunities
+ for code randomization.
+
+Chrome integration
+------------------
+
+Currently Subzero is available in Chrome for the x86-32 architecture, but under
+a flag. When the flag is enabled, Subzero is used when the `manifest file
+<https://developer.chrome.com/native-client/reference/nacl-manifest-format>`_
+linking to the ``.pexe`` file specifies the ``O0`` optimization level.
+
+The next step is to remove the flag, i.e. invoke Subzero as the only translator
+for ``O0``-specified manifest files.
+
+Ultimately, Subzero might produce code rivaling LLVM ``O2`` quality, in which
+case Subzero could be used for all PNaCl translation.
+
+Command line options
+--------------------
+
+Subzero has a number of command-line options for debugging and diagnostics.
+Among the more interesting are the following.
+
+- Using the ``-verbose`` flag, Subzero will dump the CFG, or produce other
+ diagnostic output, with various levels of detail after each pass. Instruction
+ numbers can be printed or suppressed. Deleted instructions can be printed or
+ suppressed (they are retained in the instruction list, as discussed earlier,
+ because they can help explain how lower-level instructions originated).
+ Liveness information can be printed when available. Details of register
+ allocation can be printed as register allocator decisions are made. And more.
+
+- Running Subzero with any level of verbosity produces an enormous amount of
+ output. When debugging a single function, verbose output can be suppressed
+ except for a particular function. The ``-verbose-focus`` flag suppresses
+ verbose output except for the specified function.
+
+- Subzero has a ``-timing`` option that prints a breakdown of pass-level timing
+ at exit. Timing markers can be placed in the Subzero source code to demarcate
+ logical operations or passes of interest. Basic timing information plus
+ call-stack type timing information is printed at the end.
+
+- Along with ``-timing``, the user can instead get a report on the overall
+ translation time for each function, to help focus on timing outliers. Also,
+ ``-timing-focus`` limits the ``-timing`` reporting to a single function,
+ instead of aggregating pass timing across all functions.
+
+- The ``-szstats`` option reports various statistics on each function, such as
+ stack frame size, static instruction count, etc. It may be helpful to track
+ these stats over time as Subzero is improved, as an approximate measure of
+ code quality.
+
+- The flag ``-asm-verbose``, in conjunction with emitting textual assembly
+ output, annotate the assembly output with register-focused liveness
+ information. In particular, each basic block is annotated with which
+ registers are live-in and live-out, and each instruction is annotated with
+ which registers' and stack locations' live ranges end at that instruction.
+ This is really useful when studying the generated code to find opportunities
+ for code quality improvements.
+
+Testing and debugging
+---------------------
+
+LLVM lit tests
+^^^^^^^^^^^^^^
+
+For basic testing, Subzero uses LLVM's `lit
+<http://llvm.org/docs/CommandGuide/lit.html>`_ framework for running tests. We
+have a suite of hundreds of small functions where we test for particular
+assembly code patterns across different target architectures.
+
+Cross tests
+^^^^^^^^^^^
+
+Unfortunately, the lit tests don't do a great job of precisely testing the
+correctness of the output. Much better are the cross tests, which are execution
+tests that compare Subzero and ``pnacl-llc`` translated bitcode across a wide
+variety of interesting inputs. Each cross test consists of a set of C, C++,
+and/or low-level bitcode files. The C and C++ source files are compiled down to
+bitcode. The bitcode files are translated by ``pnacl-llc`` and also by Subzero.
+Subzero mangles global symbol names with a special prefix to avoid duplicate
+symbol errors. A driver program invokes both versions on a large set of
+interesting inputs, and reports when the Subzero and ``pnacl-llc`` results
+differ. Cross tests turn out to be an excellent way of testing the basic
+lowering patterns, but they are less useful for testing more global things like
+liveness analysis and register allocation.
+
+Bisection debugging
+^^^^^^^^^^^^^^^^^^^
+
+Sometimes with a new application, Subzero will end up producing incorrect code
+that either crashes at runtime or otherwise produces the wrong results. When
+this happens, we need to narrow it down to a single function (or small set of
+functions) that yield incorrect behavior. For this, we have a bisection
+debugging framework. Here, we initially translate the entire application once
+with Subzero and once with ``pnacl-llc``. We then use ``objdump`` to
+selectively weaken symbols based on a whitelist or blacklist provided on the
+command line. The two object files can then be linked together without link
+errors, with the desired version of each method "winning". Then the binary is
+tested, and bisection proceeds based on whether the binary produces correct
+output.
+
+When the bisection completes, we are left with a minimal set of
+Subzero-translated functions that cause the failure. Usually it is a single
+function, though sometimes it might require a combination of several functions
+to cause a failure; this may be due to an incorrect call ABI, for example.
+However, Murphy's Law implies that the single failing function is enormous and
+impractical to debug. In that case, we can restart the bisection, explicitly
+blacklisting the enormous function, and try to find another candidate to debug.
+(Future work is to automate this to find all minimal sets of functions, so that
+debugging can focus on the simplest example.)
+
+Fuzz testing
+^^^^^^^^^^^^
+
+As described above, we try to find internal Subzero bugs using fuzz testing
+techniques.
+
+Sanitizers
+^^^^^^^^^^
+
+Subzero can be built with `AddressSanitizer
+<http://clang.llvm.org/docs/AddressSanitizer.html>`_ (ASan) or `ThreadSanitizer
+<http://clang.llvm.org/docs/ThreadSanitizer.html>`_ (TSan) support. This is
+done using something as simple as ``make ASAN=1`` or ``make TSAN=1``. So far,
+multithreading has been simple enough that TSan hasn't found any bugs, but ASan
+has found at least one memory leak which was subsequently fixed.
+`UndefinedBehaviorSanitizer
+<http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation>`_
+(UBSan) support is in progress. `Control flow integrity sanitization
+<http://clang.llvm.org/docs/ControlFlowIntegrity.html>`_ is also under
+consideration.
+
+Current status
+==============
+
+Target architectures
+--------------------
+
+Subzero is currently more or less complete for the x86-32 target. It has been
+refactored and extended to handle x86-64 as well, and that is mostly complete at
+this point.
+
+ARM32 work is in progress. It currently lacks the testing level of x86, at
+least in part because Subzero's register allocator needs modifications to handle
+ARM's aliasing of floating point and vector registers. Specifically, a 64-bit
+register is actually a gang of two consecutive and aligned 32-bit registers, and
+a 128-bit register is a gang of 4 consecutive and aligned 32-bit registers.
+ARM64 work has not started; when it does, it will be native-only since the
+Native Client sandbox model, validator, and other tools have never been defined.
+
+An external contributor is adding MIPS support, in most part by following the
+ARM work.
+
+Translator performance
+----------------------
+
+Single-threaded translation speed is currently about 5× the ``pnacl-llc``
+translation speed. For a large ``.pexe`` file, the time breaks down as:
+
+- 11% for parsing and initial IR building
+
+- 4% for emitting to /dev/null
+
+- 27% for liveness analysis (two liveness passes plus live range construction)
+
+- 15% for linear-scan register allocation
+
+- 9% for basic lowering
+
+- 10% for advanced phi lowering
+
+- ~11% for other minor analysis
+
+- ~10% measurement overhead to acquire these numbers
+
+Some improvements could undoubtedly be made, but it will be hard to increase the
+speed to 10× of ``pnacl-llc`` while keeping acceptable code quality. With
+``-Om1`` (lack of) optimization, we do actually achieve roughly 10×
+``pnacl-llc`` translation speed, but code quality drops by a factor of 3.
+
+Code quality
+------------
+
+Measured across 16 components of spec2k, Subzero's code quality is uniformly
+better than ``pnacl-llc`` ``-O0`` code quality, and in many cases solidly
+between ``pnacl-llc`` ``-O0`` and ``-O2``.
+
+Translator size
+---------------
+
+When built in MINIMAL mode, the x86-64 native translator size for the x86-32
+target is about 700 KB, not including the size of functions referenced in
+dynamically-linked libraries. The sandboxed version of Subzero is a bit over 1
+MB, and it is statically linked and also includes nop padding for bundling as
+well as indirect branch masking.
+
+Translator memory footprint
+---------------------------
+
+It's hard to draw firm conclusions about memory footprint, since the footprint
+is at least proportional to the input function size, and there is no real limit
+on the size of functions in the ``.pexe`` file.
+
+That said, we looked at the memory footprint over time as Subzero translated
+``pnacl-llc.pexe``, which is the largest ``.pexe`` file (7.2 MB) at our
+disposal. One of LLVM's libraries that Subzero uses can report the current
+malloc heap usage. With single-threaded translation, Subzero tends to hover
+around 15 MB of memory usage. There are a couple of monstrous functions where
+Subzero grows to around 100 MB, but then it drops back down after those
+functions finish translating. In contrast, ``pnacl-llc`` grows larger and
+larger throughout translation, reaching several hundred MB by the time it
+completes.
+
+It's a bit more interesting when we enable multithreaded translation. When
+there are N translation threads, Subzero implements a policy that limits the
+size of the translation queue to N entries -- if it is "full" when the parser
+tries to add a new CFG, the parser blocks until one of the translation threads
+removes a CFG. This means the number of in-memory CFGs can (and generally does)
+reach 2*N+1, and so the memory footprint rises in proportion to the number of
+threads. Adding to the pressure is the observation that the monstrous functions
+also take proportionally longer time to translate, so there's a good chance many
+of the monstrous functions will be active at the same time with multithreaded
+translation. As a result, for N=32, Subzero's memory footprint peaks at about
+260 MB, but drops back down as the large functions finish translating.
+
+If this peak memory size becomes a problem, it might be possible for the parser
+to resequence the functions to try to spread out the larger functions, or to
+throttle the translation queue to prevent too many in-flight large functions.
+It may also be possible to throttle based on memory pressure signaling from
+Chrome.
+
+Translator scalability
+----------------------
+
+Currently scalability is "not very good". Multiple translation threads lead to
+faster translation, but not to the degree desired. We haven't dug in to
+investigate yet.
+
+There are a few areas to investigate. First, there may be contention on the
+constant pool, which all threads access, and which requires locked access even
+for reading. This could be mitigated by keeping a CFG-local cache of the most
+common constants.
+
+Second, there may be contention on memory allocation. While almost all CFG
+objects are allocated from the CFG-local allocator, some passes use temporary
+STL containers that use the default allocator, which may require global locking.
+This could be mitigated by switching these to the CFG-local allocator.
+
+Third, multithreading may make the default allocator strategy more expensive.
+In a single-threaded environment, a pass will allocate its containers, run the
+pass, and deallocate the containers. This results in stack-like allocation
+behavior and makes the heap free list easier to manage, with less heap
+fragmentation. But when multithreading is added, the allocations and
+deallocations become much less stack-like, making allocation and deallocation
+operations individually more expensive. Again, this could be mitigated by
+switching these to the CFG-local allocator.
diff --git a/chromium/third_party/swiftshader/third_party/subzero/README.rst b/chromium/third_party/swiftshader/third_party/subzero/README.rst
index cffceba7c58..922d99d2c6f 120000..100644
--- a/chromium/third_party/swiftshader/third_party/subzero/README.rst
+++ b/chromium/third_party/swiftshader/third_party/subzero/README.rst
@@ -1 +1,213 @@
-docs/README.rst \ No newline at end of file
+Subzero - Fast code generator for PNaCl bitcode
+===============================================
+
+Design
+------
+
+See the accompanying DESIGN.rst file for a more detailed technical overview of
+Subzero.
+
+Building
+--------
+
+Subzero is set up to be built within the Native Client tree. Follow the
+`Developing PNaCl
+<https://sites.google.com/a/chromium.org/dev/nativeclient/pnacl/developing-pnacl>`_
+instructions, in particular the section on building PNaCl sources. This will
+prepare the necessary external headers and libraries that Subzero needs.
+Checking out the Native Client project also gets the pre-built clang and LLVM
+tools in ``native_client/../third_party/llvm-build/Release+Asserts/bin`` which
+are used for building Subzero.
+
+The Subzero source is in ``native_client/toolchain_build/src/subzero``. From
+within that directory, ``git checkout master && git pull`` to get the latest
+version of Subzero source code.
+
+The Makefile is designed to be used as part of the higher level LLVM build
+system. To build manually, use the ``Makefile.standalone``. There are several
+build configurations from the command line::
+
+ make -f Makefile.standalone
+ make -f Makefile.standalone DEBUG=1
+ make -f Makefile.standalone NOASSERT=1
+ make -f Makefile.standalone DEBUG=1 NOASSERT=1
+ make -f Makefile.standalone MINIMAL=1
+ make -f Makefile.standalone ASAN=1
+ make -f Makefile.standalone TSAN=1
+
+``DEBUG=1`` builds without optimizations and is good when running the translator
+inside a debugger. ``NOASSERT=1`` disables assertions and is the preferred
+configuration for performance testing the translator. ``MINIMAL=1`` attempts to
+minimize the size of the translator by compiling out everything unnecessary.
+``ASAN=1`` enables AddressSanitizer, and ``TSAN=1`` enables ThreadSanitizer.
+
+The result of the ``make`` command is the target ``pnacl-sz`` in the current
+directory.
+
+Building within LLVM trunk
+--------------------------
+
+Subzero can also be built from within a standard LLVM trunk checkout. Here is
+an example of how it can be checked out and built::
+
+ mkdir llvm-git
+ cd llvm-git
+ git clone http://llvm.org/git/llvm.git
+ cd llvm/projects/
+ git clone https://chromium.googlesource.com/native_client/pnacl-subzero
+ cd ../..
+ mkdir build
+ cd build
+ cmake -G Ninja ../llvm/
+ ninja
+ ./bin/pnacl-sz -version
+
+This creates a default build of ``pnacl-sz``; currently any options such as
+``DEBUG=1`` or ``MINIMAL=1`` have to be added manually.
+
+``pnacl-sz``
+------------
+
+The ``pnacl-sz`` program parses a pexe or an LLVM bitcode file and translates it
+into ICE (Subzero's intermediate representation). It then invokes the ICE
+translate method to lower it to target-specific machine code, optionally dumping
+the intermediate representation at various stages of the translation.
+
+The program can be run as follows::
+
+ ../pnacl-sz ./path/to/<file>.pexe
+ ../pnacl-sz ./tests_lit/pnacl-sz_tests/<file>.ll
+
+At this time, ``pnacl-sz`` accepts a number of arguments, including the
+following:
+
+ ``-help`` -- Show available arguments and possible values. (Note: this
+ unfortunately also pulls in some LLVM-specific options that are reported but
+ that Subzero doesn't use.)
+
+ ``-notranslate`` -- Suppress the ICE translation phase, which is useful if
+ ICE is missing some support.
+
+ ``-target=<TARGET>`` -- Set the target architecture. The default is x8632.
+ Future targets include x8664, arm32, and arm64.
+
+ ``-filetype=obj|asm|iasm`` -- Select the output file type. ``obj`` is a
+ native ELF file, ``asm`` is a textual assembly file, and ``iasm`` is a
+ low-level textual assembly file demonstrating the integrated assembler.
+
+ ``-O<LEVEL>`` -- Set the optimization level. Valid levels are ``2``, ``1``,
+ ``0``, ``-1``, and ``m1``. Levels ``-1`` and ``m1`` are synonyms, and
+ represent the minimum optimization and worst code quality, but fastest code
+ generation.
+
+ ``-verbose=<list>`` -- Set verbosity flags. This argument allows a
+ comma-separated list of values. The default is ``none``, and the value
+ ``inst,pred`` will roughly match the .ll bitcode file. Of particular use
+ are ``all``, ``most``, and ``none``.
+
+ ``-o <FILE>`` -- Set the assembly output file name. Default is stdout.
+
+ ``-log <FILE>`` -- Set the file name for diagnostic output (whose level is
+ controlled by ``-verbose``). Default is stdout.
+
+ ``-timing`` -- Dump some pass timing information after translating the input
+ file.
+
+Running the test suite
+----------------------
+
+Subzero uses the LLVM ``lit`` testing tool for part of its test suite, which
+lives in ``tests_lit``. To execute the test suite, first build Subzero, and then
+run::
+
+ make -f Makefile.standalone check-lit
+
+There is also a suite of cross tests in the ``crosstest`` directory. A cross
+test takes a test bitcode file implementing some unit tests, and translates it
+twice, once with Subzero and once with LLVM's known-good ``llc`` translator.
+The Subzero-translated symbols are specially mangled to avoid multiple
+definition errors from the linker. Both translated versions are linked together
+with a driver program that calls each version of each unit test with a variety
+of interesting inputs and compares the results for equality. The cross tests
+are currently invoked by running::
+
+ make -f Makefile.standalone check-xtest
+
+Similar, there is a suite of unit tests::
+
+ make -f Makefile.standalone check-unit
+
+A convenient way to run the lit, cross, and unit tests is::
+
+ make -f Makefile.standalone check
+
+Assembling ``pnacl-sz`` output as needed
+----------------------------------------
+
+``pnacl-sz`` can now produce a native ELF binary using ``-filetype=obj``.
+
+``pnacl-sz`` can also produce textual assembly code in a structure suitable for
+input to ``llvm-mc``, using ``-filetype=asm`` or ``-filetype=iasm``. An object
+file can then be produced using the command::
+
+ llvm-mc -triple=i686 -filetype=obj -o=MyObj.o
+
+Building a translated binary
+----------------------------
+
+There is a helper script, ``pydir/szbuild.py``, that translates a finalized pexe
+into a fully linked executable. Run it with ``-help`` for extensive
+documentation.
+
+By default, ``szbuild.py`` builds an executable using only Subzero translation,
+but it can also be used to produce hybrid Subzero/``llc`` binaries (``llc`` is
+the name of the LLVM translator) for bisection-based debugging. In bisection
+debugging mode, the pexe is translated using both Subzero and ``llc``, and the
+resulting object files are combined into a single executable using symbol
+weakening and other linker tricks to control which Subzero symbols and which
+``llc`` symbols take precedence. This is controlled by the ``-include`` and
+``-exclude`` arguments. These can be used to rapidly find a single function
+that Subzero translates incorrectly leading to incorrect output.
+
+There is another helper script, ``pydir/szbuild_spec2k.py``, that runs
+``szbuild.py`` on one or more components of the Spec2K suite. This assumes that
+Spec2K is set up in the usual place in the Native Client tree, and the finalized
+pexe files have been built. (Note: for working with Spec2K and other pexes,
+it's helpful to finalize the pexe using ``--no-strip-syms``, to preserve the
+original function and global variable names.)
+
+Status
+------
+
+Subzero currently fully supports the x86-32 architecture, for both native and
+Native Client sandboxing modes. The x86-64 architecture is also supported in
+native mode only, and only for the x32 flavor due to the fact that pointers and
+32-bit integers are indistinguishable in PNaCl bitcode. Sandboxing support for
+x86-64 is in progress. ARM and MIPS support is in progress. Two optimization
+levels, ``-Om1`` and ``-O2``, are implemented.
+
+The ``-Om1`` configuration is designed to be the simplest and fastest possible,
+with a minimal set of passes and transformations.
+
+* Simple Phi lowering before target lowering, by generating temporaries and
+ adding assignments to the end of predecessor blocks.
+
+* Simple register allocation limited to pre-colored or infinite-weight
+ Variables.
+
+The ``-O2`` configuration is designed to use all optimizations available and
+produce the best code.
+
+* Address mode inference to leverage the complex x86 addressing modes.
+
+* Compare/branch fusing based on liveness/last-use analysis.
+
+* Global, linear-scan register allocation.
+
+* Advanced phi lowering after target lowering and global register allocation,
+ via edge splitting, topological sorting of the parallel moves, and final local
+ register allocation.
+
+* Stack slot coalescing to reduce frame size.
+
+* Branch optimization to reduce the number of branches to the following block.
diff --git a/chromium/third_party/wayland-protocols/src/configure.ac b/chromium/third_party/wayland-protocols/src/configure.ac
index 4c43daa2c7c..fbb0ec242fd 100644
--- a/chromium/third_party/wayland-protocols/src/configure.ac
+++ b/chromium/third_party/wayland-protocols/src/configure.ac
@@ -35,6 +35,7 @@ PKG_NOARCH_INSTALLDIR
AC_CONFIG_FILES([
Makefile
wayland-protocols.pc
+ wayland-protocols-uninstalled.pc
])
AC_OUTPUT
diff --git a/chromium/third_party/wayland-protocols/src/stable/presentation-time/presentation-time.xml b/chromium/third_party/wayland-protocols/src/stable/presentation-time/presentation-time.xml
index e449b37876b..a46994c8d2c 100644
--- a/chromium/third_party/wayland-protocols/src/stable/presentation-time/presentation-time.xml
+++ b/chromium/third_party/wayland-protocols/src/stable/presentation-time/presentation-time.xml
@@ -81,7 +81,6 @@
For details on what information is returned, see the
presentation_feedback interface.
</description>
-
<arg name="surface" type="object" interface="wl_surface"
summary="target surface"/>
<arg name="callback" type="new_id" interface="wp_presentation_feedback"
@@ -120,7 +119,6 @@
recommended. Clients must be able to query the current clock
value directly, not by asking the compositor.
</description>
-
<arg name="clk_id" type="uint" summary="platform clock identifier"/>
</event>
@@ -152,7 +150,6 @@
the synchronized output. If a client has not bound to the
right wl_output global at all, this event is not sent.
</description>
-
<arg name="output" type="object" interface="wl_output"
summary="presentation output"/>
</event>
@@ -192,7 +189,6 @@
Possible zero-copy cases include direct scanout of a
fullscreen surface and a surface on a hardware overlay.
</description>
-
<entry name="vsync" value="0x1" summary="presentation was vsync'd"/>
<entry name="hw_clock" value="0x2"
summary="hardware provided the presentation timestamp"/>
@@ -246,7 +242,6 @@
a way to query the refresh count, then the arguments seq_hi
and seq_lo must be zero.
</description>
-
<arg name="tv_sec_hi" type="uint"
summary="high 32 bits of the seconds part of the presentation timestamp"/>
<arg name="tv_sec_lo" type="uint"
diff --git a/chromium/third_party/wayland-protocols/src/stable/viewporter/viewporter.xml b/chromium/third_party/wayland-protocols/src/stable/viewporter/viewporter.xml
index 5d006c08719..c732d8c35bc 100644
--- a/chromium/third_party/wayland-protocols/src/stable/viewporter/viewporter.xml
+++ b/chromium/third_party/wayland-protocols/src/stable/viewporter/viewporter.xml
@@ -54,7 +54,6 @@
a wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>
-
<arg name="id" type="new_id" interface="wp_viewport"
summary="the new viewport interface id"/>
<arg name="surface" type="object" interface="wl_surface"
@@ -159,7 +158,6 @@
The crop and scale state is double-buffered state, and will be
applied on the next wl_surface.commit.
</description>
-
<arg name="x" type="fixed" summary="source rectangle x"/>
<arg name="y" type="fixed" summary="source rectangle y"/>
<arg name="width" type="fixed" summary="source rectangle width"/>
@@ -180,7 +178,6 @@
The crop and scale state is double-buffered state, and will be
applied on the next wl_surface.commit.
</description>
-
<arg name="width" type="int" summary="surface width"/>
<arg name="height" type="int" summary="surface height"/>
</request>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
index 70372fc5d79..9c06cdcba6c 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
@@ -42,7 +42,7 @@
<request name="destroy" type="destructor">
<description summary="destroy the idle inhibitor object">
- This destroys the inhibit manager.
+ Destroy the inhibit manager.
</description>
</request>
@@ -75,7 +75,7 @@
<request name="destroy" type="destructor">
<description summary="destroy the idle inhibitor object">
- This removes the inhibitor effect from the associated wl_surface.
+ Remove the inhibitor effect from the associated wl_surface.
</description>
</request>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/input-method/input-method-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/input-method/input-method-unstable-v1.xml
index c1b2b595d97..e9d93ba609e 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/input-method/input-method-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/input-method/input-method-unstable-v1.xml
@@ -27,8 +27,8 @@
<interface name="zwp_input_method_context_v1" version="1">
<description summary="input method context">
Corresponds to a text input on the input method side. An input method context
- is created on text input activation on the input method side. It allows to
- receive information about the text input from the application via events.
+ is created on text input activation on the input method side. It allows
+ receiving information about the text input from the application via events.
Input method contexts do not keep state after deactivation and should be
destroyed after deactivation is handled.
@@ -86,7 +86,7 @@
<request name="preedit_styling">
<description summary="pre-edit styling">
- Sets styling information on composing text. The style is applied for
+ Set the styling information on composing text. The style is applied for
length in bytes from index relative to the beginning of
the composing text (as byte offset). Multiple styles can
be applied to a composing text.
@@ -100,7 +100,7 @@
<request name="preedit_cursor">
<description summary="pre-edit cursor">
- Sets the cursor position inside the composing text (as byte offset)
+ Set the cursor position inside the composing text (as byte offset)
relative to the start of the composing text.
When index is negative no cursor should be displayed.
@@ -112,6 +112,8 @@
<request name="delete_surrounding_text">
<description summary="delete text">
+ Remove the surrounding text.
+
This request will be handled on the text_input side directly following
a commit_string request.
</description>
@@ -121,11 +123,11 @@
<request name="cursor_position">
<description summary="set cursor to a new position">
- Sets the cursor and anchor to a new position. Index is the new cursor
- position in bytes (when >= 0 relative to the end of inserted text,
- otherwise relative to the beginning of the inserted text). Anchor is
- the new anchor position in bytes (when >= 0 relative to the end of the
- inserted text, otherwise relative to the beginning of the inserted
+ Set the cursor and anchor to a new position. Index is the new cursor
+ position in bytes (when >= 0 this is relative to the end of the inserted text,
+ otherwise it is relative to the beginning of the inserted text). Anchor is
+ the new anchor position in bytes (when >= 0 this is relative to the end of the
+ inserted text, otherwise it is relative to the beginning of the inserted
text). When there should be no selected text, anchor should be the same
as index.
@@ -145,7 +147,7 @@
Notify when a key event was sent. Key events should not be used for
normal text input operations, which should be done with commit_string,
delete_surrounding_text, etc. The key event follows the wl_keyboard key
- event convention. Sym is an XKB keysym, state a wl_keyboard key_state.
+ event convention. Sym is an XKB keysym, state is a wl_keyboard key_state.
</description>
<arg name="serial" type="uint" summary="serial of the latest known text input state"/>
<arg name="time" type="uint"/>
@@ -156,7 +158,7 @@
<request name="grab_keyboard">
<description summary="grab hardware keyboard">
- Allows an input method to receive hardware keyboard input and process
+ Allow an input method to receive hardware keyboard input and process
key events to generate text events (with pre-edit) over the wire. This
allows input methods which compose multiple key events for inputting
text like it is done for CJK languages.
@@ -166,11 +168,9 @@
<request name="key">
<description summary="forward key event">
- Should be used when filtering key events with grab_keyboard.
-
- When the wl_keyboard::key event is not processed by the input
- method itself and should be sent to the client instead, forward it
- with this request. The arguments should be the ones from the
+ Forward a wl_keyboard::key event to the client that was not processed
+ by the input method itself. Should be used when filtering key events
+ with grab_keyboard. The arguments should be the ones from the
wl_keyboard::key event.
For generating custom key events use the keysym request instead.
@@ -183,10 +183,9 @@
<request name="modifiers">
<description summary="forward modifiers event">
- Should be used when filtering key events with grab_keyboard.
-
- When the wl_keyboard::modifiers event should also be sent to the
- client, forward it with this request. The arguments should be the ones
+ Forward a wl_keyboard::modifiers event to the client that was not
+ processed by the input method itself. Should be used when filtering
+ key events with grab_keyboard. The arguments should be the ones
from the wl_keyboard::modifiers event.
</description>
<arg name="serial" type="uint" summary="serial from wl_keyboard::modifiers"/>
@@ -212,7 +211,7 @@
position in bytes within the surrounding text relative to the beginning
of the text. Anchor is the position in bytes of the selection anchor
within the surrounding text relative to the beginning of the text. If
- there is no selected text anchor is the same as cursor.
+ there is no selected text then anchor is the same as cursor.
</description>
<arg name="text" type="string"/>
<arg name="cursor" type="uint"/>
@@ -285,6 +284,8 @@
<request name="set_toplevel">
<description summary="set the surface type as a keyboard">
+ Set the input_panel_surface type to keyboard.
+
A keyboard surface is only shown when a text input is active.
</description>
<arg name="output" type="object" interface="wl_output"/>
@@ -293,8 +294,10 @@
<request name="set_overlay_panel">
<description summary="set the surface type as an overlay panel">
- An overlay panel is shown near the input cursor above the application
- window when a text input is active.
+ Set the input_panel_surface to be an overlay panel.
+
+ This is shown near the input cursor above the application window when
+ a text input is active.
</description>
</request>
</interface>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index 3b4861f3583..60240f9df84 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -98,7 +98,8 @@
binds to this interface. A roundtrip after binding guarantees
that the client has received all supported formats.
- For the definition of the format codes, see create request.
+ For the definition of the format codes, see the
+ zwp_linux_buffer_params_v1::create request.
XXX: Can a compositor ever enumerate them?
</description>
@@ -127,22 +128,16 @@
<enum name="error">
<entry name="already_used" value="0"
summary="the dmabuf_batch object has already been used to create a wl_buffer"/>
-
<entry name="plane_idx" value="1"
summary="plane index out of bounds"/>
-
<entry name="plane_set" value="2"
summary="the plane index was already set"/>
-
<entry name="incomplete" value="3"
summary="missing or too many planes to create a buffer"/>
-
<entry name="invalid_format" value="4"
summary="format not supported"/>
-
<entry name="invalid_dimensions" value="5"
summary="invalid width or height"/>
-
<entry name="out_of_bounds" value="6"
summary="offset + stride * height goes out of dmabuf bounds"/>
</enum>
@@ -170,7 +165,6 @@
The error PLANE_SET is raised if attempting to set a plane that
was already set.
</description>
-
<arg name="fd" type="fd" summary="dmabuf fd"/>
<arg name="plane_idx" type="uint" summary="plane index"/>
<arg name="offset" type="uint" summary="offset in bytes"/>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
index 4b95a5c0e3a..4e67a13c981 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
@@ -140,7 +140,6 @@
objects of the same seat. wl_pointer.axis and wl_pointer.button events
are unaffected.
</description>
-
<arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
@@ -171,7 +170,6 @@
state. See the the description of wp_confined_pointer for further
information.
</description>
-
<arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
@@ -231,7 +229,6 @@
effect when the associated surface gets it pending state applied. See
wl_surface.commit for details.
</description>
-
<arg name="surface_x" type="fixed"
summary="surface-local x coordinate"/>
<arg name="surface_y" type="fixed"
@@ -248,7 +245,6 @@
For details about the lock region, see wp_locked_pointer.
</description>
-
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
@@ -317,7 +313,6 @@
For details about the confine region, see wp_confined_pointer.
</description>
-
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml
index 24935a30009..ca6f81d12ac 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml
@@ -68,7 +68,6 @@
Create a relative pointer interface given a wl_pointer object. See the
wp_relative_pointer interface for more details.
</description>
-
<arg name="id" type="new_id" interface="zwp_relative_pointer_v1"/>
<arg name="pointer" type="object" interface="wl_pointer"/>
</request>
@@ -119,7 +118,6 @@
from a wl_pointer object of the same seat that the wp_relative_pointer
object is associated with.
</description>
-
<arg name="utime_hi" type="uint"
summary="high 32 bits of a 64 bit timestamp with microsecond granularity"/>
<arg name="utime_lo" type="uint"
diff --git a/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v1.xml
index c5f58e91c86..6db9c05a415 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v1.xml
@@ -542,7 +542,6 @@
wp_tablet_tool.proximity_in and wp_tablet_tool.proximity_out for
details.
</description>
-
<arg name="serial" type="uint"/>
<arg name="button" type="uint" summary="The button whose state has changed"/>
<arg name="state" type="uint" enum="button_state" summary="Whether the button was pressed or released"/>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v2.xml b/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v2.xml
index 728a3df9f4b..b286d964af8 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v2.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/tablet/tablet-unstable-v2.xml
@@ -556,7 +556,6 @@
wp_tablet_tool.proximity_in and wp_tablet_tool.proximity_out for
details.
</description>
-
<arg name="serial" type="uint"/>
<arg name="button" type="uint" summary="The button whose state has changed"/>
<arg name="state" type="uint" enum="button_state" summary="Whether the button was pressed or released"/>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml
index d37ffcf8055..29a217ebe2e 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml
@@ -4,35 +4,36 @@
<copyright>
Copyright © 2012, 2013 Intel Corporation
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice (including the next
- paragraph) shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zwp_text_input_v1" version="1">
<description summary="text input">
An object used for text input. Adds support for text input and input
- methods to applications. A text-input object is created from a
+ methods to applications. A text_input object is created from a
wl_text_input_manager and corresponds typically to a text entry in an
application.
- Requests are used to activate/deactivate the text-input object and set
+
+ Requests are used to activate/deactivate the text_input object and set
state information like surrounding and selected text or the content type.
- The information about entered text is sent to the text-input object via
+ The information about entered text is sent to the text_input object via
the pre-edit and commit events. Using this interface removes the need
for applications to directly process hardware key events and compose text
out of them.
@@ -58,11 +59,12 @@
<request name="activate">
<description summary="request activation">
- Requests the text-input object to be activated (typically when the
+ Requests the text_input object to be activated (typically when the
text entry gets focus).
+
The seat argument is a wl_seat which maintains the focus for this
activation. The surface argument is a wl_surface assigned to the
- text-input object and tracked for focus lost. The enter event
+ text_input object and tracked for focus lost. The enter event
is emitted on successful activation.
</description>
<arg name="seat" type="object" interface="wl_seat"/>
@@ -71,7 +73,7 @@
<request name="deactivate">
<description summary="request deactivation">
- Requests the text-input object to be deactivated (typically when the
+ Requests the text_input object to be deactivated (typically when the
text entry lost focus). The seat argument is a wl_seat which was used
for activation.
</description>
@@ -104,7 +106,7 @@
UTF-8 encoded. Cursor is the byte offset within the
surrounding text. Anchor is the byte offset of the
selection anchor within the surrounding text. If there is no selected
- text anchor is the same as cursor.
+ text anchor, then it is the same as cursor.
</description>
<arg name="text" type="string"/>
<arg name="cursor" type="uint"/>
@@ -178,12 +180,12 @@
<request name="set_preferred_language">
<description summary="sets preferred language">
Sets a specific language. This allows for example a virtual keyboard to
- show a language specific layout. The "language" argument is a RFC-3066
+ show a language specific layout. The "language" argument is an RFC-3066
format language tag.
- It could be used for example in a word processor to indicate language of
- currently edited document or in an instant message application which tracks
- languages of contacts.
+ It could be used for example in a word processor to indicate the
+ language of the currently edited document or in an instant message
+ application which tracks languages of contacts.
</description>
<arg name="language" type="string"/>
</request>
@@ -199,7 +201,7 @@
<event name="enter">
<description summary="enter event">
- Notify the text-input object when it received focus. Typically in
+ Notify the text_input object when it received focus. Typically in
response to an activate request.
</description>
<arg name="surface" type="object" interface="wl_surface"/>
@@ -207,7 +209,7 @@
<event name="leave">
<description summary="leave event">
- Notify the text-input object when it lost focus. Either in response
+ Notify the text_input object when it lost focus. Either in response
to a deactivate request or when the assigned surface lost focus or was
destroyed.
</description>
@@ -215,7 +217,7 @@
<event name="modifiers_map">
<description summary="modifiers map">
- Transfer an array of 0-terminated modifiers names. The position in
+ Transfer an array of 0-terminated modifier names. The position in
the array is the index of the modifier as used in the modifiers
bitmask in the keysym event.
</description>
@@ -287,7 +289,7 @@
<description summary="commit">
Notify when text should be inserted into the editor widget. The text to
commit could be either just a single character after a key press or the
- result of some composing (pre-edit). It could be also an empty text
+ result of some composing (pre-edit). It could also be an empty text
when some text should be removed (see delete_surrounding_text) or when
the input cursor should be moved (see cursor_position).
@@ -341,8 +343,8 @@
<event name="language">
<description summary="language">
- Sets the language of the input text. The "language" argument is a RFC-3066
- format language tag.
+ Sets the language of the input text. The "language" argument is an
+ RFC-3066 format language tag.
</description>
<arg name="serial" type="uint" summary="serial of the latest known text input state"/>
<arg name="language" type="string"/>
@@ -358,8 +360,8 @@
<description summary="text direction">
Sets the text direction of input text.
- It is mainly needed for showing input cursor on correct side of the
- editor when there is no input yet done and making sure neutral
+ It is mainly needed for showing an input cursor on the correct side of
+ the editor when there is no input done yet and making sure neutral
direction text is laid out properly.
</description>
<arg name="serial" type="uint" summary="serial of the latest known text input state"/>
@@ -369,12 +371,12 @@
<interface name="zwp_text_input_manager_v1" version="1">
<description summary="text input manager">
- A factory for text-input objects. This object is a global singleton.
+ A factory for text_input objects. This object is a global singleton.
</description>
<request name="create_text_input">
<description summary="create text input">
- Creates a new text-input object.
+ Creates a new text_input object.
</description>
<arg name="id" type="new_id" interface="zwp_text_input_v1"/>
</request>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml b/chromium/third_party/wayland-protocols/src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
index c6f577573c1..062b09041a2 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
@@ -80,7 +80,6 @@
be used to create a xdg_imported multiple times. Only xdg_surface
surfaces may be exported.
</description>
-
<arg name="id" type="new_id" interface="zxdg_exported_v1"
summary="the new xdg_exported object"/>
<arg name="surface" type="object" interface="wl_surface"
@@ -110,7 +109,6 @@
represents the imported surface, and the importing client can
manipulate its relationship using it. See xdg_imported for details.
</description>
-
<arg name="id" type="new_id" interface="zxdg_imported_v1"
summary="the new xdg_imported object"/>
<arg name="handle" type="string"
@@ -141,7 +139,6 @@
import the surface by calling xdg_importer.import. A handle may be
used to import the surface multiple times.
</description>
-
<arg name="handle" type="string" summary="the exported surface handle"/>
</event>
</interface>
@@ -168,7 +165,6 @@
sets up a surface to surface relation with the same stacking and positioning
semantics as xdg_surface.set_parent.
</description>
-
<arg name="surface" type="object" interface="wl_surface"
summary="the child surface"/>
</request>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v5.xml b/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v5.xml
index 542491fa8a8..ef0180d0107 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v5.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v5.xml
@@ -234,7 +234,6 @@
This request must be used in response to some sort of user action
like a button press, key press, or touch down event.
</description>
-
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
<arg name="serial" type="uint" summary="the serial of the user event"/>
<arg name="x" type="int" summary="the x position to pop up the window menu at"/>
@@ -396,7 +395,6 @@
can respond to one, it is free to discard all but the last
event it received.
</description>
-
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="states" type="array"/>
diff --git a/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml b/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml
index 565df8ce35c..e49d74fccd8 100644
--- a/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml
+++ b/chromium/third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml
@@ -247,7 +247,6 @@
The adjustments can be combined, according to a defined precedence: 1)
Flip, 2) Slide, 3) Resize.
</description>
-
<entry name="none" value="0">
<description summary="don't move the child surface when constrained">
Don't alter the surface position even if it is constrained on some
@@ -567,7 +566,7 @@
service name.
The compositor shell will try to group application surfaces together
- by their app ID. As a best practice, it is suggested to select app
+ by their app ID. As a best practice, it is suggested to select app
ID's that match the basename of the application's .desktop file.
For example, "org.freedesktop.FooViewer" where the .desktop file is
"org.freedesktop.FooViewer.desktop".
@@ -595,7 +594,6 @@
This request must be used in response to some sort of user action
like a button press, key press, or touch down event.
</description>
-
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
<arg name="serial" type="uint" summary="the serial of the user event"/>
<arg name="x" type="int" summary="the x position to pop up the window menu at"/>
@@ -884,7 +882,7 @@
If the width or height arguments are zero, it means the client
should decide its own window dimension. This may happen when the
- compositor need to configure the state of the surface but doesn't
+ compositor needs to configure the state of the surface but doesn't
have any information about any previous or expected dimension.
The states listed in the event specify how the width/height
@@ -894,7 +892,6 @@
Clients must send an ack_configure in response to this event. See
xdg_surface.configure and xdg_surface.ack_configure for details.
</description>
-
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="states" type="array"/>
@@ -905,11 +902,11 @@
The close event is sent by the compositor when the user
wants the surface to be closed. This should be equivalent to
the user clicking the close button in client-side decorations,
- if your application has any...
+ if your application has any.
- This is only a request that the user intends to close your
+ This is only a request that the user intends to close the
window. The client may choose to ignore this request, or show
- a dialog to ask the user to save their data...
+ a dialog to ask the user to save their data, etc.
</description>
</event>
</interface>
@@ -1009,7 +1006,6 @@
"owner-events" grab in X11 parlance), while the top most grabbing popup
will always have keyboard focus.
</description>
-
<arg name="seat" type="object" interface="wl_seat"
summary="the wl_seat of the user event"/>
<arg name="serial" type="uint" summary="the serial of the user event"/>
diff --git a/chromium/third_party/wayland-protocols/src/wayland-protocols-uninstalled.pc.in b/chromium/third_party/wayland-protocols/src/wayland-protocols-uninstalled.pc.in
new file mode 100644
index 00000000000..cf7adf257a7
--- /dev/null
+++ b/chromium/third_party/wayland-protocols/src/wayland-protocols-uninstalled.pc.in
@@ -0,0 +1,5 @@
+pkgdatadir=@abs_top_srcdir@
+
+Name: Wayland Protocols
+Description: Wayland protocol files (not installed)
+Version: @WAYLAND_PROTOCOLS_VERSION@
diff --git a/chromium/third_party/wayland/src/Makefile.am b/chromium/third_party/wayland/src/Makefile.am
index d35231cd33b..d78a0ca5ef6 100644
--- a/chromium/third_party/wayland/src/Makefile.am
+++ b/chromium/third_party/wayland/src/Makefile.am
@@ -151,6 +151,7 @@ built_test_programs = \
connection-test \
event-loop-test \
fixed-test \
+ interface-test \
list-test \
map-test \
os-wrappers-test \
@@ -168,16 +169,22 @@ if ENABLE_CPP_TEST
built_test_programs += cpp-compile-test
endif
-TESTS = $(built_test_programs)
+AM_TESTS_ENVIRONMENT = \
+ export WAYLAND_SCANNER='$(top_builddir)/wayland-scanner' \
+ TEST_DATA_DIR='$(top_srcdir)/tests/data' \
+ TEST_OUTPUT_DIR='$(top_builddir)/tests/output' \
+ SED=$(SED) \
+ ;
-check_PROGRAMS = \
- $(built_test_programs) \
- exec-fd-leak-checker
+TESTS = $(built_test_programs) \
+ tests/scanner-test.sh
noinst_PROGRAMS = \
+ $(built_test_programs) \
+ exec-fd-leak-checker \
fixed-benchmark
-check_LTLIBRARIES = libtest-runner.la
+noinst_LTLIBRARIES += libtest-runner.la
libtest_runner_la_SOURCES = \
tests/test-runner.c \
@@ -205,6 +212,8 @@ event_loop_test_SOURCES = tests/event-loop-test.c
event_loop_test_LDADD = libtest-runner.la
fixed_test_SOURCES = tests/fixed-test.c
fixed_test_LDADD = libtest-runner.la
+interface_test_SOURCES = tests/interface-test.c
+interface_test_LDADD = libtest-runner.la
list_test_SOURCES = tests/list-test.c
list_test_LDADD = libtest-runner.la
map_test_SOURCES = tests/map-test.c
@@ -245,4 +254,23 @@ os_wrappers_test_LDADD = libtest-runner.la
exec_fd_leak_checker_SOURCES = tests/exec-fd-leak-checker.c
exec_fd_leak_checker_LDADD = libtest-runner.la
+
+EXTRA_DIST += tests/scanner-test.sh \
+ tests/data/example.xml \
+ tests/data/example-client.h \
+ tests/data/example-server.h \
+ tests/data/example-code.c \
+ tests/data/small.xml \
+ tests/data/small-code.c \
+ tests/data/small-client.h \
+ tests/data/small-server.h \
+ tests/data/small-code-core.c \
+ tests/data/small-client-core.h \
+ tests/data/small-server-core.h
+
+tests/scanner-test.sh: $(top_builddir)/wayland-scanner
+
+clean-local:
+ -rm -rf tests/output
+
endif #ENABLE_LIBRARIES
diff --git a/chromium/third_party/wayland/src/cursor/os-compatibility.c b/chromium/third_party/wayland/src/cursor/os-compatibility.c
index d7d4b33b43b..e972d219587 100644
--- a/chromium/third_party/wayland/src/cursor/os-compatibility.c
+++ b/chromium/third_party/wayland/src/cursor/os-compatibility.c
@@ -103,7 +103,7 @@ create_tmpfile_cloexec(char *tmpname)
int
os_create_anonymous_file(off_t size)
{
- static const char template[] = "/weston-shared-XXXXXX";
+ static const char template[] = "/wayland-cursor-shared-XXXXXX";
const char *path;
char *name;
int fd;
diff --git a/chromium/third_party/wayland/src/doc/doxygen/Makefile.am b/chromium/third_party/wayland/src/doc/doxygen/Makefile.am
index c3773536230..276a395bfbf 100644
--- a/chromium/third_party/wayland/src/doc/doxygen/Makefile.am
+++ b/chromium/third_party/wayland/src/doc/doxygen/Makefile.am
@@ -9,7 +9,6 @@ noinst_DATA = \
dist_noinst_DATA = wayland.doxygen.in
scanned_src_files_shared = \
- $(top_srcdir)/src/wayland-util.c \
$(top_srcdir)/src/wayland-util.h
scanned_src_files_Client = \
diff --git a/chromium/third_party/wayland/src/doc/doxygen/wayland.doxygen.in b/chromium/third_party/wayland/src/doc/doxygen/wayland.doxygen.in
index 9d7fa0c40f1..3913a135789 100644
--- a/chromium/third_party/wayland/src/doc/doxygen/wayland.doxygen.in
+++ b/chromium/third_party/wayland/src/doc/doxygen/wayland.doxygen.in
@@ -8,7 +8,8 @@ QUIET = YES
HTML_TIMESTAMP = YES
GENERATE_LATEX = NO
MAN_LINKS = YES
-PREDEFINED = WL_EXPORT=
+PREDEFINED = WL_EXPORT= \
+ WL_PRINTF(x,y)=
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
DOT_MULTI_TARGETS = YES
diff --git a/chromium/third_party/wayland/src/doc/publican/sources/Client.xml b/chromium/third_party/wayland/src/doc/publican/sources/Client.xml
index fcdd2f2f0ba..19bf3e9572a 100644
--- a/chromium/third_party/wayland/src/doc/publican/sources/Client.xml
+++ b/chromium/third_party/wayland/src/doc/publican/sources/Client.xml
@@ -30,7 +30,7 @@
object created.
</para>
<para>
- Though some conveinence functions are provided, libwayland-client
+ Though some convenience functions are provided, libwayland-client
is designed to allow the calling code to wait for events, so that
different polling mechanisms can be used. A file descriptor is
provided, when it becomes ready for reading the calling code can
diff --git a/chromium/third_party/wayland/src/protocol/wayland.xml b/chromium/third_party/wayland/src/protocol/wayland.xml
index 8311a18de1f..098f286bab7 100644
--- a/chromium/third_party/wayland/src/protocol/wayland.xml
+++ b/chromium/third_party/wayland/src/protocol/wayland.xml
@@ -129,7 +129,7 @@
<request name="bind">
<description summary="bind an object to the display">
Binds a new, client-created object to the server using the
- specified name as the identifier.
+ specified name as the identifier.
</description>
<arg name="name" type="uint" summary="unique numeric name of the object"/>
<arg name="id" type="new_id" summary="bounded object"/>
@@ -139,9 +139,9 @@
<description summary="announce global object">
Notify the client of global objects.
- The event notifies the client that a global object with
- the given name is now available, and it implements the
- given version of the given interface.
+ The event notifies the client that a global object with
+ the given name is now available, and it implements the
+ given version of the given interface.
</description>
<arg name="name" type="uint" summary="numeric name of the global object"/>
<arg name="interface" type="string" summary="interface implemented by the object"/>
@@ -152,10 +152,10 @@
<description summary="announce removal of global object">
Notify the client of removed global objects.
- This event notifies the client that the global identified
- by name is no longer available. If the client bound to
- the global using the bind request, the client should now
- destroy that object.
+ This event notifies the client that the global identified
+ by name is no longer available. If the client bound to
+ the global using the bind request, the client should now
+ destroy that object.
The object remains valid and requests to the object will be
ignored until the client destroys it, to avoid races between
@@ -355,7 +355,7 @@
The pool can be used to create shared memory based buffer
objects. The server will mmap size bytes of the passed file
- descriptor, to use as backing memory for the pool.
+ descriptor, to use as backing memory for the pool.
</description>
<arg name="id" type="new_id" interface="wl_shm_pool" summary="pool to create"/>
<arg name="fd" type="fd" summary="file descriptor for the pool"/>
@@ -915,14 +915,14 @@
<request name="create_data_source">
<description summary="create a new data source">
- Create a new data source.
+ Create a new data source.
</description>
<arg name="id" type="new_id" interface="wl_data_source" summary="data source to create"/>
</request>
<request name="get_data_device">
<description summary="create a new data device">
- Create a new data device for a given seat.
+ Create a new data device for a given seat.
</description>
<arg name="id" type="new_id" interface="wl_data_device" summary="data device to create"/>
<arg name="seat" type="object" interface="wl_seat" summary="seat associated with the data device"/>
@@ -1308,7 +1308,7 @@
<enum name="error">
<description summary="wl_surface error values">
- These errors can be emitted in response to wl_surface requests.
+ These errors can be emitted in response to wl_surface requests.
</description>
<entry name="invalid_scale" value="0" summary="buffer scale value is invalid"/>
<entry name="invalid_transform" value="1" summary="buffer transform value is invalid"/>
@@ -1661,8 +1661,8 @@
<enum name="capability" bitfield="true">
<description summary="seat capability bitmask">
- This is a bitmask of capabilities this seat has; if a member is
- set, then it is present on the seat.
+ This is a bitmask of capabilities this seat has; if a member is
+ set, then it is present on the seat.
</description>
<entry name="pointer" value="1" summary="the seat has pointer devices"/>
<entry name="keyboard" value="2" summary="the seat has one or more keyboards"/>
@@ -1857,7 +1857,7 @@
<enum name="button_state">
<description summary="physical button state">
- Describes the physical state of a button that produced the button
+ Describes the physical state of a button that produced the button
event.
</description>
<entry name="released" value="0" summary="the button is not pressed"/>
@@ -1870,8 +1870,16 @@
The location of the click is given by the last motion or
enter event.
- The time argument is a timestamp with millisecond
- granularity, with an undefined base.
+ The time argument is a timestamp with millisecond
+ granularity, with an undefined base.
+
+ The button is a button code as defined in the Linux kernel's
+ linux/input-event-codes.h header file, e.g. BTN_LEFT.
+
+ Any 16-bit button code value is reserved for future additions to the
+ kernel's event code list. All other button codes above 0xFFFF are
+ currently undefined but may be used in future versions of this
+ protocol.
</description>
<arg name="serial" type="uint" summary="serial number of the button event"/>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
@@ -2083,7 +2091,7 @@
<entry name="no_keymap" value="0"
summary="no keymap; client must understand how to interpret the raw keycode"/>
<entry name="xkb_v1" value="1"
- summary="libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode"/>
+ summary="libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode"/>
</enum>
<event name="keymap">
@@ -2129,8 +2137,8 @@
<event name="key">
<description summary="key event">
A key was pressed or released.
- The time argument is a timestamp with millisecond
- granularity, with an undefined base.
+ The time argument is a timestamp with millisecond
+ granularity, with an undefined base.
</description>
<arg name="serial" type="uint" summary="serial number of the key event"/>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
@@ -2160,23 +2168,23 @@
<event name="repeat_info" since="4">
<description summary="repeat rate and delay">
- Informs the client about the keyboard's repeat rate and delay.
+ Informs the client about the keyboard's repeat rate and delay.
- This event is sent as soon as the wl_keyboard object has been created,
- and is guaranteed to be received by the client before any key press
- event.
+ This event is sent as soon as the wl_keyboard object has been created,
+ and is guaranteed to be received by the client before any key press
+ event.
- Negative values for either rate or delay are illegal. A rate of zero
- will disable any repeating (regardless of the value of delay).
+ Negative values for either rate or delay are illegal. A rate of zero
+ will disable any repeating (regardless of the value of delay).
- This event can be sent later on as well with a new value if necessary,
- so clients should continue listening for the event past the creation
- of wl_keyboard.
+ This event can be sent later on as well with a new value if necessary,
+ so clients should continue listening for the event past the creation
+ of wl_keyboard.
</description>
<arg name="rate" type="int"
- summary="the rate of repeating keys in characters per second"/>
+ summary="the rate of repeating keys in characters per second"/>
<arg name="delay" type="int"
- summary="delay in milliseconds since key down until repeating starts"/>
+ summary="delay in milliseconds since key down until repeating starts"/>
</event>
</interface>
@@ -2417,10 +2425,10 @@
mode that was received with the current flag set.
The size of a mode is given in physical hardware units of
- the output device. This is not necessarily the same as
- the output size in the global compositor space. For instance,
- the output may be scaled, as described in wl_output.scale,
- or transformed, as described in wl_output.transform.
+ the output device. This is not necessarily the same as
+ the output size in the global compositor space. For instance,
+ the output may be scaled, as described in wl_output.scale,
+ or transformed, as described in wl_output.transform.
</description>
<arg name="flags" type="uint" enum="mode" summary="bitfield of mode flags"/>
<arg name="width" type="int" summary="width of the mode in hardware units"/>
@@ -2432,20 +2440,20 @@
<event name="done" since="2">
<description summary="sent all information about output">
- This event is sent after all other properties have been
- sent after binding to the output object and after any
- other property changes done after that. This allows
- changes to the output properties to be seen as
- atomic, even if they happen via multiple events.
+ This event is sent after all other properties have been
+ sent after binding to the output object and after any
+ other property changes done after that. This allows
+ changes to the output properties to be seen as
+ atomic, even if they happen via multiple events.
</description>
</event>
<event name="scale" since="2">
<description summary="output scaling properties">
This event contains scaling geometry information
- that is not in the geometry event. It may be sent after
- binding the output object or if the output scale changes
- later. If it is not sent, the client should assume a
+ that is not in the geometry event. It may be sent after
+ binding the output object or if the output scale changes
+ later. If it is not sent, the client should assume a
scale of 1.
A scale larger than 1 means that the compositor will
@@ -2542,7 +2550,7 @@
<enum name="error">
<entry name="bad_surface" value="0"
- summary="the to-be sub-surface is invalid"/>
+ summary="the to-be sub-surface is invalid"/>
</enum>
<request name="get_subsurface">
@@ -2556,11 +2564,11 @@
error is raised.
</description>
<arg name="id" type="new_id" interface="wl_subsurface"
- summary="the new sub-surface object ID"/>
+ summary="the new sub-surface object ID"/>
<arg name="surface" type="object" interface="wl_surface"
- summary="the surface to be turned into a sub-surface"/>
+ summary="the surface to be turned into a sub-surface"/>
<arg name="parent" type="object" interface="wl_surface"
- summary="the parent surface"/>
+ summary="the parent surface"/>
</request>
</interface>
@@ -2629,7 +2637,7 @@
<enum name="error">
<entry name="bad_surface" value="0"
- summary="wl_surface is not a sibling or the parent"/>
+ summary="wl_surface is not a sibling or the parent"/>
</enum>
<request name="set_position">
@@ -2674,7 +2682,7 @@
of its siblings and parent.
</description>
<arg name="sibling" type="object" interface="wl_surface"
- summary="the reference surface"/>
+ summary="the reference surface"/>
</request>
<request name="place_below">
@@ -2683,7 +2691,7 @@
See wl_subsurface.place_above.
</description>
<arg name="sibling" type="object" interface="wl_surface"
- summary="the reference surface"/>
+ summary="the reference surface"/>
</request>
<request name="set_sync">
diff --git a/chromium/third_party/wayland/src/src/wayland-client-uninstalled.pc.in b/chromium/third_party/wayland/src/src/wayland-client-uninstalled.pc.in
index 3086621da4e..732736e94a3 100644
--- a/chromium/third_party/wayland/src/src/wayland-client-uninstalled.pc.in
+++ b/chromium/third_party/wayland/src/src/wayland-client-uninstalled.pc.in
@@ -1,8 +1,9 @@
libdir=@abs_builddir@/.libs
includedir=@abs_srcdir@
+protocoldir=@abs_top_builddir@/protocol
Name: Wayland Client
Description: Wayland client side library (not installed)
Version: @PACKAGE_VERSION@
-Cflags: -I${includedir}
+Cflags: -I${includedir} -I${protocoldir}
Libs: -L${libdir} -lwayland-client
diff --git a/chromium/third_party/wayland/src/src/wayland-client.c b/chromium/third_party/wayland/src/src/wayland-client.c
index 03c087a66ae..3d7361ea943 100644
--- a/chromium/third_party/wayland/src/src/wayland-client.c
+++ b/chromium/third_party/wayland/src/src/wayland-client.c
@@ -1006,7 +1006,7 @@ wl_display_connect(const char *name)
if (connection) {
int prev_errno = errno;
errno = 0;
- fd = strtol(connection, &end, 0);
+ fd = strtol(connection, &end, 10);
if (errno != 0 || connection == end || *end != '\0')
return NULL;
errno = prev_errno;
diff --git a/chromium/third_party/wayland/src/src/wayland-scanner-uninstalled.pc.in b/chromium/third_party/wayland/src/src/wayland-scanner-uninstalled.pc.in
index 8dcfef31541..132f42d0616 100644
--- a/chromium/third_party/wayland/src/src/wayland-scanner-uninstalled.pc.in
+++ b/chromium/third_party/wayland/src/src/wayland-scanner-uninstalled.pc.in
@@ -1,5 +1,5 @@
pkgdatadir=@abs_top_srcdir@
-wayland_scanner=@abs_builddir@/wayland-scanner
+wayland_scanner=@abs_top_builddir@/wayland-scanner
Name: Wayland Scanner
Description: Wayland scanner (not installed)
diff --git a/chromium/third_party/wayland/src/src/wayland-server-uninstalled.pc.in b/chromium/third_party/wayland/src/src/wayland-server-uninstalled.pc.in
index 90577828cac..562686c31d1 100644
--- a/chromium/third_party/wayland/src/src/wayland-server-uninstalled.pc.in
+++ b/chromium/third_party/wayland/src/src/wayland-server-uninstalled.pc.in
@@ -1,8 +1,9 @@
libdir=@abs_builddir@/.libs
includedir=@abs_srcdir@
+protocoldir=@abs_top_builddir@/protocol
Name: Wayland Server
Description: Server side implementation of the Wayland protocol (not installed)
Version: @PACKAGE_VERSION@
-Cflags: -I${includedir}
+Cflags: -I${includedir} -I${protocoldir}
Libs: -L${libdir} -lwayland-server
diff --git a/chromium/third_party/wayland/src/src/wayland-util.h b/chromium/third_party/wayland/src/src/wayland-util.h
index 50f3372a942..caeac826738 100644
--- a/chromium/third_party/wayland/src/src/wayland-util.h
+++ b/chromium/third_party/wayland/src/src/wayland-util.h
@@ -142,12 +142,64 @@ struct wl_message {
const struct wl_interface **types;
};
+/**
+ * Protocol object interface
+ *
+ * A wl_interface describes the API of a protocol object defined in the Wayland
+ * protocol specification. The protocol implementation uses a wl_interface
+ * within its marshalling machinery for encoding client requests.
+ *
+ * The `name` of a wl_interface is the name of the corresponding protocol
+ * interface, and `version` represents the version of the interface. The members
+ * `method_count` and `event_count` represent the number of `methods` (requests)
+ * and `events` in the respective wl_message members.
+ *
+ * For example, consider a protocol interface `foo`, marked as version `1`, with
+ * two requests and one event.
+ *
+ * \code
+ * <interface name="foo" version="1">
+ * <request name="a"></request>
+ * <request name="b"></request>
+ * <event name="c"></event>
+ * </interface>
+ * \endcode
+ *
+ * Given two wl_message arrays `foo_requests` and `foo_events`, a wl_interface
+ * for `foo` might be:
+ *
+ * \code
+ * struct wl_interface foo_interface = {
+ * "foo", 1,
+ * 2, foo_requests,
+ * 1, foo_events
+ * };
+ * \endcode
+ *
+ * \note The server side of the protocol may define interface <em>implementation
+ * types</em> that incorporate the term `interface` in their name. Take
+ * care to not confuse these server-side `struct`s with a wl_interface
+ * variable whose name also ends in `interface`. For example, while the
+ * server may define a type `struct wl_foo_interface`, the client may
+ * define a `struct wl_interface wl_foo_interface`.
+ *
+ * \sa wl_message
+ * \sa wl_proxy
+ * \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Interfaces">Interfaces</a>
+ * \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Versioning">Versioning</a>
+ */
struct wl_interface {
+ /** Interface name */
const char *name;
+ /** Interface version */
int version;
+ /** Number of methods (requests) */
int method_count;
+ /** Method (request) signatures */
const struct wl_message *methods;
+ /** Number of events */
int event_count;
+ /** Event signatures */
const struct wl_message *events;
};
@@ -209,7 +261,9 @@ struct wl_interface {
* \sa http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/list.h
*/
struct wl_list {
+ /** Previous list element */
struct wl_list *prev;
+ /** Next list element */
struct wl_list *next;
};
@@ -438,8 +492,11 @@ wl_list_insert_list(struct wl_list *list, struct wl_list *other);
*
*/
struct wl_array {
+ /** Array size */
size_t size;
+ /** Allocated space */
size_t alloc;
+ /** Array data */
void *data;
};
@@ -588,50 +645,86 @@ wl_fixed_from_int(int i)
}
/**
- * \brief A union representing all of the basic data types that can be passed
- * along the wayland wire format.
+ * Protocol message argument data types
*
- * This union represents all of the basic data types that can be passed in the
- * wayland wire format. It is used by dispatchers and runtime-friendly
- * versions of the event and request marshaling functions.
+ * This union represents all of the argument types in the Wayland protocol wire
+ * format. The protocol implementation uses wl_argument within its marshalling
+ * machinery for dispatching messages between a client and a compositor.
+ *
+ * \sa wl_message
+ * \sa wl_interface
+ * \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-wire-Format">Wire Format</a>
*/
union wl_argument {
- int32_t i; /**< signed integer */
- uint32_t u; /**< unsigned integer */
- wl_fixed_t f; /**< fixed point */
- const char *s; /**< string */
- struct wl_object *o; /**< object */
- uint32_t n; /**< new_id */
- struct wl_array *a; /**< array */
- int32_t h; /**< file descriptor */
+ int32_t i; /**< `int` */
+ uint32_t u; /**< `uint` */
+ wl_fixed_t f; /**< `fixed` */
+ const char *s; /**< `string` */
+ struct wl_object *o; /**< `object` */
+ uint32_t n; /**< `new_id` */
+ struct wl_array *a; /**< `array` */
+ int32_t h; /**< `fd` */
};
/**
- * \brief A function pointer type for a dispatcher.
+ * Dispatcher function type alias
*
* A dispatcher is a function that handles the emitting of callbacks in client
- * code. For programs directly using the C library, this is done by using
- * libffi to call function pointers. When binding to languages other than C,
+ * code. For programs directly using the C library, this is done by using
+ * libffi to call function pointers. When binding to languages other than C,
* dispatchers provide a way to abstract the function calling process to be
* friendlier to other function calling systems.
*
- * A dispatcher takes five arguments: The first is the dispatcher-specific
- * implementation data associated with the target object. The second is the
- * object on which the callback is being invoked (either wl_proxy or
- * wl_resource). The third and fourth arguments are the opcode the wl_message
- * structure corresponding to the callback being emitted. The final argument
- * is an array of arguments received from the other process via the wire
- * protocol.
+ * A dispatcher takes five arguments: The first is the dispatcher-specific
+ * implementation associated with the target object. The second is the object
+ * upon which the callback is being invoked (either wl_proxy or wl_resource).
+ * The third and fourth arguments are the opcode and the wl_message
+ * corresponding to the callback. The final argument is an array of arguments
+ * received from the other process via the wire protocol.
+ *
+ * \param "const void *" Dispatcher-specific implementation data
+ * \param "void *" Callback invocation target (wl_proxy or `wl_resource`)
+ * \param uint32_t Callback opcode
+ * \param "const struct wl_message *" Callback message signature
+ * \param "union wl_argument *" Array of received arguments
+ *
+ * \return 0 on success, or -1 on failure
*/
typedef int (*wl_dispatcher_func_t)(const void *, void *, uint32_t,
const struct wl_message *,
union wl_argument *);
+/**
+ * Log function type alias
+ *
+ * The C implementation of the Wayland protocol abstracts the details of
+ * logging. Users may customize the logging behavior, with a function conforming
+ * to the `wl_log_func_t` type, via `wl_log_set_handler_client` and
+ * `wl_log_set_handler_server`.
+ *
+ * A `wl_log_func_t` must conform to the expectations of `vprintf`, and
+ * expects two arguments: a string to write and a corresponding variable
+ * argument list. While the string to write may contain format specifiers and
+ * use values in the variable argument list, the behavior of any `wl_log_func_t`
+ * depends on the implementation.
+ *
+ * \note Take care to not confuse this with `wl_protocol_logger_func_t`, which
+ * is a specific server-side logger for requests and events.
+ *
+ * \param "const char *" String to write to the log, containing optional format
+ * specifiers
+ * \param "va_list" Variable argument list
+ *
+ * \sa wl_log_set_handler_client
+ * \sa wl_log_set_handler_server
+ */
typedef void (*wl_log_func_t)(const char *, va_list) WL_PRINTF(1, 0);
-/** \enum wl_iterator_result
+/**
+ * Return value of an iterator function
*
- * This enum represents the return value of an iterator function.
+ * \sa wl_client_for_each_resource_iterator_func_t
+ * \sa wl_client_for_each_resource
*/
enum wl_iterator_result {
/** Stop the iteration */
diff --git a/chromium/third_party/wds/src/desktop_source/mirac_broker_source.cpp b/chromium/third_party/wds/src/desktop_source/mirac_broker_source.cpp
index 24adc7acb93..d6acc956895 100644
--- a/chromium/third_party/wds/src/desktop_source/mirac_broker_source.cpp
+++ b/chromium/third_party/wds/src/desktop_source/mirac_broker_source.cpp
@@ -46,8 +46,12 @@ void MiracBrokerSource::on_connection_failure(ConnectionFailure failure) {
switch (failure) {
case CONNECTION_LOST:
std::cout << "* RTSP connection lost" << std::endl;
+ break;
case CONNECTION_TIMEOUT:
std::cout << "* RTSP connection failed: timeout" << std::endl;
+ break;
+ default:
+ std::cout << "* RTSP connection failure" << std::endl;
}
}
diff --git a/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.cc b/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.cc
index f9e96ace046..48f7737ab51 100644
--- a/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.cc
+++ b/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.cc
@@ -206,16 +206,21 @@ void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) {
// Extract the previous block.
WebRtc_MoveReadPtr(buffer_, -1);
- WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr),
- &extended_block[0], 1);
- if (block_ptr != &extended_block[0]) {
+ size_t read_elements = WebRtc_ReadBuffer(
+ buffer_, reinterpret_cast<void**>(&block_ptr), &extended_block[0], 1);
+ if (read_elements == 0u) {
+ std::fill_n(&extended_block[0], PART_LEN, 0.0f);
+ } else if (block_ptr != &extended_block[0]) {
memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float));
}
// Extract the current block.
- WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr),
- &extended_block[PART_LEN], 1);
- if (block_ptr != &extended_block[PART_LEN]) {
+ read_elements =
+ WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr),
+ &extended_block[PART_LEN], 1);
+ if (read_elements == 0u) {
+ std::fill_n(&extended_block[PART_LEN], PART_LEN, 0.0f);
+ } else if (block_ptr != &extended_block[PART_LEN]) {
memcpy(&extended_block[PART_LEN], block_ptr, PART_LEN * sizeof(float));
}
}
diff --git a/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_context.cc b/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_context.cc
index dffefc404f6..18ca9909707 100644
--- a/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_context.cc
+++ b/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_context.cc
@@ -21,10 +21,11 @@ DxgiAdapterContext::~DxgiAdapterContext() = default;
DxgiFrameContext::DxgiFrameContext() = default;
DxgiFrameContext::~DxgiFrameContext() {
- DxgiDuplicatorController::Instance()->Unregister(this);
+ Reset();
}
void DxgiFrameContext::Reset() {
+ DxgiDuplicatorController::Instance()->Unregister(this);
controller_id = 0;
}
diff --git a/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h b/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h
index c9838ad7a1e..128521ce6a3 100644
--- a/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h
+++ b/chromium/third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h
@@ -103,9 +103,8 @@ class DxgiDuplicatorController {
int ScreenCount();
private:
- // DxgiFrameContext calls private Unregister(Context*) function during
- // destructing.
- friend DxgiFrameContext::~DxgiFrameContext();
+ // DxgiFrameContext calls private Unregister(Context*) function in Reset().
+ friend void DxgiFrameContext::Reset();
// A private constructor to ensure consumers to use
// DxgiDuplicatorController::Instance().
diff --git a/chromium/third_party/xdg-utils/codereview.settings b/chromium/third_party/xdg-utils/codereview.settings
new file mode 100644
index 00000000000..9b30fa34ca5
--- /dev/null
+++ b/chromium/third_party/xdg-utils/codereview.settings
@@ -0,0 +1,9 @@
+CODE_REVIEW_SERVER: codereview.chromium.org
+CC_LIST: chromium-reviews@chromium.org
+VIEW_VC: https://chromium.googlesource.com/chromium/deps/xdg-utils/+/
+STATUS: http://chromium-status.appspot.com/status
+TRY_ON_UPLOAD: False
+TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try
+GITCL_PREUPLOAD: http://src.chromium.org/viewvc/chrome/trunk/tools/depot_tools/git-cl-upload-hook?revision=HEAD
+GITCL_PREDCOMMIT: http://src.chromium.org/viewvc/chrome/trunk/tools/depot_tools/git-cl-upload-hook?revision=HEAD
+PROJECT: chromium_deps