[qca-ssdk-shell] First commit for ssdk-shell

SSDK shell code need to be released under open source license. So
the code is moved into the new git repository and its all files'
copyright header is writen into that of ISC license.

Change-Id: Id22625bc14c944098bce6fdcf463df585f29539c
Signed-off-by: luny <luny@codeaurora.org>
diff --git a/make/components.mk b/make/components.mk
new file mode 100755
index 0000000..1c0dfba
--- /dev/null
+++ b/make/components.mk
@@ -0,0 +1,36 @@
+
+ifeq (linux, $(OS))
+  ifeq (KSLIB, $(MODULE_TYPE))
+    ifeq (TRUE, $(KERNEL_MODE))
+      COMPONENTS = HSL SAL INIT UTIL REF
+      ifeq (TRUE, $(FAL))
+        COMPONENTS += FAL
+      endif
+    else
+      COMPONENTS = HSL SAL INIT REF
+    endif
+
+    ifeq (TRUE, $(UK_IF))
+      COMPONENTS += API
+    endif
+  endif
+  
+  ifeq (USLIB, $(MODULE_TYPE))
+    ifneq (TRUE, $(KERNEL_MODE))
+      COMPONENTS = HSL SAL INIT UTIL REF
+      ifeq (TRUE, $(FAL))
+        COMPONENTS += FAL
+      endif
+    else
+      COMPONENTS = UK_IF SAL
+    endif
+
+    ifeq (TRUE, $(UK_IF))
+      COMPONENTS += API
+    endif
+  endif
+
+  ifeq (SHELL, $(MODULE_TYPE))
+    COMPONENTS = SHELL
+  endif
+endif
diff --git a/make/config.mk b/make/config.mk
new file mode 100755
index 0000000..4a55061
--- /dev/null
+++ b/make/config.mk
@@ -0,0 +1,91 @@
+
+include $(PRJ_PATH)/config
+
+ifndef SYS_PATH
+  $(error SYS_PATH isn't defined!)
+endif
+
+ifndef TOOL_PATH
+  $(error TOOL_PATH isn't defined!)
+endif
+
+#define cpu type such as PPC MIPS ARM X86
+ifndef CPU
+  CPU=mips
+endif
+
+#define os type such as linux netbsd vxworks
+ifndef OS
+  OS=linux
+endif
+
+ifndef OS_VER
+  OS_VER=2_6
+endif
+
+#support chip type such as ATHENA GARUDA
+ifndef CHIP_TYPE
+  SUPPORT_CHIP = GARUDA
+else
+  ifeq (GARUDA, $(CHIP_TYPE))
+    SUPPORT_CHIP = GARUDA
+  endif
+
+  ifeq (ATHENA, $(CHIP_TYPE))
+     SUPPORT_CHIP = ATHENA
+  endif
+
+  ifeq (SHIVA, $(CHIP_TYPE))
+     SUPPORT_CHIP = SHIVA
+  endif
+
+  ifeq (HORUS, $(CHIP_TYPE))
+     SUPPORT_CHIP = HORUS
+  endif
+
+  ifeq (ISIS, $(CHIP_TYPE))
+     SUPPORT_CHIP = ISIS
+  endif
+
+  ifeq (ISISC, $(CHIP_TYPE))
+     SUPPORT_CHIP = ISISC
+  endif
+
+  ifeq (ALL_CHIP, $(CHIP_TYPE))
+     ifneq (TRUE, $(FAL))
+         $(error FAL must be TRUE when CHIP_TYPE is defined as ALL_CHIP!)
+     endif
+     SUPPORT_CHIP = GARUDA SHIVA HORUS ISIS ISISC
+  endif
+
+  ifndef SUPPORT_CHIP
+    $(error defined CHIP_TYPE isn't supported!)
+  endif
+endif
+
+#define compile tool prefix
+ifndef TOOLPREFIX
+  TOOLPREFIX=$(CPU)-$(OS)-uclibc-
+endif
+
+DEBUG_ON=FALSE
+OPT_FLAG=
+LD_FLAG=
+
+SHELLOBJ=ssdk_sh
+US_MOD=ssdk_us
+KS_MOD=ssdk_ks
+
+ifeq (TRUE, $(KERNEL_MODE))
+  RUNMODE=km
+else
+  RUNMODE=um
+endif
+
+BLD_DIR=$(PRJ_PATH)/build/$(OS)
+BIN_DIR=$(PRJ_PATH)/build/bin
+
+VER=1.2.0
+BUILD_NUMBER=$(shell cat $(PRJ_PATH)/make/.build_number)
+VERSION=$(VER).$(BUILD_NUMBER)
+BUILD_DATE=$(shell date -u  +%F-%T)
diff --git a/make/defs.mk b/make/defs.mk
new file mode 100755
index 0000000..7d1c75b
--- /dev/null
+++ b/make/defs.mk
@@ -0,0 +1,28 @@
+DST_DIR=$(BLD_DIR)/$(MODULE_TYPE)
+
+SUB_DIR=$(patsubst %/, %, $(dir $(wildcard ./*/Makefile)))
+
+ifeq (,$(findstring $(LIB), $(COMPONENTS)))
+  SRC_LIST=
+endif
+
+SRC_FILE=$(addprefix $(PRJ_PATH)/$(LOC_DIR)/, $(SRC_LIST))
+
+OBJ_LIST=$(SRC_LIST:.c=.o)
+OBJ_FILE=$(addprefix $(DST_DIR)/, $(OBJ_LIST))
+
+DEP_LIST=$(SRC_LIST:.c=.d)
+DEP_FILE=$(addprefix $(DST_DIR)/, $(DEP_LIST))
+
+vpath %.c $(PRJ_PATH)/$(LOC_DIR)
+vpath %.c $(PRJ_PATH)/app/nathelper/linux
+vpath %.c $(PRJ_PATH)/app/nathelper/linux/lib
+vpath %.o $(DST_DIR)
+vpath %.d $(DST_DIR)
+
+DEP_LOOP=$(foreach i, $(SUB_DIR), $(MAKE) -C $(i) dep || exit 1;)
+OBJ_LOOP=$(foreach i, $(SUB_DIR), $(MAKE) -C $(i) obj || exit 1;)
+CLEAN_LOOP=$(foreach i, $(SUB_DIR), $(MAKE) -C $(i) clean;)
+CLEAN_OBJ_LOOP=$(foreach i, $(SUB_DIR), $(MAKE) -C $(i) clean_o;)
+CLEAN_DEP_LOOP=$(foreach i, $(SUB_DIR), $(MAKE) -C $(i) clean_d;)
+
diff --git a/make/linux_opt.mk b/make/linux_opt.mk
new file mode 100755
index 0000000..135b588
--- /dev/null
+++ b/make/linux_opt.mk
@@ -0,0 +1,279 @@
+ifeq (TRUE, $(IN_ACL))
+  MODULE_CFLAG += -DIN_ACL
+endif
+
+ifeq (TRUE, $(IN_FDB))
+  MODULE_CFLAG += -DIN_FDB
+endif
+
+ifeq (TRUE, $(IN_IGMP))
+  MODULE_CFLAG += -DIN_IGMP
+endif
+
+ifeq (TRUE, $(IN_LEAKY))
+  MODULE_CFLAG += -DIN_LEAKY
+endif
+
+ifeq (TRUE, $(IN_LED))
+  MODULE_CFLAG += -DIN_LED
+endif
+
+ifeq (TRUE, $(IN_MIB))
+  MODULE_CFLAG += -DIN_MIB
+endif
+
+ifeq (TRUE, $(IN_MIRROR))
+  MODULE_CFLAG += -DIN_MIRROR
+endif
+
+ifeq (TRUE, $(IN_MISC))
+  MODULE_CFLAG += -DIN_MISC
+endif
+
+ifeq (TRUE, $(IN_PORTCONTROL))
+  MODULE_CFLAG += -DIN_PORTCONTROL
+endif
+
+ifeq (TRUE, $(IN_PORTVLAN))
+  MODULE_CFLAG += -DIN_PORTVLAN
+endif
+
+ifeq (TRUE, $(IN_QOS))
+  MODULE_CFLAG += -DIN_QOS
+endif
+
+ifeq (TRUE, $(IN_RATE))
+  MODULE_CFLAG += -DIN_RATE
+endif
+
+ifeq (TRUE, $(IN_STP))
+  MODULE_CFLAG += -DIN_STP
+endif
+
+ifeq (TRUE, $(IN_VLAN))
+  MODULE_CFLAG += -DIN_VLAN
+endif
+
+ifeq (TRUE, $(IN_REDUCED_ACL))
+  MODULE_CFLAG += -DIN_REDUCED_ACL
+endif
+
+ifeq (TRUE, $(IN_COSMAP))
+  MODULE_CFLAG += -DIN_COSMAP
+endif
+
+ifeq (TRUE, $(IN_IP))
+  MODULE_CFLAG += -DIN_IP
+endif
+
+ifeq (TRUE, $(IN_NAT))
+  MODULE_CFLAG += -DIN_NAT
+endif
+
+ifeq (TRUE, $(IN_TRUNK))
+  MODULE_CFLAG += -DIN_TRUNK
+endif
+
+ifeq (TRUE, $(IN_SEC))
+  MODULE_CFLAG += -DIN_SEC
+endif
+
+ifeq (TRUE, $(IN_NAT_HELPER))
+  MODULE_CFLAG += -DIN_NAT_HELPER
+endif
+
+ifeq (TRUE, $(IN_INTERFACECONTROL))
+  MODULE_CFLAG += -DIN_INTERFACECONTROL
+endif
+
+ifeq (TRUE, $(IN_MACBLOCK))
+  MODULE_CFLAG += -DIN_MACBLOCK
+endif
+
+ifneq (TRUE, $(FAL))
+  MODULE_CFLAG += -DHSL_STANDALONG
+endif
+
+ifeq (TRUE, $(UK_IF))
+  MODULE_CFLAG += -DUK_IF
+endif
+
+#ifdef UK_NL_PROT
+  MODULE_CFLAG += -DUK_NL_PROT=$(UK_NL_PROT)
+#endif
+
+#ifdef UK_MINOR_DEV
+  MODULE_CFLAG += -DUK_MINOR_DEV=$(UK_MINOR_DEV)
+#endif
+
+ifeq (TRUE, $(API_LOCK))
+  MODULE_CFLAG += -DAPI_LOCK
+endif
+
+ifeq (TRUE, $(REG_ACCESS_SPEEDUP))
+  MODULE_CFLAG += -DREG_ACCESS_SPEEDUP
+endif
+
+ifeq (TRUE, $(DEBUG_ON))
+  MODULE_CFLAG += -g
+endif
+
+MODULE_CFLAG += $(OPT_FLAG) -Wall -DVERSION=\"$(VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\" -DCPU=\"$(CPU)\" -DOS=\"$(OS)\"
+
+MODULE_INC += -I$(PRJ_PATH)/include \
+                   -I$(PRJ_PATH)/include/common \
+                   -I$(PRJ_PATH)/include/api \
+                   -I$(PRJ_PATH)/include/fal \
+                   -I$(PRJ_PATH)/include/ref \
+                   -I$(PRJ_PATH)/include/hsl \
+                   -I$(PRJ_PATH)/include/hsl/phy \
+                   -I$(PRJ_PATH)/include/sal/os \
+                   -I$(PRJ_PATH)/include/sal/sd \
+                   -I$(PRJ_PATH)/include/sal/sd/linux/hydra_howl \
+                   -I$(PRJ_PATH)/include/sal/sd/linux/uk_interface \
+                   -I$(PRJ_PATH)/include/init
+
+ifneq (,$(findstring ATHENA, $(SUPPORT_CHIP)))
+  MODULE_INC   += -I$(PRJ_PATH)/include/hsl/athena
+  MODULE_CFLAG += -DATHENA
+endif
+
+ifneq (,$(findstring GARUDA, $(SUPPORT_CHIP)))
+  MODULE_INC   += -I$(PRJ_PATH)/include/hsl/garuda
+  MODULE_CFLAG += -DGARUDA
+endif
+
+ifneq (,$(findstring SHIVA, $(SUPPORT_CHIP)))
+  MODULE_INC   += -I$(PRJ_PATH)/include/hsl/shiva
+  MODULE_CFLAG += -DSHIVA
+endif
+
+ifneq (,$(findstring HORUS, $(SUPPORT_CHIP)))
+  MODULE_INC   += -I$(PRJ_PATH)/include/hsl/horus
+  MODULE_CFLAG += -DHORUS
+endif
+
+ifneq (,$(findstring ISIS, $(SUPPORT_CHIP)))
+  ifneq (ISISC, $(SUPPORT_CHIP))
+     MODULE_INC   += -I$(PRJ_PATH)/include/hsl/isis
+     MODULE_CFLAG += -DISIS
+  endif
+endif
+
+ifneq (,$(findstring ISISC, $(SUPPORT_CHIP)))
+  MODULE_INC   += -I$(PRJ_PATH)/include/hsl/isisc
+  MODULE_CFLAG += -DISISC
+endif
+
+# check for GCC version
+ifeq (4, $(GCC_VER))
+  MODULE_CFLAG += -DGCCV4
+endif
+
+ifeq (KSLIB, $(MODULE_TYPE))
+
+  ifeq (3_4, $(OS_VER))
+		MODULE_CFLAG += -DKVER34
+		MODULE_CFLAG += -DKVER32
+	    MODULE_CFLAG += -DLNX26_22
+	    MODULE_INC += -I$(SYS_PATH) \
+	          -I$(SYS_PATH)/include \
+              -I$(SYS_PATH)/source/include \
+              -I$(SYS_PATH)/source/arch/arm/mach-msm/include \
+              -I$(SYS_PATH)/source/arch/arm/include \
+              -I$(SYS_PATH)/source/arch/arm/include/asm \
+              -I$(SYS_PATH)/arch/arm/include/generated \
+              -I$(SYS_PATH)/source/arch/arm/include/asm/mach \
+	      -I$(SYS_PATH)/usr/include
+
+  endif
+
+  ifeq (3_2, $(OS_VER))
+	MODULE_CFLAG += -DKVER32
+	MODULE_CFLAG += -DLNX26_22
+	ifeq (mips, $(CPU))
+	  MODULE_INC += -I$(SYS_PATH) \
+            -I$(SYS_PATH)/include \
+            -I$(SYS_PATH)/arch/mips/include \
+	    -I$(SYS_PATH)/arch/mips/include/asm/mach-ar7240 \
+	    -I$(SYS_PATH)/arch/mips/include/asm/mach-generic \
+		-I$(SYS_PATH)/arch/mips/include/asm/mach-ar7 \
+	    -I$(SYS_PATH)/usr/include
+
+	    #CPU_CFLAG    = -G 0 -mno-abicalls -fno-pic -pipe -mabi=32 -march=mips32r2
+          ifndef CPU_CFLAG
+	    CPU_CFLAG    = -Wstrict-prototypes -fomit-frame-pointer -G 0 -mno-abicalls -fno-strict-aliasing \
+                     -O2 -fno-pic -pipe -mabi=32 -march=mips32r2 -DMODULE -mlong-calls -DEXPORT_SYMTAB
+          endif
+    else
+	    MODULE_INC += -I$(SYS_PATH) \
+              -I$(SYS_PATH)/include \
+              -I$(SYS_PATH)/arch/arm/include \
+              -I$(SYS_PATH)/arch/arm/include/asm \
+              -I$(SYS_PATH)/arch/arm/mach-fv16xx/include \
+	      -I$(SYS_PATH)/arch/arm/include/generated \
+	      -I$(SYS_PATH)/include/generated \
+	      -I$(SYS_PATH)/usr/include
+        endif
+
+
+  endif
+
+  ifeq (2_6, $(OS_VER))
+        MODULE_CFLAG += -DKVER26
+        MODULE_CFLAG += -DLNX26_22
+        ifeq (mips, $(CPU))
+          MODULE_INC += -I$(SYS_PATH) \
+            -I$(SYS_PATH)/include \
+            -I$(SYS_PATH)/arch/mips/include \
+            -I$(SYS_PATH)/arch/mips/include/asm/mach-ar7240 \
+            -I$(SYS_PATH)/arch/mips/include/asm/mach-generic \
+            -I$(SYS_PATH)/usr/include
+
+            #CPU_CFLAG    = -G 0 -mno-abicalls -fno-pic -pipe -mabi=32 -march=mips32r2
+          ifndef CPU_CFLAG
+            CPU_CFLAG    = -Wstrict-prototypes -fomit-frame-pointer -G 0 -mno-abicalls -fno-strict-aliasing \
+                     -O2 -fno-pic -pipe -mabi=32 -march=mips32r2 -DMODULE -mlong-calls -DEXPORT_SYMTAB
+          endif
+        else
+	    MODULE_INC += -I$(SYS_PATH) \
+              -I$(SYS_PATH)/include \
+              -I$(SYS_PATH)/arch/arm/include \
+              -I$(SYS_PATH)/arch/arm/include/asm \
+              -I$(SYS_PATH)/arch/arm/mach-fv16xx/include \
+	      -I$(SYS_PATH)/arch/arm/include/generated \
+	      -I$(SYS_PATH)/include/generated \
+	      -I$(SYS_PATH)/usr/include
+        endif
+
+
+  endif
+
+  MODULE_CFLAG += -D__KERNEL__ -DKERNEL_MODULE $(CPU_CFLAG)
+
+
+endif
+
+ifeq (SHELL, $(MODULE_TYPE))
+  MODULE_INC += -I$(PRJ_PATH)/include/shell
+
+    ifeq (2_6, $(OS_VER))
+  	  MODULE_CFLAG += -DKVER26
+    else
+   	  MODULE_CFLAG += -DKVER24
+    endif
+
+    ifeq (TRUE, $(KERNEL_MODE))
+      MODULE_CFLAG += -static
+    else
+      MODULE_CFLAG += -static -DUSER_MODE
+    endif
+endif
+
+ifneq (TRUE, $(KERNEL_MODE))
+  ifneq (SHELL, $(MODULE_TYPE))
+    MODULE_CFLAG +=  -DUSER_MODE
+  endif
+endif
+
+CFLAGS += $(MODULE_INC) $(MODULE_CFLAG)
diff --git a/make/target.mk b/make/target.mk
new file mode 100755
index 0000000..a72c239
--- /dev/null
+++ b/make/target.mk
@@ -0,0 +1,49 @@
+
+include $(PRJ_PATH)/make/$(OS)_opt.mk
+
+include $(PRJ_PATH)/make/tools.mk
+
+obj: $(OBJ_LIST)
+	$(OBJ_LOOP)
+
+dep: build_dir $(DEP_LIST)
+	$(DEP_LOOP)
+
+$(OBJ_LIST): %.o : %.c %.d
+	$(CC) $(CFLAGS) -c $< -o $(DST_DIR)/$@
+
+$(DEP_LIST) : %.d : %.c
+	$(CC) $(CFLAGS) -MM $< > $(DST_DIR)/$@.tmp
+	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $(DST_DIR)/$@.tmp > $(DST_DIR)/$@
+	$(RM) -f $(DST_DIR)/$@.tmp;
+
+build_dir: $(DST_DIR)
+
+$(DST_DIR):
+	$(MKDIR) -p $(DST_DIR)
+
+.PHONY: clean
+clean: clean_o clean_d
+	$(CLEAN_LOOP)
+
+.PHONY: clean_o
+clean_o: clean_obj
+	$(CLEAN_OBJ_LOOP)
+
+.PHONY: clean_d
+clean_d: clean_dep
+	$(CLEAN_DEP_LOOP)
+
+clean_obj:
+ifneq (,$(word 1, $(OBJ_FILE)))
+	$(RM) -f $(OBJ_FILE)
+endif
+
+clean_dep:
+ifneq (,$(word 1, $(DEP_FILE)))
+	$(RM) -f $(DEP_FILE)
+endif
+
+ifneq (,$(word 1, $(DEP_FILE)))
+  sinclude $(DEP_FILE)
+endif	
diff --git a/make/tools.mk b/make/tools.mk
new file mode 100755
index 0000000..6ed3872
--- /dev/null
+++ b/make/tools.mk
@@ -0,0 +1,12 @@
+
+ifeq (linux, $(OS))
+  CC=$(TOOL_PATH)/$(TOOLPREFIX)gcc
+  AR=$(TOOL_PATH)/$(TOOLPREFIX)ar
+  LD=$(TOOL_PATH)/$(TOOLPREFIX)ld
+  STRIP=$(TOOL_PATH)/$(TOOLPREFIX)strip
+  MAKE=make -S
+  CP=cp
+  MKDIR=mkdir
+  RM=rm
+  PERL=perl
+endif