diff options
Diffstat (limited to 'userspace')
-rw-r--r-- | userspace/.gitignore | 1 | ||||
-rw-r--r-- | userspace/Makefile | 73 | ||||
-rw-r--r-- | userspace/Makefile.configs | 15 | ||||
-rw-r--r-- | userspace/Makefile.sources | 34 | ||||
-rw-r--r-- | userspace/README.txt | 12 | ||||
-rw-r--r-- | userspace/src/Makefile.tmk | 46 |
6 files changed, 181 insertions, 0 deletions
diff --git a/userspace/.gitignore b/userspace/.gitignore new file mode 100644 index 00000000..d1638636 --- /dev/null +++ b/userspace/.gitignore | |||
@@ -0,0 +1 @@ | |||
build/ \ No newline at end of file | |||
diff --git a/userspace/Makefile b/userspace/Makefile new file mode 100644 index 00000000..70e93bad --- /dev/null +++ b/userspace/Makefile | |||
@@ -0,0 +1,73 @@ | |||
1 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
2 | # | ||
3 | # Permission is hereby granted, free of charge, to any person obtaining a | ||
4 | # copy of this software and associated documentation files (the "Software"), | ||
5 | # to deal in the Software without restriction, including without limitation | ||
6 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
7 | # and/or sell copies of the Software, and to permit persons to whom the | ||
8 | # Software is furnished to do so, subject to the following conditions: | ||
9 | # | ||
10 | # The above copyright notice and this permission notice shall be included in | ||
11 | # all copies or substantial portions of the Software. | ||
12 | # | ||
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
16 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
18 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
19 | # DEALINGS IN THE SOFTWARE. | ||
20 | |||
21 | # Turn off suffix rules. They are deprecated. | ||
22 | .SUFFIXES: | ||
23 | |||
24 | # Full paths. Makes submakefiles easier. That said this make file _must_ be run | ||
25 | # from <NVGPU>/userspace/. | ||
26 | TWD=$(CURDIR) | ||
27 | |||
28 | # Top level out dir. | ||
29 | OUT=$(TWD)/build | ||
30 | |||
31 | # Nvgpu driver code. | ||
32 | NVGPU_SRC=$(TWD)/../drivers/gpu/nvgpu | ||
33 | NVGPU_OUT=$(OUT)/libnvgpu | ||
34 | |||
35 | INCLUDES= \ | ||
36 | -I$(NVGPU_SRC) \ | ||
37 | -I$(NVGPU_SRC)/include \ | ||
38 | -I../include \ | ||
39 | -I../include/uapi | ||
40 | |||
41 | CONFIGS= \ | ||
42 | -D__NVGPU_POSIX__ | ||
43 | |||
44 | # Compiler, c-flags, etc. | ||
45 | |||
46 | # CC = clang | ||
47 | CC = gcc | ||
48 | CFLAGS = -Wall -ggdb -Werror -fPIC $(INCLUDES) $(CONFIGS) | ||
49 | LIBS = -lpthread -pthread | ||
50 | |||
51 | # Source files. We expect $(OBJS) and $(HEADERS) to get filled in here. | ||
52 | include Makefile.sources | ||
53 | |||
54 | # Linuxy configs. We want these so that we can mirror builds from the actual | ||
55 | # Linux kernel. | ||
56 | include Makefile.configs | ||
57 | |||
58 | all: $(OUT)/libnvgpu-drv.so | ||
59 | |||
60 | $(OUT)/libnvgpu-drv.so: $(OBJS) | ||
61 | $(CC) -shared -o $(OUT)/libnvgpu-drv.so $(OBJS) -lgcov | ||
62 | |||
63 | # Default build target for all the object files we want to build in userspace. | ||
64 | $(NVGPU_OUT)/%.o : $(NVGPU_SRC)/%.c $(HEADERS) | ||
65 | @if [ ! -d $(dir $@) ] ; then \ | ||
66 | mkdir -p $(dir $@) ; \ | ||
67 | fi | ||
68 | $(CC) $(CFLAGS) $(configs) -c -o $@ $< | ||
69 | |||
70 | .PHONY: clean | ||
71 | |||
72 | clean: | ||
73 | rm -rf $(OUT) | ||
diff --git a/userspace/Makefile.configs b/userspace/Makefile.configs new file mode 100644 index 00000000..d7e807af --- /dev/null +++ b/userspace/Makefile.configs | |||
@@ -0,0 +1,15 @@ | |||
1 | # | ||
2 | # Define various configs such as VIDMEM, etc. This is a bit annoying since | ||
3 | # this really should be specific to Linux, but many header files need to | ||
4 | # be aware of the CONFIG_* defines. As such we replicate some of the configs | ||
5 | # that we potientially will want enabled in testing. | ||
6 | # | ||
7 | |||
8 | configs := | ||
9 | |||
10 | # Enabled configs. | ||
11 | # None right now! | ||
12 | |||
13 | # Uncomment these to enable the config. | ||
14 | # configs += -DCONFIG_NVGPU_TRACK_MEM_USAGE=y | ||
15 | # configs += -DCONFIG_GK20A_VIDMEM | ||
diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources new file mode 100644 index 00000000..3598c971 --- /dev/null +++ b/userspace/Makefile.sources | |||
@@ -0,0 +1,34 @@ | |||
1 | # -*- mode: makefile -*- | ||
2 | # | ||
3 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
4 | # | ||
5 | # Permission is hereby granted, free of charge, to any person obtaining a | ||
6 | # copy of this software and associated documentation files (the "Software"), | ||
7 | # to deal in the Software without restriction, including without limitation | ||
8 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
9 | # and/or sell copies of the Software, and to permit persons to whom the | ||
10 | # Software is furnished to do so, subject to the following conditions: | ||
11 | # | ||
12 | # The above copyright notice and this permission notice shall be included in | ||
13 | # all copies or substantial portions of the Software. | ||
14 | # | ||
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
21 | # DEALINGS IN THE SOFTWARE. | ||
22 | |||
23 | include ../drivers/gpu/nvgpu/Makefile.sources | ||
24 | |||
25 | OBJS := $(srcs:%.c=$(NVGPU_OUT)/%.o) | ||
26 | |||
27 | |||
28 | HEADERS := \ | ||
29 | $(NVGPU_SRC)/include/nvgpu/*.h \ | ||
30 | $(NVGPU_SRC)/include/nvgpu/hw/*/*.h \ | ||
31 | $(NVGPU_SRC)/gk20a/*.h \ | ||
32 | $(NVGPU_SRC)/gm20b/*.h \ | ||
33 | $(NVGPU_SRC)/gp10b/*.h \ | ||
34 | $(NVGPU_SRC)/gv11b/*.h | ||
diff --git a/userspace/README.txt b/userspace/README.txt new file mode 100644 index 00000000..2599716a --- /dev/null +++ b/userspace/README.txt | |||
@@ -0,0 +1,12 @@ | |||
1 | |||
2 | |||
3 | NVGPU in userspace! | ||
4 | ~~~~~~~~~~~~~~~~~~~ | ||
5 | |||
6 | 1. Why do this? | ||
7 | |||
8 | Unit testing. Safety. Code coverage. Etc. | ||
9 | |||
10 | 2. Design and implementation | ||
11 | |||
12 | Hrmm. | ||
diff --git a/userspace/src/Makefile.tmk b/userspace/src/Makefile.tmk new file mode 100644 index 00000000..f2da773d --- /dev/null +++ b/userspace/src/Makefile.tmk | |||
@@ -0,0 +1,46 @@ | |||
1 | ################################### tell Emacs this is a -*- makefile-gmake -*- | ||
2 | # | ||
3 | # Copyright (c) 2014-2016 NVIDIA CORPORATION. All Rights Reserved. | ||
4 | # | ||
5 | # NVIDIA CORPORATION and its licensors retain all intellectual property | ||
6 | # and proprietary rights in and to this software, related documentation | ||
7 | # and any modifications thereto. Any use, reproduction, disclosure or | ||
8 | # distribution of this software and related documentation without an express | ||
9 | # license agreement from NVIDIA CORPORATION is strictly prohibited. | ||
10 | # | ||
11 | # tmake for SW Mobile component makefile | ||
12 | # | ||
13 | # Component makefile for compiling host submit tests as a part of an umbrella. | ||
14 | # | ||
15 | ############################################################################### | ||
16 | |||
17 | ifdef NV_COMPONENT_FLAG_NVTEST_EXECUTABLE_SECTION | ||
18 | include $(NV_BUILD_START_COMPONENT) | ||
19 | |||
20 | NV_COMPONENT_NAME := nvgpu_unit | ||
21 | |||
22 | NV_COMPONENT_SOURCES := unit_main.c \ | ||
23 | nvgpu.c \ | ||
24 | args.c \ | ||
25 | io.c \ | ||
26 | module.c \ | ||
27 | results.c \ | ||
28 | exec.c | ||
29 | |||
30 | # The actual userspace nvgpu library. | ||
31 | NV_COMPONENT_NEEDED_INTERFACE_DIRS := ../../drivers/gpu/nvgpu | ||
32 | |||
33 | NV_COMPONENT_INCLUDES := ../include \ | ||
34 | ../../drivers/gpu/nvgpu \ | ||
35 | ../../drivers/gpu/nvgpu/include | ||
36 | |||
37 | |||
38 | |||
39 | include $(NV_BUILD_NVTEST_EXECUTABLE) | ||
40 | endif | ||
41 | |||
42 | # Local Variables: | ||
43 | # indent-tabs-mode: t | ||
44 | # tab-width: 8 | ||
45 | # End: | ||
46 | # vi: set tabstop=8 noexpandtab: | ||