Initial commit
This commit is contained in:
167
.gitignore
vendored
Normal file
167
.gitignore
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/c,git,c++,linux,cmake,qtcreator,qt
|
||||
|
||||
### C ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
|
||||
# Precompiled Headers
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
|
||||
# Executables
|
||||
|
||||
### CMake ###
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
build
|
||||
|
||||
### Git ###
|
||||
*.orig
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### Qt ###
|
||||
# C++ objects and libs
|
||||
|
||||
|
||||
# Qt-es
|
||||
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
Makefile*
|
||||
*build-*
|
||||
|
||||
# QtCreator
|
||||
|
||||
*.autosave
|
||||
|
||||
# QtCtreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCtreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
|
||||
### QtCreator ###
|
||||
# gitignore for Qt Creator like IDE for pure C/C++ project without Qt
|
||||
#
|
||||
# Reference: http://doc.qt.io/qtcreator/creator-project-generic.html
|
||||
|
||||
|
||||
|
||||
# Qt Creator autogenerated files
|
||||
|
||||
|
||||
# A listing of all the files included in the project
|
||||
*.files
|
||||
|
||||
# Include directories
|
||||
*.includes
|
||||
|
||||
# Project configuration settings like predefined Macros
|
||||
*.config
|
||||
|
||||
# Qt Creator settings
|
||||
*.creator
|
||||
|
||||
# User project settings
|
||||
*.creator.user*
|
||||
|
||||
# Qt Creator backups
|
||||
|
||||
|
||||
# End of https://www.gitignore.io/api/c,git,c++,linux,cmake,qtcreator,qt
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 kttd
|
||||
|
||||
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
|
||||
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.
|
||||
75
dev-utility/BuildKernelModule.cmake
Normal file
75
dev-utility/BuildKernelModule.cmake
Normal file
@@ -0,0 +1,75 @@
|
||||
function(module_objects module_name input_files output_string)
|
||||
foreach(module_file ${input_files})
|
||||
string(REGEX MATCH "^.*[oc]$" match_file ${module_file})
|
||||
if(NOT ${match_file})
|
||||
file(RELATIVE_PATH rel_file "${PROJECT_SOURCE_DIR}" ${module_file} )
|
||||
string(REPLACE ".c" ".o" module_object ${rel_file})
|
||||
list(APPEND module_objects "${module_name}-objs += ${module_object}")
|
||||
endif()
|
||||
endforeach()
|
||||
string(REPLACE ";" "\n" module_objects_string "${module_objects}")
|
||||
set(${output_string} ${module_objects_string} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(module_include_directories input_dirs output_string)
|
||||
foreach(include_dir ${input_dirs})
|
||||
get_filename_component(abs_path ${include_dir} REALPATH)
|
||||
list(APPEND module_includes "ccflags-y += -I${abs_path}")
|
||||
include_directories(${abs_path})
|
||||
endforeach()
|
||||
string(REPLACE ";" "\n" module_includes_string "${module_includes}")
|
||||
set(${output_string} ${module_includes_string} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(module_add_definitions input_definitions output_string)
|
||||
foreach(input_definition ${input_definitions})
|
||||
add_definitions(${input_definition})
|
||||
list(APPEND module_definitions "ccflags-y += ${input_definition}")
|
||||
endforeach()
|
||||
string(REPLACE ";" "\n" module_definitions_string "${module_definitions}")
|
||||
set(${output_string} ${module_definitions_string} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(module_kbuild module_name module_files module_include_dirs module_defs output_string)
|
||||
module_objects("${module_name}" "${module_files}" kobjects_string)
|
||||
module_include_directories("${module_include_dirs}" kincludes_string)
|
||||
module_add_definitions("${module_defs}" kdefintions_string)
|
||||
set(${output_string}
|
||||
"${module_name}-m += ${module_name}.o
|
||||
${kobjects_string}
|
||||
|
||||
${kincludes_string}
|
||||
|
||||
${kdefintions_string}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(add_module module_name module_files module_include_dirs module_defs kernel_dir)
|
||||
set(module_build_path "${PROJECT_BINARY_DIR}/${module_name}")
|
||||
module_kbuild("${module_name}" "${module_files}" "${module_include_dirs}" "${module_include_dirs}" Kbuild_string)
|
||||
file(WRITE "${module_build_path}/Kbuild" ${Kbuild_string})
|
||||
|
||||
foreach(copy_file ${module_files})
|
||||
file(RELATIVE_PATH rel_copy_file "${PROJECT_SOURCE_DIR}" ${copy_file} )
|
||||
list(APPEND cmd_list "cp --parents ${copy_file} ${module_build_path}")
|
||||
endforeach()
|
||||
string(REPLACE ";" "\n" cmd_list_string "${cmd_list}")
|
||||
file(WRITE "${module_build_path}/cp.sh" "#!/bin/bash\n${cmd_list_string}")
|
||||
file(COPY "${module_build_path}/cp.sh"
|
||||
DESTINATION "${module_build_path}/.tmp"
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
file(REMOVE "${module_build_path}/cp.sh")
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${module_name}.built
|
||||
COMMAND "${module_build_path}/.tmp/cp.sh"
|
||||
COMMAND ${CMAKE_MAKE_PROGRAM} -C ${kernel_dir} M=${module_build_path} modules KBUILD_EXTRA_SYMBOLS=${module_build_path}/Module.symvers
|
||||
COMMAND cmake -E touch ${module_name}.built
|
||||
COMMENT "Kernel make modules ${module_name}:\n${Kbuild_string}\n"
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/CMakeLists.txt ${module_files} ${module_include_dirs}
|
||||
VERBATIM)
|
||||
|
||||
ADD_CUSTOM_TARGET("${module_name}" ALL
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/${module_name}.built
|
||||
SOURCES ${module_files}
|
||||
COMMENT "Building Kernel Module ${module_name}")
|
||||
endfunction()
|
||||
65
src/kunity.c
Normal file
65
src/kunity.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "kunity.h"
|
||||
//{ global include region
|
||||
|
||||
#include <linux/string.h>
|
||||
|
||||
//}
|
||||
//{ local include region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ local define region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ local enum region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ local typedef region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{local struct region
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ local function prototype region
|
||||
|
||||
//}
|
||||
|
||||
//{ local global var region
|
||||
static string_builder_s sb;
|
||||
//}
|
||||
|
||||
|
||||
//{ global function implements region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ local function implements region
|
||||
void putchark(char a)
|
||||
{
|
||||
if (a == '\n')
|
||||
{
|
||||
const char * c = (const char *)&sb.buffer[0];
|
||||
printk(c);
|
||||
sb.write_postion = 0;
|
||||
memset(sb.buffer, 0, 1024);
|
||||
return;
|
||||
}
|
||||
|
||||
sb.buffer[sb.write_postion] = a;
|
||||
sb.write_postion = (sb.write_postion + 1) % 1024;
|
||||
}
|
||||
//}
|
||||
30
src/kunity.h
Normal file
30
src/kunity.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef KUNITY_H
|
||||
#define KUNITY_H
|
||||
#include "kunity_t.h"
|
||||
|
||||
#ifndef TEST_MACRO
|
||||
|
||||
//{ global include region
|
||||
#include <unity.h>
|
||||
//}
|
||||
//{ local include region
|
||||
|
||||
//}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//{ function region
|
||||
|
||||
extern void putchark(char a);
|
||||
|
||||
//}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_MACRO
|
||||
|
||||
#endif // KUNITY_H
|
||||
55
src/kunity_t.h
Normal file
55
src/kunity_t.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef KUNITY_T_H
|
||||
#define KUNITY_T_H
|
||||
|
||||
//{ global include region
|
||||
#include <linux/types.h>
|
||||
|
||||
#ifndef KUNITY_TEST_RUNNER_APP
|
||||
#include <linux/export.h>
|
||||
#endif
|
||||
|
||||
//}
|
||||
//{ local include region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ define region
|
||||
|
||||
#ifndef KUNITY_LINE_SIZE
|
||||
#define KUNITY_LINE_SIZE 1024
|
||||
#endif
|
||||
|
||||
#ifndef KUNITY_TEST
|
||||
#define KUNITY_TEST(function_name) \
|
||||
extern void function_name (void); \
|
||||
EXPORT_SYMBOL(function_name); \
|
||||
void function_name()
|
||||
#endif
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ enum region
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//{ typedef region
|
||||
|
||||
//}
|
||||
|
||||
//{ struct region
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct string_builder_sTag
|
||||
{
|
||||
size_t write_postion;
|
||||
char buffer[KUNITY_LINE_SIZE];
|
||||
} string_builder_s, ptr_string_builder_s;
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//}
|
||||
|
||||
#endif // KUNITY_T_H
|
||||
38
src/unity_config.h
Normal file
38
src/unity_config.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef UNITY_CONFIG_H
|
||||
#define UNITY_CONFIG_H
|
||||
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||
#define UNITY_EXCLUDE_SETJMP_H
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_MATH_H
|
||||
#define UNITY_EXCLUDE_MATH_H
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_LIMITS_H
|
||||
#define UNITY_EXCLUDE_LIMITS_H
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_STDINT_H
|
||||
#define UNITY_EXCLUDE_STDINT_H
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
#define UNITY_EXCLUDE_FLOAT
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_OUTPUT_CHAR
|
||||
#define UNITY_OUTPUT_CHAR(a) putchark(a)
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_OUTPUT_CHAR_HEADER_DECLARATION
|
||||
#define UNITY_OUTPUT_CHAR_HEADER_DECLARATION putchark(char a)
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_INT_WIDTH
|
||||
#define UNITY_INT_WIDTH (32)
|
||||
#endif
|
||||
|
||||
#endif // UNITY_CONFIG_H
|
||||
Reference in New Issue
Block a user