summaryrefslogtreecommitdiffstats
path: root/userspace
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-01-22 19:30:53 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-07 07:41:26 -0400
commit6e739d924fe9b778fa82396e0e941143f498acb8 (patch)
treef112ede8573c2f8bf76e0bdaadf33c6c71343820 /userspace
parente6b3bb4e6b3d4013f83ba6d31c780947f16cf410 (diff)
gpu: nvgpu: Userspace POSIX support
Add support for compiling nvgpu in a POSIX compliant userspace. This code adds all of the necessary abstraction interfaces (mostly stubbed) to enabled extremely limited and basic functionality in nvgpu. The goal of this code is to facilitate unit testing of the nvgpu common core. By doing this in userspace it is much easier to write tests that rely on very particular states within nvgpu since a user can very precisely control the state of nvgpu. JIRA NVGPU-525 Change-Id: I30e95016df14997d951075777e0585f912dc5960 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1683914 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'userspace')
-rw-r--r--userspace/.gitignore1
-rw-r--r--userspace/Makefile73
-rw-r--r--userspace/Makefile.configs15
-rw-r--r--userspace/Makefile.sources34
-rw-r--r--userspace/README.txt12
-rw-r--r--userspace/src/Makefile.tmk46
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/.
26TWD=$(CURDIR)
27
28# Top level out dir.
29OUT=$(TWD)/build
30
31# Nvgpu driver code.
32NVGPU_SRC=$(TWD)/../drivers/gpu/nvgpu
33NVGPU_OUT=$(OUT)/libnvgpu
34
35INCLUDES= \
36 -I$(NVGPU_SRC) \
37 -I$(NVGPU_SRC)/include \
38 -I../include \
39 -I../include/uapi
40
41CONFIGS= \
42 -D__NVGPU_POSIX__
43
44# Compiler, c-flags, etc.
45
46# CC = clang
47CC = gcc
48CFLAGS = -Wall -ggdb -Werror -fPIC $(INCLUDES) $(CONFIGS)
49LIBS = -lpthread -pthread
50
51# Source files. We expect $(OBJS) and $(HEADERS) to get filled in here.
52include Makefile.sources
53
54# Linuxy configs. We want these so that we can mirror builds from the actual
55# Linux kernel.
56include Makefile.configs
57
58all: $(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
72clean:
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
8configs :=
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
23include ../drivers/gpu/nvgpu/Makefile.sources
24
25OBJS := $(srcs:%.c=$(NVGPU_OUT)/%.o)
26
27
28HEADERS := \
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
61. Why do this?
7
8 Unit testing. Safety. Code coverage. Etc.
9
102. 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
17ifdef NV_COMPONENT_FLAG_NVTEST_EXECUTABLE_SECTION
18include $(NV_BUILD_START_COMPONENT)
19
20NV_COMPONENT_NAME := nvgpu_unit
21
22NV_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.
31NV_COMPONENT_NEEDED_INTERFACE_DIRS := ../../drivers/gpu/nvgpu
32
33NV_COMPONENT_INCLUDES := ../include \
34 ../../drivers/gpu/nvgpu \
35 ../../drivers/gpu/nvgpu/include
36
37
38
39include $(NV_BUILD_NVTEST_EXECUTABLE)
40endif
41
42# Local Variables:
43# indent-tabs-mode: t
44# tab-width: 8
45# End:
46# vi: set tabstop=8 noexpandtab: