From ebd1227d820146685d5215335120b11fc65a3386 Mon Sep 17 00:00:00 2001 From: gaoyang3513 Date: Sat, 16 Nov 2024 16:09:10 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20=20osal=20=E6=A8=A1=E5=9D=97=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-Bus/01-Platform/01-osdev/Makefile | 87 ++++++++++++++++++++++++ 03-Bus/01-Platform/01-osdev/OSAL_osdev.c | 1 + Makefile | 4 +- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 03-Bus/01-Platform/01-osdev/Makefile diff --git a/03-Bus/01-Platform/01-osdev/Makefile b/03-Bus/01-Platform/01-osdev/Makefile new file mode 100644 index 000000000..770d965f6 --- /dev/null +++ b/03-Bus/01-Platform/01-osdev/Makefile @@ -0,0 +1,87 @@ +#******************************************************************************* +# HangZhou Hikvision Digital Technology Co., Ltd. All Right Reserved. +# Author : +# Version : V1.0.0 2020.10.21 +# Description : +# Note : yegaoyang@hikvision.com.cn Modified 2020.10.21 +#******************************************************************************* + +#******************************************************************************* +# Path information +#******************************************************************************* +LOCAL_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) +KERNEL_DIR ?= /home/gaoyang3513/Source/06-SG20x/02-Projects/SDK_SG200x_V2/linux_5.10/build/sg2000_milkv_duos_glibc_arm64_sd +#KERNEL_DIR ?= $(HOME)/Source/06-SG20x/02-Projects/SDK_SG200x_V2/linux_5.10/build/sg2000_milkv_duos_glibc_arm64_sd/ + +# ParDirectory +LIBS_DIR := +INCLUDE_DIR := + +# Subdirectory + +# Output +OUTPUT_DIR := $(LOCAL_DIR)/output +INSTALL_DIR ?= $(LOCAL_DIR)/__install + +#******************************************************************************* +# Variables +#******************************************************************************* +MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo) + +MOD_NAME := osal + +#******************************************************************************* +# Compile configure +#******************************************************************************* +ARCH ?= arm64 +CROSS_COMPILE ?= ${HOME}/Source/06-SG20x/02-Projects/SDK_SG200x_V2/host-tools/gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- + +CC := $(CROSS_COMPILE)gcc +LD := $(CROSS_COMPILE)ld +AR := $(CROSS_COMPILE)ar +STRIP := $(CROSS_COMPILE)strip +OBJDUMP := $(CROSS_COMPILE)objdump + +export ARCH CROSS_COMPILE + +#******************************************************************************* +# Targets +#******************************************************************************* +.PHONY: all install clean + +ifeq ($(KERNELRELEASE),) +all: init + @$(MAKE) modules -C $(KERNEL_DIR) M=$(LOCAL_DIR) -j$(MULTI_CORES) +# @$(MAKE) modules_install -C $(KERNEL_DIR) M=$(LOCAL_DIR) INSTALL_MOD_PATH=$(KERNEL_DIR)/_install_modules INSTALL_MOD_DIR=private + @$(OBJDUMP) -hdS $(MOD_NAME).o > $(MOD_NAME).dmp + +clean: +# File + @for n in *.o *.ko *.mod.c *.mod *.cmd *.symvers *.order; do \ + find $(LOCAL_DIR) -type f -name $$n -exec rm {} \;;\ + done +# Directory + @if [ -d $(LOCAL_DIR)/output ]; then rm -rf $(LOCAL_DIR)/output; fi; + @if [ -d $(LOCAL_DIR)/__install ]; then rm -rf $(LOCAL_DIR)/__install; fi; + @if [ -d $(LOCAL_DIR)/.tmp_versions ]; then rm -rf $(LOCAL_DIR)/.tmp_versions; fi; + + +install: + @mkdir -p $(INSTALL_DIR)/lib/modules/private + @install -m 644 -D $(MOD_NAME).ko $(INSTALL_DIR)/lib/modules/private; + +init: + @mkdir -p $(OUTPUT_DIR) + +else +obj-m := $(MOD_NAME).o + +$(MOD_NAME)-objs := OSAL_osdev.o + +INC_DIRS := + +ccflags-y += + +EXTRA_CFLAGS += -Wno-error=date-time # Fix compile error on gcc 4.9 and later +EXTRA_CFLAGS += -Wno-date-time -g +endif # ifeq ($(KERNELRELEASE),) diff --git a/03-Bus/01-Platform/01-osdev/OSAL_osdev.c b/03-Bus/01-Platform/01-osdev/OSAL_osdev.c index 7c7a170ef..30fe644f2 100644 --- a/03-Bus/01-Platform/01-osdev/OSAL_osdev.c +++ b/03-Bus/01-Platform/01-osdev/OSAL_osdev.c @@ -10,6 +10,7 @@ #include #include #include +#include // MKDEV #include "OSAL_osdev.h" diff --git a/Makefile b/Makefile index 5b9b35d6d..205e1a577 100644 --- a/Makefile +++ b/Makefile @@ -30,8 +30,8 @@ export KERNEL_DIR MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo) SUB_DIRS := \ - spi \ - 01-Debug + 04-Debug \ + 03-Bus/01-Platform/01-osdev \ #******************************************************************************* # Compile configure