add D-Link DMS-1250 GPL

it even contains the modern RTL8224 sources

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
This commit is contained in:
Markus Stockhausen 2025-04-27 13:49:04 -04:00
parent 55d518a97b
commit 21e259eea2
4947 changed files with 3101418 additions and 0 deletions

View file

@ -0,0 +1,385 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Diag Shell Source
#
CFLAGS_y += -Wall -Werror -Wuninitialized -Wstrict-prototypes -Wno-strict-aliasing -DRTUSR -lm
INCLUDE =
CMDS_y =
CMDS_y += diag_main.c
CMDS_y += diag_cmd.c
CMDS_y += diag_om.c
CMDS_y += diag_eee.c
CMDS_y += diag_reg.c
CMDS_y += diag_serdes.c
CMDS_y += diag_trap.c
CMDS_y += diag_port.c
CMDS_y += diag_stp.c
CMDS_y += diag_time.c
CMDS_y += diag_l2.c
CMDS_y += diag_l3.c
CMDS_y += diag_qos.c
CMDS_y += diag_trunk.c
CMDS_y += diag_rate.c
CMDS_y += diag_switch.c
CMDS_y += diag_sys.c
CMDS_y += diag_counter.c
CMDS_y += diag_sec.c
CMDS_y += diag_mirror.c
CMDS_y += diag_vlan.c
CMDS_y += diag_flowctrl.c
CMDS_y += diag_led.c
ifneq ($(CONFIG_SDK_DRIVER_GPIO),)
CMDS_y += diag_gpio.c
endif
CMDS_y += diag_diag.c
CMDS_y += diag_debug.c
CMDS_y += diag_acl.c
CMDS_y += diag_pie.c
ifneq ($(CONFIG_SDK_APP_OVS),)
CMDS_y += diag_ovs.c
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9310)),)
CMDS_y += diag_mpls.c
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
CMDS_y += diag_oam.c
endif
ifneq ($(CONFIG_SDK_DRIVER_SPI),)
CMDS_y += diag_spi.c
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
CMDS_y += diag_tunnel.c
CMDS_y += diag_vxlan.c
CMDS_y += diag_openflow.c
CMDS_y += diag_bpe.c
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
CMDS_y += diag_stack.c
CMDS_y += diag_ipmcast.c
CMDS_y += diag_mcast.c
endif
ifneq ($(CONFIG_SDK_RTL8231),)
CMDS_y += diag_rtl8231.c
endif
ifneq ($(CONFIG_SDK_DRIVER_NIC),)
CMDS_y += diag_nic.c
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C),)
CMDS_y += diag_i2c.c
endif
ifneq ($(CONFIG_SDK_DRIVER_L2NTFY),)
CMDS_y += diag_l2_ntfy.c
endif
ifneq ($(CONFIG_RRCP_MASTER),)
CMDS_y += diag_rrcpmaster.c
endif
ifneq ($(CONFIG_SDK_UART1),)
CMDS_y += diag_uart.c
CMDS_y += diag_cameo_poe.c
endif
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
CMDS_y += diag_sdk.c
INCLUDE += -I$(UT_INCLUDE)
endif
DEF =
ifneq ($(CONFIG_SDK_DRIVER_NIC),)
DEF += -D CONFIG_SDK_DRIVER_NIC
endif
ifneq ($(CONFIG_SDK_DRIVER_EXTC_NIC),)
DEF += -D CONFIG_SDK_DRIVER_EXTC_NIC
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C),)
DEF += -D CONFIG_SDK_DRIVER_I2C
endif
ifneq ($(CONFIG_SDK_DRIVER_L2NTFY),)
DEF += -D CONFIG_SDK_DRIVER_L2NTFY
endif
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
DEF += -D CONFIG_SDK_DRIVER_TEST
endif
ifneq ($(CONFIG_SDK_RTL8231),)
DEF += -D CONFIG_SDK_RTL8231
endif
ifneq ($(CONFIG_SDK_DRIVER_GPIO),)
DEF += -D CONFIG_SDK_DRIVER_GPIO
endif
ifneq ($(CONFIG_SDK_DRIVER_SPI),)
DEF += -D CONFIG_SDK_DRIVER_SPI
endif
ifneq ($(CONFIG_SDK_DEBUG),)
DEF += -D CONFIG_SDK_DEBUG
endif
ifneq ($(CONFIG_SDK_UART1),)
DEF += -D CONFIG_SDK_UART1
endif
ifneq ($(CONFIG_SDK_APP_DIAG_EXT),)
DEF += -D CONFIG_SDK_APP_DIAG_EXT
ifeq ($(CONFIG_SDK_RTL9310),y)
DEF += -D CONFIG_SDK_DIAG_EXT_RTL9310
else ifeq ($(CONFIG_SDK_RTL9300),y)
DEF += -D CONFIG_SDK_DIAG_EXT_RTL9300
else ifeq ($(CONFIG_SDK_RTL8390),y)
DEF += -D CONFIG_SDK_DIAG_EXT_RTL8390
else ifeq ($(CONFIG_SDK_RTL8380),y)
DEF += -D CONFIG_SDK_DIAG_EXT_RTL8380
endif
endif
ifeq ($(CONFIG_SDK_RTL8390),y)
DEF += -D CONFIG_SDK_RTL8390
endif
ifeq ($(CONFIG_SDK_RTL8380),y)
DEF += -D CONFIG_SDK_RTL8380
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
DEF += -D CONFIG_SDK_RTL9310
endif
ifeq ($(CONFIG_SDK_RTL9300),y)
DEF += -D CONFIG_SDK_RTL9300
endif
ifneq ($(CONFIG_SDK_RTL8295),)
DEF += -D CONFIG_SDK_RTL8295
endif
ifneq ($(CONFIG_SDK_RTL8295R),)
DEF += -D CONFIG_SDK_RTL8295R
endif
ifneq ($(CONFIG_SDK_RTL8214QF),)
DEF += -D CONFIG_SDK_RTL8214QF
endif
ifneq ($(CONFIG_SDK_RTL8226),)
DEF += -D CONFIG_SDK_RTL8226
endif
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
DEF += -D CONFIG_SDK_MODEL_MODE
endif
ifeq ($(CONFIG_SDK_FPGA_PLATFORM),y)
DEF += -D CONFIG_SDK_FPGA_PLATFORM
endif
ifeq ($(CONFIG_SDK_EXTERNAL_CPU),y)
DEF += -D CONFIG_SDK_EXTERNAL_CPU
endif
CFLAGS += -D CONFIG_SDK_GENERAL_TABLE_REG_ACCESS
ifeq ($(PHY_ONLY), y)
DEF += -D PHY_ONLY
endif
SDK_ROOT_DIR = $(SDKDIR)
SYS_DIR = $(SDK_ROOT_DIR)/system/linux
OSAL_DIR = $(SDK_ROOT_DIR)/system/osal/linux
SYS_INC = $(SDK_ROOT_DIR)/system/include
RTUSR_INC = $(SYS_DIR)/rtk/rtusr/include
COMMON_DIR = $(SDK_ROOT_DIR)/src/common/user
PHONY :=
ifeq ($(CONFIG_SDK_APP_DIAG_DIR_DIAG_V2),y)
DIAG_NAME = diag_v2
endif
DIAGDIR = $(SDK_ROOT_DIR)/src/app/$(DIAG_NAME)
DIAG_INC = $(DIAGDIR)/include
DIAG_SRC = $(DIAGDIR)/src
DIAG_CFG = $(DIAGDIR)/config
DIAG_BIN = $(DIAGDIR)/bin
INCLUDE += -I$(SDK_INCLUDE) -I$(SDK_INCLUDE)/dal -I$(SYS_INC) -I$(DRV_INCLUDE) -I$(APP_LIB_INCLUDE)/rrcp -I$(DIAG_INC) -I$(SDK_ROOT_DIR)/../app
FLTFLAGS += -s 524288
CFLAGS_EXTRA = $(CFLAGS_y)
LIB = -L$(SDK_LIBDIR) -lc
LIB_DEP :=
SDK_VCS_HDR := $(SDK_ROOT_DIR)/system/include/common/vcs_rev.h
ifeq ($(SDK_VCS_HDR), $(wildcard $(SDK_VCS_HDR)))
CFLAGS += -DVCS_REVISION
endif
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
INCLUDE += -I$(MODELDIR) -I$(MODELDIR)/common
endif
UTIL = diag_util.c
CMDS = $(CMDS_y)
OBJ = $(COMMON_DIR)/rt_error.o
ifneq ($(CONFIG_RRCP_MASTER),)
LIB += -L$(APP_LIB_INCLUDE)/rrcp -lrrcp
endif
ifneq ($(CONFIG_SDK_KERNEL_LINUX_USER_MODE),)
OBJ += $(SYS_DIR)/usrAppStart.o
LIB += -lrtk -lrtcore -lpthread
LIB_DEP += $(SDK_LIBDIR)/librtk.a $(SDK_LIBDIR)/librtcore.a
ifneq ($(CONFIG_SDK_DRIVER_NIC),)
LIB += -lrtnic
LIB_DEP += $(SDK_LIBDIR)/librtnic.a
endif
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
LIB += -lut
LIB_DEP += $(SDK_LIBDIR)/libut.a
endif
else
INCLUDE += -I$(RTUSR_INC)
#OBJ += $(OSAL_DIR)/user/cache.o
#OBJ += $(OSAL_DIR)/user/memory.o
#OBJ += $(OSAL_DIR)/user/wait.o
OBJ += $(OSAL_DIR)/user/sem.o
OBJ += $(OSAL_DIR)/user/thread.o
#OBJ += $(OSAL_DIR)/user/time.o
LIB += -lrtusr -lpthread
LIB_DEP += $(SDK_LIBDIR)/librtusr.a
endif
EXEC = diag
TARGET := $(DIAG_SRC)/obj
SRC = $(UTIL) $(CMDS)
OBJ += $(shell for i in $(SRC); do n=`basename $$i`; echo -n $(TARGET)/$${n%%.*}.o ""; done)
OBJ += $(DIAG_SRC)/parser/cparser.o \
$(DIAG_SRC)/parser/cparser_fsm.o \
$(DIAG_SRC)/parser/cparser_io_unix.o \
$(DIAG_SRC)/parser/cparser_line.o \
$(DIAG_SRC)/parser/cparser_token.o \
$(DIAG_SRC)/parser/cparser_token_tbl.o \
$(DIAG_SRC)/parser/cparser_tree.o
CMD_TREE_SRC := $(DIAG_SRC)/parser/cparser_tree.c
CMD_TREE_HDR := $(DIAG_INC)/parser/cparser_tree.h
CLI_SRC := $(shell find $(DIAG_CFG)/ -name *.cli)
FLAG_HDR := $(shell find $(DIAG_INC)/flag/ -name *.h)
ifeq ($(CONFIG_RISE),y)
INCLUDE += -I$(SDK_ROOT_DIR)/../module
endif
# Dependency of building cparser command tree
CMD_TREE_DEP := \
$(SYS_INC)/common/sdk_autoconf.h \
$(SYS_INC)/common/rt_autoconf.h \
$(CLI_SRC) \
$(FLAG_HDR)
ifneq ($(CONFIG_SDK_APP_DIAG_EXT),)
OBJ += $(DIAG_SRC)/ext/diag_ext_common.o
ifeq ($(CONFIG_SDK_RTL9310),y)
OBJ += $(DIAG_SRC)/ext/diag_ext_9310.o
else ifeq ($(CONFIG_SDK_RTL9300),y)
OBJ += $(DIAG_SRC)/ext/diag_ext_9300.o
else ifeq ($(CONFIG_SDK_RTL8390),y)
OBJ += $(DIAG_SRC)/ext/diag_ext_8390.o
else ifeq ($(CONFIG_SDK_RTL8380),y)
OBJ += $(DIAG_SRC)/ext/diag_ext_8380.o
endif
endif
DEPS := $(OBJ:.o=.d)
SCRIPT_OPTS :=
ifeq ($(CONFIG_SDK_SQUT_CMD_OPT),y)
SCRIPT_OPTS += -sdktest
endif
DIAG_LIB := $(SDK_LIBDIR)/librtdiag.a
PHONY += all
all: diag-tree $(CLI_OBJ) $(DIAG_BIN)/$(EXEC) $(DIAG_LIB)
PHONY += diag-tree
diag-tree: $(CMD_TREE_SRC)
PHONY += diag-tree-clean
diag-tree-clean:
-rm -f $(CMD_TREE_SRC)
-rm -f $(CMD_TREE_HDR)
$(CMD_TREE_SRC) $(CMD_TREE_HDR): $(CMD_TREE_DEP)
@echo "Build cparser command tree."
@-rm -f $(CMD_TREE_SRC)
@-rm -f $(CMD_TREE_HDR)
@-rm -f ./parser/cparser_tree.o
@cd ../config; \
chmod 755 ./script/mk_parser.py; \
./script/mk_parser.py $(DEF) $(SCRIPT_OPTS) diag_shell.cli -fd ../include/flag/ -f cmd_flag.h; \
echo "Prepare to copy cparser files"; \
if [ -f ../config/cparser_tree.h ]; \
then \
mv ../config/cparser_tree.h $(CMD_TREE_HDR); \
fi
@if [ -f ../config/cparser_tree.c ]; \
then \
mv ../config/cparser_tree.c $(CMD_TREE_SRC); \
fi
$(DIAG_BIN)/$(EXEC): $(OBJ) $(LIB_DEP)
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) $(INCLUDE) $(OPTIMIZE) $(OBJ) $(LIB) -o $@
$(STRIP) $@
$(DIAG_LIB): $(OBJ)
$(AR) rcs $@ $(OBJ)
$(AR) d $@ usrAppStart.o
$(STRIP) --strip-debug -R .note -R .comment $@
$(TARGET)/%.o: %.c
$(CC) $(INCLUDE) $(CFLAGS_EXTRA) $(CFLAGS) -c -o $@ $<
%.o: %.c
$(CC) $(INCLUDE) $(CFLAGS_EXTRA) $(CFLAGS) -c -o $@ $<
%.d $(TARGET)/%.d: %.c
@set -e; rm -f $@; rm -f $@.*;\
$(CC) -MM $(INCLUDE) $< > $@.$$$$; \
sed 's,\($(*F)\)\.o[ :]*,$(@D)/$(*F).o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.*
#Don't create dependencies when we're cleaning, installing, ...
NODEP := clean tgz install romfs $(CMD_TREE_SRC) $(CMD_TREE_HDR) diag-tree diag-tree-clean
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEP))))
-include $(DEPS)
endif
PHONY += install
install: $(DIAG_BIN)/$(EXEC)
cp $(EXEC) $(BINDIR)
PHONY += romfs
ifdef CONFIG_SYS_KERNEL_LINUX_COMPRESSED_FS
romfs: $(DIAG_BIN)/$(EXEC)
$(SQFSINST) $(DIAG_BIN)/$(EXEC) /bin/$(EXEC)
else
romfs: $(DIAG_BIN)/$(EXEC)
$(ROMFSINST) $(DIAG_BIN)/$(EXEC) /bin/$(EXEC)
endif
PHONY += clean
clean:
rm -f $(OBJ) $(DIAG_BIN)/$(EXEC) $(DEPS) *.gdb *.elf *.elf2flt
PHONY += tgz
tgz: clean
cd ..; cd ..; tar zcvf $(EXEC).tgz $(EXEC)
.PHONY: $(PHONY)

View file

@ -0,0 +1,23 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for PHY
#
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
CUST2_PHY_DIR :=
CUST2_PHY_OBJ :=
ifeq ($(CONFIG_SDK_PHY_CUST2),y)
CUST_PHY += $(CUST2_PHY_OBJ)
CUST_PHY_CFLAGS += -I$(CUST2_PHY_DIR)
endif

View file

@ -0,0 +1,23 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for PHY
#
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
CUST3_PHY_DIR :=
CUST3_PHY_OBJ :=
ifeq ($(CONFIG_SDK_PHY_CUST3),y)
CUST_PHY += $(CUST3_PHY_OBJ)
CUST_PHY_CFLAGS += -I$(CUST3_PHY_DIR)
endif

View file

@ -0,0 +1,25 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for PHY
#
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
CUST4_PHY_DIR :=
CUST4_PHY_OBJ :=
ifeq ($(CONFIG_SDK_PHY_CUST4),y)
CUST_PHY += $(CUST4_PHY_OBJ)
CUST_PHY_CFLAGS += -I$(CUST4_PHY_DIR)
endif

View file

@ -0,0 +1,23 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for PHY
#
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
CUST5_PHY_DIR :=
CUST5_PHY_OBJ :=
ifeq ($(CONFIG_SDK_PHY_CUST5),y)
CUST_PHY += $(CUST5_PHY_OBJ)
CUST_PHY_CFLAGS += -I$(CUST5_PHY_DIR)
endif

View file

@ -0,0 +1,140 @@
#
# Copyright (C) 2017 Realtek Semiconductor Corp.
#
# Source for SDK Diag Shell
#
DIAGDIR =
DIAG_SRC := sdk/src/app/diag_v2/src
DIAG_SRC_EXT := sdk/src/app/diag_v2/src/ext
COMMON_DIR := sdk/src/common/user
OSAL_DIR := sdk/system/osal/linux
DIAG_OBJ =
DIAG_OBJ += $(DIAG_SRC)/diag_main.o
DIAG_OBJ += $(DIAG_SRC)/diag_cmd.o
DIAG_OBJ += $(DIAG_SRC)/diag_om.o
DIAG_OBJ += $(DIAG_SRC)/diag_eee.o
DIAG_OBJ += $(DIAG_SRC)/diag_reg.o
DIAG_OBJ += $(DIAG_SRC)/diag_serdes.o
DIAG_OBJ += $(DIAG_SRC)/diag_trap.o
DIAG_OBJ += $(DIAG_SRC)/diag_port.o
DIAG_OBJ += $(DIAG_SRC)/diag_stp.o
DIAG_OBJ += $(DIAG_SRC)/diag_time.o
DIAG_OBJ += $(DIAG_SRC)/diag_l2.o
DIAG_OBJ += $(DIAG_SRC)/diag_l3.o
DIAG_OBJ += $(DIAG_SRC)/diag_qos.o
DIAG_OBJ += $(DIAG_SRC)/diag_trunk.o
DIAG_OBJ += $(DIAG_SRC)/diag_rate.o
DIAG_OBJ += $(DIAG_SRC)/diag_switch.o
DIAG_OBJ += $(DIAG_SRC)/diag_sys.o
DIAG_OBJ += $(DIAG_SRC)/diag_counter.o
DIAG_OBJ += $(DIAG_SRC)/diag_sec.o
DIAG_OBJ += $(DIAG_SRC)/diag_mirror.o
DIAG_OBJ += $(DIAG_SRC)/diag_vlan.o
DIAG_OBJ += $(DIAG_SRC)/diag_flowctrl.o
DIAG_OBJ += $(DIAG_SRC)/diag_led.o
DIAG_OBJ += $(DIAG_SRC)/diag_diag.o
DIAG_OBJ += $(DIAG_SRC)/diag_debug.o
DIAG_OBJ += $(DIAG_SRC)/diag_acl.o
DIAG_OBJ += $(DIAG_SRC)/diag_pie.o
DIAG_OBJ += $(DIAG_SRC)/diag_util.o
ifeq ($(CONFIG_SDK_SW_SER), y)
DIAG_OBJ += $(DIAG_SRC)/diag_ser.o
endif
DIAG_OBJ += $(COMMON_DIR)/rt_error.o
DIAG_OBJ += $(OSAL_DIR)/user/thread.o
DIAG_OBJ += $(OSAL_DIR)/user/sem.o
ifneq ($(CONFIG_SDK_RTSDN),)
DIAG_OBJ += $(DIAG_SRC)/diag_dpa.o
endif
ifneq ($(CONFIG_SDK_APP_OVS),)
DIAG_OBJ += $(DIAG_SRC)/diag_ovs.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9310)),)
DIAG_OBJ += $(DIAG_SRC)/diag_mpls.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
DIAG_OBJ += $(DIAG_SRC)/diag_oam.o
endif
ifneq ($(CONFIG_SDK_DRIVER_SPI),)
DIAG_OBJ += $(DIAG_SRC)/diag_spi.o
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
DIAG_OBJ += $(DIAG_SRC)/diag_tunnel.o
DIAG_OBJ += $(DIAG_SRC)/diag_vxlan.o
DIAG_OBJ += $(DIAG_SRC)/diag_openflow.o
DIAG_OBJ += $(DIAG_SRC)/diag_bpe.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
DIAG_OBJ += $(DIAG_SRC)/diag_stack.o
DIAG_OBJ += $(DIAG_SRC)/diag_ipmcast.o
DIAG_OBJ += $(DIAG_SRC)/diag_mcast.o
endif
ifneq ($(filter y,$(CONFIG_SDK_DRIVER_NIC) $(CONFIG_SDK_DRIVER_EXTC_NIC)),)
DIAG_OBJ += $(DIAG_SRC)/diag_nic.o
endif
ifneq ($(CONFIG_SDK_DRIVER_L2NTFY),)
DIAG_OBJ += $(DIAG_SRC)/diag_l2_ntfy.o
endif
ifneq ($(CONFIG_SDK_RTL8231),)
DIAG_OBJ += $(DIAG_SRC)/diag_rtl8231.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C),)
DIAG_OBJ += $(DIAG_SRC)/diag_i2c.o
endif
ifneq ($(CONFIG_SDK_DRIVER_GPIO),)
DIAG_OBJ += $(DIAG_SRC)/diag_gpio.o
endif
ifneq ($(CONFIG_SDK_UART1),)
DIAG_OBJ += $(DIAG_SRC)/diag_uart.o
endif
ifneq ($(CONFIG_SDK_APP_DIAG_EXT),)
DIAG_OBJ += $(DIAG_SRC_EXT)/diag_ext_common.o
ifeq ($(CONFIG_SDK_RTL9310),y)
DIAG_OBJ += $(DIAG_SRC_EXT)/diag_ext_9310.o
else ifeq ($(CONFIG_SDK_RTL9300),y)
DIAG_OBJ += $(DIAG_SRC_EXT)/diag_ext_9300.o
else ifeq ($(CONFIG_SDK_RTL8390),y)
DIAG_OBJ += $(DIAG_SRC_EXT)/diag_ext_8390.o
else ifeq ($(CONFIG_SDK_RTL8380),y)
DIAG_OBJ += $(DIAG_SRC_EXT)/diag_ext_8380.o
endif
endif
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
DIAG_OBJ += $(DIAG_SRC)/diag_sdk.o
INCLUDE += -I$(UT_INCLUDE)
endif
DIAG_ENGINE_OBJ += $(DIAG_SRC)/parser/cparser.o \
$(DIAG_SRC)/parser/cparser_fsm.o \
$(DIAG_SRC)/parser/cparser_io_unix.o \
$(DIAG_SRC)/parser/cparser_line.o \
$(DIAG_SRC)/parser/cparser_token.o \
$(DIAG_SRC)/parser/cparser_token_tbl.o \
$(DIAG_SRC)/parser/cparser_tree.o
CFLAGS += -D CONFIG_SDK_GENERAL_TABLE_REG_ACCESS
DIAG_OBJ += $(DIAG_ENGINE_OBJ)

View file

@ -0,0 +1,98 @@
# Copyright (C) 2015 Realtek Semiconductor Corp.
#
# Makefile for including all system configurations
#
#
# This makefile is used for generate diag cparser_tree.c/h independently form source code build flow.
# cparser_tree.c/h are the command tree source code of diag shell commands.
# They are generated at source code build time before building diag executable.
#
# In this makefile provides a method for the generation of cparser_tree.c/h without build the source code.
# Here it prepares environment variables that Makefile.app.diag need and
# use diag-tree target in Makefile.app.diag for cparser_tree.c/h
# Note that Python is required for the tree generation script.
#
# Input: RTK_SDKDIR - the full path of sdk direcoty.
#
# Usage:
# Assume RTK sdk is located under "project/switch/rtk" folder:
# project/switch/rtk
# +-- sdk
# | +- build
# | +- config
# | +- src
# | +- ...
# +...
#
# Example-1:
# Execute make command at switch folder:
# cd project/switch/rtk
# make -f sdk/build/Makefile.diagtree "RTK_SDKDIR=${PWD}/sdk" diag-tree
#
# Example-2:
# Clean the diag tree files then build again:
# cd project/switch/rtk/sdk
# make -f sdk/build/Makefile.diagtree "RTK_SDKDIR=${PWD}/sdk" diag-tree-clean diag-tree
#
#
# SDK directory path
#
RTK_SDKDIR := $(ROOT_PATH)/sdk
DT_SDK_CONFIG := $(RTK_SDKDIR)/config/.config
DT_SDK_BUILD := $(RTK_SDKDIR)/build
DT_DIAG_DIR := $(RTK_SDKDIR)/src/app/diag_v2
#
#Prepare variable for Makefile.app.diag
#
export SDKDIR := $(RTK_SDKDIR)
export SDK_CONFIG := $(DT_SDK_CONFIG)
export SDK_BUILD := $(DT_SDK_BUILD)
#
# Include SDK .config file
#
ifeq ($(SDK_CONFIG),$(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
export
endif
PHONY += diag-tree-help
diag-tree-help:
@echo 'To generate diag tree files:'
@echo ' make -f $${PWD}/sdk/build/Makefile.diagtree "RTK_SDKDIR=$${PWD}/sdk" diag-tree'
@echo 'To remove diag tree files:'
@echo ' make -f $${PWD}/sdk/build/Makefile.diagtree "RTK_SDKDIR=$${PWD}/sdk" diag-tree-clean'
@echo ''
PHONY += diag-tree
diag-tree: diag-make-check
make -C $(DT_DIAG_DIR)/src diag-tree
PHONY += diag-tree-clean
diag-tree-clean: diag-make-check
make -C $(DT_DIAG_DIR)/src diag-tree-clean
PHONY += diag-make-check
ifeq ($(RTK_SDKDIR),)
diag-make-check:
@echo "Error! \"RTK_SDKDIR\" undefined!"
@echo " Please specify full sdk path to \"RTK_SDKDIR\" variable."
@echo ' E.g. make -f $${PWD}/sdk/build/Makefile.diagtree "RTK_SDKDIR=$${PWD}/sdk" diag-tree'
@exit 1
else
diag-make-check:
endif
.PHONY: $(PHONY)

View file

@ -0,0 +1,98 @@
# Copyright (C) 2015 Realtek Semiconductor Corp.
#
# Makefile for including all system configurations
#
#
# This makefile is used for generate diag cparser_tree.c/h independently form source code build flow.
# cparser_tree.c/h are the command tree source code of diag shell commands.
# They are generated at source code build time before building diag executable.
#
# In this makefile provides a method for the generation of cparser_tree.c/h without build the source code.
# Here it prepares environment variables that Makefile.app.diag need and
# use diag-tree target in Makefile.app.diag for cparser_tree.c/h
# Note that Python is required for the tree generation script.
#
# Input: RTK_SDKDIR - the full path of sdk direcoty.
#
# Usage:
# Assume RTK switch sdk is located under "project/driver/rtk" folder:
# project/driver/rtk
# +-- sdk
# | +- build
# | +- config
# | +- src
# | +- ...
# +...
#
# Example-1:
# Execute make command at switch folder:
# cd project/driver/rtk
# make -f sdk/build/Makefile.diagtree_gen "RTK_SDKDIR=${PWD}/sdk" diag-tree
#
# Example-2:
# Clean the diag tree files then build again:
# cd project/driver/rtk
# make -f sdk/build/Makefile.diagtree_gen "RTK_SDKDIR=${PWD}/sdk" diag-tree-clean diag-tree
#
#
# SDK directory path
#
RTK_SDKDIR ?= $(shell pwd)/sdk
DT_SDK_CONFIG := $(RTK_SDKDIR)/config/.config
DT_SDK_BUILD := $(RTK_SDKDIR)/build
DT_DIAG_DIR := $(RTK_SDKDIR)/src/app/diag_v2
#
#Prepare variable for Makefile.app.diag
#
export SDKDIR := $(RTK_SDKDIR)
export SDK_CONFIG := $(DT_SDK_CONFIG)
export SDK_BUILD := $(DT_SDK_BUILD)
#
# Include SDK .config file
#
ifeq ($(SDK_CONFIG),$(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
export
endif
PHONY += diag-tree-help
diag-tree-help:
@echo 'To generate diag tree files:'
@echo ' make -f $${PWD}sdk/build//Makefile.diagtree_gen "RTK_SDKDIR=$${PWD}/sdk" diag-tree'
@echo 'To remove diag tree files:'
@echo ' make -f $${PWD}sdk/build//Makefile.diagtree_gen "RTK_SDKDIR=$${PWD}/sdk" diag-tree-clean'
@echo ''
PHONY += diag-tree
diag-tree: diag-make-check
make -C $(DT_DIAG_DIR)/src diag-tree
PHONY += diag-tree-clean
diag-tree-clean: diag-make-check
make -C $(DT_DIAG_DIR)/src diag-tree-clean
PHONY += diag-make-check
ifeq ($(RTK_SDKDIR),)
diag-make-check:
@echo "Error! \"RTK_SDKDIR\" undefined!"
@echo " Please specify full sdk path to \"RTK_SDKDIR\" variable."
@echo ' E.g. make -f $${PWD}/Makefile.diagtree "RTK_SDKDIR=$${PWD}/sdk" diag-tree'
@exit 1
else
diag-make-check:
endif
.PHONY: $(PHONY)

View file

@ -0,0 +1,27 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Driver Switch Directory
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
EXTRA_CFLAGS += -Wall -Werror -Wuninitialized -Wstrict-prototypes
obj-$(CONFIG_SDK_DRIVER_RTNIC) += rtnic/
obj-$(CONFIG_SDK_DRIVER_RTCORE_IN_LINUX_KERNEL) += rtcore/
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
obj-$(CONFIG_SDK_DRIVER_RTK) += rtk/
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
obj-$(CONFIG_SDK_DRIVER_TEST) += unittest/
endif
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
obj-$(CONFIG_SDK_DRIVER_RTK) += ../../../../../../model/
endif
endif

View file

@ -0,0 +1,55 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtcore Kernel Module
#
TARGET := rtcore
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
SDK_TOP_DIR := ../../..
SDK_SYS_DIR := ../..
#
# main
#
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
sinclude $(SDKDIR)/build/Makefile.rtcore
else
sinclude $(SDKDIR)/build/Makefile.rtcore_u
endif
#
# for linux kernel module
#
RTCORE_LINUX_OBJ := \
$(SDK_SYS_DIR)/linux/dev_config.o \
rtcore_drv.o
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
ifeq ($(CONFIG_SDK_DRIVER_RTCORE),m)
RTCORE_LINUX_OBJ += \
rtcore_export.o
endif
endif
ALL_OBJ := $(RTCORE_LINUX_OBJ) $(RTCORE_OBJ) $(USER_MODE_EXTRA)
EXTRA_CFLAGS += -DRTK_LKM
obj-$(CONFIG_SDK_DRIVER_RTCORE) += $(TARGET).o
$(TARGET)-objs := $(ALL_OBJ)
clean:
@$(RM) $(ALL_OBJ)
@find $(SDK_SYS_DIR) \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-type f -print | xargs rm -f

View file

@ -0,0 +1,48 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtdrv Kernel Module
#
EXTRA_CFLAGS += -Wall -Werror -Wuninitialized -Wstrict-prototypes
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE)
EXTRA_CFLAGS += -DRTUSR
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
EXTRA_CFLAGS += -I$(MODELDIR) -I$(MODELDIR)/common
ifeq ($(CONFIG_SDK_RTL9300),y)
EXTRA_CFLAGS += -I$(MODELDIR)/testcase/9300 -I$(MODELDIR)/behavior_src/9300
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
EXTRA_CFLAGS += -I$(MODELDIR)/testcase/9310 -I$(MODELDIR)/behavior_src/9310
endif
endif
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
EXTRA_CFLAGS += -I$(UT_INCLUDE)
endif
ifeq ($(CONFIG_SDK_DRIVER_RTDRV),m)
EXTRA_CFLAGS += -mlong-calls -fno-pic
EXTRA_CFLAGS += -D__RTDRV_MODULE__
endif
TARGET = rtdrv
EXTRA_CFLAGS += -DRTK_LKM
obj-$(CONFIG_SDK_DRIVER_RTDRV) += $(TARGET).o
$(TARGET)-objs := rtdrv_netfilter.o
ifeq ($(CONFIG_SDK_APP_DIAG_EXT),y)
ifeq ($(CONFIG_SDK_RTL9310),y)
$(TARGET)-objs += ext/rtdrv_netfilter_ext_9310.o
else ifeq ($(CONFIG_SDK_RTL9300),y)
$(TARGET)-objs += ext/rtdrv_netfilter_ext_9300.o
else ifeq ($(CONFIG_SDK_RTL8390),y)
$(TARGET)-objs += ext/rtdrv_netfilter_ext_8390.o
else ifeq ($(CONFIG_SDK_RTL8380),y)
$(TARGET)-objs += ext/rtdrv_netfilter_ext_8380.o
endif
endif

View file

@ -0,0 +1,55 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtk Kernel Module
#
SDK_TOP_DIR := ../../..
#
# main
#
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.rtk
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.phy
#
# for linux kernel module
#
MOD_DIR := ../system/linux/rtk
MOD_OBJ := \
$(MOD_DIR)/module.o
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
MOD_OBJ += \
$(MOD_DIR)/model_module.o
else ifeq ($(CONFIG_SDK_APP_DIAG_EXT),y)
MOD_OBJ += \
$(MOD_DIR)/model_module.o
endif
ALL_OBJ := $(RTK_ALL_OBJ) $(PHY_OBJ) $(CUST_PHY)
ifeq ($(CONFIG_SDK_DRIVER_COMPILE),m)
ALL_OBJ += $(MOD_OBJ)
EXTRA_CFLAGS += -mlong-calls -fno-pic
endif
ifeq ($(CONFIG_SDK_DRIVER_COMPILE),y)
ALL_OBJ += $(MOD_OBJ)
EXTRA_CFLAGS += -mlong-calls -fno-pic
endif
EXTRA_CFLAGS += -DRTK_LKM
TARGET := rtk
obj-$(CONFIG_SDK_DRIVER_COMPILE) += $(TARGET).o
$(TARGET)-objs := $(ALL_OBJ)
clean:
@$(RM) $(ALL_OBJ)
@find \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-type f -print | xargs rm -f

View file

@ -0,0 +1,26 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtnic Kernel Module
#
EXTRA_CFLAGS += -Wall -Werror -Wuninitialized -Wstrict-prototypes
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE)
ifeq ($(CONFIG_SDK_DRIVER_RTNIC),m)
EXTRA_CFLAGS += -mlong-calls -fno-pic
EXTRA_CFLAGS += -D__RTNIC_MODULE__
endif
TARGET = rtnic
EXTRA_CFLAGS += -DRTK_LKM
obj-$(CONFIG_SDK_DRIVER_RTNIC) += $(TARGET).o
$(TARGET)-objs := rtnic_drv.o
clean:
@$(RM) $(ALL_OBJ)
@find \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-type f -print | xargs rm -f

View file

@ -0,0 +1,21 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Net Switch Directory
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
EXTRA_CFLAGS += -Wall -Werror -Wuninitialized -Wstrict-prototypes
ifeq ($(CONFIG_SDK_DRIVER_MX),m)
EXTRA_CFLAGS += -mlong-calls -fno-pic
endif
ifneq ($(CONFIG_SDK_LINKED_KMOD),y)
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
obj-$(CONFIG_SDK_DRIVER_RTDRV) += rtdrv/
endif
endif

View file

@ -0,0 +1,51 @@
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux User Switch Directory
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
RTCORE_DIR = rtcore
dir_y =
libdir_y =
libdir_$(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE) += rtusr
dir_$(CONFIG_SDK_APP_DIAG) += diag
dir_$(CONFIG_SDK_APP_OVS) += ovs
all: librtcore
for i in $(libdir_y) ; do \
$(MAKE) -C $$i || exit $? ; \
done
for i in $(dir_y) ; do \
$(MAKE) -C $$i || exit $? ; \
done
ifneq ($(CONFIG_SDK_KERNEL_LINUX_USER_MODE),)
libdir_$(CONFIG_SDK_DRIVER_TEST) += unittest
libdir_$(CONFIG_SDK_DRIVER_RTK) += rtk
libdir_$(CONFIG_SDK_DRIVER_NIC) += rtnic
librtcore:
$(MAKE) -C $(RTCORE_DIR) -f $(SDK_BUILD)/Makefile.linux.user.rtcore
else
librtcore:
endif
alldir = $(dir_y) $(libdir_y)
romfs:
for i in $(alldir) ; do \
$(MAKE) -C $$i romfs || exit $? ; \
done
clean:
for i in $(alldir) ; do \
$(MAKE) -C $$i clean ; \
done
$(MAKE) -C $(RTCORE_DIR) clean -f $(SDK_BUILD)/Makefile.linux.user.rtcore

View file

@ -0,0 +1,60 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtcore User Library
#
TARGET := $(SDK_LIBDIR)/librtcore.a
SDK_TOP_DIR := ../..
SDK_SYS_DIR := ../system
#
# main
#
#Added by ZhaoPan on 2017/12/13. update the directory path
#include $(SDK_TOP_DIR)/sdk/build/Makefile.rtcore
include $(SDK_TOP_DIR)/rtk-sdk/build/Makefile.rtcore
RTCORE_USR_DIR := $(SDK_SYS_DIR)/linux/rtcore/user
RTCORE_USR_OBJ :=
ifeq ($(CONFIG_SDK_DRIVER_NIC_USER_MODE),y)
RTCORE_USR_OBJ += \
$(RTCORE_USR_DIR)/rtcore_drv_usr.o
endif
ALL_OBJ := $(RTCORE_OBJ) $(RTCORE_USR_OBJ)
DEPS := $(ALL_OBJ:.o=.d)
EXTRA_CFLAGS += -Wall -Werror -Wuninitialized -Wstrict-prototypes
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE) -URTK_UNIVERSAL_BSP
.PHONY: $(TARGET)
$(TARGET): $(ALL_OBJ)
$(AR) rcs $@ $(ALL_OBJ)
$(STRIP) --strip-debug -R .note -R .comment $@
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM $(CFLAGS) $(EXTRA_CFLAGS) $< > $@.$$$$; \
sed 's,\($(*F)\)\.o[ :]*,$(@D)/$(*F).o $@ : ,g' < $@.$$$$ > $@
@rm -f $@.*
NODEP := clean install romfs
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEP))))
-include $(DEPS)
endif
romfs:
clean:
rm -rf $(TARGET) $(ALL_OBJ) $(DEPS)

View file

@ -0,0 +1,51 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtk User Library
#
SDK_TOP_DIR := ../..
#
# main
#
include $(SDK_TOP_DIR)/rtk-sdk/build/Makefile.rtk
include $(SDK_TOP_DIR)/rtk-sdk/build/Makefile.phy
#
# for lib
#
ALL_OBJ := $(RTK_ALL_OBJ) $(PHY_OBJ) $(CUST_PHY)
DEPS := $(ALL_OBJ:.o=.d)
TARGET := $(SDK_LIBDIR)/librtk.a
.PHONY: $(TARGET)
$(TARGET): $(ALL_OBJ)
$(AR) rcs $@ $(ALL_OBJ)
$(STRIP) --strip-debug -R .note -R .comment $@
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM $(CFLAGS) $(EXTRA_CFLAGS) $< > $@.$$$$; \
sed 's,\($(*F)\)\.o[ :]*,$(@D)/$(*F).o $@ : ,g' < $@.$$$$ > $@
@rm -f $@.*
#Don't create dependencies when we're cleaning, installing, ...
NODEP := clean install romfs
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEP))))
-include $(DEPS)
endif
romfs:
clean:
rm -rf $(TARGET) $(ALL_OBJ) $(DEPS)

View file

@ -0,0 +1,55 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtk User Library
#
SDK_TOP_DIR := ../../../..
#
# main
#
NTFY_DIR := ../l2ntfy
NTFY_USR_DIR:= ../l2ntfy/user
NIC_DIR := .
NIC_KRN_DIR := .
include $(SDK_TOP_DIR)/rtk-sdk/build/Makefile.rtnic
#
# for lib
#
ALL_OBJ := $(NIC_ALL_OBJ)
DEPS := $(ALL_OBJ:.o=.d)
TARGET := $(SDK_LIBDIR)/librtnic.a
.PHONY: $(TARGET)
$(TARGET): $(ALL_OBJ)
$(AR) rcs $@ $(ALL_OBJ)
$(STRIP) --strip-debug -R .note -R .comment $@
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM $(CFLAGS) $(EXTRA_CFLAGS) $< > $@.$$$$; \
sed 's,\($(*F)\)\.o[ :]*,$(@D)/$(*F).o $@ : ,g' < $@.$$$$ > $@
@rm -f $@.*
#Don't create dependencies when we're cleaning, installing, ...
NODEP := clean install romfs
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEP))))
-include $(DEPS)
endif
romfs:
clean:
rm -rf $(TARGET) $(ALL_OBJ) $(DEPS)

View file

@ -0,0 +1,48 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtusr User Library
#
CFLAGS_y += -Wall -Werror -Wuninitialized -Wstrict-prototypes -DRTUSR
include ../../../../../../sdk/build/Makefile.rtrpc
vpath %.c ../../../../../../sdk/src/dal/rtrpc/
INCLUDE += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE) -I../include -I$(UT_INCLUDE)
TARGET := obj
SRCS = $(RTRPC_SRC)
OBJS = $(shell for i in $(SRCS); do n=`basename $$i`; echo -n $(TARGET)/$${n%%.*}.o ""; done)
DEPS := $(OBJS:.o=.d)
LIBNAME = $(SDK_LIBDIR)/librtusr.a
all: $(LIBNAME)
$(LIBNAME): $(OBJS)
$(AR) rv $(LIBNAME) $(OBJS)
$(STRIP) --strip-debug -R .note -R .comment $@
$(TARGET)/%.o: %.c
$(CC) $(INCLUDE) $(CFLAGS) $(CFLAGS_y) -c -o $@ $<
$(TARGET)/%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM $(INCLUDE) $(CFLAGS) $(CFLAGS_y) $< > $@.$$$$; \
sed 's,\($(*F)\)\.o[ :]*,$(@D)/$(*F).o $@ : ,g' < $@.$$$$ > $@
@rm -f $@.*
#Don't create dependencies when we're cleaning, installing, ...
NODEP := clean install romfs
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEP))))
-include $(DEPS)
endif
romfs:
clean:
rm -f $(OBJS) $(LIBNAME) $(DEPS)

View file

@ -0,0 +1,207 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtk Kernel Module
#
#
# include configuration file
#
sinclude $(SDK_CONFIG)
#
# path definition
#
PHY_HAL_MAC_DIR ?= hal/mac
PHY_HAL_PHY_DIR ?= hal/phy
HAL_COMMON_DIR ?= hal/common
PHY_DAL_DIR ?= dal
PHY_RTK_DIR ?= rtk
#
# main
#
PHY_OBJ := \
$(PHY_RTK_DIR)/phy.o \
$(PHY_DAL_DIR)/dal_phy.o \
$(PHY_HAL_PHY_DIR)/phy_probe.o \
$(PHY_HAL_PHY_DIR)/identify.o \
$(PHY_HAL_PHY_DIR)/phy_common.o
#MACSec PHY driver
ifneq ($(filter y,$(CONFIG_SDK_RTL826XB)),)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/macsec/phy_macsec.o \
$(PHY_HAL_PHY_DIR)/macsec/aes/aes.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8295) $(CONFIG_SDK_RTL8295R) $(CONFIG_SDK_RTL8214QF) $(CONFIG_SDK_RTL8224QF)),)
PHY_OBJ += \
$(PHY_HAL_MAC_DIR)/rtl8295.o
endif
ifeq ($(CONFIG_SDK_RTL8208D),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8208.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8208_patch.o
else ifeq ($(CONFIG_SDK_RTL8208G),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8208.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8208_patch.o
else ifeq ($(CONFIG_SDK_RTL8208L),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8208.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8208_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8212F),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8212f.o
endif
ifeq ($(CONFIG_SDK_RTL8212B),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214fb.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214fb_patch.o
else ifeq ($(CONFIG_SDK_RTL8214B),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214fb.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214fb_patch.o
else ifeq ($(CONFIG_SDK_RTL8214FB),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214fb.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214fb_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8218B),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218b.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218b_patch.o
else ifeq ($(CONFIG_SDK_RTL8218FB),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218b.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218b_patch.o
else ifeq ($(CONFIG_SDK_RTL8214FC),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218b.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218b_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8218D),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218d.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218d_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8214C),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214c.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8214c_patch.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8295R) $(CONFIG_SDK_RTL8214QF) $(CONFIG_SDK_RTL8224QF)),)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8295.o \
$(PHY_HAL_PHY_DIR)/phy_rtl8295_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8226),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8226.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8226) $(CONFIG_SDK_RTL8284)),)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/nic_rtl8226/nic_rtl8226.o \
$(PHY_HAL_PHY_DIR)/nic_rtl8226/nic_rtl8226b.o \
$(PHY_HAL_PHY_DIR)/nic_rtl8226/nic_rtl8226_init.o \
$(PHY_HAL_PHY_DIR)/nic_rtl8226/nic_rtl8226b_init.o \
$(PHY_HAL_PHY_DIR)/nic_rtl8226/nic_rtl8226_port.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL826X) $(CONFIG_SDK_RTL826XI) $(CONFIG_SDK_RTL825X) $(CONFIG_SDK_RTL825XI) $(CONFIG_SDK_RTL825XL)),)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl826x.o \
$(PHY_HAL_PHY_DIR)/phy_rtl826x_patch.o
endif
ifeq ($(CONFIG_SDK_RTL826XB),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl826xb.o \
$(PHY_HAL_PHY_DIR)/phy_rtl826xb_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8218E),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218e.o
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8218e_patch.o
endif
ifeq ($(CONFIG_SDK_EXPERIMENTAL_RTL8211FS),y)
PHY_OBJ += $(PHY_HAL_PHY_DIR)/phy_experimental_rtl8211fs.o
endif
ifeq ($(CONFIG_SDK_RTL8224),y)
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_rtl8224.o \
$(PHY_HAL_PHY_DIR)/phy_rtl8224_patch.o
endif
#
# For customer PHY
#
CUST_PHY :=
CUST_PHY_CFLAGS :=
ifeq ($(CONFIG_SDK_PHY_CUST1),y)
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.custPhy1
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_cust1.o
EXTRA_CFLAGS += $(CUST_PHY_CFLAGS)
endif
ifeq ($(CONFIG_SDK_PHY_CUST2),y)
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.custPhy2
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_cust2.o
EXTRA_CFLAGS += $(CUST_PHY_CFLAGS)
endif
ifeq ($(CONFIG_SDK_PHY_CUST3),y)
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.custPhy3
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_cust3.o
EXTRA_CFLAGS += $(CUST_PHY_CFLAGS)
endif
ifeq ($(CONFIG_SDK_PHY_CUST4),y)
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.custPhy4
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_cust4.o
EXTRA_CFLAGS += $(CUST_PHY_CFLAGS)
endif
ifeq ($(CONFIG_SDK_PHY_CUST5),y)
sinclude $(SDK_TOP_DIR)/sdk/build/Makefile.custPhy5
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_cust5.o
EXTRA_CFLAGS += $(CUST_PHY_CFLAGS)
endif
PHY_OBJ += \
$(PHY_HAL_PHY_DIR)/phy_construct.o
PHY_OBJ += \
$(HAL_COMMON_DIR)/miim.o
PHY_OBJ += \
$(HAL_COMMON_DIR)/miim_debug.o

View file

@ -0,0 +1,324 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for SDK Rtcore Module
#
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
#
# path definition
#
DRV_DIR := $(SDK_SYS_DIR)/drv
# decide target file path for kernel or user mode (will change the arch. later, may remove)
ifeq ($(CONFIG_SDK_KERNEL_LINUX),y)
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
TGT_DIR :=
else ifeq ($(CONFIG_SDK_KERNEL_LINUX_USER_MODE),y)
TGT_DIR := /user
else
$(warning: Should define one of CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE or CONFIG_SDK_KERNEL_LINUX_USER_MODE)
endif
else
TGT_DIR :=
endif
COMMON_DIR := $(SDK_SYS_DIR)/common
DBG_DIR := $(COMMON_DIR)/debug$(TGT_DIR)
RTCORE_INIT_DIR := $(COMMON_DIR)/rtcore$(TGT_DIR)
UTIL_DIR := $(COMMON_DIR)/util$(TGT_DIR)
GPIO_DIR := $(DRV_DIR)/gpio$(TGT_DIR)
I2C_DIR := $(DRV_DIR)/i2c$(TGT_DIR)
INTR_DIR := $(DRV_DIR)/intr$(TGT_DIR)
RTL8231_DIR := $(DRV_DIR)/rtl8231$(TGT_DIR)
SPI_DIR := $(DRV_DIR)/spi$(TGT_DIR)
SWCORE_DIR := $(DRV_DIR)/swcore$(TGT_DIR)
TC_DIR := $(DRV_DIR)/tc$(TGT_DIR)
UART1_DIR := $(DRV_DIR)/uart$(TGT_DIR)
WATCHDOG_DIR := $(DRV_DIR)/watchdog$(TGT_DIR)
HWP_DIR := $(SDK_SYS_DIR)/hwp$(TGT_DIR)
IOAL_DIR := $(SDK_SYS_DIR)/ioal$(TGT_DIR)
OSAL_DIR := $(SDK_SYS_DIR)/osal/linux$(TGT_DIR)
IOAL_INIT_DIR := $(IOAL_DIR)
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
ifeq ($(CONFIG_SDK_MODEL_MODE_USER),y)
IOAL_INIT_DIR := $(SDK_TOP_DIR)/model/ioal
endif
endif
#
# compiler/linker option
#
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE) -URTK_UNIVERSAL_BSP -Werror -Wno-array-bounds
ifneq ($(CONFIG_SDK_DRIVER_TEST),)
EXTRA_CFLAGS += -I$(UT_INCLUDE)
endif
#
# main
#
COMMON_OBJ :=
DRV_OBJ :=
NTFY_OBJ :=
NIC_OBJ :=
COMMON_OBJ += \
$(COMMON_DIR)$(TGT_DIR)/rt_chip.o \
$(DBG_DIR)/rt_log.o \
$(RTCORE_INIT_DIR)/rtcore_init.o
ifneq ($(filter y,$(CONFIG_SDK_TC_DRV) $(CONFIG_SDK_TC_TC1_TIME)),)
COMMON_OBJ += $(UTIL_DIR)/rt_util_system.o
endif
ifeq ($(CONFIG_SDK_KERNEL_LINUX),y)
COMMON_OBJ += \
$(DBG_DIR)/mem_debug.o
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
DRV_OBJ += \
$(GPIO_DIR)/gpio.o \
$(GPIO_DIR)/gpio_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
DRV_OBJ += \
$(GPIO_DIR)/gpio_common.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
DRV_OBJ += \
$(GPIO_DIR)/gpio_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
DRV_OBJ += \
$(GPIO_DIR)/gpio_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
DRV_OBJ += \
$(GPIO_DIR)/gpio_rtl8380.o
endif
ifeq ($(CONFIG_SDK_KERNEL_LINUX_USER_MODE),y)
DRV_OBJ += $(GPIO_DIR)/rtusr_gpio.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_I2C),y)
DRV_OBJ += \
$(I2C_DIR)/i2c.o \
$(I2C_DIR)/i2c_probe.o \
$(I2C_DIR)/i2c_software_drv.o
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9300),)
DRV_OBJ += \
$(I2C_DIR)/i2c_rtl9300.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9310),)
DRV_OBJ += \
$(I2C_DIR)/i2c_rtl9310.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8390),)
DRV_OBJ += \
$(I2C_DIR)/i2c_rtl8390.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8380),)
DRV_OBJ += \
$(I2C_DIR)/i2c_rtl8380.o
endif
endif
DRV_OBJ += \
$(INTR_DIR)/intr.o \
$(INTR_DIR)/intr_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
DRV_OBJ += \
$(INTR_DIR)/intr_rtl9310.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
DRV_OBJ += \
$(INTR_DIR)/intr_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
DRV_OBJ += \
$(INTR_DIR)/intr_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
DRV_OBJ += \
$(INTR_DIR)/intr_rtl8380.o
endif
DRV_OBJ += $(UTIL_DIR)/rt_util_intr.o
ifneq ($(CONFIG_SDK_KERNEL_LINUX_USER_MODE),y)
DRV_OBJ += $(UTIL_DIR)/rt_util_intrk.o
endif
NTFY_DIR := $(DRV_DIR)/l2ntfy
NTFY_USR_DIR:= $(DRV_DIR)/l2ntfy/user
ifneq ($(CONFIG_SDK_DRIVER_NIC),)
NIC_DIR := $(DRV_DIR)/nic
NIC_KRN_DIR := $(DRV_DIR)/nic
include $(SDK_BUILD)/Makefile.rtnic
endif
ifeq ($(CONFIG_SDK_RTL8231),y)
DRV_OBJ += \
$(GPIO_DIR)/ext_gpio.o \
$(RTL8231_DIR)/rtl8231.o \
$(RTL8231_DIR)/rtl8231_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
DRV_OBJ += \
$(RTL8231_DIR)/rtl8231_rtl9310.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
DRV_OBJ += \
$(RTL8231_DIR)/rtl8231_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
DRV_OBJ += \
$(RTL8231_DIR)/rtl8231_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
DRV_OBJ += \
$(RTL8231_DIR)/rtl8231_rtl8380.o
endif
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8231) $(CONFIG_SDK_DRIVER_GPIO)),)
DRV_OBJ += $(GPIO_DIR)/generalCtrl_gpio.o
endif
ifeq ($(CONFIG_SDK_DRIVER_SPI),y)
DRV_OBJ += $(SPI_DIR)/spi.o
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
ifeq ($(CONFIG_SDK_BSP_SPI_DRV),y)
DRV_OBJ += $(SPI_DIR)/spi-controller-driver.o
endif
endif
ifeq ($(CONFIG_SDK_SPI_DEV_1),y)
DRV_OBJ += $(SPI_DIR)/spi_dev1.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_2),y)
DRV_OBJ += $(SPI_DIR)/spi_dev2.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_3),y)
DRV_OBJ += $(SPI_DIR)/spi_dev3.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_4),y)
DRV_OBJ += $(SPI_DIR)/spi_dev4.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_5),y)
DRV_OBJ += $(SPI_DIR)/spi_dev5.o
DRV_OBJ += $(SPI_DIR)/spi_dev3.o
endif
endif
ifeq ($(CONFIG_SDK_KERNEL_LINUX),y)
ifneq ($(KERNELRELEASE),)
#this is linux mode, and in kernel space (i.e. lkm)
else
#this is linux mode, and in user space
DRV_OBJ += $(SWCORE_DIR)/chip_probe.o
endif
else
#this is non-linux mode or loader
DRV_OBJ += $(SWCORE_DIR)/chip_probe.o
endif
DRV_OBJ += $(SWCORE_DIR)/swcore.o
ifeq ($(CONFIG_SDK_TC_DRV),y)
DRV_OBJ += $(TC_DIR)/tc_probe.o \
$(TC_DIR)/tc.o\
$(TC_DIR)/tc_common.o
ifeq ($(CONFIG_SDK_TC_TC1_TIME),y)
DRV_OBJ += $(UTIL_DIR)/rt_util_time.o
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
DRV_OBJ += $(UTIL_DIR)/rt_util_timeIsr.o
endif
endif
endif
ifeq ($(CONFIG_SDK_UART1),y)
DRV_OBJ += \
$(UART1_DIR)/uart.o \
$(UART1_DIR)/uart_probe.o\
$(UART1_DIR)/uart_common.o
endif
ifeq ($(CONFIG_SDK_DRIVER_WATCHDOG),y)
DRV_OBJ += \
$(WATCHDOG_DIR)/watchdog.o \
$(WATCHDOG_DIR)/watchdog_probe.o\
$(WATCHDOG_DIR)/watchdog_common.o
endif
HWP_OBJ := \
$(HWP_DIR)/hwp_init.o \
$(HWP_DIR)/hwp_probe.o \
$(HWP_DIR)/hwp.o \
$(HWP_DIR)/profile_list.o
IOAL_OBJ := \
$(IOAL_INIT_DIR)/ioal_init.o \
$(IOAL_DIR)/mem32.o \
$(IOAL_DIR)/phy_reset.o \
$(IOAL_DIR)/ioal_param.o \
$(IOAL_DIR)/ioal_log.o
ifeq ($(CONFIG_SDK_KERNEL_LINUX),y)
OSAL_OBJ := \
$(OSAL_DIR)/atomic.o \
$(OSAL_DIR)/cache.o \
$(OSAL_DIR)/lib.o \
$(OSAL_DIR)/memory.o \
$(OSAL_DIR)/sem.o \
$(OSAL_DIR)/thread.o \
$(OSAL_DIR)/time.o \
$(OSAL_DIR)/wait.o
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
OSAL_OBJ += \
$(OSAL_DIR)/isr.o \
$(OSAL_DIR)/spl.o
endif
endif
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
EXTRA_CFLAGS += -I$(SDK_TOP_DIR)/model
ifeq ($(CONFIG_SDK_RTL9300),y)
EXTRA_CFLAGS += -I$(SDK_TOP_DIR)/model/behavior_src/9300
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
EXTRA_CFLAGS += -I$(SDK_TOP_DIR)/model/behavior_src/9310
endif
EXTRA_CFLAGS += -I$(SDK_TOP_DIR)/model/common
EXTRA_CFLAGS += -I$(SDK_TOP_DIR)/kernel/uClinux/uClibc/include
IOAL_OBJ += \
$(SDK_TOP_DIR)/../model/virtualmac/vmac_target.o
endif
RTCORE_OBJ := $(COMMON_OBJ) $(DRV_OBJ) $(HWP_OBJ) $(IOAL_OBJ) $(OSAL_OBJ) $(NTFY_OBJ)
ifneq ($(CONFIG_SDK_DRIVER_NIC),)
RTCORE_OBJ += $(NIC_OBJ)
endif

View file

@ -0,0 +1,145 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for SDK Rtcore Module (user mode kernel module)
#
EXTRA_CFLAGS += -DRTK_USERMODE_LKM
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE) -URTK_UNIVERSAL_BSP -Werror -Wno-array-bounds
USER_MODE_EXTRA := \
$(SDK_SYS_DIR)/osal/linux/isr.o \
$(SDK_SYS_DIR)/osal/linux/memory.o \
$(SDK_SYS_DIR)/osal/linux/cache.o \
$(SDK_SYS_DIR)/common/rtcore/rtcore_init.o \
$(SDK_SYS_DIR)/common/debug/rt_log.o \
$(SDK_SYS_DIR)/common/util/rt_util_system.o \
$(SDK_SYS_DIR)/ioal/mem32.o \
$(SDK_SYS_DIR)/ioal/ioal_init.o \
$(SDK_SYS_DIR)/ioal/ioal_param.o \
$(SDK_SYS_DIR)/ioal/ioal_log.o \
$(SDK_SYS_DIR)/hwp/hwp_init.o \
$(SDK_SYS_DIR)/hwp/hwp_probe.o \
$(SDK_SYS_DIR)/hwp/hwp.o \
$(SDK_SYS_DIR)/hwp/profile_list.o \
$(SDK_SYS_DIR)/osal/linux/sem.o \
$(SDK_SYS_DIR)/osal/linux/thread.o \
$(SDK_SYS_DIR)/osal/linux/time.o \
$(SDK_SYS_DIR)/osal/linux/atomic.o
ifeq ($(CONFIG_SDK_DRIVER_SPI),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi.o
ifneq ($(CONFIG_SDK_SPI_DEV_1),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev1.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_2),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev2.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_3),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev3.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_4),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev4.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_5),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev5.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev3.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_I2C),y)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c.o \
$(SDK_SYS_DIR)/drv/i2c/i2c_probe.o \
$(SDK_SYS_DIR)/drv/i2c/i2c_software_drv.o
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9300),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl9300.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9310),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl9310.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8390),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl8390.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8380),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl8380.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio.o \
$(SDK_SYS_DIR)/drv/gpio/gpio_probe.o \
$(SDK_SYS_DIR)/drv/gpio/generalCtrl_gpio.o
ifneq ($(CONFIG_SDK_RTL9310),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_common.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_rtl8380.o
endif
endif
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl9310.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl8380.o
endif
USER_MODE_EXTRA += $(SDK_SYS_DIR)/common/util/rt_util_intrk.o
ifeq ($(CONFIG_SDK_RTL8231),y)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/ext_gpio.o \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231.o \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl9310.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl8380.o
endif
endif
ifeq ($(CONFIG_SDK_TC_DRV),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/tc/tc_probe.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/tc/tc.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/tc/tc_common.o
ifeq ($(CONFIG_SDK_TC_TC1_TIME),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/common/util/rt_util_time.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/common/util/rt_util_timeIsr.o
endif
endif

View file

@ -0,0 +1,142 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for SDK Rtcore Module (user mode kernel module)
#
EXTRA_CFLAGS += -DRTK_USERMODE_LKM -URTK_UNIVERSAL_BSP
USER_MODE_EXTRA := \
$(SDK_SYS_DIR)/osal/linux/memory.o \
$(SDK_SYS_DIR)/osal/linux/cache.o \
$(SDK_SYS_DIR)/common/rtcore/rtcore_init.o \
$(SDK_SYS_DIR)/common/debug/rt_log.o \
$(SDK_SYS_DIR)/ioal/mem32.o \
$(SDK_SYS_DIR)/ioal/ioal_init.o \
$(SDK_SYS_DIR)/ioal/ioal_param.o \
$(SDK_SYS_DIR)/ioal/ioal_log.o \
$(SDK_SYS_DIR)/hwp/hwp_init.o \
$(SDK_SYS_DIR)/hwp/hwp_probe.o \
$(SDK_SYS_DIR)/hwp/hwp.o \
$(SDK_SYS_DIR)/hwp/profile_list.o \
$(SDK_SYS_DIR)/osal/linux/sem.o \
$(SDK_SYS_DIR)/osal/linux/thread.o \
$(SDK_SYS_DIR)/osal/linux/time.o \
$(SDK_SYS_DIR)/drv/swcore/chip_probe.o
ifeq ($(CONFIG_SDK_DRIVER_SPI),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi.o
ifeq ($(CONFIG_SDK_SPI_DEV_1),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev1.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_2),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev2.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_3),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev3.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_4),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev4.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_5),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev5.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/spi/spi_dev3.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_I2C),y)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c.o \
$(SDK_SYS_DIR)/drv/i2c/i2c_probe.o \
$(SDK_SYS_DIR)/drv/i2c/i2c_software_drv.o
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9300),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl9300.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9310),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl9310.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8390),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl8390.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8380),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/i2c/i2c_rtl8380.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio.o \
$(SDK_SYS_DIR)/drv/gpio/gpio_probe.o \
$(SDK_SYS_DIR)/drv/gpio/generalCtrl_gpio.o
ifneq ($(CONFIG_SDK_RTL9310),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_common.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/gpio_rtl8380.o
endif
endif
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl9310.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/intr/intr_rtl8380.o
endif
USER_MODE_EXTRA += $(SDK_SYS_DIR)/common/util/rt_util_intrk.o
ifeq ($(CONFIG_SDK_RTL8231),y)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/gpio/ext_gpio.o \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231.o \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_probe.o
ifneq ($(CONFIG_SDK_RTL9310),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl9310.o
endif
ifneq ($(CONFIG_SDK_RTL9300),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl9300.o
endif
ifneq ($(CONFIG_SDK_RTL8390),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl8390.o
endif
ifneq ($(CONFIG_SDK_RTL8380),)
USER_MODE_EXTRA += \
$(SDK_SYS_DIR)/drv/rtl8231/rtl8231_rtl8380.o
endif
endif
ifeq ($(CONFIG_SDK_TC_DRV),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/tc/tc_probe.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/tc/tc.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/drv/tc/tc_common.o
ifeq ($(CONFIG_SDK_TC_TC1_TIME),y)
USER_MODE_EXTRA += $(SDK_SYS_DIR)/common/util/rt_util_time.o
USER_MODE_EXTRA += $(SDK_SYS_DIR)/common/util/rt_util_timeIsr.o
endif
endif

View file

@ -0,0 +1,21 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtdrv Kernel Module
#
RTDRV_ALL_OBJ :=
ifeq ($(CONFIG_SDK_APP_DIAG_EXT),y)
ifeq ($(CONFIG_SDK_RTL9310),y)
RTDRV_ALL_OBJ += ext/rtdrv_netfilter_ext_9310.o
else ifeq ($(CONFIG_SDK_RTL9300),y)
RTDRV_ALL_OBJ += ext/rtdrv_netfilter_ext_9300.o
else ifeq ($(CONFIG_SDK_RTL8390),y)
RTDRV_ALL_OBJ += ext/rtdrv_netfilter_ext_8390.o
else ifeq ($(CONFIG_SDK_RTL8380),y)
RTDRV_ALL_OBJ += ext/rtdrv_netfilter_ext_8380.o
endif
endif

View file

@ -0,0 +1,338 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtk Kernel Module
#
#
# include configuration file
#
sinclude $(SDK_CONFIG)
#
# include customer files
#
ifeq ($(CONFIG_SDK_DRIVER_RTK_CUSTOMER),y)
CUSTOMER_RTK_API_DIR := $(SDK_TOP_DIR)/rtk-sdk/src/rtk/customer
include $(CUSTOMER_RTK_API_DIR)/customer_api.mk
endif
#
# path definition
#
COMMON_DIR := common
COMMON_UTIL_DIR := common/util
HAL_DIR := hal
HAL_CHIPDEF_DIR := $(HAL_DIR)/chipdef
HAL_CHIPDEF_CYPRESS_DIR := $(HAL_CHIPDEF_DIR)/cypress
HAL_CHIPDEF_MAPLE_DIR := $(HAL_CHIPDEF_DIR)/maple
HAL_CHIPDEF_MANGO_DIR := $(HAL_CHIPDEF_DIR)/mango
HAL_CHIPDEF_LONGAN_DIR := $(HAL_CHIPDEF_DIR)/longan
HAL_COMMON_DIR := $(HAL_DIR)/common
HAL_MAC_DIR := $(HAL_DIR)/mac
HAL_PHY_DIR := $(HAL_DIR)/phy
DAL_DIR := dal
DAL_CYPRESS_DIR := $(DAL_DIR)/cypress
DAL_MAPLE_DIR := $(DAL_DIR)/maple
DAL_MANGO_DIR := $(DAL_DIR)/mango
DAL_LONGAN_DIR := $(DAL_DIR)/longan
DAL_RTRPC_DIR := $(DAL_DIR)/rtrpc
RTK_DIR := rtk
#
# compiler/linker option
#
EXTRA_CFLAGS += -Wall -Werror -Wuninitialized -Wstrict-prototypes -Wno-array-bounds
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE) -I$(DRV_INCLUDE)
#
# main
#
COMMON_OBJ := \
$(COMMON_DIR)/rt_error.o \
$(COMMON_UTIL_DIR)/rt_bitop.o \
$(COMMON_UTIL_DIR)/rt_util.o \
$(COMMON_UTIL_DIR)/rt_util_test.o \
$(COMMON_UTIL_DIR)/rt_util_serdes.o \
$(COMMON_UTIL_DIR)/rt_util_led.o
HAL_OBJ := \
$(HAL_CHIPDEF_DIR)/chipdef.o \
$(HAL_CHIPDEF_DIR)/driver.o \
$(HAL_COMMON_DIR)/halctrl.o \
$(HAL_MAC_DIR)/mac_probe.o \
$(HAL_MAC_DIR)/drv/drv.o \
$(HAL_MAC_DIR)/mem.o \
$(HAL_MAC_DIR)/reg.o \
$(HAL_MAC_DIR)/miim_common_drv.o \
$(HAL_MAC_DIR)/serdes.o \
$(HAL_MAC_DIR)/mac_debug.o
ifeq ($(CONFIG_SDK_RTL8390),y)
HAL_OBJ += \
$(HAL_PHY_DIR)/phy_rtl8390.o \
$(HAL_MAC_DIR)/led/led_rtl8390.o\
$(HAL_MAC_DIR)/drv/drv_rtl8390.o \
$(HAL_CHIPDEF_CYPRESS_DIR)/rtk_cypress_reg_list.o \
$(HAL_CHIPDEF_CYPRESS_DIR)/rtk_cypress_regField_list.o \
$(HAL_CHIPDEF_CYPRESS_DIR)/rtk_cypress_table_list.o \
$(HAL_CHIPDEF_CYPRESS_DIR)/rtk_cypress_tableField_list.o \
$(HAL_CHIPDEF_CYPRESS_DIR)/chip_rtl8390.o
endif
ifeq ($(CONFIG_SDK_RTL8380),y)
HAL_OBJ += \
$(HAL_PHY_DIR)/phy_rtl8380.o \
$(HAL_MAC_DIR)/led/led_rtl8380.o\
$(HAL_MAC_DIR)/drv/drv_rtl8380.o \
$(HAL_CHIPDEF_MAPLE_DIR)/rtk_maple_reg_list.o \
$(HAL_CHIPDEF_MAPLE_DIR)/rtk_maple_regField_list.o \
$(HAL_CHIPDEF_MAPLE_DIR)/rtk_maple_table_list.o \
$(HAL_CHIPDEF_MAPLE_DIR)/rtk_maple_tableField_list.o \
$(HAL_CHIPDEF_MAPLE_DIR)/chip_rtl8380.o
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
HAL_OBJ += \
$(HAL_PHY_DIR)/phy_rtl9310.o \
$(HAL_MAC_DIR)/drv/drv_rtl9310.o \
$(HAL_MAC_DIR)/led/led_rtl9310.o\
$(HAL_CHIPDEF_MANGO_DIR)/rtk_mango_reg_list.o \
$(HAL_CHIPDEF_MANGO_DIR)/rtk_mango_regField_list.o \
$(HAL_CHIPDEF_MANGO_DIR)/rtk_mango_table_list.o \
$(HAL_CHIPDEF_MANGO_DIR)/rtk_mango_tableField_list.o \
$(HAL_CHIPDEF_MANGO_DIR)/chip_rtl9310.o
endif
ifeq ($(CONFIG_SDK_RTL9300),y)
HAL_OBJ += \
$(HAL_PHY_DIR)/phy_rtl9300.o \
$(HAL_MAC_DIR)/led/led_rtl9300.o\
$(HAL_MAC_DIR)/drv/drv_rtl9300.o \
$(HAL_CHIPDEF_LONGAN_DIR)/rtk_longan_reg_list.o \
$(HAL_CHIPDEF_LONGAN_DIR)/rtk_longan_regField_list.o \
$(HAL_CHIPDEF_LONGAN_DIR)/rtk_longan_table_list.o \
$(HAL_CHIPDEF_LONGAN_DIR)/rtk_longan_tableField_list.o \
$(HAL_CHIPDEF_LONGAN_DIR)/chip_rtl9300.o
endif
DAL_OBJ := \
$(DAL_DIR)/dal_common.o \
$(DAL_DIR)/dal_mgmt.o \
$(DAL_DIR)/dal_linkMon.o
ifeq ($(CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE),y)
DAL_OBJ += \
$(DAL_DIR)/dal_linkFaultMon.o
endif
DAL_OBJ += \
$(DAL_DIR)/dal_waMon.o
ifeq ($(CONFIG_SDK_RTL8390),y)
DAL_OBJ += \
$(DAL_CYPRESS_DIR)/dal_cypress_mapper.o \
$(DAL_CYPRESS_DIR)/dal_cypress_eee.o \
$(DAL_CYPRESS_DIR)/dal_cypress_flowctrl.o \
$(DAL_CYPRESS_DIR)/dal_cypress_l2.o \
$(DAL_CYPRESS_DIR)/dal_cypress_l3.o \
$(DAL_CYPRESS_DIR)/dal_cypress_mirror.o \
$(DAL_CYPRESS_DIR)/dal_cypress_port.o \
$(DAL_CYPRESS_DIR)/dal_cypress_qos.o \
$(DAL_CYPRESS_DIR)/dal_cypress_stp.o \
$(DAL_CYPRESS_DIR)/dal_cypress_switch.o \
$(DAL_CYPRESS_DIR)/dal_cypress_time.o \
$(DAL_CYPRESS_DIR)/dal_cypress_trap.o \
$(DAL_CYPRESS_DIR)/dal_cypress_trunk.o \
$(DAL_CYPRESS_DIR)/dal_cypress_sec.o \
$(DAL_CYPRESS_DIR)/dal_cypress_vlan.o \
$(DAL_CYPRESS_DIR)/dal_cypress_stat.o \
$(DAL_CYPRESS_DIR)/dal_cypress_rate.o \
$(DAL_CYPRESS_DIR)/dal_cypress_acl.o \
$(DAL_CYPRESS_DIR)/dal_cypress_oam.o \
$(DAL_CYPRESS_DIR)/dal_cypress_mpls.o \
$(DAL_CYPRESS_DIR)/dal_cypress_diag.o \
$(DAL_CYPRESS_DIR)/dal_cypress_common.o \
$(DAL_CYPRESS_DIR)/dal_cypress_waFunc.o \
$(DAL_CYPRESS_DIR)/dal_cypress_sds.o \
$(DAL_CYPRESS_DIR)/dal_cypress_led.o
endif
ifeq ($(CONFIG_SDK_RTL8380),y)
DAL_OBJ += \
$(DAL_MAPLE_DIR)/dal_maple_mapper.o \
$(DAL_MAPLE_DIR)/dal_maple_eee.o \
$(DAL_MAPLE_DIR)/dal_maple_flowctrl.o \
$(DAL_MAPLE_DIR)/dal_maple_l2.o \
$(DAL_MAPLE_DIR)/dal_maple_l3.o \
$(DAL_MAPLE_DIR)/dal_maple_led.o \
$(DAL_MAPLE_DIR)/dal_maple_mirror.o \
$(DAL_MAPLE_DIR)/dal_maple_port.o \
$(DAL_MAPLE_DIR)/dal_maple_qos.o \
$(DAL_MAPLE_DIR)/dal_maple_stp.o \
$(DAL_MAPLE_DIR)/dal_maple_switch.o \
$(DAL_MAPLE_DIR)/dal_maple_trap.o \
$(DAL_MAPLE_DIR)/dal_maple_trunk.o \
$(DAL_MAPLE_DIR)/dal_maple_sec.o \
$(DAL_MAPLE_DIR)/dal_maple_vlan.o \
$(DAL_MAPLE_DIR)/dal_maple_stat.o \
$(DAL_MAPLE_DIR)/dal_maple_rate.o \
$(DAL_MAPLE_DIR)/dal_maple_acl.o \
$(DAL_MAPLE_DIR)/dal_maple_time.o \
$(DAL_MAPLE_DIR)/dal_maple_waFunc.o \
$(DAL_MAPLE_DIR)/dal_maple_diag.o
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
DAL_OBJ += \
$(DAL_MANGO_DIR)/dal_mango_mapper.o \
$(DAL_MANGO_DIR)/dal_mango_common.o \
$(DAL_MANGO_DIR)/dal_mango_port.o \
$(DAL_MANGO_DIR)/dal_mango_l2.o \
$(DAL_MANGO_DIR)/dal_mango_l3.o \
$(DAL_MANGO_DIR)/dal_mango_led.o \
$(DAL_MANGO_DIR)/dal_mango_tunnel.o \
$(DAL_MANGO_DIR)/dal_mango_vxlan.o \
$(DAL_MANGO_DIR)/dal_mango_mcast.o \
$(DAL_MANGO_DIR)/dal_mango_ipmcast.o \
$(DAL_MANGO_DIR)/dal_mango_stp.o \
$(DAL_MANGO_DIR)/dal_mango_mirror.o \
$(DAL_MANGO_DIR)/dal_mango_qos.o \
$(DAL_MANGO_DIR)/dal_mango_mpls.o \
$(DAL_MANGO_DIR)/dal_mango_sec.o \
$(DAL_MANGO_DIR)/dal_mango_eee.o \
$(DAL_MANGO_DIR)/dal_mango_trap.o \
$(DAL_MANGO_DIR)/dal_mango_trunk.o \
$(DAL_MANGO_DIR)/dal_mango_vlan.o \
$(DAL_MANGO_DIR)/dal_mango_bpe.o \
$(DAL_MANGO_DIR)/dal_mango_stat.o \
$(DAL_MANGO_DIR)/dal_mango_rate.o \
$(DAL_MANGO_DIR)/dal_mango_flowctrl.o \
$(DAL_MANGO_DIR)/dal_mango_oam.o \
$(DAL_MANGO_DIR)/dal_mango_stack.o \
$(DAL_MANGO_DIR)/dal_mango_pie.o \
$(DAL_MANGO_DIR)/dal_mango_acl.o \
$(DAL_MANGO_DIR)/dal_mango_openflow.o \
$(DAL_MANGO_DIR)/dal_mango_sds.o \
$(DAL_MANGO_DIR)/dal_mango_diag.o \
$(DAL_MANGO_DIR)/dal_mango_switch.o \
$(DAL_MANGO_DIR)/dal_mango_waFunc.o
endif
ifeq ($(CONFIG_SDK_RTL9300),y)
DAL_OBJ += \
$(DAL_LONGAN_DIR)/dal_longan_mapper.o \
$(DAL_LONGAN_DIR)/dal_longan_eee.o \
$(DAL_LONGAN_DIR)/dal_longan_common.o \
$(DAL_LONGAN_DIR)/dal_longan_port.o \
$(DAL_LONGAN_DIR)/dal_longan_stp.o \
$(DAL_LONGAN_DIR)/dal_longan_pie.o \
$(DAL_LONGAN_DIR)/dal_longan_l2.o \
$(DAL_LONGAN_DIR)/dal_longan_rate.o \
$(DAL_LONGAN_DIR)/dal_longan_flowctrl.o \
$(DAL_LONGAN_DIR)/dal_longan_trunk.o \
$(DAL_LONGAN_DIR)/dal_longan_acl.o \
$(DAL_LONGAN_DIR)/dal_longan_qos.o \
$(DAL_LONGAN_DIR)/dal_longan_vlan.o \
$(DAL_LONGAN_DIR)/dal_longan_trap.o \
$(DAL_LONGAN_DIR)/dal_longan_mirror.o \
$(DAL_LONGAN_DIR)/dal_longan_stat.o \
$(DAL_LONGAN_DIR)/dal_longan_sec.o \
$(DAL_LONGAN_DIR)/dal_longan_switch.o \
$(DAL_LONGAN_DIR)/dal_longan_diag.o \
$(DAL_LONGAN_DIR)/dal_longan_led.o \
$(DAL_LONGAN_DIR)/dal_longan_oam.o \
$(DAL_LONGAN_DIR)/dal_longan_l3.o \
$(DAL_LONGAN_DIR)/dal_longan_ipmcast.o \
$(DAL_LONGAN_DIR)/dal_longan_waFunc.o \
$(DAL_LONGAN_DIR)/dal_longan_sds.o \
$(DAL_LONGAN_DIR)/dal_longan_mcast.o
DAL_OBJ += $(DAL_LONGAN_DIR)/dal_longan_stack.o
endif
DAL_OBJ += \
$(DAL_DIR)/dal_construct.o
ifeq ($(CONFIG_SDK_RTL8390),y)
DAL_OBJ += \
$(DAL_CYPRESS_DIR)/dal_cypress_construct.o
endif
ifeq ($(CONFIG_SDK_RTL8380),y)
DAL_OBJ += \
$(DAL_MAPLE_DIR)/dal_maple_construct.o
endif
ifeq ($(CONFIG_SDK_RTL9300),y)
DAL_OBJ += \
$(DAL_LONGAN_DIR)/dal_longan_construct.o
endif
ifeq ($(CONFIG_SDK_RTL9310),y)
DAL_OBJ += \
$(DAL_MANGO_DIR)/dal_mango_construct.o
endif
ifeq ($(CONFIG_RISE),y)
EXTRA_CFLAGS += -I$(ROOT_PATH)/module/stk/src
include $(SDK_TOP_DIR)/sdk/build/Makefile.rtrpc
RTRPC_OBJ = $(shell for i in $(RTRPC_SRC); do n=`basename $$i`; echo -n $(DAL_RTRPC_DIR)/$${n%%.*}.o ""; done)
else
RTRPC_OBJ =
endif
RTK_OBJ := \
$(RTK_DIR)/init.o \
$(RTK_DIR)/eee.o \
$(RTK_DIR)/flowctrl.o \
$(RTK_DIR)/l2.o \
$(RTK_DIR)/l3.o \
$(RTK_DIR)/mirror.o \
$(RTK_DIR)/port.o \
$(RTK_DIR)/qos.o \
$(RTK_DIR)/rate.o \
$(RTK_DIR)/sec.o \
$(RTK_DIR)/stat.o \
$(RTK_DIR)/stp.o \
$(RTK_DIR)/switch.o \
$(RTK_DIR)/time.o \
$(RTK_DIR)/trap.o \
$(RTK_DIR)/vlan.o \
$(RTK_DIR)/bpe.o \
$(RTK_DIR)/trunk.o \
$(RTK_DIR)/issinit.o \
$(RTK_DIR)/led.o \
$(RTK_DIR)/acl.o \
$(RTK_DIR)/diag.o \
$(RTK_DIR)/stack.o \
$(RTK_DIR)/pie.o \
$(RTK_DIR)/mpls.o \
$(RTK_DIR)/oam.o \
$(RTK_DIR)/ipmcast.o \
$(RTK_DIR)/mcast.o \
$(RTK_DIR)/tunnel.o \
$(RTK_DIR)/vxlan.o \
$(RTK_DIR)/openflow.o \
$(RTK_DIR)/sds.o
ifeq ($(CONFIG_SDK_DRIVER_RTK_CUSTOMER),y)
RTK_OBJ += \
$(CUSTOMER_RTK_API_SRC)
endif
#
# for model code
#
ifeq ($(CONFIG_SDK_MODEL_MODE),y)
ifeq ($(CONFIG_SDK_RTL9310),y)
EXTRA_CFLAGS += -I$(MODELDIR) -I$(MODELDIR)/common -I$(MODELDIR)/behavior_src/9310 -I$(MODELDIR)/testcase/9310
endif
ifeq ($(CONFIG_SDK_RTL9300),y)
EXTRA_CFLAGS += -I$(MODELDIR) -I$(MODELDIR)/common -I$(MODELDIR)/behavior_src/9300
endif
endif
RTK_ALL_OBJ := $(COMMON_OBJ) $(HAL_OBJ) $(DAL_OBJ) $(RTRPC_OBJ) $(RTK_OBJ) $(PHY_OBJ) $(CUST_PHY)

View file

@ -0,0 +1,96 @@
#
# Copyright (C) 2016 Realtek Semiconductor Corp.
#
# Makefile for SDK Rtnic Module
#
#
# include configuration file
#
ifeq ($(SDK_CONFIG), $(wildcard $(SDK_CONFIG)))
include $(SDK_CONFIG)
endif
#
# main
#
NTFY_OBJ :=
NIC_OBJ :=
ifeq ($(CONFIG_SDK_DRIVER_EXTC_NIC),y)
NIC_DIR := $(SDK_SYS_DIR)/drv/nic
NIC_KRN_DIR := $(SDK_SYS_DIR)/drv/nic_pci
NIC_OBJ += $(NIC_KRN_DIR)/nic_9310.o \
$(NIC_KRN_DIR)/nic_diag.o \
$(NIC_DIR)/nic_rx.o
endif
ifeq ($(CONFIG_SDK_DRIVER_L2NTFY),y)
NTFY_OBJ += \
$(NTFY_DIR)/l2ntfy_probe.o
ifneq ($(CONFIG_SDK_DRIVER_L2NTFY_R9310),)
NTFY_OBJ += \
$(NTFY_DIR)/l2ntfy_rtl9310.o
endif
ifneq ($(CONFIG_SDK_DRIVER_L2NTFY_R8390),)
NTFY_OBJ += \
$(NTFY_DIR)/l2ntfy_rtl8390.o
endif
ifneq ($(CONFIG_SDK_DRIVER_L2NTFY_R9300),)
NTFY_OBJ += \
$(NTFY_DIR)/l2ntfy_rtl9300.o
endif
ifeq ($(CONFIG_SDK_DRIVER_NIC_KERNEL_MODE),y)
NTFY_OBJ += \
$(NTFY_DIR)/l2ntfy.o
else
NTFY_OBJ += \
$(NTFY_DIR)/l2ntfy_usr.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_NIC),y)
NIC_OBJ += \
$(NIC_KRN_DIR)/nic_probe.o \
$(NIC_KRN_DIR)/nic_diag.o
ifeq ($(CONFIG_SDK_DRIVER_NIC_R9310),y)
NIC_OBJ += \
$(NIC_DIR)/nic_rtl9310.o
endif
ifeq ($(CONFIG_SDK_DRIVER_NIC_R9300),y)
NIC_OBJ += \
$(NIC_DIR)/nic_rtl9300.o
endif
ifeq ($(CONFIG_SDK_DRIVER_NIC_R8390),y)
NIC_OBJ += \
$(NIC_DIR)/nic_rtl8390.o
endif
ifeq ($(CONFIG_SDK_DRIVER_NIC_R8380),y)
NIC_OBJ += \
$(NIC_DIR)/nic_rtl8380.o
endif
ifeq ($(CONFIG_SDK_DRIVER_NIC_KERNEL_MODE),y)
ifneq ($(filter y,$(CONFIG_SDK_RTL8380) $(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
NIC_OBJ += \
$(NIC_DIR)/nic.o
endif
else ifeq ($(CONFIG_SDK_DRIVER_NIC_USER_MODE),y)
ifneq ($(filter y,$(CONFIG_SDK_RTL8380) $(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
NIC_OBJ += \
$(NIC_DIR)/nic_usr.o \
$(NIC_DIR)/nic_rx.o
endif
else ifeq ($(CONFIG_IN_UBOOT),y)
ifneq ($(filter y,$(CONFIG_SDK_RTL8380) $(CONFIG_SDK_RTL8390) $(CONFIG_SDK_RTL9300) $(CONFIG_SDK_RTL9310)),)
NIC_OBJ += \
$(NIC_DIR)/nic.o
endif
endif
endif
NIC_ALL_OBJ := $(NIC_OBJ) $(NTFY_OBJ)

View file

@ -0,0 +1,77 @@
#
# Copyright (C) 2009 Realtek Semiconductor Corp.
#
# Makefile for SDK Linux Rtusr User Library
#
RTRPC_SRC =
RTRPC_SRC += rtrpc_init.c
RTRPC_SRC += rtrpc_mapper.c
RTRPC_SRC += rtrpc_msg.c
RTRPC_SRC += rtrpc_l2.c
RTRPC_SRC += rtrpc_l3.c
RTRPC_SRC += rtrpc_port.c
RTRPC_SRC += rtrpc_vlan.c
RTRPC_SRC += rtrpc_bpe.c
RTRPC_SRC += rtrpc_stp.c
RTRPC_SRC += rtrpc_counter.c
RTRPC_SRC += rtrpc_time.c
RTRPC_SRC += rtrpc_trap.c
RTRPC_SRC += rtrpc_qos.c
RTRPC_SRC += rtrpc_trunk.c
RTRPC_SRC += rtrpc_debug.c
RTRPC_SRC += rtrpc_mirror.c
RTRPC_SRC += rtrpc_flowctrl.c
RTRPC_SRC += rtrpc_rate.c
RTRPC_SRC += rtrpc_switch.c
RTRPC_SRC += rtrpc_sys.c
RTRPC_SRC += rtrpc_nic.c
RTRPC_SRC += rtrpc_sds.c
RTRPC_SRC += rtrpc_diag.c
RTRPC_SRC += rtrpc_eee.c
RTRPC_SRC += rtrpc_sec.c
RTRPC_SRC += rtrpc_led.c
RTRPC_SRC += rtrpc_acl.c
RTRPC_SRC += rtrpc_pie.c
RTRPC_SRC += rtrpc_private.c
RTRPC_SRC += rtrpc_mpls.c
RTRPC_SRC += rtrpc_oam.c
RTRPC_SRC += rtrpc_tunnel.c
RTRPC_SRC += rtrpc_vxlan.c
RTRPC_SRC += rtrpc_openflow.c
RTRPC_SRC += rtrpc_mcast.c
RTRPC_SRC += rtrpc_ipmcast.c
RTRPC_SRC += rtrpc_stack.c
RTRPC_SRC += rtrpc_serdes.c
RTRPC_SRC += rtrpc_hwp.c
RTRPC_SRC += rtrpc_util.c
ifeq ($(CONFIG_SDK_DRIVER_L2NTFY), y)
RTRPC_SRC += rtrpc_l2_ntfy.c
endif
ifeq ($(CONFIG_SDK_UART1), y)
RTRPC_SRC += rtrpc_uart.c
endif
ifeq ($(CONFIG_SDK_RTL8380), y)
ifeq ($(CONFIG_SDK_APP_DIAG_EXT), y)
RTRPC_SRC += rtrpc_ext_8380.c
INCLUDE += -I$(MODELDIR)
endif
endif
ifeq ($(CONFIG_SDK_RTL9300), y)
ifeq ($(CONFIG_SDK_APP_DIAG_EXT), y)
RTRPC_SRC += rtrpc_ext_9300.c
INCLUDE += -I$(MODELDIR)
endif
endif
ifeq ($(CONFIG_SDK_RTL9310), y)
ifeq ($(CONFIG_SDK_APP_DIAG_EXT), y)
RTRPC_SRC += rtrpc_ext_9310.c
INCLUDE += -I$(MODELDIR)
endif
endif

View file

@ -0,0 +1,28 @@
#
# Copyright (C) 2019 Realtek Semiconductor Corp.
#
# Makefile for SDK - arch-B lib
#
SDK_TOP_DIR := ../../..
#
# include makefile
#
include $(SDK_TOP_DIR)/sdk/build/Makefile.rtcore
include $(SDK_TOP_DIR)/sdk/build/Makefile.rtk
include $(SDK_TOP_DIR)/sdk/build/Makefile.phy
include $(SDK_TOP_DIR)/sdk/build/Makefile.diag
include $(SDK_TOP_DIR)/sdk/build/Makefile.rtnic
#
# object
#
RTK_ALL_OBJ := $(addprefix sdk/src/,$(RTK_ALL_OBJ))
PHY_OBJ := $(addprefix sdk/src/,$(PHY_OBJ))
arch_B_lib := $(RTCORE_OBJ) $(RTK_ALL_OBJ) $(PHY_OBJ) $(NIC_ALL_OBJ) $(DIAG_OBJ)

View file

@ -0,0 +1,60 @@
#
# Copyright (C) 2015 Realtek Semiconductor Corp.
#
# Makefile for SDK U-Boot Module
#
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).o
# CPPFLAGS += -I$(TOPDIR)/board/Realtek/switch -I$(TOPDIR)/board/Realtek/include
AFLAGS += -I$(TOPDIR)/board/Realtek/switch -I$(TOPDIR)/board/Realtek/include
ifeq ($(CONFIG_SDK_PHY_CUST2),y)
#AFLAGS +=
endif
ifeq ($(CONFIG_SDK_PHY_CUST3),y)
#AFLAGS +=
endif
ifeq ($(CONFIG_SDK_PHY_CUST4),y)
#AFLAGS +=
endif
ifeq ($(CONFIG_SDK_PHY_CUST5),y)
#AFLAGS +=
endif
COBJS := $(BOARD).o board_cmd.o
ifdef CONFIG_CMD_DRAM_TEST
COBJS += memctl_dram.o
endif
ifdef CONFIG_CMD_FLASH_TEST
COBJS += memctl_flash.o
endif
include $(TOPDIR)/board/Realtek/switch/sdk/build/Makefile.uboot.sdk
SOBJS :=
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
SOBJS := $(addprefix $(obj),$(SOBJS))
all: $(subdir) $(LIB)
$(LIB): $(OBJS) $(SOBJS)
$(call cmd_link_o_target, $(OBJS) $(SOBJS))
#########################################################################
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
sinclude $(obj).depend
#########################################################################

View file

@ -0,0 +1,351 @@
#
# Copyright (C) 2015 Realtek Semiconductor Corp.
#
# Makefile for SDK U-Boot Module (SDK-3 usage)
#
SWITCH_DIR = ../switch
SDK_DIR = $(SWITCH_DIR)/sdk
COBJS += $(SDK_DIR)/system/uboot/uboot_init.o
ifeq ($(CONFIG_TURNKEY_SYSINFO),y)
COBJS += $(SDK_DIR)/system/uboot/cmd/cmd_sysinfo.o
endif
ifeq ($(CONFIG_UBOOT_SDK_SUPPORT),y)
COBJS += $(SDK_DIR)/system/uboot/cmd/cmd_upgrade.o
COBJS += $(SDK_DIR)/system/uboot/cmd/cmd_partition.o
COBJS += $(SDK_DIR)/system/uboot/cmd/uboot_cmd.o
COBJS += $(SDK_DIR)/system/uboot/cmd/uboot_func.o
COBJS += $(SDK_DIR)/system/common/rtcore/rtcore_init.o
COBJS += $(SDK_DIR)/system/hwp/hwp_init.o
COBJS += $(SDK_DIR)/system/hwp/hwp.o
COBJS += $(SDK_DIR)/system/hwp/hwp_probe.o
COBJS += $(SDK_DIR)/system/hwp/profile_list.o
COBJS += $(SDK_DIR)/system/ioal/ioal_init.o
COBJS += $(SDK_DIR)/system/ioal/ioal_param.o
COBJS += $(SDK_DIR)/system/ioal/ioal_log.o
COBJS += $(SDK_DIR)/system/ioal/mem32.o
COBJS += $(SDK_DIR)/system/ioal/phy_reset.o
COBJS += $(SDK_DIR)/system/osal/uboot/time.o
COBJS += $(SDK_DIR)/system/osal/uboot/lib.o
COBJS += $(SDK_DIR)/system/osal/uboot/memory.o
COBJS += $(SDK_DIR)/system/osal/uboot/sem.o
COBJS += $(SDK_DIR)/system/osal/uboot/spl.o
COBJS += $(SDK_DIR)/system/osal/uboot/cache.o
COBJS += $(SDK_DIR)/system/osal/uboot/thread.o
COBJS += $(SDK_DIR)/system/drv/swcore/swcore.o
COBJS += $(SDK_DIR)/system/drv/swcore/chip_probe.o
ifeq ($(CONFIG_SDK_DRIVER_NIC),y)
COBJS += $(SDK_DIR)/system/drv/nic/nic_probe.o
COBJS += $(SDK_DIR)/system/drv/nic/nic.o
COBJS += $(SDK_DIR)/system/uboot/rtnic/uboot_rtnic_drv.o
endif
ifeq ($(CONFIG_SDK_RTL8231),y)
COBJS += $(SDK_DIR)/system/drv/gpio/ext_gpio.o
COBJS += $(SDK_DIR)/system/drv/rtl8231/rtl8231_probe.o
COBJS += $(SDK_DIR)/system/drv/rtl8231/rtl8231.o
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
COBJS += $(SDK_DIR)/system/drv/gpio/gpio.o
COBJS += $(SDK_DIR)/system/drv/gpio/generalCtrl_gpio.o
COBJS += $(SDK_DIR)/system/drv/gpio/gpio_probe.o
endif
ifeq ($(CONFIG_SDK_DRIVER_SPI),y)
COBJS += $(SDK_DIR)/system/drv/spi/spi.o
ifeq ($(CONFIG_SDK_SPI_DEV_1),y)
COBJS += $(SDK_DIR)/system/drv/spi/spi_dev1.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_2),y)
COBJS += $(SDK_DIR)/system/drv/spi/spi_dev2.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_3),y)
COBJS += $(SDK_DIR)/system/drv/spi/spi_dev3.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_4),y)
COBJS += $(SDK_DIR)/system/drv/spi/spi_dev4.o
endif
ifeq ($(CONFIG_SDK_SPI_DEV_5),y)
COBJS += $(SDK_DIR)/system/drv/spi/spi_dev5.o
COBJS += $(SDK_DIR)/system/drv/spi/spi_dev3.o
endif
endif
ifeq ($(CONFIG_SDK_DRIVER_I2C),y)
COBJS += $(SDK_DIR)/system/drv/i2c/i2c.o
COBJS += $(SDK_DIR)/system/drv/i2c/i2c_probe.o
COBJS += $(SDK_DIR)/system/drv/i2c/i2c_software_drv.o
endif
ifeq ($(CONFIG_SDK_TC_DRV),y)
COBJS += $(SDK_DIR)/system/drv/tc/tc_probe.o
COBJS += $(SDK_DIR)/system/drv/tc/tc.o
COBJS += $(SDK_DIR)/system/drv/tc/tc_common.o
ifeq ($(CONFIG_SDK_TC_TC1_TIME),y)
COBJS += $(SDK_DIR)/system/common/util/rt_util_time.o
endif
endif
COBJS += $(SDK_DIR)/system/common/rt_chip.o
COBJS += $(SDK_DIR)/system/common/util/rt_util_system.o
COBJS += $(SDK_DIR)/src/common/util/rt_util.o
COBJS += $(SDK_DIR)/src/common/util/rt_bitop.o
COBJS += $(SDK_DIR)/src/hal/chipdef/chipdef.o
COBJS += $(SDK_DIR)/src/hal/chipdef/driver.o
COBJS += $(SDK_DIR)/src/hal/common/halctrl.o
COBJS += $(SDK_DIR)/src/hal/common/miim.o
COBJS += $(SDK_DIR)/src/hal/mac/reg.o
COBJS += $(SDK_DIR)/src/hal/mac/miim_common_drv.o
COBJS += $(SDK_DIR)/src/hal/mac/mac_probe.o
COBJS += $(SDK_DIR)/src/hal/mac/drv/drv.o
COBJS += $(SDK_DIR)/src/hal/mac/mem.o
COBJS += $(SDK_DIR)/src/hal/mac/serdes.o
ifneq ($(filter y,$(CONFIG_SDK_RTL8295) $(CONFIG_SDK_RTL8295R) $(CONFIG_SDK_RTL8214QF)),)
COBJS += $(SDK_DIR)/src/hal/mac/rtl8295.o
endif
COBJS += $(SDK_DIR)/src/hal/phy/phy_construct.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_probe.o
COBJS += $(SDK_DIR)/src/hal/phy/identify.o
COBJS += $(SDK_DIR)/src/dal/dal_construct.o
COBJS += $(SDK_DIR)/src/dal/dal_mgmt.o
COBJS += $(SDK_DIR)/src/dal/dal_phy.o
COBJS += $(SDK_DIR)/src/dal/dal_common.o
COBJS += $(SDK_DIR)/src/rtk/init.o
COBJS += $(SDK_DIR)/src/rtk/port.o
COBJS += $(SDK_DIR)/src/rtk/phy.o
COBJS += $(SDK_DIR)/src/rtk/l2.o
COBJS += $(SDK_DIR)/src/rtk/trunk.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_common.o
ifeq ($(CONFIG_SDK_RTL8208D),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8208.o
else ifeq ($(CONFIG_SDK_RTL8208G),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8208.o
else ifeq ($(CONFIG_SDK_RTL8208L),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8208.o
endif
ifeq ($(CONFIG_SDK_RTL8212B),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8214fb.o
else ifeq ($(CONFIG_SDK_RTL8214B),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8214fb.o
else ifeq ($(CONFIG_SDK_RTL8214FB),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8214fb.o
endif
ifeq ($(CONFIG_SDK_RTL8218B),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218b.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218b_patch.o
else ifeq ($(CONFIG_SDK_RTL8218FB),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218b.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218b_patch.o
else ifeq ($(CONFIG_SDK_RTL8214FC),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218b.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218b_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8218D),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218d.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218d_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8218E),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218e.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8218e_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8226),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8226.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL826X) $(CONFIG_SDK_RTL826XI) $(CONFIG_SDK_RTL825X) $(CONFIG_SDK_RTL825XI) $(CONFIG_SDK_RTL825XL) $(CONFIG_SDK_RTL8224)),)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl826x.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl826x_patch.o
endif
ifeq ($(CONFIG_SDK_RTL826XB),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl826xb.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl826xb_patch.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8226) $(CONFIG_SDK_RTL8284)),)
COBJS += $(SDK_DIR)/src/hal/phy/nic_rtl8226/nic_rtl8226.o
COBJS += $(SDK_DIR)/src/hal/phy/nic_rtl8226/nic_rtl8226b.o
COBJS += $(SDK_DIR)/src/hal/phy/nic_rtl8226/nic_rtl8226_init.o
COBJS += $(SDK_DIR)/src/hal/phy/nic_rtl8226/nic_rtl8226b_init.o
COBJS += $(SDK_DIR)/src/hal/phy/nic_rtl8226/nic_rtl8226_port.o
endif
ifeq ($(CONFIG_SDK_RTL8214C),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8214c.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8214c_patch.o
endif
ifeq ($(CONFIG_SDK_RTL8224),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8224.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8224_patch.o
endif
ifneq ($(filter y,$(CONFIG_SDK_RTL8295R) $(CONFIG_SDK_RTL8214QF)),)
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8295.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8295_patch.o
endif
ifeq ($(CONFIG_SDK_PHY_CUST2),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_cust2.o
endif
ifeq ($(CONFIG_SDK_PHY_CUST3),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_cust3.o
endif
ifeq ($(CONFIG_SDK_PHY_CUST4),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_cust4.o
endif
ifeq ($(CONFIG_SDK_PHY_CUST5),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_cust5.o
endif
ifeq ($(CONFIG_SDK_EXPERIMENTAL_RTL8211FS),y)
COBJS += $(SDK_DIR)/src/hal/phy/phy_experimental_rtl8211fs.o
endif
ifeq ($(SWBOARD),rtl9310)
COBJS += $(SDK_DIR)/src/dal/mango/dal_mango_mapper.o
COBJS += $(SDK_DIR)/src/hal/chipdef/mango/chip_rtl9310.o
COBJS += $(SDK_DIR)/src/hal/chipdef/mango/rtk_mango_regField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/mango/rtk_mango_reg_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/mango/rtk_mango_tableField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/mango/rtk_mango_table_list.o
COBJS += $(SDK_DIR)/src/dal/mango/dal_mango_construct.o
COBJS += $(SDK_DIR)/src/dal/mango/dal_mango_sds.o
COBJS += $(SDK_DIR)/src/dal/mango/dal_mango_port.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl9310.o
COBJS += $(SDK_DIR)/src/hal/mac/drv/drv_rtl9310.o
COBJS += $(SDK_DIR)/src/hal/mac/led/led_rtl9310.o
ifeq ($(CONFIG_SDK_DRIVER_NIC_R9310),y)
COBJS += $(SDK_DIR)/system/drv/nic/nic_rtl9310.o
endif
ifeq ($(CONFIG_SDK_RTL8231),y)
COBJS += $(SDK_DIR)/system/drv/rtl8231/rtl8231_rtl9310.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9310),)
COBJS += $(SDK_DIR)/system/drv/i2c/i2c_rtl9310.o
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
COBJS += $(SDK_DIR)/system/drv/gpio/gpio_common.o
endif
endif
ifeq ($(SWBOARD),rtl9300)
ifeq ($(CONFIG_SDK_DRIVER_NIC_R9300),y)
COBJS += $(SDK_DIR)/system/drv/nic/nic_rtl9300.o
endif
ifeq ($(CONFIG_SDK_RTL8231),y)
COBJS += $(SDK_DIR)/system/drv/rtl8231/rtl8231_rtl9300.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R9300),)
COBJS += $(SDK_DIR)/system/drv/i2c/i2c_rtl9300.o
endif
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl9300.o
COBJS += $(SDK_DIR)/src/hal/mac/drv/drv_rtl9300.o
COBJS += $(SDK_DIR)/src/hal/mac/led/led_rtl9300.o
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
COBJS += $(SDK_DIR)/system/drv/gpio/gpio_rtl9300.o
endif
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_mapper.o
COBJS += $(SDK_DIR)/src/hal/chipdef/longan/chip_rtl9300.o
COBJS += $(SDK_DIR)/src/hal/chipdef/longan/rtk_longan_regField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/longan/rtk_longan_reg_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/longan/rtk_longan_tableField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/longan/rtk_longan_table_list.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_port.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_l2.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_flowctrl.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_stack.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_trunk.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_eee.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_sds.o
COBJS += $(SDK_DIR)/src/dal/longan/dal_longan_construct.o
endif
ifeq ($(SWBOARD),rtl8380)
ifeq ($(CONFIG_SDK_DRIVER_NIC_R8380),y)
COBJS += $(SDK_DIR)/system/drv/nic/nic_rtl8380.o
endif
ifeq ($(CONFIG_SDK_RTL8231),y)
COBJS += $(SDK_DIR)/system/drv/rtl8231/rtl8231_rtl8380.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8380),)
COBJS += $(SDK_DIR)/system/drv/i2c/i2c_rtl8380.o
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
COBJS += $(SDK_DIR)/system/drv/gpio/gpio_rtl8380.o
endif
COBJS += $(SDK_DIR)/src/dal/maple/dal_maple_construct.o
COBJS += $(SDK_DIR)/src/dal/maple/dal_maple_mapper.o
COBJS += $(SDK_DIR)/src/hal/chipdef/maple/chip_rtl8380.o
COBJS += $(SDK_DIR)/src/hal/chipdef/maple/rtk_maple_regField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/maple/rtk_maple_reg_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/maple/rtk_maple_tableField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/maple/rtk_maple_table_list.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8380.o
COBJS += $(SDK_DIR)/src/hal/mac/led/led_rtl8380.o
COBJS += $(SDK_DIR)/src/hal/mac/drv/drv_rtl8380.o
COBJS += $(SDK_DIR)/src/dal/maple/dal_maple_port.o
# COBJS += $(SDK_DIR)/src/dal/maple/dal_maple_l2.o
COBJS += $(SDK_DIR)/src/dal/maple/dal_maple_eee.o
endif
ifeq ($(SWBOARD),rtl8390)
ifeq ($(CONFIG_SDK_DRIVER_NIC_R8390),y)
COBJS += $(SDK_DIR)/system/drv/nic/nic_rtl8390.o
endif
ifeq ($(CONFIG_SDK_RTL8231),y)
COBJS += $(SDK_DIR)/system/drv/rtl8231/rtl8231_rtl8390.o
endif
ifneq ($(CONFIG_SDK_DRIVER_I2C_R8390),)
COBJS += $(SDK_DIR)/system/drv/i2c/i2c_rtl8390.o
endif
ifeq ($(CONFIG_SDK_DRIVER_GPIO),y)
COBJS += $(SDK_DIR)/system/drv/gpio/gpio_rtl8390.o
endif
COBJS += $(SDK_DIR)/src/dal/cypress/dal_cypress_construct.o
COBJS += $(SDK_DIR)/src/dal/cypress/dal_cypress_mapper.o
COBJS += $(SDK_DIR)/src/hal/chipdef/cypress/chip_rtl8390.o
COBJS += $(SDK_DIR)/src/hal/chipdef/cypress/rtk_cypress_regField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/cypress/rtk_cypress_reg_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/cypress/rtk_cypress_tableField_list.o
COBJS += $(SDK_DIR)/src/hal/chipdef/cypress/rtk_cypress_table_list.o
COBJS += $(SDK_DIR)/src/hal/phy/phy_rtl8390.o
COBJS += $(SDK_DIR)/src/hal/mac/led/led_rtl8390.o
COBJS += $(SDK_DIR)/src/hal/mac/drv/drv_rtl8390.o
COBJS += $(SDK_DIR)/src/dal/cypress/dal_cypress_port.o
# COBJS += $(SDK_DIR)/src/dal/cypress/dal_cypress_l2.o
COBJS += $(SDK_DIR)/src/dal/cypress/dal_cypress_eee.o
endif
endif

View file

@ -0,0 +1,27 @@
#
# For Building Linux Kernel Module
#
CFLAGS += $(EXTRA_CFLAGS)
ifneq ($(KERNELRELEASE),)
obj-m := $(LKM_TARGET).o
$(LKM_TARGET)-objs := $(LKM_ALL_OBJ)
else
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNEL_PATH) M=$(PWD) "CC=$(CC)" "LD=$(LD)" "AR=$(AR)" "CFLAGS=$(CFLAGS)" "LDFLAGS=$(LDFLAGS)" modules
endif
clean:
@find \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' -o -name '.depend' -o -name '*.o.cmd' \
-o -name 'Module.symvers' -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' -o -name 'modules.order' \) \
-type f -print | xargs rm -rf
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif

View file

@ -0,0 +1,37 @@
# Copyright (C) 2015 Realtek Semiconductor Corp.
#
# Makefile for including all system configurations
#
ROOT_CONFIG_FILE = $(ROOT_PATH)/$(KERNEL_DIR)/$(OS_TYPE)/.config
ifeq ($(ROOT_CONFIG_FILE), $(wildcard $(ROOT_CONFIG_FILE)))
include $(ROOT_CONFIG_FILE)
endif
ARCH_CONFIG_FILE = $(ROOT_PATH)/$(KERNEL_DIR)/$(OS_TYPE)/config.arch
ifeq ($(ARCH_CONFIG_FILE), $(wildcard $(ARCH_CONFIG_FILE)))
include $(ARCH_CONFIG_FILE)
endif
SDK_INCLUDE = $(ROOT_PATH)/$(SDK_DIR)/include
DRV_INCLUDE = $(ROOT_PATH)/$(SDK_DIR)/system/linux
SYS_INCLUDE = $(ROOT_PATH)/$(SDK_DIR)/system/include
EXTRA_CFLAGS += -nostdinc -isystem /opt/toolchain/msdk-4.4.7-mips-EB-2.6.19-u0.9.33-m32t-150429-cn2sd6-150528/bin/../lib/gcc/mips-linux-uclibc/4.4.7/include
EXTRA_CFLAGS += -Iinclude/asm-mips/mach-realtek/rtl83xx-universal-bsp
EXTRA_CFLAGS += -D__linux__
EXTRA_CFLAGS += -Os
EXTRA_CFLAGS += -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 -Wa,-mips32 -Wa,--trap
EXTRA_CFLAGS += -Wall -Werror -Wstrict-prototypes -Wundef
EXTRA_CFLAGS += -Wno-trigraphs -fno-strict-aliasing -fno-common
EXTRA_CFLAGS += -mabi=32 -G 0 -fno-pic -pipe -msoft-float -ffreestanding -mips32
EXTRA_CFLAGS += -fno-builtin
EXTRA_CFLAGS += -Iinclude/asm-mips/mach-generic -fomit-frame-pointer -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
EXTRA_CFLAGS += -mlong-calls
EXTRA_CFLAGS += -I$(SDK_INCLUDE) -I$(SYS_INCLUDE)
#EXTRA_CFLAGS += -include include/linux/autoconf.h
#EXTRA_CFLAGS += -Iinclude

View file

@ -0,0 +1,186 @@
#
# Automatically generated make config: don't edit
#
#
# Chip Support
#
#
# Select your target MAC chip(s)
#
# CONFIG_SDK_RTL9310 is not set
CONFIG_SDK_RTL9300=y
# CONFIG_SDK_RTL8390 is not set
# CONFIG_SDK_RTL8380 is not set
#
# Select your target PHYs chip
#
# CONFIG_SDK_RTL8208D is not set
# CONFIG_SDK_RTL8208G is not set
# CONFIG_SDK_RTL8208L is not set
# CONFIG_SDK_RTL8212B is not set
# CONFIG_SDK_RTL8214B is not set
# CONFIG_SDK_RTL8214FB is not set
# CONFIG_SDK_RTL8214FC is not set
# CONFIG_SDK_RTL8214C is not set
CONFIG_SDK_RTL8214QF=y
# CONFIG_SDK_RTL8218B is not set
CONFIG_SDK_RTL8218D=y
CONFIG_SDK_RTL8218E=y
# CONFIG_SDK_RTL8218FB is not set
# CONFIG_SDK_RTL8224QF is not set
CONFIG_SDK_RTL8226=y
CONFIG_SDK_RTL8295R=y
# CONFIG_SDK_RTL826X is not set
# CONFIG_SDK_RTL826XI is not set
# CONFIG_SDK_RTL825X is not set
# CONFIG_SDK_RTL825XI is not set
# CONFIG_SDK_RTL825XL is not set
CONFIG_SDK_RTL8224=y
CONFIG_SDK_RTL826XB=y
#
# Select your target Peripheral chip
#
CONFIG_SDK_RTL8231=y
#
# Select customer defined PHYs chip
#
# CONFIG_SDK_PHY_CUST1 is not set
# CONFIG_SDK_PHY_CUST2 is not set
# CONFIG_SDK_PHY_CUST3 is not set
# CONFIG_SDK_PHY_CUST4 is not set
# CONFIG_SDK_PHY_CUST5 is not set
CONFIG_SDK_EXPERIMENTAL_RTL8211FS=y
#
# CPU
#
# CONFIG_SDK_EXTERNAL_CPU is not set
# CONFIG_SDK_ENDIAN_LITTLE is not set
#
# Operating System
#
CONFIG_SDK_KERNEL_LINUX=y
# CONFIG_SDK_OS_KERNEL_OTHER is not set
# CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE is not set
CONFIG_SDK_KERNEL_LINUX_USER_MODE=y
CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE=y
#
# SDK Driver
#
#
# Rtcore Driver support
#
CONFIG_SDK_DRIVER_RTCORE=m
CONFIG_SDK_DRIVER_RTCORE_IN_LINUX_KERNEL=y
CONFIG_SDK_DRIVER_NIC=y
# CONFIG_SDK_DRIVER_EXTC_NIC is not set
# CONFIG_SDK_DRIVER_EXTC_PCI is not set
CONFIG_SDK_DRIVER_GPIO=y
CONFIG_SDK_DRIVER_SPI=y
CONFIG_SDK_DRIVER_I2C=y
CONFIG_SDK_TC_DRV=y
CONFIG_SDK_DRIVER_WATCHDOG=y
CONFIG_SDK_TC_TC1_TIME=y
CONFIG_SDK_UART1=y
CONFIG_SDK_BSP_USBHCD=y
# CONFIG_SDK_DRIVER_NIC_KERNEL_MODE is not set
CONFIG_SDK_DRIVER_NIC_USER_MODE=y
# CONFIG_SDK_DRIVER_NIC_R9310 is not set
CONFIG_SDK_DRIVER_NIC_R9300=y
# CONFIG_SDK_DRIVER_NIC_R8390 is not set
# CONFIG_SDK_DRIVER_NIC_R8380 is not set
CONFIG_SDK_DRIVER_L2NTFY=y
# CONFIG_SDK_DRIVER_L2NTFY_R9310 is not set
CONFIG_SDK_DRIVER_L2NTFY_R9300=y
# CONFIG_SDK_DRIVER_L2NTFY_R8390 is not set
# CONFIG_SDK_DRIVER_I2C_R9310 is not set
CONFIG_SDK_DRIVER_I2C_R9300=y
# CONFIG_SDK_DRIVER_I2C_R8390 is not set
# CONFIG_SDK_DRIVER_I2C_R8380 is not set
#
# Rtk Driver / RTK API support
#
CONFIG_SDK_DRIVER_RTK=y
# CONFIG_SDK_DRIVER_RTK_LEGACY_API is not set
CONFIG_SDK_DRIVER_RTK_CUSTOMER=y
CONFIG_SDK_DRIVER_RTK=y
CONFIG_SDK_DRIVER_RTK_CUSTOMER=y
# CONFIG_SDK_DRIVER_MX is not set
CONFIG_SDK_DRIVER_COMPILE=m
#
# SDK Application
#
CONFIG_SDK_APP_DIAG=y
CONFIG_SDK_APP_DIAG_DIR_DIAG_V2=y
# CONFIG_SDK_APP_DIAG_EXT is not set
# CONFIG_SDK_SQUT_CMD_OPT is not set
CONFIG_SDK_APP_COMPILE=y
#
# SDK Debug
#
CONFIG_SDK_DEBUG=y
CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL=y
# CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL_MASK is not set
CONFIG_SDK_DEBUG_LOG_LEVEL=3
CONFIG_SDK_DEBUG_LOG_MOD_MASK=FFFFFFFFFFFFFFFF
# CONFIG_SDK_DUMP_REG_WITH_NAME is not set
# CONFIG_SDK_DUMP_TABLE_WITH_NAME is not set
#
# BSP Option
#
CONFIG_SDK_BSP_FLASH=y
CONFIG_FLASH_LAYOUT_TYPE5=y
CONFIG_TURNKEY_SYSINFO=y
CONFIG_DUAL_IMAGE=y
CONFIG_ENV_MTD_INDEX=1
CONFIG_ENV2_MTD_INDEX=2
CONFIG_BDINFO_MTD_INDEX=3
CONFIG_SDK_BSP_MTD=y
CONFIG_SDK_BSP_MTD_SPI=y
# CONFIG_SDK_BSP_MTD_NOR is not set
CONFIG_SDK_BSP_MTD_SPIM=y
CONFIG_SDK_BSP_MTD_NORSF_G3=y
CONFIG_SDK_BSP_MTD_COMMON=y
# CONFIG_SDK_BSP_MTD_RTK_SPI_NAND is not set
CONFIG_SDK_BSP_MTD_SPI_NAND_G3=y
CONFIG_SDK_BSP_MTD_ECC_G2=y
CONFIG_SDK_SPI_DEV_NONE=y
# CONFIG_SDK_SPI_DEV_1 is not set
# CONFIG_SDK_SPI_DEV_2 is not set
# CONFIG_SDK_SPI_DEV_3 is not set
# CONFIG_SDK_SPI_DEV_4 is not set
# CONFIG_SDK_SPI_DEV_5 is not set
CONFIG_SDK_BSP_SPI_NOR_BOOT=y
# CONFIG_SDK_BSP_SPI_NAND_BOOT is not set
#
# Misc Option
#
# CONFIG_SDK_EXPERIMENTAL is not set
# CONFIG_SDK_FPGA_PLATFORM is not set
# CONFIG_SDK_DRIVER_TEST is not set
# CONFIG_SDK_MODEL_MODE is not set
# CONFIG_SDK_LINKED_KMOD is not set
# CONFIG_TRUNK_FAILOVER_HANDLING is not set
# CONFIG_SDK_RX_THREAD is not set
CONFIG_SDK_LINKMON_POLLING_MODE=y
# CONFIG_SDK_LINKMON_ISR_MODE is not set
# CONFIG_SDK_LINKMON_MIXED_MODE is not set
# CONFIG_RISE is not set
# CONFIG_SDK_HW_PROFILE_PROBE_GPIO is not set
CONFIG_SDK_HW_PROFILE_PROBE_UBOOT_ENV=y
CONFIG_SDK_OS_VERSION="Linux 3.18.24"
CONFIG_SDK_COMPILER_VERSION="GCC 4.8.5"
CONFIG_SDK_LIBC_VERSION="uClibc-0.9.33.2 with NPTL"

View file

@ -0,0 +1,176 @@
#
# Automatically generated make config: don't edit
#
#
# Chip Support
#
#
# Select your target MAC chip(s)
#
# CONFIG_SDK_RTL9310 is not set
CONFIG_SDK_RTL9300=y
# CONFIG_SDK_RTL8390 is not set
# CONFIG_SDK_RTL8380 is not set
#
# Select your target PHYs chip
#
# CONFIG_SDK_RTL8208D is not set
# CONFIG_SDK_RTL8208G is not set
# CONFIG_SDK_RTL8208L is not set
# CONFIG_SDK_RTL8212B is not set
# CONFIG_SDK_RTL8214B is not set
# CONFIG_SDK_RTL8214FB is not set
CONFIG_SDK_RTL8214QF=y
# CONFIG_SDK_RTL8218B is not set
CONFIG_SDK_RTL8218D=y
CONFIG_SDK_RTL8218E=y
# CONFIG_SDK_RTL8218FB is not set
# CONFIG_SDK_RTL8224QF is not set
CONFIG_SDK_RTL8226=y
CONFIG_SDK_RTL8295R=y
# CONFIG_SDK_RTL826X is not set
# CONFIG_SDK_RTL826XI is not set
# CONFIG_SDK_RTL825X is not set
# CONFIG_SDK_RTL825XI is not set
# CONFIG_SDK_RTL825XL is not set
CONFIG_SDK_RTL8224=y
CONFIG_SDK_RTL826XB=y
CONFIG_SDK_EXPERIMENTAL_RTL8211FS=y
#
# Select your target Peripheral chip
#
CONFIG_SDK_RTL8231=y
#
# Select customer defined PHYs chip
#
# CONFIG_SDK_PHY_CUST1 is not set
# CONFIG_SDK_PHY_CUST2 is not set
# CONFIG_SDK_PHY_CUST3 is not set
# CONFIG_SDK_PHY_CUST4 is not set
# CONFIG_SDK_PHY_CUST5 is not set
#
# CPU
#
# CONFIG_SDK_EXTERNAL_CPU is not set
CONFIG_SDK_ENDIAN_BIG=y
# CONFIG_SDK_ENDIAN_LITTLE is not set
#
# Operating System
#
CONFIG_SDK_KERNEL_LINUX=y
# CONFIG_SDK_OS_KERNEL_OTHER is not set
# CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE is not set
CONFIG_SDK_KERNEL_LINUX_USER_MODE=y
CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE=y
#
# SDK Driver
#
#
# Rtcore Driver support
#
CONFIG_SDK_DRIVER_RTCORE=m
CONFIG_SDK_DRIVER_RTCORE_IN_LINUX_KERNEL=y
CONFIG_SDK_DRIVER_NIC=y
CONFIG_SDK_DRIVER_GPIO=y
CONFIG_SDK_DRIVER_SPI=y
CONFIG_SDK_DRIVER_I2C=y
CONFIG_SDK_TC_DRV=y
CONFIG_SDK_DRIVER_WATCHDOG=y
CONFIG_SDK_TC_TC1_TIME=y
CONFIG_SDK_UART1=y
# CONFIG_SDK_DRIVER_NIC_KERNEL_MODE is not set
CONFIG_SDK_DRIVER_NIC_USER_MODE=y
# CONFIG_SDK_DRIVER_NIC_R9310 is not set
CONFIG_SDK_DRIVER_NIC_R9300=y
# CONFIG_SDK_DRIVER_NIC_R8390 is not set
# CONFIG_SDK_DRIVER_NIC_R8380 is not set
CONFIG_SDK_DRIVER_L2NTFY=y
# CONFIG_SDK_DRIVER_L2NTFY_R9310 is not set
CONFIG_SDK_DRIVER_L2NTFY_R9300=y
# CONFIG_SDK_DRIVER_L2NTFY_R8390 is not set
# CONFIG_SDK_DRIVER_I2C_R9310 is not set
CONFIG_SDK_DRIVER_I2C_R9300=y
# CONFIG_SDK_DRIVER_I2C_R8390 is not set
# CONFIG_SDK_DRIVER_I2C_R8380 is not set
#
# Rtk Driver / RTK API support
#
CONFIG_SDK_DRIVER_RTK=y
# CONFIG_SDK_DRIVER_RTK_LEGACY_API is not set
CONFIG_SDK_DRIVER_RTK_CUSTOMER=y
CONFIG_SDK_DRIVER_RTK=y
CONFIG_SDK_DRIVER_RTK_CUSTOMER=y
# CONFIG_SDK_DRIVER_MX is not set
CONFIG_SDK_DRIVER_COMPILE=m
#
# SDK Application
#
CONFIG_SDK_APP_DIAG=y
CONFIG_SDK_APP_DIAG_DIR_DIAG_V2=y
# CONFIG_SDK_APP_DIAG_EXT is not set
# CONFIG_SDK_SQUT_CMD_OPT is not set
CONFIG_SDK_APP_COMPILE=y
#
# SDK Debug
#
CONFIG_SDK_DEBUG=y
CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL=y
# CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL_MASK is not set
CONFIG_SDK_DEBUG_LOG_LEVEL=3
CONFIG_SDK_DEBUG_LOG_MOD_MASK=FFFFFFFFFFFFFFFF
# CONFIG_SDK_DUMP_REG_WITH_NAME is not set
# CONFIG_SDK_DUMP_TABLE_WITH_NAME is not set
#
# BSP Option
#
CONFIG_SDK_BSP_FLASH=y
CONFIG_FLASH_LAYOUT_TYPE5=y
CONFIG_TURNKEY_SYSINFO=y
CONFIG_DUAL_IMAGE=y
CONFIG_ENV_MTD_INDEX=1
CONFIG_ENV2_MTD_INDEX=2
CONFIG_BDINFO_MTD_INDEX=3
CONFIG_SDK_BSP_MTD=y
CONFIG_SDK_BSP_MTD_SPI=y
# CONFIG_SDK_BSP_MTD_NOR is not set
CONFIG_SDK_BSP_MTD_SPIM=y
CONFIG_SDK_BSP_MTD_NORSF_G3=y
CONFIG_SDK_BSP_MTD_COMMON=y
CONFIG_SDK_BSP_USBHCD=y
CONFIG_SDK_SPI_DEV_NONE=y
# CONFIG_SDK_SPI_DEV_1 is not set
# CONFIG_SDK_SPI_DEV_2 is not set
# CONFIG_SDK_SPI_DEV_3 is not set
# CONFIG_SDK_SPI_DEV_4 is not set
#
# Misc Option
#
# CONFIG_SDK_FPGA_PLATFORM is not set
# CONFIG_SDK_DRIVER_TEST is not set
# CONFIG_SDK_MODEL_MODE is not set
# CONFIG_SDK_LINKED_KMOD is not set
# CONFIG_TRUNK_FAILOVER_HANDLING is not set
# CONFIG_SDK_RX_THREAD is not set
CONFIG_SDK_LINKMON_POLLING_MODE=y
# CONFIG_SDK_LINKMON_ISR_MODE is not set
# CONFIG_SDK_LINKMON_MIXED_MODE is not set
# CONFIG_SDK_STACKING_PROTO is not set
# CONFIG_SDK_HW_PROFILE_PROBE_GPIO is not set
CONFIG_SDK_HW_PROFILE_PROBE_UBOOT_ENV=y
CONFIG_SDK_OS_VERSION="Linux 3.18.24"
CONFIG_SDK_COMPILER_VERSION="GCC 4.8.5"
CONFIG_SDK_LIBC_VERSION="uClibc-0.9.33.2 with NPTL"

View file

@ -0,0 +1,330 @@
#
# Format of this file: description<nl>variable<nl> helptext<nl>...<nl><nl>.
# If the question being documented is of type "choice", we list
# only the first occurring config variable. The help texts
# must not contain empty lines. No variable should occur twice; if it
# does, only the first occurrence will be used by Configure. The lines
# in a help text should be indented two positions. Lines starting with
# `#' are ignored. To be nice to menuconfig, limit your lines to 70
# characters. Use emacs' kfill.el to edit this file or you lose.
#
CONFIG_SDK_RTL9310
Realtek RTL9310 Switch SoC
CONFIG_SDK_RTL9300
Realtek RTL9300 Switch SoC
CONFIG_SDK_RTL8390
Realtek RTL8390 Switch SoC
CONFIG_SDK_RTL8380
Realtek RTL8380 Switch SoC
CONFIG_SDK_RTL8208
Realtek RTL8208/RTL8208D PHY SoC - 8 port 10/100 Fast Ethernet PHY
CONFIG_SDK_RTL8208D
Realtek RTL8208D PHY SoC - 8 port 10/100 Fast Ethernet PHY
CONFIG_SDK_RTL8208G
Realtek RTL8208G PHY SoC - 8 port 10/100 Fast Ethernet PHY
CONFIG_SDK_RTL8208L
Realtek RTL8208L PHY SoC - 8 port 10/100 Fast Ethernet PHY
CONFIG_SDK_RTL8218B
Realtek RTL8218B PHY SoC - 8 port 10/100/1000 Giga Ethernet PHY
CONFIG_SDK_RTL8218FB
Realtek RTL8218FB PHY SoC - 4 port 10/100/1000+ 4 port 10/100/1000 Combo Giga Ethernet PHY
CONFIG_SDK_RTL8212B
Realtek RTL8212B PHY SoC - 2 port 10/100/1000 Combo Giga Ethernet PHY
CONFIG_SDK_RTL8214B
Realtek RTL8214B PHY SoC - 4 port 10/100/1000 Combo Giga Ethernet PHY
CONFIG_SDK_RTL8214FB
Realtek RTL8214FB PHY SoC - 4 port 10/100/1000 Combo Giga Ethernet PHY,
pin-to-pin compatible with RTL8214F
CONFIG_SDK_RTL8214FC
Realtek RTL8214FC PHY SoC - 4 port 10/100/1000 Combo Giga Ethernet PHY,
CONFIG_SDK_RTL8214QF
Realtek RTL8214QF PHY SoC - 4 port Fiber Giga Ethernet PHY
CONFIG_SDK_RTL8218D
Realtek RTL8218D PHY SoC - 8 port 10/100/1000 Giga Ethernet PHY
CONFIG_SDK_RTL8218E
Realtek RTL8218E PHY SoC - 8 port 10/100/1000 Giga Ethernet PHY
CONFIG_SDK_RTL8224QF
Realtek RTL8224QF PHY SoC - 4 port 2.5G Fiber Ethernet PHY
CONFIG_SDK_RTL8226
Realtek RTL8226 and RTL8226B PHY SoC - 1 port 2.5G Ethernet PHY
CONFIG_SDK_RTL826X
Realtek RTL8261/8264 PHY SoC - 1/4 port 10G Ethernet PHY
CONFIG_SDK_RTL826XI
Realtek RTL8261I/8264I PHY SoC - 1/4 port 10G Ethernet PHY
CONFIG_SDK_RTL825X
Realtek RTL8251/8254 PHY SoC - 1/4 port 5G Ethernet PHY
CONFIG_SDK_RTL825XI
Realtek RTL8251I/8254I PHY SoC - 1/4 port 5G Ethernet PHY
CONFIG_SDK_RTL825XL
Realtek RTL8251L/8254L PHY SoC - 1/4 port 5G Ethernet PHY
CONFIG_SDK_RTL826XB
Realtek RTL8264B/8261B/8261N PHY - 1/4 port 10G Ethernet PHY
CONFIG_SDK_RTL8224
Realtek RTL8224 PHY SoC - 1/4 port 2.5G Ethernet PHY
CONFIG_SDK_RTL8295R
Realtek RTL8295R PHY SoC - 1 port Fiber 10 Giga Ethernet PHY
CONFIG_SDK_RTL8231
Realtek RTL8231 SoC - LED/GPIO chip
CONFIG_SDK_ENDIAN_LITTLE
SDK for Little Endian CPU
CONFIG_SDK_KERNEL_LINUX
SDK for Linux platform
CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE
Compile SDK component to become a loadable Linux module
CONFIG_SDK_DRIVER_COMPILE
Compile all drivers below RTK Layer as built-in or module
CONFIG_SDK_DRIVER_NIC
Select the option to compile the NIC driver
CONFIG_SDK_DRIVER_EXTC_NIC
Select the option to compile the NIC driver for External CPU
CONFIG_SDK_DRIVER_EXTC_PCI
Select the option to compile the PCI driver for External CPU
CONFIG_SDK_DRIVER_NIC_KERNEL_MODE
Select the NIC driver in kernel mode
CONFIG_SDK_DRIVER_NIC_USER_MODE
Select the NIC driver in user mode
CONFIG_SDK_DRIVER_NIC_R9310
Select the option to compile the 9310 NIC driver
CONFIG_SDK_DRIVER_NIC_R9300
Select the option to compile the 9300 NIC driver
CONFIG_SDK_DRIVER_NIC_R8390
Select the option to compile the 8390 NIC driver
CONFIG_SDK_DRIVER_NIC_R8380
Select the option to compile the 8380 NIC driver
CONFIG_SDK_DRIVER_L2NTFY
Select the option to compile the L2 notification driver
CONFIG_SDK_DRIVER_L2NTFY_R9310
Select the option to compile the 9310 L2 notification driver
CONFIG_SDK_DRIVER_L2NTFY_R9300
Select the option to compile the 9300 L2 notification driver
CONFIG_SDK_DRIVER_L2NTFY_R8390
Select the option to compile the 8390 L2 notification driver
CONFIG_SDK_DRIVER_RTCORE
Select the option to compile the feature code for SDK Kernel Core Driver
CONFIG_SDK_NIC_RX_CB_IN_ISR_CONTEXT
The packet RX user callback would execute in ISR context if selected.
Otherwise, it would execute in thread or Bottom Half ... etc.
CONFIG_SDK_DRIVER_RTK
Select the option to compile the feature code for RTK Kernel Driver or RTK User Library
CONFIG_SDK_DRIVER_RTK_CUSTOMER
Select the option to compile the customer RTK API code for RTK Kernel Driver or RTK User Library
CONFIG_SDK_DRIVER_TEST
Select the option to compile the internal testing code for SDK Kernel Driver
CONFIG_SDK_DRIVER_MX
SDK Linux Net Driver
CONFIG_SDK_DRIVER_RTDRV
SDK Linux User/Kernel Common Driver
CONFIG_SDK_DRIVER_RTNIC
SDK Linux Ethernet Driver
CONFIG_SDK_DEBUG
Enable or disable SDK debug messages. Reduce the code size when you do not select this
CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL
Type: log level of debug messages
CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL_MASK
Type: log level-mask of debug messages
CONFIG_SDK_DEBUG_LOG_LEVEL
default "3"
Designate the logging level of debug messages.
0: FATAL ERROR
1: MAJOR ERROR
2: MINOR ERROR
3: WARNING
4: EVENT
5: INFO
6: FUNC_ENTER
7: DEBUG
8: TRACE
CONFIG_SDK_DEBUG_LOG_LEVEL_MASK
default "0xF"
Assign a bitmask of debug levels
0xF : DEFAULT LEVEL MASK OF MESSAGES (WARNING)
0x0 : ALL MESSAGES OFF
0x1FF : ALL MESSAGES ON
CONFIG_SDK_DEBUG_LOG_MOD_MASK
default "0xFFFFFFFFFFFFFFFF"
Assign a bitmask of debug modules
0x0 : ALL MODULES OFF
0xFFFFFFFFFFFFFFFF: ALL MODULES ON
Please refer to the debug header file for other bit definition
CONFIG_SDK_APP_COMPILE
Compile SDK application code
CONFIG_SDK_APP_DIAG
Compile SDK Diag Shell
CONFIG_SDK_SQUT_CMD_OPT
Add additional command option for SDK QA Unit Test
CONFIG_RRCP_MASTER
Compile the RRCP function
CONFIG_SDK_DRIVER_GPIO
Select the option to enable GPIO driver support
CONFIG_SDK_BSP_FLASH
Enable the flash common setting
CONFIG_FLASH_BLOCK_SIZE
The flash block size definition
CONFIG_FLASH_SIZE_4MB
Select the flash size
CONFIG_FLASH_SIZE_8MB
Select the flash size
CONFIG_FLASH_SIZE_16MB
Select the flash size
CONFIG_DUAL_IMAGE
Enable the dual image support
CONFIG_FLASH_LAYOUT_TYPE1
Select the flash layout type 1
CONFIG_SDK_BSP_MTD
Enable the MTD driver
CONFIG_SDK_BSP_MTD_SPI
Enable the SPI flash driver
CONFIG_SDK_BSP_MTD_SPI_QUAD_IO
Select the SPI flash driver to QUAD IO type
CONFIG_SDK_BSP_MTD_NOR
Enable the NOR flash driver
CONFIG_SDK_FPGA_PLATFORM
Select the option to verify SDK on FPGA development platform
CONFIG_SDK_MODEL_MODE
Select the option to verify SDK on x86 development platform
CONFIG_SDK_LINKED_KMOD
Select the option to linked the SDK kernel mode and don't build from source again
CONFIG_TRUNK_FAILOVER_HANDLING
Select the option to enable the trunk failover handing mechanism
CONFIG_SDK_REG_DFLT_VAL
Select the option to include the register default value in strcuture
CONFIG_SDK_REG_FIELD_TYPE
Select the option to include the register field type in strcuture
CONFIG_SDK_RX_THREAD
Select the option to enable the NIC receive thread
CONFIG_SDK_LINKMON_POLLING_MODE
Select the option to enable the LinkMon thread by polling mode
CONFIG_SDK_LINKMON_ISR_MODE
Select the option to enable the LinkMon thread by interrupt mode
CONFIG_SDK_LINKMON_MIXED_MODE
Select the option to enable the LinkMon thread by polling and interrupt mixed mode
CONFIG_SDK_AUTO_COMBO_MEDIA_BY_GPIO
Detect the GPIO signal and auto configure media of combo port by software thread
CONFIG_SDK_WA_EEE_COMPATIBLE
Select the option to workaround the eee compatible issue in RTL8208D PHY
CONFIG_SDK_WA_RTL8231_RESET
Select the option to workaround the reset issue in RTL8231
CONFIG_SDK_WA_PKTBUF_WATCHDOG
Select the option to monitor packet buffer status and trigger packet buffer recovery procedure
CONFIG_SDK_WA_RTL833X_COMBO_LED
Select the option to workaround the combo port led display in MAC RTL833X chip.
CONFIG_SDK_UART1
Select the option to enable uart1 function.
CONFIG_SDK_PORT_VIEW_PHYSICAL_PORT
Select the RTK API port view option to physical port
CONFIG_SDK_HW_PROFILE_BRAND_RTK
Select the option to use Realtek demo board hardware profiles.
CONFIG_SDK_SPI_DEV_1
839x SPI master to 8380 slave
CONFIG_SDK_SPI_DEV_2
839x SPI, 839x GPIO, 838x GPIO to max slave
CONFIG_SDK_SPI_DEV_3
9300 SPI master to 9300 SPI slave
CONFIG_SDK_SPI_DEV_4
9300 SPI master to max slave (testing)
CONFIG_SDK_SPI_DEV_5
9300 SPI master to multiple 9300 SPI slave
CONFIG_SDK_EXPERIMENTAL
Select the option to show experimental functions in menu
CONFIG_SDK_EXPERIMENTAL_RTL8211FS
Experimental driver for Realtek RTL8211FS PHY

View file

View file

@ -0,0 +1,71 @@
############################################################################
SDK_AUTOCONG_H=sdk_autoconf.h
all:
clean:
$(MAKE) -C $(SDK_SCRIPTSDIR) clean
$(MAKE) -C $(SDK_SCRIPTSDIR)/lxdialog clean
@rm -f config.tk autoconf.h .config .config.old $(SDK_INC_COMMON)/$(SDK_AUTOCONG_H)
############################################################################
#
# The config stuff
#
ifeq ("x$(CONFIG_SHELL)","x")
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
endif
SDK_INC_COMMON := ../system/include/common
SDK_SCRIPTSDIR := scripts
config.tk: Makefile config.in $(SDK_SCRIPTSDIR)/header.tk $(SDK_SCRIPTSDIR)/tail.tk \
$(wildcard $(ROOTDIR)/prop/config.in)
$(MAKE) -C $(SDK_SCRIPTSDIR) tkparse
ARCH=m68knommu $(SDK_SCRIPTSDIR)/tkparse < config.in > config.tmp
@if [ -f /usr/local/bin/wish ]; then \
echo '#!'"/usr/local/bin/wish -f" > config.tk; \
else \
echo '#!'"/usr/bin/wish -f" > config.tk; \
fi
cat $(SDK_SCRIPTSDIR)/header.tk >> ./config.tk
cat config.tmp >> config.tk
rm -f config.tmp
echo "set defaults \"defconfig\"" >> config.tk
echo "set autoconf_file \"autoconf.h\"" >> config.tk
echo "set help_file \"Configure.help\"" >> config.tk
cat $(SDK_SCRIPTSDIR)/tail.tk >> config.tk
chmod 755 config.tk
xconfig: config.tk
@$(CONFIG_SHELL) -n config.in
wish -f config.tk
oldconfig:
@$(CONFIG_SHELL) -n config.in
@HELP_FILE=Configure.help \
AUTOCONF_FILE=autoconf.h \
$(CONFIG_SHELL) $(SDK_SCRIPTSDIR)/Configure -d config.in
config:
@$(CONFIG_SHELL) -n config.in
@HELP_FILE=Configure.help \
AUTOCONF_FILE=autoconf.h \
$(CONFIG_SHELL) $(SDK_SCRIPTSDIR)/Configure config.in
@cp autoconf.h $(SDK_INC_COMMON)/$(SDK_AUTOCONG_H)
menuconfig:
@$(CONFIG_SHELL) -n config.in
make -C $(SDK_SCRIPTSDIR)/lxdialog all
@HELP_FILE=Configure.help \
AUTOCONF_FILE=autoconf.h \
$(CONFIG_SHELL) $(SDK_SCRIPTSDIR)/Menuconfig config.in
@cp autoconf.h $(SDK_INC_COMMON)/$(SDK_AUTOCONG_H)
sdkconfig: menuconfig
############################################################################

View file

@ -0,0 +1,189 @@
/*
* Automatically generated C config: don't edit
*/
#define AUTOCONF_INCLUDED
/*
* Chip Support
*/
/*
* Select your target MAC chip(s)
*/
#undef CONFIG_SDK_RTL9310
#define CONFIG_SDK_RTL9300 1
#undef CONFIG_SDK_RTL8390
#undef CONFIG_SDK_RTL8380
/*
* Select your target PHYs chip
*/
#undef CONFIG_SDK_RTL8208D
#undef CONFIG_SDK_RTL8208G
#undef CONFIG_SDK_RTL8208L
#undef CONFIG_SDK_RTL8212B
#undef CONFIG_SDK_RTL8214B
#undef CONFIG_SDK_RTL8214FB
#undef CONFIG_SDK_RTL8214FC
#undef CONFIG_SDK_RTL8214C
#define CONFIG_SDK_RTL8214QF 1
#undef CONFIG_SDK_RTL8218B
#define CONFIG_SDK_RTL8218D 1
#define CONFIG_SDK_RTL8218E 1
#undef CONFIG_SDK_RTL8218FB
#undef CONFIG_SDK_RTL8224QF
#define CONFIG_SDK_RTL8226 1
#define CONFIG_SDK_RTL8295R 1
#undef CONFIG_SDK_RTL826X
#undef CONFIG_SDK_RTL826XI
#undef CONFIG_SDK_RTL825X
#undef CONFIG_SDK_RTL825XI
#undef CONFIG_SDK_RTL825XL
#define CONFIG_SDK_RTL8224 1
#define CONFIG_SDK_RTL826XB 1
/*
* Select your target Peripheral chip
*/
#define CONFIG_SDK_RTL8231 1
/*
* Select customer defined PHYs chip
*/
#undef CONFIG_SDK_PHY_CUST1
#undef CONFIG_SDK_PHY_CUST2
#undef CONFIG_SDK_PHY_CUST3
#undef CONFIG_SDK_PHY_CUST4
#undef CONFIG_SDK_PHY_CUST5
#define CONFIG_SDK_EXPERIMENTAL_RTL8211FS 1
/*
* CPU
*/
#undef CONFIG_SDK_EXTERNAL_CPU
#undef CONFIG_SDK_ENDIAN_LITTLE
/*
* Operating System
*/
#define CONFIG_SDK_KERNEL_LINUX 1
#undef CONFIG_SDK_OS_KERNEL_OTHER
#undef CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE
#define CONFIG_SDK_KERNEL_LINUX_USER_MODE 1
#define CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE 1
/*
* SDK Driver
*/
/*
* Rtcore Driver support
*/
#undef CONFIG_SDK_DRIVER_RTCORE
#define CONFIG_SDK_DRIVER_RTCORE_MODULE 1
#define CONFIG_SDK_DRIVER_RTCORE_IN_LINUX_KERNEL 1
#define CONFIG_SDK_DRIVER_NIC 1
#undef CONFIG_SDK_DRIVER_EXTC_NIC
#undef CONFIG_SDK_DRIVER_EXTC_PCI
#define CONFIG_SDK_DRIVER_GPIO 1
#define CONFIG_SDK_DRIVER_SPI 1
#define CONFIG_SDK_DRIVER_I2C 1
#define CONFIG_SDK_TC_DRV 1
#define CONFIG_SDK_DRIVER_WATCHDOG 1
#define CONFIG_SDK_TC_TC1_TIME 1
#define CONFIG_SDK_UART1 1
#define CONFIG_SDK_BSP_USBHCD 1
#undef CONFIG_SDK_DRIVER_NIC_KERNEL_MODE
#define CONFIG_SDK_DRIVER_NIC_USER_MODE 1
#undef CONFIG_SDK_DRIVER_NIC_R9310
#define CONFIG_SDK_DRIVER_NIC_R9300 1
#undef CONFIG_SDK_DRIVER_NIC_R8390
#undef CONFIG_SDK_DRIVER_NIC_R8380
#define CONFIG_SDK_DRIVER_L2NTFY 1
#undef CONFIG_SDK_DRIVER_L2NTFY_R9310
#define CONFIG_SDK_DRIVER_L2NTFY_R9300 1
#undef CONFIG_SDK_DRIVER_L2NTFY_R8390
#undef CONFIG_SDK_DRIVER_I2C_R9310
#define CONFIG_SDK_DRIVER_I2C_R9300 1
#undef CONFIG_SDK_DRIVER_I2C_R8390
#undef CONFIG_SDK_DRIVER_I2C_R8380
/*
* Rtk Driver / RTK API support
*/
#define CONFIG_SDK_DRIVER_RTK 1
#undef CONFIG_SDK_DRIVER_RTK_LEGACY_API
#define CONFIG_SDK_DRIVER_RTK_CUSTOMER 1
#define CONFIG_SDK_DRIVER_RTK 1
#define CONFIG_SDK_DRIVER_RTK_CUSTOMER 1
#undef CONFIG_SDK_DRIVER_MX
#undef CONFIG_SDK_DRIVER_COMPILE
#define CONFIG_SDK_DRIVER_COMPILE_MODULE 1
/*
* SDK Application
*/
#define CONFIG_SDK_APP_DIAG 1
#define CONFIG_SDK_APP_DIAG_DIR_DIAG_V2 1
#undef CONFIG_SDK_APP_DIAG_EXT
#undef CONFIG_SDK_SQUT_CMD_OPT
#define CONFIG_SDK_APP_COMPILE 1
/*
* SDK Debug
*/
#define CONFIG_SDK_DEBUG 1
#define CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL 1
#undef CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL_MASK
#define CONFIG_SDK_DEBUG_LOG_LEVEL 3
#define CONFIG_SDK_DEBUG_LOG_MOD_MASK 0xFFFFFFFFFFFFFFFFULL
#undef CONFIG_SDK_DUMP_REG_WITH_NAME
#undef CONFIG_SDK_DUMP_TABLE_WITH_NAME
/*
* BSP Option
*/
#define CONFIG_SDK_BSP_FLASH 1
#define CONFIG_FLASH_LAYOUT_TYPE5 1
#define CONFIG_TURNKEY_SYSINFO 1
#define CONFIG_DUAL_IMAGE 1
#define CONFIG_ENV_MTD_INDEX 0x1
#define CONFIG_ENV2_MTD_INDEX 0x2
#define CONFIG_BDINFO_MTD_INDEX 0x3
#define CONFIG_SDK_BSP_MTD 1
#define CONFIG_SDK_BSP_MTD_SPI 1
#undef CONFIG_SDK_BSP_MTD_NOR
#define CONFIG_SDK_BSP_MTD_SPIM 1
#define CONFIG_SDK_BSP_MTD_NORSF_G3 1
#define CONFIG_SDK_BSP_MTD_COMMON 1
#undef CONFIG_SDK_BSP_MTD_RTK_SPI_NAND
#define CONFIG_SDK_BSP_MTD_SPI_NAND_G3 1
#define CONFIG_SDK_BSP_MTD_ECC_G2 1
#define CONFIG_SDK_SPI_DEV_NONE 1
#undef CONFIG_SDK_SPI_DEV_1
#undef CONFIG_SDK_SPI_DEV_2
#undef CONFIG_SDK_SPI_DEV_3
#undef CONFIG_SDK_SPI_DEV_4
#undef CONFIG_SDK_SPI_DEV_5
#define CONFIG_SDK_BSP_SPI_NOR_BOOT 1
#undef CONFIG_SDK_BSP_SPI_NAND_BOOT
/*
* Misc Option
*/
#undef CONFIG_SDK_EXPERIMENTAL
#undef CONFIG_SDK_FPGA_PLATFORM
#undef CONFIG_SDK_DRIVER_TEST
#undef CONFIG_SDK_MODEL_MODE
#undef CONFIG_SDK_LINKED_KMOD
#undef CONFIG_TRUNK_FAILOVER_HANDLING
#undef CONFIG_SDK_RX_THREAD
#define CONFIG_SDK_LINKMON_POLLING_MODE 1
#undef CONFIG_SDK_LINKMON_ISR_MODE
#undef CONFIG_SDK_LINKMON_MIXED_MODE
#undef CONFIG_RISE
#undef CONFIG_SDK_HW_PROFILE_PROBE_GPIO
#define CONFIG_SDK_HW_PROFILE_PROBE_UBOOT_ENV 1
#define CONFIG_SDK_OS_VERSION "Linux 3.18.24"
#define CONFIG_SDK_COMPILER_VERSION "GCC 4.8.5"
#define CONFIG_SDK_LIBC_VERSION "uClibc-0.9.33.2 with NPTL"

View file

@ -0,0 +1,527 @@
#############################################################################
#
# NOTE : it is fairly important that changes to this file consider their
# effect on other platforms and default setups. If you can, only
# add to the file, changing the name of a variable will break
# many configurations.
#
# www.snapgear.com
#
#############################################################################
mainmenu_name "SDK Configuration"
#############################################################################
mainmenu_option next_comment
comment 'Chip Support'
comment 'Select your target MAC chip(s)'
if [ "$CONFIG_IN_UBOOT" == "y" ]; then
choice 'MAC chip' "RTL8380 CONFIG_SDK_RTL8380
RTL8390 CONFIG_SDK_RTL8390
RTL9300 CONFIG_SDK_RTL9300
RTL9310 CONFIG_SDK_RTL9310" RTL9300
else
bool 'RTL9310' CONFIG_SDK_RTL9310 n
bool 'RTL9300' CONFIG_SDK_RTL9300 n
bool 'RTL8390' CONFIG_SDK_RTL8390 n
bool 'RTL8380' CONFIG_SDK_RTL8380 n
fi
comment 'Select your target PHYs chip'
bool 'RTL8208D' CONFIG_SDK_RTL8208D n
bool 'RTL8208G' CONFIG_SDK_RTL8208G n
bool 'RTL8208L' CONFIG_SDK_RTL8208L n
bool 'RTL8212B' CONFIG_SDK_RTL8212B n
bool 'RTL8214B' CONFIG_SDK_RTL8214B n
bool 'RTL8214FB' CONFIG_SDK_RTL8214FB n
bool 'RTL8214FC' CONFIG_SDK_RTL8214FC n
bool 'RTL8214C' CONFIG_SDK_RTL8214C n
bool 'RTL8214QF' CONFIG_SDK_RTL8214QF n
bool 'RTL8218B' CONFIG_SDK_RTL8218B n
bool 'RTL8218D' CONFIG_SDK_RTL8218D n
bool 'RTL8218E' CONFIG_SDK_RTL8218E n
bool 'RTL8218FB' CONFIG_SDK_RTL8218FB n
bool 'RTL8224QF' CONFIG_SDK_RTL8224QF n
bool 'RTL8226' CONFIG_SDK_RTL8226 n
bool 'RTL8295R' CONFIG_SDK_RTL8295R n
bool 'RTL8261/RTL8264' CONFIG_SDK_RTL826X n
bool 'RTL8261I/RTL8264I' CONFIG_SDK_RTL826XI n
bool 'RTL8251/RTL8254' CONFIG_SDK_RTL825X n
bool 'RTL8251I/RTL8254I' CONFIG_SDK_RTL825XI n
bool 'RTL8251L/RTL8254L' CONFIG_SDK_RTL825XL n
bool 'RTL8224' CONFIG_SDK_RTL8224 n
bool 'RTL8261N/61B/64B' CONFIG_SDK_RTL826XB n
comment 'Select your target Peripheral chip'
bool 'RTL8231' CONFIG_SDK_RTL8231 n
comment 'Select customer defined PHYs chip'
bool 'CUSTOMER PHY 1' CONFIG_SDK_PHY_CUST1 n
bool 'CUSTOMER PHY 2' CONFIG_SDK_PHY_CUST2 n
bool 'CUSTOMER PHY 3' CONFIG_SDK_PHY_CUST3 n
bool 'CUSTOMER PHY 4' CONFIG_SDK_PHY_CUST4 n
bool 'CUSTOMER PHY 5' CONFIG_SDK_PHY_CUST5 n
if [ "$CONFIG_SDK_EXPERIMENTAL" == "y" ]; then
comment 'Select experimental PHY chip(s)'
bool 'RTL8211FS' CONFIG_SDK_EXPERIMENTAL_RTL8211FS n
else
define_bool CONFIG_SDK_EXPERIMENTAL_RTL8211FS y
fi
endmenu
#############################################################################
#if [ "$CONFIG_IN_UBOOT" != "y" ]; then
mainmenu_option next_comment
comment 'CPU'
bool 'External CPU' CONFIG_SDK_EXTERNAL_CPU n
bool 'CPU Little Endian' CONFIG_SDK_ENDIAN_LITTLE n
endmenu
#fi
#############################################################################
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
mainmenu_option next_comment
comment 'Operating System'
choice 'Select OS Kernel' "Linux CONFIG_SDK_KERNEL_LINUX \
Other CONFIG_SDK_OS_KERNEL_OTHER \
" Linux
if [ "$CONFIG_SDK_KERNEL_LINUX" = "y" ]; then
choice 'Mode Support' "Kernel CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE \
User CONFIG_SDK_KERNEL_LINUX_USER_MODE" Kernel
bool ' Loadable Module Support' CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE y
else
define_bool CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE n
fi
if [ "$PREV_CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE" == "n" -a "$CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE" == "y" ]; then
# Once the Linux mode change to Kernel mode, recover some settings here
define_tristate CONFIG_SDK_DRIVER_MX m
define_tristate CONFIG_SDK_DRIVER_RTDRV m
define_tristate CONFIG_SDK_DRIVER_RTNIC m
define_tristate CONFIG_SDK_DRIVER_COMPILE m
if [ "$CONFIG_SDK_DRIVER_RTK" = "y" ]; then
define_tristate CONFIG_SDK_DRIVER_RTK m
fi
if [ "$CONFIG_SDK_DRIVER_TEST" = "y" ]; then
define_tristate CONFIG_SDK_DRIVER_TEST m
fi
fi
PREV_CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE=$CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE
if [ "$CONFIG_SDK_KERNEL_LINUX_USER_MODE" = "y" ]; then
if [ "$CONFIG_SDK_DRIVER_RTK" = "m" ]; then
define_tristate CONFIG_SDK_DRIVER_RTK y
fi
if [ "$CONFIG_SDK_DRIVER_RTDRV" = "m" -o "$CONFIG_SDK_DRIVER_RTDRV" = "y" ]; then
define_tristate CONFIG_SDK_DRIVER_RTDRV n
fi
if [ "$CONFIG_SDK_DRIVER_RTNIC" = "m" -o "$CONFIG_SDK_DRIVER_RTNIC" = "y" ]; then
define_tristate CONFIG_SDK_DRIVER_RTNIC n
fi
if [ "$CONFIG_SDK_DRIVER_TEST" = "m" ]; then
define_tristate CONFIG_SDK_DRIVER_TEST y
fi
fi
endmenu
fi
#############################################################################
if [ "$CONFIG_IN_UBOOT" == "y" ]; then
bool 'SDK support' CONFIG_UBOOT_SDK_SUPPORT y
fi
if [ "$CONFIG_UBOOT_SDK_SUPPORT" == "y" -o "$CONFIG_IN_UBOOT" != "y" ]; then
mainmenu_option next_comment
comment 'SDK Driver'
comment 'Rtcore Driver support'
tristate 'Rtcore Driver' CONFIG_SDK_DRIVER_RTCORE m
bool 'Build Rtcore Driver in Linux Kernel' CONFIG_SDK_DRIVER_RTCORE_IN_LINUX_KERNEL y
dep_mbool 'Nic Driver' CONFIG_SDK_DRIVER_NIC $CONFIG_SDK_DRIVER_RTCORE
dep_mbool 'External CPU Nic Driver' CONFIG_SDK_DRIVER_EXTC_NIC
dep_mbool 'External CPU PCI Driver' CONFIG_SDK_DRIVER_EXTC_PCI
if [ "$CONFIG_SDK_EXTERNAL_CPU" == "y" ]; then
define_bool CONFIG_SDK_DRIVER_GPIO n
if [ "$CONFIG_SDK_RTL9300" == "y" ]; then
define_bool CONFIG_SDK_DRIVER_SPI y
else
define_bool CONFIG_SDK_DRIVER_SPI n
fi
define_bool CONFIG_SDK_DRIVER_I2C n
define_bool CONFIG_SDK_TC_DRV n
define_bool CONFIG_SDK_DRIVER_WATCHDOG n
define_bool CONFIG_SDK_TC_TC1_TIME n
define_bool CONFIG_SDK_UART1 n
define_bool CONFIG_SDK_BSP_USBHCD n
else
if [ "$CONFIG_SDK_DRIVER_RTCORE" != "n" ]; then
define_bool CONFIG_SDK_DRIVER_GPIO y
define_bool CONFIG_SDK_DRIVER_SPI y
define_bool CONFIG_SDK_DRIVER_I2C y
if [ "$CONFIG_IN_UBOOT" == "y" ]; then
define_bool CONFIG_SDK_TC_DRV n
define_bool CONFIG_SDK_DRIVER_WATCHDOG n
else
define_bool CONFIG_SDK_TC_DRV y
define_bool CONFIG_SDK_DRIVER_WATCHDOG y
fi
#
# Timer/Counter(TC), Config TC1 as time stamps(debug/time-measure purpose)
#
if [ "$CONFIG_SDK_TC_DRV" = "y" ]; then
define_bool CONFIG_SDK_TC_TC1_TIME y
fi
if [ "$CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE" = "y" ]; then
define_bool CONFIG_SDK_UART1 y
else
define_bool CONFIG_SDK_UART1 y
fi
if [ "$CONFIG_SDK_KERNEL_LINUX" = "y" ]; then
if [ "$CONFIG_SDK_RTL9300" = "y" -o "$CONFIG_SDK_RTL9310" = "y" ]; then
define_bool CONFIG_SDK_BSP_USBHCD y
fi
fi
fi
fi
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" ]; then
if [ "$CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_NIC_KERNEL_MODE y
define_bool CONFIG_SDK_DRIVER_NIC_USER_MODE n
fi
if [ "$CONFIG_SDK_KERNEL_LINUX_USER_MODE" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_NIC_KERNEL_MODE n
define_bool CONFIG_SDK_DRIVER_NIC_USER_MODE y
fi
fi
#
# Set per chip NIC driver configuration according to Chip Support and NIC driver support status
#
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" -a "$CONFIG_SDK_RTL9310" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_NIC_R9310 y
else
define_bool CONFIG_SDK_DRIVER_NIC_R9310 n
fi
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" -a "$CONFIG_SDK_RTL9300" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_NIC_R9300 y
else
define_bool CONFIG_SDK_DRIVER_NIC_R9300 n
fi
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" -a "$CONFIG_SDK_RTL8390" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_NIC_R8390 y
else
define_bool CONFIG_SDK_DRIVER_NIC_R8390 n
fi
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" -a "$CONFIG_SDK_RTL8380" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_NIC_R8380 y
else
define_bool CONFIG_SDK_DRIVER_NIC_R8380 n
fi
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" -o "$CONFIG_SDK_DRIVER_EXTC_NIC" = "y" ]; then
dep_mbool 'L2 Notification Driver' CONFIG_SDK_DRIVER_L2NTFY $CONFIG_SDK_DRIVER_RTCORE
fi
if [ "$CONFIG_SDK_DRIVER_L2NTFY" = "y" -a "$CONFIG_SDK_RTL9310" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_L2NTFY_R9310 y
else
define_bool CONFIG_SDK_DRIVER_L2NTFY_R9310 n
fi
if [ "$CONFIG_SDK_DRIVER_L2NTFY" = "y" -a "$CONFIG_SDK_RTL9300" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_L2NTFY_R9300 y
else
define_bool CONFIG_SDK_DRIVER_L2NTFY_R9300 n
fi
if [ "$CONFIG_SDK_DRIVER_L2NTFY" = "y" -a "$CONFIG_SDK_RTL8390" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_L2NTFY_R8390 y
else
define_bool CONFIG_SDK_DRIVER_L2NTFY_R8390 n
fi
fi
#
# Set per chip I2C driver configuration according to Chip Support and I2C driver support status
#
if [ "$CONFIG_SDK_DRIVER_I2C" = "y" -a "$CONFIG_SDK_RTL9310" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_I2C_R9310 y
else
define_bool CONFIG_SDK_DRIVER_I2C_R9310 n
fi
if [ "$CONFIG_SDK_DRIVER_I2C" = "y" -a "$CONFIG_SDK_RTL9300" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_I2C_R9300 y
else
define_bool CONFIG_SDK_DRIVER_I2C_R9300 n
fi
if [ "$CONFIG_SDK_DRIVER_I2C" = "y" -a "$CONFIG_SDK_RTL8390" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_I2C_R8390 y
else
define_bool CONFIG_SDK_DRIVER_I2C_R8390 n
fi
if [ "$CONFIG_SDK_DRIVER_I2C" = "y" -a "$CONFIG_SDK_RTL8380" = "y" ]; then
define_bool CONFIG_SDK_DRIVER_I2C_R8380 y
else
define_bool CONFIG_SDK_DRIVER_I2C_R8380 n
fi
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
comment 'Rtk Driver / RTK API support'
tristate 'Rtk Driver / RTK API' CONFIG_SDK_DRIVER_RTK m
bool ' Support RTK Legacy API' CONFIG_SDK_DRIVER_RTK_LEGACY_API y
if [ "$CONFIG_SDK_DRIVER_RTK" = "m" -o "$CONFIG_SDK_DRIVER_RTK" = "y" ]; then
bool ' Customization API' CONFIG_SDK_DRIVER_RTK_CUSTOMER y
fi
if [ "$CONFIG_SDK_KERNEL_LINUX_USER_MODE" = "y" ]; then
tristate 'Rtk Driver / RTK API' CONFIG_SDK_DRIVER_RTK y
if [ "$CONFIG_SDK_DRIVER_RTK" = "m" -o "$CONFIG_SDK_DRIVER_RTK" = "y" ]; then
bool ' Customization API' CONFIG_SDK_DRIVER_RTK_CUSTOMER y
fi
fi
if [ "$CONFIG_SDK_KERNEL_LINUX" = "y" -a "$CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE" = "y" ]; then
comment 'Linux Net Driver support'
tristate 'Linux Net Driver' CONFIG_SDK_DRIVER_MX m
else
define_tristate CONFIG_SDK_DRIVER_MX n
fi
if [ "$CONFIG_SDK_DRIVER_MX" = "y" ]; then
bool ' Linux User/Kernel Interface' CONFIG_SDK_DRIVER_RTDRV y
if [ "$CONFIG_SDK_DRIVER_RTDRV" = "m" ]; then
define_bool CONFIG_SDK_DRIVER_RTDRV y
fi
#"Linux Ethernet Driver" depends on "NIC Driver"
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" ]; then
bool ' Linux Ethernet Driver' CONFIG_SDK_DRIVER_RTNIC y
if [ "$CONFIG_SDK_DRIVER_RTNIC" = "m" ]; then
define_bool CONFIG_SDK_DRIVER_RTNIC y
fi
else
define_bool CONFIG_SDK_DRIVER_RTNIC n
fi
elif [ "$CONFIG_SDK_DRIVER_MX" = "m" ]; then
tristate ' Linux User/Kernel Interface' CONFIG_SDK_DRIVER_RTDRV m
#"Linux Ethernet Driver" depends on "NIC Driver"
if [ "$CONFIG_SDK_DRIVER_NIC" = "y" ]; then
tristate ' Linux Ethernet Driver' CONFIG_SDK_DRIVER_RTNIC m
else
define_tristate CONFIG_SDK_DRIVER_RTNIC n
fi
fi
tristate 'build driver in linux kernel' CONFIG_SDK_DRIVER_COMPILE m
fi
endmenu
fi
#############################################################################
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
mainmenu_option next_comment
comment 'SDK Application'
bool 'SDK Diag Shell' CONFIG_SDK_APP_DIAG y
if [ "$CONFIG_SDK_APP_DIAG" = "y" ]; then
define_bool CONFIG_SDK_APP_DIAG_DIR_DIAG_V2 y
bool ' Extension Diag Shell' CONFIG_SDK_APP_DIAG_EXT y
bool ' Extra command option for QA unit test' CONFIG_SDK_SQUT_CMD_OPT y
fi
if [ "$CONFIG_SDK_APP_DIAG" = "y" ]; then
define_bool CONFIG_SDK_APP_COMPILE y
fi
endmenu
fi
#############################################################################
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
mainmenu_option next_comment
comment 'SDK Debug'
bool 'Enable SDK Debug Message' CONFIG_SDK_DEBUG y
if [ "$CONFIG_SDK_DEBUG" = "y" ]; then
choice 'Debug Log Type' "Level CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL \
Level-Mask CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL_MASK \
" Level
if [ "$CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL" = "y" ]; then
int 'Log Level' CONFIG_SDK_DEBUG_LOG_LEVEL 3
else
hex 'Log Level Mask' CONFIG_SDK_DEBUG_LOG_LEVEL_MASK 0xF
fi
hex_ull 'Debug Log Module Mask' CONFIG_SDK_DEBUG_LOG_MOD_MASK FFFFFFFFFFFFFFFF
fi
bool 'Dump Register content with Name' CONFIG_SDK_DUMP_REG_WITH_NAME n
bool 'Dump Table content with Name' CONFIG_SDK_DUMP_TABLE_WITH_NAME n
endmenu
fi
#############################################################################
mainmenu_option next_comment
comment 'BSP Option'
bool 'Flash Common Setting' CONFIG_SDK_BSP_FLASH y
if [ "$CONFIG_SDK_BSP_FLASH" = "y" ]; then
choice 'Flash Layout' " Type5 CONFIG_FLASH_LAYOUT_TYPE5 \
" Type5
define_bool CONFIG_TURNKEY_SYSINFO y
define_bool CONFIG_DUAL_IMAGE y
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
hex 'ENV MTD Index' CONFIG_ENV_MTD_INDEX ""
hex 'ENV2 MTD Index' CONFIG_ENV2_MTD_INDEX ""
hex 'BDINFO MTD Index' CONFIG_BDINFO_MTD_INDEX ""
fi
fi
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
if [ "$CONFIG_SDK_KERNEL_LINUX" = "y" ]; then
tristate 'Linux Mtd Driver' CONFIG_SDK_BSP_MTD m
if [ "$CONFIG_SDK_BSP_MTD" = "m" ]; then
tristate ' SPI Flash Driver' CONFIG_SDK_BSP_MTD_SPI m
tristate ' NOR Flash Driver' CONFIG_SDK_BSP_MTD_NOR n
define_tristate CONFIG_SDK_BSP_MTD_SPIM m
define_bool CONFIG_SDK_BSP_MTD_NORSF_G3 m
define_bool CONFIG_SDK_BSP_MTD_COMMON m
if [ "$CONFIG_SDK_RTL9310" = "y" -o "$CONFIG_SDK_RTL9300" = "y" ]; then
tristate ' SPI NAND_Flash Driver' CONFIG_SDK_BSP_MTD_RTK_SPI_NAND m
if [ "$CONFIG_SDK_BSP_SPI_NAND_BOOT" = "y" ]; then
define_bool CONFIG_SDK_BSP_MTD_SPI_NAND_G2 m
define_bool CONFIG_SDK_BSP_MTD_ECC_G1 m
else
define_bool CONFIG_SDK_BSP_MTD_SPI_NAND_G3 m
define_bool CONFIG_SDK_BSP_MTD_ECC_G2 m
fi
fi
fi
if [ "$CONFIG_SDK_BSP_MTD" = "y" ]; then
bool ' SPI Flash Driver' CONFIG_SDK_BSP_MTD_SPI y
bool ' NOR Flash Driver' CONFIG_SDK_BSP_MTD_NOR n
define_bool CONFIG_SDK_BSP_MTD_SPIM y
define_bool CONFIG_SDK_BSP_MTD_NORSF_G3 y
define_bool CONFIG_SDK_BSP_MTD_COMMON y
if [ "$CONFIG_SDK_RTL9310" = "y" -o "$CONFIG_SDK_RTL9300" = "y" ]; then
bool ' SPI NAND_Flash Driver' CONFIG_SDK_BSP_MTD_RTK_SPI_NAND y
if [ "$CONFIG_SDK_BSP_SPI_NAND_BOOT" = "y" ]; then
define_bool CONFIG_SDK_BSP_MTD_SPI_NAND_G2 y
define_bool CONFIG_SDK_BSP_MTD_ECC_G1 y
else
define_bool CONFIG_SDK_BSP_MTD_SPI_NAND_G3 y
define_bool CONFIG_SDK_BSP_MTD_ECC_G2 y
fi
fi
fi
fi
if [ "$CONFIG_SDK_KERNEL_LINUX" = "y" ]; then
if [ "$CONFIG_DEFAULTS_KERNEL_3_18_24" = "y" -a "$CONFIG_SDK_SPI_DEV_NONE" != "y" ]; then
bool 'Linux SPI Controller Driver' CONFIG_SDK_BSP_SPI_DRV y
fi
fi
fi
choice 'SPI device' "none CONFIG_SDK_SPI_DEV_NONE \
dev1 CONFIG_SDK_SPI_DEV_1 \
dev2 CONFIG_SDK_SPI_DEV_2 \
dev3 CONFIG_SDK_SPI_DEV_3 \
dev4 CONFIG_SDK_SPI_DEV_4 \
dev5 CONFIG_SDK_SPI_DEV_5 " none
choice 'Device Boot Type' "SPI_NOR_Boot CONFIG_SDK_BSP_SPI_NOR_BOOT
SPI_NAND_Boot CONFIG_SDK_BSP_SPI_NAND_BOOT" SPI_NOR_Boot
endmenu
#############################################################################
#############################################################################
mainmenu_option next_comment
comment 'Misc Option'
bool 'Experimental options' CONFIG_SDK_EXPERIMENTAL n
bool 'FPGA Platform' CONFIG_SDK_FPGA_PLATFORM n
if [ "$CONFIG_IN_UBOOT" != "y" ]; then
tristate 'SDK Unit Test' CONFIG_SDK_DRIVER_TEST y
bool 'Model Code Simulation' CONFIG_SDK_MODEL_MODE n
if [ "$CONFIG_SDK_MODEL_MODE" = "y" ]; then
choice 'Select Model Execution Mode' "KERNEL CONFIG_SDK_MODEL_MODE_KERNEL \
USER CONFIG_SDK_MODEL_MODE_USER" KERNEL
bool ' Virtual Array ONLY' CONFIG_VIRTUAL_ARRAY_ONLY n
fi
bool 'Linked Kernel Module Mode' CONFIG_SDK_LINKED_KMOD n
bool 'TRUNK FailOver Handling' CONFIG_TRUNK_FAILOVER_HANDLING n
bool 'NIC Rx Thread' CONFIG_SDK_RX_THREAD n
if [ "$CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE" = "y" ]; then
choice 'Select LinkMon Thread Mode' "Polling CONFIG_SDK_LINKMON_POLLING_MODE \
Interrupt CONFIG_SDK_LINKMON_ISR_MODE \
Mixed CONFIG_SDK_LINKMON_MIXED_MODE" Polling
else
choice 'Select LinkMon Thread Mode' "Polling CONFIG_SDK_LINKMON_POLLING_MODE \
Interrupt CONFIG_SDK_LINKMON_ISR_MODE \
Mixed CONFIG_SDK_LINKMON_MIXED_MODE" Polling
fi
bool ' RISE' CONFIG_RISE y
fi
choice 'Hardware profile probe method' "GPIO CONFIG_SDK_HW_PROFILE_PROBE_GPIO \
UBOOT-ENV CONFIG_SDK_HW_PROFILE_PROBE_UBOOT_ENV" UBOOT-ENV
if [ "$CONFIG_DEFAULTS_KERNEL_3_18_24" = "y" ]; then
string 'OS Version' CONFIG_SDK_OS_VERSION 'Linux 3.18.24'
string 'GCC Version' CONFIG_SDK_COMPILER_VERSION 'GCC 4.8.5'
elif [ "$CONFIG_DEFAULTS_KERNEL_2_6" = "y" ]; then
string 'OS Version' CONFIG_SDK_OS_VERSION 'Linux 2.6.19'
string 'GCC Version' CONFIG_SDK_COMPILER_VERSION 'GCC 4.4.7'
else
string 'OS Version' CONFIG_SDK_OS_VERSION ''
string 'GCC Version' CONFIG_SDK_COMPILER_VERSION ''
fi
if [ "$CONFIG_LIBCDIR" = "uClibc-0.9.33-485-318" ]; then
string 'C Library Version' CONFIG_SDK_LIBC_VERSION 'uClibc-0.9.33.2 with NPTL'
elif [ "$CONFIG_LIBCDIR" = "uClibc-0.9.33" ]; then
string 'C Library Version' CONFIG_SDK_LIBC_VERSION 'uClibc-0.9.33.2 with NPTL'
else
string 'C Library Version' CONFIG_SDK_LIBC_VERSION ''
fi
endmenu
#############################################################################

View file

@ -0,0 +1,105 @@
#
# Automatically generated by make menuconfig: don't edit
#
#
# Chip Support
#
CONFIG_SDK_RTL8208=y
CONFIG_SDK_RTL8214=y
CONFIG_SDK_RTL8214F=y
CONFIG_SDK_RTL8201=y
CONFIG_SDK_RTL8218=y
CONFIG_SDK_RTL8218B=n
CONFIG_SDK_RTL8218FB=n
CONFIG_SDK_RTL8212F=y
CONFIG_SDK_RTL8212B=y
CONFIG_SDK_RTL8214B=y
CONFIG_SDK_RTL8214FB=y
CONFIG_SDK_RTL8214FC=n
# CONFIG_SDK_RTL8231 is not set
#
# CPU Endian
#
# CONFIG_SDK_ENDIAN_LITTLE is not set
#
# Operating System
#
CONFIG_SDK_KERNEL_LINUX=y
CONFIG_SDK_KERNEL_LINUX_KERNEL_MODE=y
# CONFIG_SDK_KERNEL_LINUX_USER_MODE is not set
CONFIG_SDK_KERNEL_LINUX_MODULE_LOADABLE=y
#
# SDK Driver
#
CONFIG_SDK_DRIVER_RTCORE=m
CONFIG_SDK_DRIVER_NIC=m
CONFIG_SDK_DRIVER_NIC_KERNEL_MODE=y
# CONFIG_SDK_DRIVER_NIC_USER_MODE is not set
CONFIG_SDK_DRIVER_L2NTFY=y
CONFIG_SDK_DRIVER_RTK=m
# CONFIG_SDK_DRIVER_RTK_CUSTOMER is not set
CONFIG_SDK_DRIVER_MX=m
CONFIG_SDK_DRIVER_RTDRV=m
CONFIG_SDK_DRIVER_RTNIC=m
CONFIG_SDK_DRIVER_COMPILE=m
#
# SDK Application
#
CONFIG_SDK_APP_DIAG=y
CONFIG_SDK_APP_DIAG_DIR_DIAG=y
# CONFIG_SDK_APP_DIAG_DIR_DIAG_V2 is not set
# CONFIG_RRCP_MASTER is not set
CONFIG_SDK_APP_COMPILE=y
#
# SDK Debug
#
CONFIG_SDK_DEBUG=y
CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL=y
# CONFIG_SDK_DEBUG_LOG_TYPE_LEVEL_MASK is not set
CONFIG_SDK_DEBUG_LOG_LEVEL=3
CONFIG_SDK_DEBUG_LOG_MOD_MASK=FFFFFFFFFFFFFFFF
#
# BSP Option
#
CONFIG_SDK_DRIVER_GPIO=y
CONFIG_SDK_DRIVER_SPI=y
CONFIG_SDK_BSP_FLASH=y
CONFIG_FLASH_BLOCK_SIZE=20000
# CONFIG_FLASH_SIZE_4MB is not set
# CONFIG_FLASH_SIZE_8MB is not set
CONFIG_FLASH_SIZE_16MB=y
# CONFIG_DUAL_IMAGE is not set
CONFIG_FLASH_LAYOUT_TYPE1=y
# CONFIG_FLASH_LAYOUT_TYPE2 is not set
CONFIG_SDK_BSP_MTD=y
CONFIG_SDK_BSP_MTD_SPI=y
# CONFIG_SDK_BSP_MTD_SPI_QUAD_IO is not set
# CONFIG_SDK_BSP_MTD_NOR is not set
CONFIG_SDK_BSP_MTD_SPIM=y
#
# Misc Option
#
# CONFIG_SDK_FPGA_PLATFORM is not set
# CONFIG_SDK_DRIVER_TEST is not set
# CONFIG_SDK_MODEL_MODE is not set
# CONFIG_SDK_LINKED_KMOD is not set
# CONFIG_TRUNK_FAILOVER_HANDLING is not set
# CONFIG_SDK_RX_THREAD is not set
CONFIG_SDK_LINKMON_POLLING_MODE=y
# CONFIG_SDK_LINKMON_ISR_MODE is not set
# CONFIG_SDK_LINKMON_MIXED_MODE is not set
# CONFIG_SDK_AUTO_COMBO_MEDIA_BY_GPIO is not set
CONFIG_SDK_WA_EEE_COMPATIBLE=y
# CONFIG_SDK_WA_RTL8231_RESET is not set
# CONFIG_SDK_WA_PKTBUF_WATCHDOG is not set
# CONFIG_SDK_WA_RTL833X_COMBO_LED is not set
# CONFIG_SDK_UART1 is not set
# CONFIG_SDK_PORT_VIEW_PHYSICAL_PORT is not set

View file

@ -0,0 +1,694 @@
#! /bin/sh
#
# This script is used to configure the Linux kernel.
#
# It was inspired by the challenge in the original Configure script
# to ``do something better'', combined with the actual need to ``do
# something better'' because the old configure script wasn't flexible
# enough.
#
# Raymond Chen was the original author of Configure.
# Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
#
# 050793 - use IFS='@' to get around a bug in a pre-version of bash-1.13
# with an empty IFS.
#
# 030995 (storner@osiris.ping.dk) - added support for tri-state answers,
# for selecting modules to compile.
#
# 180995 Bernhard Kaindl (bkaindl@ping.at) - added dummy functions for
# use with a config.in modified for make menuconfig.
#
# 301195 (boldt@math.ucsb.edu) - added help text support
#
# 281295 Paul Gortmaker - make tri_state functions collapse to boolean
# if module support is not enabled.
#
# 010296 Aaron Ucko (ucko@vax1.rockhurst.edu) - fix int and hex to accept
# arbitrary ranges
#
# 150296 Dick Streefland (dicks@tasking.nl) - report new configuration
# items and ask for a value even when doing a "make oldconfig"
#
# 200396 Tom Dyas (tdyas@eden.rutgers.edu) - when the module option is
# chosen for an item, define the macro <option_name>_MODULE
#
# 090397 Axel Boldt (boldt@math.ucsb.edu) - avoid ? and + in regular
# expressions for GNU expr since version 1.15 and up use \? and \+.
#
# 300397 Phil Blundell (pjb27@cam.ac.uk) - added support for min/max
# arguments to "int", allow dep_tristate to take a list of dependencies
# rather than just one.
#
# 090398 Axel Boldt (boldt@math.ucsb.edu) - allow for empty lines in help
# texts.
#
# 102598 Michael Chastain (mec@shout.net) - put temporary files in
# current directory, not in /tmp.
#
# 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
# - Improve the exit message (Jeff Ronne).
#
# 12/Jan/2001 - stolen for other uses, can still be used as is for kernel
# davidm
#
# Make sure we're really running bash.
#
# I would really have preferred to write this script in a language with
# better string handling, but alas, bash is the only scripting language
# that I can be reasonable sure everybody has on their linux machine.
#
[ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
# Disable filename globbing once and for all.
# Enable function cacheing.
set -f -h
#
# Dummy functions for use with a config.in modified for menuconf
#
function mainmenu_option () {
:
}
function mainmenu_name () {
:
}
function endmenu () {
:
}
#
# help prints the corresponding help text from ${HELP_FILE} to stdout
#
# help variable
#
function help () {
if [ -f ${HELP_FILE} ]
then
#first escape regexp special characters in the argument:
var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g')
#now pick out the right help text:
text=$(sed -n "/^$var[ ]*\$/,\${
/^$var[ ]*\$/c\\
${var}:\\
/^#/b
/^[^ ]/q
p
}" ${HELP_FILE})
if [ -z "$text" ]
then
echo; echo " Sorry, no help available for this option yet.";echo
else
(echo; echo "$text") | ${PAGER:-more}
fi
else
echo;
echo " Can't access the file ${HELP_FILE} which"
echo " should contain the help texts."
echo
fi
}
#
# readln reads a line into $ans.
#
# readln prompt default oldval
#
function readln () {
if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
echo "$1"
ans=$2
else
echo -n "$1"
[ -z "$3" ] && echo -n "(NEW) "
IFS='@' read ans || exit 1
[ -z "$ans" ] && ans=$2
fi
}
#
# comment does some pretty-printing
#
# comment 'xxx'
#
function comment () {
echo "*"; echo "* $1" ; echo "*"
(echo "" ; echo "#"; echo "# $1" ; echo "#") >>$CONFIG
(echo "" ; echo "/*"; echo " * $1" ; echo " */") >>$CONFIG_H
}
#
# define_bool sets the value of a boolean argument
#
# define_bool define value
#
function define_bool () {
define_tristate $1 $2
}
function define_tristate () {
case "$2" in
"y")
echo "$1=y" >>$CONFIG
echo "#define $1 1" >>$CONFIG_H
;;
"m")
echo "$1=m" >>$CONFIG
echo "#undef $1" >>$CONFIG_H
echo "#define $1_MODULE 1" >>$CONFIG_H
;;
"n")
echo "# $1 is not set" >>$CONFIG
echo "#undef $1" >>$CONFIG_H
;;
esac
eval "$1=$2"
}
#
# bool processes a boolean argument
#
# bool question define
#
function bool () {
old=$(eval echo "\${$2}")
def=${old:-'n'}
case "$def" in
"y" | "m") defprompt="Y/n/?"
def="y"
;;
"n") defprompt="N/y/?"
;;
esac
while :; do
readln "$1 ($2) [$defprompt] " "$def" "$old"
case "$ans" in
[yY] | [yY]es ) define_bool "$2" "y"
break;;
[nN] | [nN]o ) define_bool "$2" "n"
break;;
* ) help "$2"
;;
esac
done
}
#
# tristate processes a tristate argument
#
# tristate question define
#
function tristate () {
if [ "$CONFIG_MODULES" != "y" ]; then
bool "$1" "$2"
else
old=$(eval echo "\${$2}")
def=${old:-'n'}
case "$def" in
"y") defprompt="Y/m/n/?"
;;
"m") defprompt="M/n/y/?"
;;
"n") defprompt="N/y/m/?"
;;
esac
while :; do
readln "$1 ($2) [$defprompt] " "$def" "$old"
case "$ans" in
[yY] | [yY]es ) define_tristate "$2" "y"
break ;;
[nN] | [nN]o ) define_tristate "$2" "n"
break ;;
[mM] ) define_tristate "$2" "m"
break ;;
* ) help "$2"
;;
esac
done
fi
}
#
# dep_tristate processes a tristate argument that depends upon
# another option or options. If any of the options we depend upon is a
# module, then the only allowable options are M or N. If all are Y, then
# this is a normal tristate. This is used in cases where modules
# are nested, and one module requires the presence of something
# else in the kernel.
#
# dep_tristate question define default ...
#
function dep_tristate () {
old=$(eval echo "\${$2}")
def=${old:-'n'}
ques=$1
var=$2
need_module=0
shift 2
while [ $# -gt 0 ]; do
case "$1" in
n)
define_tristate "$var" "n"
return
;;
m)
need_module=1
;;
esac
shift
done
if [ $need_module = 1 ]; then
if [ "$CONFIG_MODULES" = "y" ]; then
case "$def" in
"y" | "m") defprompt="M/n/?"
def="m"
;;
"n") defprompt="N/m/?"
;;
esac
while :; do
readln "$ques ($var) [$defprompt] " "$def" "$old"
case "$ans" in
[nN] | [nN]o ) define_tristate "$var" "n"
break ;;
[mM] ) define_tristate "$var" "m"
break ;;
[yY] | [yY]es ) echo
echo " This answer is not allowed, because it is not consistent with"
echo " your other choices."
echo " This driver depends on another one which you chose to compile"
echo " as a module. This means that you can either compile this one"
echo " as a module as well (with M) or leave it out altogether (N)."
echo
;;
* ) help "$var"
;;
esac
done
fi
else
tristate "$ques" "$var"
fi
}
function dep_bool () {
ques=$1
var=$2
shift 2
while [ $# -gt 0 ]; do
case "$1" in
m | n)
define_bool "$var" "n"
return
;;
esac
shift
done
bool "$ques" "$var"
}
function dep_mbool () {
ques=$1
var=$2
shift 2
while [ $# -gt 0 ]; do
case "$1" in
n)
define_bool "$var" "n"
return
;;
esac
shift
done
bool "$ques" "$var"
}
#
# define_int sets the value of a integer argument
#
# define_int define value
#
function define_int () {
echo "$1=$2" >>$CONFIG
echo "#define $1 $2" >>$CONFIG_H
eval "$1=$2"
}
function define_pint () {
echo "$1=$2" >>$CONFIG
echo "#define $1 $2" >>$CONFIG_H
eval "$1=$2"
}
#
# int processes an integer argument with optional limits
#
# int question define default [min max]
#
function int () {
old=$(eval echo "\${$2}")
def=${old:-$3}
if [ $# -gt 3 ]; then
min=$4
else
min=-10000000 # !!
fi
if [ $# -gt 4 ]; then
max=$5
else
max=10000000 # !!
fi
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
# if expr \( \( $ans + 0 \) \>= $min \) \& \( $ans \<= $max \) >/dev/null 2>&1 ; then
define_int "$2" "$ans"
break
# else
# help "$2"
# fi
done
}
function pint () {
old=$(eval echo "\${$2}")
def=${old:-$3}
if [ $# -gt 3 ]; then
min=$4
else
min=-10000000 # !!
fi
if [ $# -gt 4 ]; then
max=$5
else
max=10000000 # !!
fi
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
# if expr \( \( $ans + 0 \) \>= $min \) \& \( $ans \<= $max \) >/dev/null 2>&1 ; then
define_pint "$2" "$ans"
break
# else
# help "$2"
# fi
done
}
#
# define_hex sets the value of a hexadecimal argument
#
# define_hex define value
#
function define_hex () {
echo "$1=$2" >>$CONFIG
echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
eval "$1=$2"
}
function define_phex () {
echo "$1=$2" >>$CONFIG
echo "#define $1 0x${2#*[x,X]}" >>$CONFIG_H
eval "$1=$2"
}
function define_hex_ull () {
echo "$1=$2" >>$CONFIG
echo "#define $1 0x${2#*[x,X]}ULL" >>$CONFIG_H
eval "$1=$2"
}
#
# hex processes an hexadecimal argument
#
# hex question define default
#
function hex () {
old=$(eval echo "\${$2}")
def=${old:-$3}
def=${def#*[x,X]}
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
ans=${ans#*[x,X]}
if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
define_hex "$2" "$ans"
break
else
help "$2"
fi
done
}
function phex () {
old=$(eval echo "\${$2}")
def=${old:-$3}
def=${def#*[x,X]}
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
ans=${ans#*[x,X]}
if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
define_phex "$2" "$ans"
break
else
help "$2"
fi
done
}
function hex_ull () {
old=$(eval echo "\${$2}")
def=${old:-$3}
def=${def#*[x,X]}
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
ans=${ans#*[x,X]}
if expr "$ans" : '[0-9a-fA-F][0-9a-fA-F]*$' > /dev/null; then
define_hex_ull "$2" "$ans"
break
else
help "$2"
fi
done
}
#
# define_string sets the value of a string argument
#
# define_string define value
#
function define_string () {
echo "$1=\"$2\"" >>$CONFIG
echo "#define $1 \"$2\"" >>$CONFIG_H
eval "$1=\"$2\""
}
function define_pstring () {
echo "$1=\"$2\"" >>$CONFIG
echo "#define $1 $2" >>$CONFIG_H
eval "$1=\"$2\""
}
#
# string processes a string argument
#
# string question define default
#
function string () {
old=$(eval echo "\${$2}")
def=${old:-$3}
while :; do
if [ "$old" = "?" ]; then
readln "$1 ($2) [$def] " "$def" ""
else
readln "$1 ($2) [$def] " "$def" "$old"
fi
if [ "$ans" = "?" ]; then
help "$2"
else
break
fi
done
define_string "$2" "$ans"
}
function pstring () {
old=$(eval echo "\${$2}")
def=${old:-$3}
while :; do
if [ "$old" = "?" ]; then
readln "$1 ($2) [$def] " "$def" ""
else
readln "$1 ($2) [$def] " "$def" "$old"
fi
if [ "$ans" = "?" ]; then
help "$2"
else
break
fi
done
define_pstring "$2" "$ans"
}
#
# choice processes a choice list (1-out-of-n)
#
# choice question choice-list default
#
# The choice list has a syntax of:
# NAME WHITESPACE VALUE { WHITESPACE NAME WHITESPACE VALUE }
# The user may enter any unique prefix of one of the NAMEs and
# choice will define VALUE as if it were a boolean option.
# VALUE must be in all uppercase. Normally, VALUE is of the
# form CONFIG_<something>. Thus, if the user selects <something>,
# the CPP symbol CONFIG_<something> will be defined and the
# shell variable CONFIG_<something> will be set to "y".
#
function choice () {
question="$1"
choices="$2"
old=
def=$3
# determine default answer:
names=""
set -- $choices
firstvar=$2
while [ -n "$2" ]; do
if [ -n "$names" ]; then
names="$names, $1"
else
names="$1"
fi
if [ "$(eval echo \"\${$2}\")" = "y" ]; then
old=$1
def=$1
fi
shift; shift
done
val=""
while [ -z "$val" ]; do
ambg=n
readln "$question ($names) [$def] " "$def" "$old"
ans=$(echo $ans | tr a-z A-Z)
set -- $choices
while [ -n "$1" ]; do
name=$(echo $1 | tr a-z A-Z)
case "$name" in
"$ans"* | */"$ans"* )
case "$name" in
"$ans" | */"$ans"/* | \
"$ans"/* | */"$ans" )
val="$2"
break # exact match
;;
esac
if [ -n "$val" ]; then
echo;echo \
" Sorry, \"$ans\" is ambiguous; please enter a longer string."
echo
val=""
ambg=y
break
else
val="$2"
fi;;
esac
shift; shift
done
if [ "$val" = "" -a "$ambg" = "n" ]; then
help "$firstvar"
fi
done
set -- $choices
while [ -n "$2" ]; do
if [ "$2" = "$val" ]; then
echo " defined $val"
define_bool "$2" "y"
else
define_bool "$2" "n"
fi
shift; shift
done
}
CONFIG=.tmpconfig
CONFIG_H=.tmpconfig.h
trap "rm -f $CONFIG $CONFIG_H ; exit 1" 1 2
if [ -z "$HELP_FILE" ]
then
HELP_FILE="Documentation/Configure.help"
fi
#
# Make sure we start out with a clean slate.
#
echo "#" > $CONFIG
echo "# Automatically generated make config: don't edit" >> $CONFIG
echo "#" >> $CONFIG
echo "/*" > $CONFIG_H
echo " * Automatically generated C config: don't edit" >> $CONFIG_H
echo " */" >> $CONFIG_H
echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
DEFAULT=""
if [ "$1" = "-d" ] ; then
DEFAULT="-d"
shift
fi
CONFIG_IN=./config.in
if [ "$1" != "" ] ; then
CONFIG_IN=$1
fi
DEFAULTS=arch/$ARCH/defconfig
if [ -f .config ]; then
DEFAULTS=.config
fi
if [ -f $DEFAULTS ]; then
echo "#"
echo "# Using defaults found in" $DEFAULTS
echo "#"
. $PWD/$DEFAULTS
sed -e 's/# \(CONFIG_[^ ]*\) is not.*/\1=n/' <$DEFAULTS >.config-is-not.$$
. $PWD/.config-is-not.$$
rm $PWD/.config-is-not.$$
else
echo "#"
echo "# No defaults found"
echo "#"
fi
. $PWD/$CONFIG_IN
rm -f .config.old
if [ -f .config ]; then
mv .config .config.old
fi
mv .tmpconfig .config
if [ -w "`dirname ${AUTOCONF_FILE:=include/linux/autoconf.h}`" ]; then
mv .tmpconfig.h ${AUTOCONF_FILE:-include/linux/autoconf.h}
fi
echo ""; echo ""
echo "*** End of SDK configuration."
echo "*** Check the top-level Makefile for additional configuration."
#if [ ! -f .hdepend -o "$CONFIG_MODVERSIONS" = "y" ] ; then
# echo "*** Next, you must run 'make dep'."
#else
# echo "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'."
#fi
echo
exit 0

View file

@ -0,0 +1,39 @@
HEADER=header.tk
TAIL=tail.tk
# Previous versions always remade kconfig.tk because they always depended
# on soundscript. This runs fairly fast, and I can't find all the
# Config.in files to depend on anyways. So I'll force it to remake.
kconfig.tk: dummy
kconfig.tk: ${TOPDIR}/Makefile ${TOPDIR}/arch/${ARCH}/config.in \
tkparse ${HEADER} ${TAIL}
@if [ -f /usr/local/bin/wish ]; then \
echo '#!'"/usr/local/bin/wish -f" > kconfig.tk; \
else \
echo '#!'"/usr/bin/wish -f" > kconfig.tk; \
fi
cat ${HEADER} >> ./kconfig.tk
./tkparse < ../arch/${ARCH}/config.in >> kconfig.tk
echo "set defaults \"arch/${ARCH}/defconfig\"" >> kconfig.tk
echo "set ARCH \"${ARCH}\"" >> kconfig.tk
cat ${TAIL} >> kconfig.tk
chmod 755 kconfig.tk
tkparse: tkparse.o tkcond.o tkgen.o
${HOSTCC} -o tkparse tkparse.o tkcond.o tkgen.o
tkparse.o: tkparse.c tkparse.h
tkcond.o: tkcond.c tkparse.h
tkgen.o: tkgen.c tkparse.h
tkparse.o tkcond.o tkgen.o:
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $(@:.o=.c)
clean:
rm -f *~ kconfig.tk *.o tkparse
# include $(TOPDIR)/Rules.make

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,194 @@
Menuconfig gives the Linux kernel configuration a long needed face
lift. Featuring text based color menus and dialogs, it does not
require X Windows. With this utility you can easily select a kernel
option to modify without sifting through 100 other options.
Overview
--------
Some kernel features may be built directly into the kernel.
Some may be made into loadable runtime modules. Some features
may be completely removed altogether. There are also certain
kernel parameters which are not really features, but must be
entered in as decimal or hexadecimal numbers or possibly text.
Menu items beginning with [*], <M> or [ ] represent features
configured to be built in, modularized or removed respectively.
Pointed brackets <> represent module capable features.
more...
To change any of these features, highlight it with the cursor
keys and press <Y> to build it in, <M> to make it a module or
<N> to removed it. You may also press the <Space Bar> to cycle
through the available options (ie. Y->N->M->Y).
Items beginning with numbers or other text within parenthesis can
be changed by highlighting the item and pressing <Enter>. Then
enter the new parameter into the dialog box that pops up.
Some additional keyboard hints:
Menus
----------
o Use the Up/Down arrow keys (cursor keys) to highlight the item
you wish to change or submenu wish to select and press <Enter>.
Submenus are designated by "--->".
Shortcut: Press the option's highlighted letter (hotkey).
Pressing a hotkey more than once will sequence
through all visible items which use that hotkey.
You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll
unseen options into view.
o To exit a menu use the cursor keys to highlight the <Exit> button
and press <ENTER>.
Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey
using those letters. You may press a single <ESC>, but
there is a delayed response which you may find annoying.
Also, the <TAB> and cursor keys will cycle between <Select>,
<Exit> and <Help>
o To get help with an item, use the cursor keys to highlight <Help>
and Press <ENTER>.
Shortcut: Press <H> or <?>.
Radiolists (Choice lists)
-----------
o Use the cursor keys to select the option you wish to set and press
<S> or the <SPACE BAR>.
Shortcut: Press the first letter of the option you wish to set then
press <S> or <SPACE BAR>.
o To see available help for the item, use the cursor keys to highlight
<Help> and Press <ENTER>.
Shortcut: Press <H> or <?>.
Also, the <TAB> and cursor keys will cycle between <Select> and
<Help>
Data Entry
-----------
o Enter the requested information and press <ENTER>
If you are entering hexadecimal values, it is not necessary to
add the '0x' prefix to the entry.
o For help, use the <TAB> or cursor keys to highlight the help option
and press <ENTER>. You can try <TAB><H> as well.
Text Box (Help Window)
--------
o Use the cursor keys to scroll up/down/left/right. The VI editor
keys h,j,k,l function here as do <SPACE BAR> and <B> for those
who are familiar with less and lynx.
o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.
Final Acceptance
----------------
With the exception of the old style sound configuration,
YOUR CHANGES ARE NOT FINAL. You will be given a last chance to
confirm them prior to exiting Menuconfig.
If Menuconfig quits with an error while saving your configuration,
you may look in the file /usr/src/linux/.menuconfig.log for
information which may help you determine the cause.
Alternate Configuration Files
-----------------------------
Menuconfig supports the use of alternate configuration files for
those who, for various reasons, find it necessary to switch
between different kernel configurations.
At the end of the main menu you will find two options. One is
for saving the current configuration to a file of your choosing.
The other option is for loading a previously saved alternate
configuration.
Even if you don't use alternate configuration files, but you
find during a Menuconfig session that you have completely messed
up your settings, you may use the "Load Alternate..." option to
restore your previously saved settings from ".config" without
restarting Menuconfig.
Other information
-----------------
The windowing utility, lxdialog, will only be rebuilt if your kernel
source tree is fresh, or changes are patched into it via a kernel
patch or you do 'make mrproper'. If changes to lxdialog are patched
in, most likely the rebuild time will be short. You may force a
complete rebuild of lxdialog by changing to it's directory and doing
'make clean all'
If you use Menuconfig in an XTERM window make sure you have your
$TERM variable set to point to a xterm definition which supports color.
Otherwise, Menuconfig will look rather bad. Menuconfig will not
display correctly in a RXVT window because rxvt displays only one
intensity of color, bright.
Menuconfig will display larger menus on screens or xterms which are
set to display more than the standard 25 row by 80 column geometry.
In order for this to work, the "stty size" command must be able to
display the screen's current row and column geometry. I STRONGLY
RECOMMEND that you make sure you do NOT have the shell variables
LINES and COLUMNS exported into your environment. Some distributions
export those variables via /etc/profile. Some ncurses programs can
become confused when those variables (LINES & COLUMNS) don't reflect
the true screen size.
NOTICE: lxdialog requires the ncurses libraries to compile. If you
don't already have ncurses you really should get it.
The makefile for lxdialog attempts to find your ncurses
header file. Although it should find the header for older
versions of ncurses, it is probably a good idea to get the
latest ncurses anyway.
If you have upgraded your ncurses libraries, MAKE SURE you
remove the old ncurses header files. If you don't you
will most certainly get a segmentation fault.
WARNING: It is not recommended that you change any defines in
lxdialog's header files. If you have a grayscale display and
are brave, you may tinker with color.h to tune the colors to
your preference.
COMPATIBILITY ISSUE:
There have been some compatibility problems reported with
older versions of bash and sed. I am trying to work these
out but it is preferable that you upgrade those utilities.
******** IMPORTANT, OPTIONAL ALTERNATE PERSONALITY AVAILABLE ********
******** ********
If you prefer to have all of the kernel options listed in a single
menu, rather than the default multimenu hierarchy, you may edit the
Menuconfig script and change the line "single_menu_mode=" to
"single_menu_mode=TRUE".
This mode is not recommended unless you have a fairly fast machine.
*********************************************************************
Propaganda
----------
The windowing support utility (lxdialog) is a VERY modified version of
the dialog utility by Savio Lam <lam836@cs.cuhk.hk>. Although lxdialog
is significantly different from dialog, I have left Savio's copyrights
intact. Please DO NOT contact Savio with questions about lxdialog.
He will not be able to assist.
William Roadcap was the original author of Menuconfig.
Michael Elizabeth Chastain <mec@shout.net> is the current maintainer.
<END OF FILE>

View file

@ -0,0 +1,5 @@
Yes, this is a rip off of the 2.4 linux script directory, it allows
us to configure things even when we do not know the kernel version.
We can also hack these guys without hurting the kernel config.

View file

@ -0,0 +1 @@
Menuconfig requires bash

View file

@ -0,0 +1,640 @@
# FILE: header.tk
# This file is boilerplate TCL/TK function definitions for 'make xconfig'.
#
# CHANGES
# =======
#
# 8 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
# - Remove unused do_cmd function (part of the 2.0 sound support).
# - Arrange buttons in three columns for better screen fitting.
# - Add CONSTANT_Y, CONSTANT_M, CONSTANT_N for commands like:
# dep_tristate 'foo' CONFIG_FOO m
#
# 23 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
# - Shut vfix the hell up.
#
# 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
# - Improve the exit message (Jeff Ronne).
#
# This is a handy replacement for ".widget cget" that requires neither tk4
# nor additional source code uglification.
#
proc cget { w option } {
return "[lindex [$w configure $option] 4]"
}
#
# Function to compensate for broken config.in scripts like the sound driver,
# which make dependencies on variables that are never even conditionally
# defined.
#
proc vfix { var } {
global $var
if [ catch {eval concat $$var} ] {
set $var 4
}
}
#
# Constant values used by certain dep_tristate commands.
#
set CONSTANT_Y 1
set CONSTANT_M 2
set CONSTANT_N 0
set CONSTANT_E 4
#
# Create a "reference" object to steal colors from.
#
button .ref
#
# On monochrome displays, -disabledforeground is blank by default; that's
# bad. Fill it with -foreground instead.
#
if { [cget .ref -disabledforeground] == "" } {
.ref configure -disabledforeground [cget .ref -foreground]
}
#
# Define some macros we will need to parse the config.in file.
#
proc mainmenu_name { text } {
wm title . "$text"
}
proc menu_option { w menu_num text } {
global menus_per_column
global processed_top_level
set processed_top_level [expr $processed_top_level + 1]
if { $processed_top_level <= $menus_per_column } then {
set myframe left
} elseif { $processed_top_level <= [expr 2 * $menus_per_column] } then {
set myframe middle
} else {
set myframe right
}
button .f0.x$menu_num -anchor w -text "$text" \
-command "$w .$w \"$text\""
pack .f0.x$menu_num -pady 0 -side top -fill x -in .f0.$myframe
}
proc load_configfile { w title func } {
catch {destroy $w}
toplevel $w -class Dialog
global loadfile
frame $w.x
label $w.bm -bitmap questhead
pack $w.bm -pady 10 -side top -padx 10
label $w.x.l -text "Enter filename:" -relief raised
entry $w.x.x -width 35 -relief sunken -borderwidth 2 \
-textvariable loadfile
pack $w.x.l $w.x.x -anchor w -side left
pack $w.x -side top -pady 10
wm title $w "$title"
set oldFocus [focus]
frame $w.f
button $w.f.back -text "OK" -width 20 \
-command "destroy $w; focus $oldFocus;$func .fileio"
button $w.f.canc -text "Cancel" \
-width 20 -command "destroy $w; focus $oldFocus"
pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
pack $w.f -pady 10 -side bottom -padx 10 -anchor w
focus $w
global winx; global winy
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
wm geometry $w +$winx+$winy
}
bind all <Alt-q> {maybe_exit .maybe}
proc maybe_exit { w } {
catch {destroy $w}
toplevel $w -class Dialog
label $w.bm -bitmap questhead
pack $w.bm -pady 10 -side top -padx 10
message $w.m -width 400 -aspect 300 \
-text "Changes will be lost. Are you sure?" -relief flat
pack $w.m -pady 10 -side top -padx 10
wm title $w "Are you sure?"
set oldFocus [focus]
frame $w.f
button $w.f.back -text "OK" -width 20 \
-command "exit"
button $w.f.canc -text "Cancel" \
-width 20 -command "destroy $w; focus $oldFocus"
pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
pack $w.f -pady 10 -side bottom -padx 10 -anchor w
bind $w <Return> "exit"
bind $w <Escape> "destroy $w; focus $oldFocus"
focus $w
global winx; global winy
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
wm geometry $w +$winx+$winy
}
proc read_config_file { w } {
global loadfile
if { [string length $loadfile] != 0 && [file readable $loadfile] == 1 } then {
read_config $loadfile
} else {
catch {destroy $w}
toplevel $w -class Dialog
message $w.m -width 400 -aspect 300 -text \
"Unable to read file $loadfile" \
-relief raised
label $w.bm -bitmap error
pack $w.bm $w.m -pady 10 -side top -padx 10
wm title $w "Xconfig Internal Error"
set oldFocus [focus]
frame $w.f
button $w.f.back -text "Bummer" \
-width 10 -command "destroy $w; focus $oldFocus"
pack $w.f.back -side bottom -pady 10 -anchor s
pack $w.f -pady 10 -side top -padx 10 -anchor s
focus $w
global winx; global winy
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
wm geometry $w +$winx+$winy
}
}
proc write_config_file { w } {
global loadfile
if { [string length $loadfile] != 0
&& ([file writable $loadfile] == 1 || ([file exists $loadfile] == 0 && [file writable [file dirname $loadfile]] == 1)) } then {
writeconfig $loadfile /dev/null
} else {
catch {destroy $w}
toplevel $w -class Dialog
message $w.m -width 400 -aspect 300 -text \
"Unable to write file $loadfile" \
-relief raised
label $w.bm -bitmap error
pack $w.bm $w.m -pady 10 -side top -padx 10
wm title $w "Xconfig Internal Error"
set oldFocus [focus]
frame $w.f
button $w.f.back -text "OK" \
-width 10 -command "destroy $w; focus $oldFocus"
pack $w.f.back -side bottom -pady 10 -anchor s
pack $w.f -pady 10 -side top -padx 10 -anchor s
focus $w
global winx; global winy
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
wm geometry $w +$winx+$winy
}
}
proc read_config { filename } {
set file1 [open $filename r]
clear_choices
while { [gets $file1 line] >= 0} {
if [regexp {([0-9A-Za-z_]+)=([ynm])} $line foo var value] {
if { $value == "y" } then { set cmd "global $var; set $var 1" }
if { $value == "n" } then { set cmd "global $var; set $var 0" }
if { $value == "m" } then { set cmd "global $var; set $var 2" }
eval $cmd
}
if [regexp {# ([0-9A-Za-z_]+) is not set} $line foo var] {
set cmd "global $var; set $var 0"
eval $cmd
}
if [regexp {([0-9A-Za-z_]+)=([0-9A-Fa-f]+)} $line foo var value] {
set cmd "global $var; set $var $value"
eval $cmd
}
if [regexp {([0-9A-Za-z_]+)="([^"]*)"} $line foo var value] {
set cmd "global $var; set $var \"$value\""
eval $cmd
}
}
close $file1
update_choices
update_mainmenu
}
proc write_comment { file1 file2 text } {
puts $file1 ""
puts $file1 "#"
puts $file1 "# $text"
puts $file1 "#"
puts $file2 "/*"
puts $file2 " * $text"
puts $file2 " */"
}
proc effective_dep { deplist } {
global CONFIG_MODULES
set depend 1
foreach i $deplist {
if {$i == 0} then {set depend 0}
if {$i == 2 && $depend == 1} then {set depend 2}
}
if {$depend == 2 && $CONFIG_MODULES == 0} then {set depend 0}
return $depend
}
proc sync_tristate { var dep } {
global CONFIG_MODULES
if {$dep == 0 && ($var == 1 || $var == 2)} then {
set var 0
} elseif {$dep == 2 && $var == 1} then {
set var 2
} elseif {$var == 2 && $CONFIG_MODULES == 0} then {
if {$dep == 1} then {set var 1} else {set var 0}
}
return $var
}
proc sync_bool { var dep modset } {
set var [sync_tristate $var $dep]
if {$dep == 2 && $var == 2} then {
set var $modset
}
return $var
}
proc write_tristate { file1 file2 varname variable deplist modset } {
set variable [sync_tristate $variable [effective_dep $deplist]]
if { $variable == 2 } \
then { set variable $modset }
if { $variable == 1 } \
then { puts $file1 "$varname=y"; \
puts $file2 "#define $varname 1" } \
elseif { $variable == 2 } \
then { puts $file1 "$varname=m"; \
puts $file2 "#undef $varname"; \
puts $file2 "#define ${varname}_MODULE 1" } \
elseif { $variable == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
else { \
puts stdout "ERROR - Attempting to write value for unconfigured variable ($varname)." \
}
}
proc write_int { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=$variable"; \
puts $file2 "#define $varname ($variable)"; \
}
}
proc write_hex { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=$variable"; \
puts -nonewline $file2 "#define $varname 0x"; \
puts $file2 [exec echo $variable | sed s/^0\[xX\]//]; \
}
}
proc write_string { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=\"$variable\""; \
puts $file2 "#define $varname \"$variable\""; \
}
}
proc option_name {w mnum line text helpidx} {
button $w.x$line.l -text "$text" -relief groove -anchor w
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
-activeback [cget $w.x$line.l -bg]
button $w.x$line.help -text "Help" -relief raised \
-command "dohelp .dohelp $helpidx .menu$mnum"
pack $w.x$line.help -side right -fill y
pack $w.x$line.l -side right -fill both -expand on
}
proc toggle_switch2 {w mnum line text variable} {
frame $w.x$line -relief sunken
radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
-relief groove -width 2 -command "update_active"
radiobutton $w.x$line.m -text "-" -variable $variable -value 2 \
-relief groove -width 2 -command "update_active"
radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
-relief groove -width 2 -command "update_active"
option_name $w $mnum $line $text $variable
pack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y
}
proc toggle_switch3 {w mnum line text variable} {
frame $w.x$line -relief sunken
radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
-relief groove -width 2 -command "update_active"
radiobutton $w.x$line.m -text "m" -variable $variable -value 2 \
-relief groove -width 2 -command "update_active"
radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
-relief groove -width 2 -command "update_active"
option_name $w $mnum $line $text $variable
global CONFIG_MODULES
if {($CONFIG_MODULES == 0)} then {
$w.x$line.m configure -state disabled
}
pack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y
}
proc bool {w mnum line text variable} {
toggle_switch2 $w $mnum $line $text $variable
$w.x$line.m configure -state disabled
pack $w.x$line -anchor w -fill both -expand on
}
proc tristate {w mnum line text variable } {
toggle_switch3 $w $mnum $line $text $variable
pack $w.x$line -anchor w -fill both -expand on
}
proc dep_tristate {w mnum line text variable } {
tristate $w $mnum $line $text $variable
}
proc dep_bool {w mnum line text variable } {
bool $w $mnum $line $text $variable
}
proc int { w mnum line text variable } {
frame $w.x$line
entry $w.x$line.x -width 18 -relief sunken -borderwidth 2 \
-textvariable $variable
option_name $w $mnum $line $text $variable
pack $w.x$line.x -anchor w -side right -fill y
pack $w.x$line -anchor w -fill both -expand on
}
proc hex { w mnum line text variable } {
int $w $mnum $line $text $variable
}
proc istring { w mnum line text variable } {
frame $w.x$line
entry $w.x$line.x -width 18 -relief sunken -borderwidth 2 \
-textvariable $variable
option_name $w $mnum $line $text $variable
pack $w.x$line.x -anchor w -side right -fill y
pack $w.x$line -anchor w -fill both -expand on
}
proc minimenu { w mnum line text variable helpidx } {
frame $w.x$line
menubutton $w.x$line.x -textvariable $variable -menu \
$w.x$line.x.menu -relief raised \
-anchor w
option_name $w $mnum $line $text $helpidx
pack $w.x$line.x -anchor w -side right -fill y
pack $w.x$line -anchor w -fill both -expand on
}
proc menusplit {w m n} {
if { $n > 2 } then {
update idletasks
set menuoptsize [expr [$m yposition 2] - [$m yposition 1]]
set maxsize [winfo screenheight $w]
set splitpoint [expr $maxsize * 4 / 5 / $menuoptsize - 1]
for {set i [expr $splitpoint + 1]} {$i <= $n} {incr i $splitpoint} {
$m entryconfigure $i -columnbreak 1
}
}
}
proc menutitle {text menu w} {
wm title $w "$text"
}
proc submenu { w mnum line text subnum } {
frame $w.x$line
button $w.x$line.l -text "" -width 15 -relief groove
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
-activeback [cget $w.x$line.l -bg] -state disabled
button $w.x$line.m -text "$text" -relief raised -anchor w \
-command "catch {destroy .menu$subnum}; menu$subnum .menu$subnum \"$text\""
pack $w.x$line.l -side left -fill both
pack $w.x$line.m -anchor w -side right -fill both -expand on
pack $w.x$line -anchor w -fill both -expand on
}
proc comment {w mnum line text } {
frame $w.x$line
button $w.x$line.l -text "" -width 15 -relief groove
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
-activeback [cget $w.x$line.l -bg] -state disabled
button $w.x$line.m -text "$text" -relief groove -anchor w
$w.x$line.m configure -activefore [cget $w.x$line.m -fg] \
-activeback [cget $w.x$line.m -bg]
pack $w.x$line.l -side left -fill both
pack $w.x$line.m -anchor w -side right -fill both -expand on
pack $w.x$line -anchor w -fill both -expand on
}
proc dohelp {w var parent} {
catch {destroy $w}
toplevel $w -class Dialog
set filefound 0
set found 0
set lineno 0
global help_file
if { [file readable $help_file ] == 1} then {
set filefound 1
# First escape sed regexp special characters in var:
set var [exec echo "$var" | sed s/\[\]\[\/.^$*\]/\\\\&/g]
# Now pick out right help text:
set message [exec sed -n "
/^$var\[ \]*\$/,\${
/^$var\[ \]*\$/c\\
${var}:\\
/^#/b
/^\[^ \]/q
s/^ //
p
}
" $help_file ]
set found [expr [string length "$message"] > 0]
}
frame $w.f1
pack $w.f1 -fill both -expand on
# Do the OK button
#
set oldFocus [focus]
frame $w.f2
button $w.f2.ok -text "OK" \
-width 10 -command "destroy $w; catch {focus $oldFocus}"
pack $w.f2.ok -side bottom -pady 6 -anchor n
pack $w.f2 -side bottom -padx 10 -anchor s
scrollbar $w.f1.vscroll -command "$w.f1.canvas yview"
pack $w.f1.vscroll -side right -fill y
canvas $w.f1.canvas -relief flat -borderwidth 0 \
-yscrollcommand "$w.f1.vscroll set"
frame $w.f1.f
pack $w.f1.canvas -side right -fill y -expand on
if { $found == 0 } then {
if { $filefound == 0 } then {
message $w.f1.f.m -width 750 -aspect 300 -relief flat -text \
"No help available - unable to open file $help_file. This file should have come with your distribution."
} else {
message $w.f1.f.m -width 400 -aspect 300 -relief flat -text \
"No help available for $var"
}
label $w.f1.bm -bitmap error
wm title $w "RTFM"
} else {
text $w.f1.f.m -width 73 -relief flat -wrap word
$w.f1.f.m insert 0.0 $message
$w.f1.f.m conf -state disabled -height [$w.f1.f.m index end]
label $w.f1.bm -bitmap info
wm title $w "Configuration help"
}
pack $w.f1.f.m -side left
pack $w.f1.bm $w.f1.f -side left -padx 10
focus $w
set winx [expr [winfo x $parent]+20]
set winy [expr [winfo y $parent]+20]
wm geometry $w +$winx+$winy
set sizok [expr [winfo reqheight $w.f2.ok] + 12]
set maxy [expr [winfo screenheight .] * 3 / 4]
set canvtotal [winfo reqheight $w.f1.f.m]
if [expr $sizok + $canvtotal < $maxy] {
set sizy $canvtotal
} else {
set sizy [expr $maxy - $sizok]
}
$w.f1.canvas configure -height $sizy -width [winfo reqwidth $w.f1.f.m] \
-scrollregion "0 0 [winfo reqwidth $w.f1.f.m] \
[winfo reqheight $w.f1.f.m]"
$w.f1.canvas create window 0 0 -anchor nw -window $w.f1.f
update idletasks
set maxy [winfo screenheight .]
if [expr $sizok + $canvtotal < $maxy] {
set sizy [expr $sizok + $canvtotal]
} else {
set sizy $maxy
}
wm maxsize $w [winfo width $w] $sizy
}
bind all <Alt-s> { catch {exec cp -f .config .config.old}; \
writeconfig .config include/linux/autoconf.h; wrapup .wrap }
proc wrapup {w } {
catch {destroy $w}
toplevel $w -class Dialog
global CONFIG_MODVERSIONS; vfix CONFIG_MODVERSIONS
if { ([file exists .hdepend] != 1) || ($CONFIG_MODVERSIONS == 1) } then {
message $w.m -width 400 -aspect 300 -relief raised -text \
"End of Linux kernel configuration. Check the top-level Makefile for additional configuration. Next, you must run 'make dep'."
} else {
message $w.m -width 400 -aspect 300 -relief raised -text \
"End of Linux kernel configuration. Check the top-level Makefile for additional configuration. Next, you may 'make bzImage', 'make bzdisk', or 'make bzlilo.'"
}
label $w.bm -bitmap info
pack $w.bm $w.m -pady 10 -side top -padx 10
wm title $w "Kernel build instructions"
set oldFocus [focus]
frame $w.f
button $w.f.back -text "OK" \
-width 10 -command "exit"
pack $w.f.back -side bottom -pady 10 -anchor s
pack $w.f -pady 10 -side top -padx 10 -anchor s
focus $w
bind $w <Return> "exit"
global winx; global winy
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
wm geometry $w +$winx+$winy
}
proc unregister_active {num} {
global active_menus
set index [lsearch -exact $active_menus $num]
if {$index != -1} then {set active_menus [lreplace $active_menus $index $index]}
}
proc update_active {} {
global active_menus total_menus
set max 0
if {[llength $active_menus] > 0} then {
set max [lindex $active_menus end]
update_define [toplevel_menu [lindex $active_menus 0]] $max 0
}
foreach i $active_menus {
if {[winfo exists .menu$i] == 0} then {
unregister_active $i
} else {
update_menu$i
}
}
update_define [expr $max + 1] $total_menus 1
update_mainmenu
}
proc configure_entry {w option items} {
foreach i $items {
$w.$i configure -state $option
}
}
proc validate_int {name val default} {
if {([exec echo $val | sed s/^-//g | tr -d \[:digit:\] ] != "")} then {
global $name; set $name $default
}
}
proc validate_hex {name val default} {
if {([exec echo $val | tr -d \[:xdigit:\] ] != "")} then {
global $name; set $name $default
}
}
proc update_define {first last allow_update} {
for {set i $first} {$i <= $last} {incr i} {
update_define_menu$i
if {$allow_update == 1} then update
}
}
#
# Next set up the particulars for the top level menu, and define a few
# buttons which we will stick down at the bottom.
#
frame .f0
frame .f0.left
frame .f0.middle
frame .f0.right
set active_menus [list]
set processed_top_level 0
set autoconf_file ""
set help_file ""

View file

@ -0,0 +1,4 @@
This is NOT the official version of dialog. This version has been
significantly modified from the original. It is for use by the Linux
kernel configuration script. Please do not bother Savio Lam with
questions about this program.

View file

@ -0,0 +1,47 @@
HOSTCFLAGS += -DLOCALE
LIBS = -lncurses
ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
HOSTCFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
else
ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
HOSTCFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
else
ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
HOSTCFLAGS += -DCURSES_LOC="<ncurses.h>"
else
HOSTCFLAGS += -DCURSES_LOC="<curses.h>"
endif
endif
endif
HOSTCC = gcc
OBJS = checklist.o menubox.o textbox.o yesno.o inputbox.o \
util.o lxdialog.o msgbox.o
%.o: %.c
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
all: ncurses lxdialog
lxdialog: $(OBJS)
$(HOSTCC) -o lxdialog $(OBJS) $(LIBS)
ncurses:
@echo "main() {}" > lxtemp.c
@if $(HOSTCC) -lncurses lxtemp.c ; then \
rm -f lxtemp.c a.out; \
else \
rm -f lxtemp.c; \
echo -e "\007" ;\
echo ">> Unable to find the Ncurses libraries." ;\
echo ">>" ;\
echo ">> You must have Ncurses installed in order" ;\
echo ">> to use 'make menuconfig'" ;\
echo ;\
exit 1 ;\
fi
clean:
rm -f core *.o *~ lxdialog

View file

@ -0,0 +1,373 @@
/*
* checklist.c -- implements the checklist box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension
* Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
static int list_width, check_x, item_x, checkflag;
/*
* Print list item
*/
static void
print_item (WINDOW * win, const char *item, int status,
int choice, int selected)
{
int i;
/* Clear 'residue' of last item */
wattrset (win, menubox_attr);
wmove (win, choice, 0);
for (i = 0; i < list_width; i++)
waddch (win, ' ');
wmove (win, choice, check_x);
wattrset (win, selected ? check_selected_attr : check_attr);
if (checkflag == FLAG_CHECK)
wprintw (win, "[%c]", status ? 'X' : ' ');
else
wprintw (win, "(%c)", status ? 'X' : ' ');
wattrset (win, selected ? tag_selected_attr : tag_attr);
mvwaddch(win, choice, item_x, item[0]);
wattrset (win, selected ? item_selected_attr : item_attr);
waddstr (win, (char *)item+1);
}
/*
* Print the scroll indicators.
*/
static void
print_arrows (WINDOW * win, int choice, int item_no, int scroll,
int y, int x, int height)
{
wmove(win, y, x);
if (scroll > 0) {
wattrset (win, uarrow_attr);
waddch (win, ACS_UARROW);
waddstr (win, "(-)");
}
else {
wattrset (win, menubox_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
}
y = y + height + 1;
wmove(win, y, x);
if ((height < item_no) && (scroll + choice < item_no - 1)) {
wattrset (win, darrow_attr);
waddch (win, ACS_DARROW);
waddstr (win, "(+)");
}
else {
wattrset (win, menubox_border_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
}
}
/*
* Display the termination buttons
*/
static void
print_buttons( WINDOW *dialog, int height, int width, int selected)
{
int x = width / 2 - 11;
int y = height - 2;
print_button (dialog, "Select", y, x, selected == 0);
print_button (dialog, " Help ", y, x + 14, selected == 1);
wmove(dialog, y, x+1 + 14*selected);
wrefresh (dialog);
}
/*
* Display a dialog box with a list of options that can be turned on or off
* The `flag' parameter is used to select between radiolist and checklist.
*/
int
dialog_checklist (const char *title, const char *prompt, int height, int width,
int list_height, int item_no, const char * const * items, int flag)
{
int i, x, y, box_x, box_y;
int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
WINDOW *dialog, *list;
checkflag = flag;
/* Allocate space for storing item on/off status */
if ((status = malloc (sizeof (int) * item_no)) == NULL) {
endwin ();
fprintf (stderr,
"\nCan't allocate memory in dialog_checklist().\n");
exit (-1);
}
/* Initializes status */
for (i = 0; i < item_no; i++)
{
status[i] = !strcasecmp (items[i * 3 + 2], "on");
if (!choice && status[i])
choice = i;
}
max_choice = MIN (list_height, item_no);
/* center dialog box on screen */
x = (COLS - width) / 2;
y = (LINES - height) / 2;
draw_shadow (stdscr, y, x, height, width);
dialog = newwin (height, width, y, x);
keypad (dialog, TRUE);
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 )
{
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL)
{
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 3);
list_width = width - 6;
box_y = height - list_height - 5;
box_x = (width - list_width) / 2 - 1;
/* create new window for the list */
list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1);
keypad (list, TRUE);
/* draw a box around the list items */
draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2,
menubox_border_attr, menubox_attr);
/* Find length of longest item in order to center checklist */
check_x = 0;
for (i = 0; i < item_no; i++)
check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4);
check_x = (list_width - check_x) / 2;
item_x = check_x + 4;
if (choice >= list_height) {
scroll = choice - list_height + 1;
choice -= scroll;
}
/* Print the list */
for (i = 0; i < max_choice; i++) {
print_item (list, items[(scroll+i) * 3 + 1],
status[i+scroll], i, i == choice);
}
wnoutrefresh (list);
print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height);
print_buttons(dialog, height, width, 0);
while (key != ESC)
{
key = wgetch (dialog);
for (i = 0; i < max_choice; i++)
if (toupper(key) == toupper(items[(scroll+i)*3+1][0]))
break;
if ( i < max_choice || key == KEY_UP || key == KEY_DOWN
|| key == '+' || key == '-' )
{
if (key == KEY_UP || key == '-')
{
if (!choice)
{
if (!scroll)
continue;
/* Scroll list down */
if (list_height > 1)
{
/* De-highlight current first item */
print_item (list, items[scroll * 3 + 1],
status[scroll], 0, FALSE);
scrollok (list, TRUE);
wscrl (list, -1);
scrollok (list, FALSE);
}
scroll--;
print_item (list, items[scroll * 3 + 1],
status[scroll], 0, TRUE);
wnoutrefresh (list);
print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height);
wrefresh (dialog);
continue; /* wait for another key press */
}
else
i = choice - 1;
}
else if (key == KEY_DOWN || key == '+')
{
if (choice == max_choice - 1)
{
if (scroll + choice >= item_no - 1)
continue;
/* Scroll list up */
if (list_height > 1)
{
/* De-highlight current last item before scrolling up */
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
status[scroll + max_choice - 1],
max_choice - 1, FALSE);
scrollok (list, TRUE);
scroll (list);
scrollok (list, FALSE);
}
scroll++;
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
status[scroll + max_choice - 1],
max_choice - 1, TRUE);
wnoutrefresh (list);
print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height);
wrefresh (dialog);
continue; /* wait for another key press */
}
else
i = choice + 1;
}
if (i != choice)
{
/* De-highlight current item */
print_item (list, items[(scroll + choice) * 3 + 1],
status[scroll + choice], choice, FALSE);
/* Highlight new item */
choice = i;
print_item (list, items[(scroll + choice) * 3 + 1],
status[scroll + choice], choice, TRUE);
wnoutrefresh (list);
wrefresh (dialog);
}
continue; /* wait for another key press */
}
switch (key) {
case 'H':
case 'h':
case '?':
delwin (dialog);
free (status);
return 1;
case TAB:
case KEY_LEFT:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 1 : (button > 1 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh (dialog);
break;
case 'S':
case 's':
case ' ':
case '\n':
if (!button) {
if (flag == FLAG_CHECK) {
status[scroll + choice] = !status[scroll + choice];
wmove (list, choice, check_x);
wattrset (list, check_selected_attr);
wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' ');
} else {
if (!status[scroll + choice]) {
for (i = 0; i < item_no; i++)
status[i] = 0;
status[scroll + choice] = 1;
for (i = 0; i < max_choice; i++)
print_item (list, items[(scroll + i) * 3 + 1],
status[scroll + i], i, i == choice);
}
}
wnoutrefresh (list);
wrefresh (dialog);
for (i = 0; i < item_no; i++) {
if (status[i]) {
if (flag == FLAG_CHECK) {
fprintf (stderr, "\"%s\" ", items[i * 3]);
} else {
fprintf (stderr, "%s", items[i * 3]);
}
}
}
}
delwin (dialog);
free (status);
return button;
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
}
delwin (dialog);
free (status);
return -1; /* ESC pressed */
}

View file

@ -0,0 +1,161 @@
/*
* colors.h -- color attribute definitions
*
* AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Default color definitions
*
* *_FG = foreground
* *_BG = background
* *_HL = highlight?
*/
#define SCREEN_FG COLOR_CYAN
#define SCREEN_BG COLOR_BLUE
#define SCREEN_HL TRUE
#define SHADOW_FG COLOR_BLACK
#define SHADOW_BG COLOR_BLACK
#define SHADOW_HL TRUE
#define DIALOG_FG COLOR_BLACK
#define DIALOG_BG COLOR_WHITE
#define DIALOG_HL FALSE
#define TITLE_FG COLOR_YELLOW
#define TITLE_BG COLOR_WHITE
#define TITLE_HL TRUE
#define BORDER_FG COLOR_WHITE
#define BORDER_BG COLOR_WHITE
#define BORDER_HL TRUE
#define BUTTON_ACTIVE_FG COLOR_WHITE
#define BUTTON_ACTIVE_BG COLOR_BLUE
#define BUTTON_ACTIVE_HL TRUE
#define BUTTON_INACTIVE_FG COLOR_BLACK
#define BUTTON_INACTIVE_BG COLOR_WHITE
#define BUTTON_INACTIVE_HL FALSE
#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE
#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE
#define BUTTON_KEY_ACTIVE_HL TRUE
#define BUTTON_KEY_INACTIVE_FG COLOR_RED
#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE
#define BUTTON_KEY_INACTIVE_HL FALSE
#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW
#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE
#define BUTTON_LABEL_ACTIVE_HL TRUE
#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK
#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE
#define BUTTON_LABEL_INACTIVE_HL TRUE
#define INPUTBOX_FG COLOR_BLACK
#define INPUTBOX_BG COLOR_WHITE
#define INPUTBOX_HL FALSE
#define INPUTBOX_BORDER_FG COLOR_BLACK
#define INPUTBOX_BORDER_BG COLOR_WHITE
#define INPUTBOX_BORDER_HL FALSE
#define SEARCHBOX_FG COLOR_BLACK
#define SEARCHBOX_BG COLOR_WHITE
#define SEARCHBOX_HL FALSE
#define SEARCHBOX_TITLE_FG COLOR_YELLOW
#define SEARCHBOX_TITLE_BG COLOR_WHITE
#define SEARCHBOX_TITLE_HL TRUE
#define SEARCHBOX_BORDER_FG COLOR_WHITE
#define SEARCHBOX_BORDER_BG COLOR_WHITE
#define SEARCHBOX_BORDER_HL TRUE
#define POSITION_INDICATOR_FG COLOR_YELLOW
#define POSITION_INDICATOR_BG COLOR_WHITE
#define POSITION_INDICATOR_HL TRUE
#define MENUBOX_FG COLOR_BLACK
#define MENUBOX_BG COLOR_WHITE
#define MENUBOX_HL FALSE
#define MENUBOX_BORDER_FG COLOR_WHITE
#define MENUBOX_BORDER_BG COLOR_WHITE
#define MENUBOX_BORDER_HL TRUE
#define ITEM_FG COLOR_BLACK
#define ITEM_BG COLOR_WHITE
#define ITEM_HL FALSE
#define ITEM_SELECTED_FG COLOR_WHITE
#define ITEM_SELECTED_BG COLOR_BLUE
#define ITEM_SELECTED_HL TRUE
#define TAG_FG COLOR_YELLOW
#define TAG_BG COLOR_WHITE
#define TAG_HL TRUE
#define TAG_SELECTED_FG COLOR_YELLOW
#define TAG_SELECTED_BG COLOR_BLUE
#define TAG_SELECTED_HL TRUE
#define TAG_KEY_FG COLOR_YELLOW
#define TAG_KEY_BG COLOR_WHITE
#define TAG_KEY_HL TRUE
#define TAG_KEY_SELECTED_FG COLOR_YELLOW
#define TAG_KEY_SELECTED_BG COLOR_BLUE
#define TAG_KEY_SELECTED_HL TRUE
#define CHECK_FG COLOR_BLACK
#define CHECK_BG COLOR_WHITE
#define CHECK_HL FALSE
#define CHECK_SELECTED_FG COLOR_WHITE
#define CHECK_SELECTED_BG COLOR_BLUE
#define CHECK_SELECTED_HL TRUE
#define UARROW_FG COLOR_GREEN
#define UARROW_BG COLOR_WHITE
#define UARROW_HL TRUE
#define DARROW_FG COLOR_GREEN
#define DARROW_BG COLOR_WHITE
#define DARROW_HL TRUE
/* End of default color definitions */
#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y)))
#define COLOR_NAME_LEN 10
#define COLOR_COUNT 8
/*
* Global variables
*/
typedef struct {
char name[COLOR_NAME_LEN];
int value;
} color_names_st;
extern color_names_st color_names[];
extern int color_table[][3];

View file

@ -0,0 +1,184 @@
/*
* dialog.h -- common declarations for all dialog modules
*
* AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include CURSES_LOC
/*
* Colors in ncurses 1.9.9e do not work properly since foreground and
* background colors are OR'd rather than separately masked. This version
* of dialog was hacked to work with ncurses 1.9.9e, making it incompatible
* with standard curses. The simplest fix (to make this work with standard
* curses) uses the wbkgdset() function, not used in the original hack.
* Turn it off if we're building with 1.9.9e, since it just confuses things.
*/
#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
#define OLD_NCURSES 1
#undef wbkgdset
#define wbkgdset(w,p) /*nothing*/
#else
#define OLD_NCURSES 0
#endif
#define TR(params) _tracef params
#define ESC 27
#define TAB 9
#define MAX_LEN 2048
#define BUF_SIZE (10*1024)
#define MIN(x,y) (x < y ? x : y)
#define MAX(x,y) (x > y ? x : y)
#ifndef ACS_ULCORNER
#define ACS_ULCORNER '+'
#endif
#ifndef ACS_LLCORNER
#define ACS_LLCORNER '+'
#endif
#ifndef ACS_URCORNER
#define ACS_URCORNER '+'
#endif
#ifndef ACS_LRCORNER
#define ACS_LRCORNER '+'
#endif
#ifndef ACS_HLINE
#define ACS_HLINE '-'
#endif
#ifndef ACS_VLINE
#define ACS_VLINE '|'
#endif
#ifndef ACS_LTEE
#define ACS_LTEE '+'
#endif
#ifndef ACS_RTEE
#define ACS_RTEE '+'
#endif
#ifndef ACS_UARROW
#define ACS_UARROW '^'
#endif
#ifndef ACS_DARROW
#define ACS_DARROW 'v'
#endif
/*
* Attribute names
*/
#define screen_attr attributes[0]
#define shadow_attr attributes[1]
#define dialog_attr attributes[2]
#define title_attr attributes[3]
#define border_attr attributes[4]
#define button_active_attr attributes[5]
#define button_inactive_attr attributes[6]
#define button_key_active_attr attributes[7]
#define button_key_inactive_attr attributes[8]
#define button_label_active_attr attributes[9]
#define button_label_inactive_attr attributes[10]
#define inputbox_attr attributes[11]
#define inputbox_border_attr attributes[12]
#define searchbox_attr attributes[13]
#define searchbox_title_attr attributes[14]
#define searchbox_border_attr attributes[15]
#define position_indicator_attr attributes[16]
#define menubox_attr attributes[17]
#define menubox_border_attr attributes[18]
#define item_attr attributes[19]
#define item_selected_attr attributes[20]
#define tag_attr attributes[21]
#define tag_selected_attr attributes[22]
#define tag_key_attr attributes[23]
#define tag_key_selected_attr attributes[24]
#define check_attr attributes[25]
#define check_selected_attr attributes[26]
#define uarrow_attr attributes[27]
#define darrow_attr attributes[28]
/* number of attributes */
#define ATTRIBUTE_COUNT 29
/*
* Global variables
*/
extern bool use_colors;
extern bool use_shadow;
extern chtype attributes[];
extern const char *backtitle;
/*
* Function prototypes
*/
extern void create_rc (const char *filename);
extern int parse_rc (void);
void init_dialog (void);
void end_dialog (void);
void attr_clear (WINDOW * win, int height, int width, chtype attr);
void dialog_clear (void);
void color_setup (void);
void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x);
void print_button (WINDOW * win, const char *label, int y, int x, int selected);
void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box,
chtype border);
void draw_shadow (WINDOW * win, int y, int x, int height, int width);
int first_alpha (const char *string, const char *exempt);
int dialog_yesno (const char *title, const char *prompt, int height, int width);
int dialog_msgbox (const char *title, const char *prompt, int height,
int width, int pause);
int dialog_textbox (const char *title, const char *file, int height, int width);
int dialog_menu (const char *title, const char *prompt, int height, int width,
int menu_height, const char *choice, int item_no,
const char * const * items);
int dialog_checklist (const char *title, const char *prompt, int height,
int width, int list_height, int item_no,
const char * const * items, int flag);
extern unsigned char dialog_input_result[];
int dialog_inputbox (const char *title, const char *prompt, int height,
int width, const char *init);
/*
* This is the base for fictitious keys, which activate
* the buttons.
*
* Mouse-generated keys are the following:
* -- the first 32 are used as numbers, in addition to '0'-'9'
* -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
* -- uppercase chars are used to invoke the button (M_EVENT + 'O')
*/
#define M_EVENT (KEY_MAX+1)
/*
* The `flag' parameter in checklist is used to select between
* radiolist and checklist
*/
#define FLAG_CHECK 1
#define FLAG_RADIO 0

View file

@ -0,0 +1,258 @@
/*
* inputbox.c -- implements the input box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
unsigned char dialog_input_result[MAX_LEN + 1];
/*
* Print the termination buttons
*/
static void
print_buttons(WINDOW *dialog, int height, int width, int selected)
{
int x = width / 2 - 11;
int y = height - 2;
print_button (dialog, " Ok ", y, x, selected==0);
print_button (dialog, " Help ", y, x + 14, selected==1);
wmove(dialog, y, x+1+14*selected);
wrefresh(dialog);
}
/*
* Display a dialog box for inputing a string
*/
int
dialog_inputbox (const char *title, const char *prompt, int height, int width,
const char *init)
{
int i, x, y, box_y, box_x, box_width;
int input_x = 0, scroll = 0, key = 0, button = -1;
unsigned char *instr = dialog_input_result;
WINDOW *dialog;
/* center dialog box on screen */
x = (COLS - width) / 2;
y = (LINES - height) / 2;
draw_shadow (stdscr, y, x, height, width);
dialog = newwin (height, width, y, x);
keypad (dialog, TRUE);
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 )
{
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL)
{
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 3);
/* Draw the input field box */
box_width = width - 6;
getyx (dialog, y, x);
box_y = y + 2;
box_x = (width - box_width) / 2;
draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2,
border_attr, dialog_attr);
print_buttons(dialog, height, width, 0);
/* Set up the initial value */
wmove (dialog, box_y, box_x);
wattrset (dialog, inputbox_attr);
if (!init)
instr[0] = '\0';
else
strcpy (instr, init);
input_x = strlen (instr);
if (input_x >= box_width)
{
scroll = input_x - box_width + 1;
input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]);
}
else
waddstr (dialog, instr);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
while (key != ESC)
{
key = wgetch (dialog);
if (button == -1)
{ /* Input box selected */
switch (key)
{
case TAB:
case KEY_UP:
case KEY_DOWN:
break;
case KEY_LEFT:
continue;
case KEY_RIGHT:
continue;
case KEY_BACKSPACE:
case 127:
if (input_x || scroll)
{
wattrset (dialog, inputbox_attr);
if (!input_x)
{
scroll = scroll < box_width - 1 ?
0 : scroll - (box_width - 1);
wmove (dialog, box_y, box_x);
for (i = 0; i < box_width; i++)
waddch (dialog, instr[scroll + input_x + i] ?
instr[scroll + input_x + i] : ' ');
input_x = strlen (instr) - scroll;
}
else
input_x--;
instr[scroll + input_x] = '\0';
mvwaddch (dialog, box_y, input_x + box_x, ' ');
wmove (dialog, box_y, input_x + box_x);
wrefresh (dialog);
}
continue;
default:
if (key < 0x100 && isprint (key))
{
if (scroll + input_x < MAX_LEN)
{
wattrset (dialog, inputbox_attr);
instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0';
if (input_x == box_width - 1)
{
scroll++;
wmove (dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]);
}
else
{
wmove (dialog, box_y, input_x++ + box_x);
waddch (dialog, key);
}
wrefresh (dialog);
} else
flash (); /* Alarm user about overflow */
continue;
}
}
}
switch (key)
{
case 'O':
case 'o':
delwin (dialog);
return 0;
case 'H':
case 'h':
delwin (dialog);
return 1;
case KEY_UP:
case KEY_LEFT:
switch (button)
{
case -1:
button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 0:
button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
break;
case 1:
button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0);
break;
}
break;
case TAB:
case KEY_DOWN:
case KEY_RIGHT:
switch (button)
{
case -1:
button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0);
break;
case 0:
button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 1:
button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
break;
}
break;
case ' ':
case '\n':
delwin (dialog);
return (button == -1 ? 0 : button);
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
}
delwin (dialog);
return -1; /* ESC pressed */
}

View file

@ -0,0 +1,243 @@
/*
* dialog - Display simple dialog boxes from shell scripts
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
static void Usage (const char *name);
typedef int (jumperFn) (const char *title, int argc, const char * const * argv);
struct Mode {
char *name;
int argmin, argmax, argmod;
jumperFn *jumper;
};
jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox;
jumperFn j_msgbox, j_infobox;
static struct Mode modes[] =
{
{"--menu", 9, 0, 3, j_menu},
{"--checklist", 9, 0, 3, j_checklist},
{"--radiolist", 9, 0, 3, j_radiolist},
{"--yesno", 5,5,1, j_yesno},
{"--textbox", 5,5,1, j_textbox},
{"--inputbox", 5, 6, 1, j_inputbox},
{"--msgbox", 5, 5, 1, j_msgbox},
{"--infobox", 5, 5, 1, j_infobox},
{NULL, 0, 0, 0, NULL}
};
static struct Mode *modePtr;
#ifdef LOCALE
#include <locale.h>
#endif
int
main (int argc, const char * const * argv)
{
int offset = 0, clear_screen = 0, end_common_opts = 0, retval;
const char *title = NULL;
#ifdef LOCALE
(void) setlocale (LC_ALL, "");
#endif
#ifdef TRACE
trace(TRACE_CALLS|TRACE_UPDATE);
#endif
if (argc < 2)
{
Usage (argv[0]);
exit (-1);
}
while (offset < argc - 1 && !end_common_opts) { /* Common options */
if (!strcmp (argv[offset + 1], "--title"))
{
if (argc - offset < 3 || title != NULL) {
Usage (argv[0]);
exit (-1);
}
else
{
title = argv[offset + 2];
offset += 2;
}
}
else if (!strcmp (argv[offset + 1], "--backtitle"))
{
if (backtitle != NULL)
{
Usage (argv[0]);
exit (-1);
}
else
{
backtitle = argv[offset + 2];
offset += 2;
}
}
else if (!strcmp (argv[offset + 1], "--clear"))
{
if (clear_screen) { /* Hey, "--clear" can't appear twice! */
Usage (argv[0]);
exit (-1);
}
else if (argc == 2)
{
/* we only want to clear the screen */
init_dialog ();
refresh (); /* init_dialog() will clear the screen for us */
end_dialog ();
return 0;
}
else
{
clear_screen = 1;
offset++;
}
}
else /* no more common options */
end_common_opts = 1;
}
if (argc - 1 == offset) { /* no more options */
Usage (argv[0]);
exit (-1);
}
/* use a table to look for the requested mode, to avoid code duplication */
for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
if (!strcmp (argv[offset + 1], modePtr->name))
break;
if (!modePtr->name)
Usage (argv[0]);
if (argc - offset < modePtr->argmin)
Usage (argv[0]);
if (modePtr->argmax && argc - offset > modePtr->argmax)
Usage (argv[0]);
init_dialog ();
retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
if (clear_screen) { /* clear screen before exit */
attr_clear (stdscr, LINES, COLS, screen_attr);
refresh ();
}
end_dialog();
exit (retval);
}
/*
* Print program usage
*/
static void
Usage (const char *name)
{
fprintf (stderr, "\
\ndialog, by Savio Lam (lam836@cs.cuhk.hk).\
\n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\
\n modified/gutted for use as a Linux kernel config tool by \
\n William Roadcap (roadcapw@cfw.com)\
\n\
\n* Display dialog boxes from shell scripts *\
\n\
\nUsage: %s --clear\
\n %s [--title <title>] [--backtitle <backtitle>] --clear <Box options>\
\n\
\nBox options:\
\n\
\n --menu <text> <height> <width> <menu height> <tag1> <item1>...\
\n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\
\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\
\n --textbox <file> <height> <width>\
\n --inputbox <text> <height> <width> [<init>]\
\n --yesno <text> <height> <width>\
\n", name, name);
exit (-1);
}
/*
* These are the program jumpers
*/
int
j_menu (const char *t, int ac, const char * const * av)
{
return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), av[6], (ac - 6) / 2, av + 7);
}
int
j_checklist (const char *t, int ac, const char * const * av)
{
return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
}
int
j_radiolist (const char *t, int ac, const char * const * av)
{
return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
}
int
j_textbox (const char *t, int ac, const char * const * av)
{
return dialog_textbox (t, av[2], atoi (av[3]), atoi (av[4]));
}
int
j_yesno (const char *t, int ac, const char * const * av)
{
return dialog_yesno (t, av[2], atoi (av[3]), atoi (av[4]));
}
int
j_inputbox (const char *t, int ac, const char * const * av)
{
int ret = dialog_inputbox (t, av[2], atoi (av[3]), atoi (av[4]),
ac == 6 ? av[5] : (char *) NULL);
if (ret == 0)
fprintf(stderr, dialog_input_result);
return ret;
}
int
j_msgbox (const char *t, int ac, const char * const * av)
{
return dialog_msgbox (t, av[2], atoi (av[3]), atoi (av[4]), 1);
}
int
j_infobox (const char *t, int ac, const char * const * av)
{
return dialog_msgbox (t, av[2], atoi (av[3]), atoi (av[4]), 0);
}

View file

@ -0,0 +1,475 @@
/*
* menubox.c -- implements the menu box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Changes by Clifford Wolf (god@clifford.at)
*
* [ 1998-06-13 ]
*
* *) A bugfix for the Page-Down problem
*
* *) Formerly when I used Page Down and Page Up, the cursor would be set
* to the first position in the menu box. Now lxdialog is a bit
* smarter and works more like other menu systems (just have a look at
* it).
*
* *) Formerly if I selected something my scrolling would be broken because
* lxdialog is re-invoked by the Menuconfig shell script, can't
* remember the last scrolling position, and just sets it so that the
* cursor is at the bottom of the box. Now it writes the temporary file
* lxdialog.scrltmp which contains this information. The file is
* deleted by lxdialog if the user leaves a submenu or enters a new
* one, but it would be nice if Menuconfig could make another "rm -f"
* just to be sure. Just try it out - you will recognise a difference!
*
* [ 1998-06-14 ]
*
* *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files
* and menus change their size on the fly.
*
* *) If for some reason the last scrolling position is not saved by
* lxdialog, it sets the scrolling so that the selected item is in the
* middle of the menu box, not at the bottom.
*
* 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)
* Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus.
* This fixes a bug in Menuconfig where using ' ' to descend into menus
* would leave mis-synchronized lxdialog.scrltmp files lying around,
* fscanf would read in 'scroll', and eventually that value would get used.
*/
#include "dialog.h"
static int menu_width, item_x;
/*
* Print menu item
*/
static void
print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey)
{
int j;
char menu_item[menu_width+1];
strncpy(menu_item, item, menu_width);
menu_item[menu_width] = 0;
j = first_alpha(menu_item, "YyNnMm");
/* Clear 'residue' of last item */
wattrset (win, menubox_attr);
wmove (win, choice, 0);
#if OLD_NCURSES
{
int i;
for (i = 0; i < menu_width; i++)
waddch (win, ' ');
}
#else
wclrtoeol(win);
#endif
wattrset (win, selected ? item_selected_attr : item_attr);
mvwaddstr (win, choice, item_x, menu_item);
if (hotkey)
{
wattrset (win, selected ? tag_key_selected_attr : tag_key_attr);
mvwaddch(win, choice, item_x+j, menu_item[j]);
}
}
/*
* Print the scroll indicators.
*/
static void
print_arrows (WINDOW * win, int item_no, int scroll,
int y, int x, int height)
{
int cur_y, cur_x;
getyx(win, cur_y, cur_x);
wmove(win, y, x);
if (scroll > 0)
{
wattrset (win, uarrow_attr);
waddch (win, ACS_UARROW);
waddstr (win, "(-)");
}
else {
wattrset (win, menubox_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
}
y = y + height + 1;
wmove(win, y, x);
if ((height < item_no) && (scroll + height < item_no)) {
wattrset (win, darrow_attr);
waddch (win, ACS_DARROW);
waddstr (win, "(+)");
}
else {
wattrset (win, menubox_border_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
}
wmove(win, cur_y, cur_x);
}
/*
* Display the termination buttons.
*/
static void
print_buttons (WINDOW *win, int height, int width, int selected)
{
int x = width / 2 - 16;
int y = height - 2;
print_button (win, "Select", y, x, selected == 0);
print_button (win, " Exit ", y, x + 12, selected == 1);
print_button (win, " Help ", y, x + 24, selected == 2);
wmove(win, y, x+1+12*selected);
wrefresh (win);
}
/*
* Display a menu for choosing among a number of options
*/
int
dialog_menu (const char *title, const char *prompt, int height, int width,
int menu_height, const char *current, int item_no,
const char * const * items)
{
int i, j, x, y, box_x, box_y;
int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice;
WINDOW *dialog, *menu;
FILE *f;
max_choice = MIN (menu_height, item_no);
/* center dialog box on screen */
x = (COLS - width) / 2;
y = (LINES - height) / 2;
draw_shadow (stdscr, y, x, height, width);
dialog = newwin (height, width, y, x);
keypad (dialog, TRUE);
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
wattrset (dialog, border_attr);
mvwaddch (dialog, height - 3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
wbkgdset (dialog, dialog_attr & A_COLOR);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 )
{
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL)
{
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 3);
menu_width = width - 6;
box_y = height - menu_height - 5;
box_x = (width - menu_width) / 2 - 1;
/* create new window for the menu */
menu = subwin (dialog, menu_height, menu_width,
y + box_y + 1, x + box_x + 1);
keypad (menu, TRUE);
/* draw a box around the menu items */
draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2,
menubox_border_attr, menubox_attr);
/*
* Find length of longest item in order to center menu.
* Set 'choice' to default item.
*/
item_x = 0;
for (i = 0; i < item_no; i++) {
item_x = MAX (item_x, MIN(menu_width, strlen (items[i * 2 + 1]) + 2));
if (strcmp(current, items[i*2]) == 0)
choice = i;
}
item_x = (menu_width - item_x) / 2;
/* get the scroll info from the temp file */
if ( (f=fopen("lxdialog.scrltmp","r")) != NULL )
{
if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) &&
(scroll+max_choice > choice) && (scroll >= 0) &&
(scroll+max_choice <= item_no) )
{
first_item = scroll;
choice = choice - scroll;
fclose(f);
}
else
{
scroll=0;
remove("lxdialog.scrltmp");
fclose(f);
f=NULL;
}
}
if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) )
{
if (choice >= item_no-max_choice/2)
scroll = first_item = item_no-max_choice;
else
scroll = first_item = choice - max_choice/2;
choice = choice - scroll;
}
/* Print the menu */
for (i=0; i < max_choice; i++)
{
print_item (menu, items[(first_item + i) * 2 + 1], i, i == choice,
(items[(first_item + i)*2][0] != ':'));
}
wnoutrefresh (menu);
print_arrows(dialog, item_no, scroll,
box_y, box_x+item_x+1, menu_height);
print_buttons (dialog, height, width, 0);
while (key != ESC)
{
key = wgetch(dialog);
if (key < 256 && isalpha(key)) key = tolower(key);
if (strchr("ynm", key))
i = max_choice;
else
{
for (i = choice+1; i < max_choice; i++)
{
j = first_alpha(items[(scroll+i)*2+1], "YyNnMm");
if (key == tolower(items[(scroll+i)*2+1][j]))
break;
}
if (i == max_choice)
for (i = 0; i < max_choice; i++) {
j = first_alpha(items[(scroll+i)*2+1], "YyNnMm");
if (key == tolower(items[(scroll+i)*2+1][j]))
break;
}
}
if (i < max_choice
|| key == KEY_UP || key == KEY_DOWN
|| key == '-' || key == '+'
|| key == KEY_PPAGE || key == KEY_NPAGE)
{
print_item (menu, items[(scroll+choice)*2+1], choice, FALSE,
(items[(scroll+choice)*2][0] != ':'));
if (key == KEY_UP || key == '-')
{
if (choice < 2 && scroll)
{
/* Scroll menu down */
scrollok (menu, TRUE);
wscrl (menu, -1);
scrollok (menu, FALSE);
scroll--;
print_item (menu, items[scroll * 2 + 1], 0, FALSE,
(items[scroll*2][0] != ':'));
}
else
choice = MAX(choice - 1, 0);
}
else if (key == KEY_DOWN || key == '+')
{
print_item (menu, items[(scroll+choice)*2+1], choice, FALSE,
(items[(scroll+choice)*2][0] != ':'));
if ((choice > max_choice-3)
&& (scroll + max_choice < item_no)
)
{
/* Scroll menu up */
scrollok (menu, TRUE);
scroll (menu);
scrollok (menu, FALSE);
scroll++;
print_item (menu, items[(scroll+max_choice-1)*2+1],
max_choice-1, FALSE,
(items[(scroll+max_choice-1)*2][0] != ':'));
}
else
choice = MIN(choice+1, max_choice-1);
}
else if (key == KEY_PPAGE)
{
scrollok (menu, TRUE);
for (i=0; (i < max_choice); i++)
{
if (scroll > 0)
{
wscrl (menu, -1);
scroll--;
print_item (menu, items[scroll * 2 + 1], 0, FALSE,
(items[scroll*2][0] != ':'));
}
else
{
if (choice > 0)
choice--;
}
}
scrollok (menu, FALSE);
}
else if (key == KEY_NPAGE)
{
for (i=0; (i < max_choice); i++)
{
if (scroll+max_choice < item_no)
{
scrollok (menu, TRUE);
scroll(menu);
scrollok (menu, FALSE);
scroll++;
print_item (menu, items[(scroll+max_choice-1)*2+1],
max_choice-1, FALSE,
(items[(scroll+max_choice-1)*2][0] != ':'));
}
else
{
if (choice+1 < max_choice)
choice++;
}
}
}
else
choice = i;
print_item (menu, items[(scroll+choice)*2+1], choice, TRUE,
(items[(scroll+choice)*2][0] != ':'));
print_arrows(dialog, item_no, scroll,
box_y, box_x+item_x+1, menu_height);
wnoutrefresh (menu);
wrefresh (dialog);
continue; /* wait for another key press */
}
switch (key)
{
case KEY_LEFT:
case TAB:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 2 : (button > 2 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh (dialog);
break;
case ' ':
case 's':
case 'y':
case 'n':
case 'm':
/* save scroll info */
if ( (f=fopen("lxdialog.scrltmp","w")) != NULL )
{
fprintf(f,"%d\n",scroll);
fclose(f);
}
delwin (dialog);
fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
switch (key) {
case 's': return 3;
case 'y': return 3;
case 'n': return 4;
case 'm': return 5;
case ' ': return 6;
}
return 0;
case 'h':
case '?':
button = 2;
case '\n':
delwin (dialog);
if (button == 2)
fprintf(stderr, "%s \"%s\"\n",
items[(scroll + choice) * 2],
items[(scroll + choice) * 2 + 1] +
first_alpha(items[(scroll + choice) * 2 + 1],""));
else
fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
remove("lxdialog.scrltmp");
return button;
case 'e':
case 'x':
key = ESC;
case ESC:
break;
}
}
delwin (dialog);
remove("lxdialog.scrltmp");
return -1; /* ESC pressed */
}

View file

@ -0,0 +1,90 @@
/*
* msgbox.c -- implements the message box and info box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
/*
* Display a message box. Program will pause and display an "OK" button
* if the parameter 'pause' is non-zero.
*/
int
dialog_msgbox (const char *title, const char *prompt, int height, int width,
int pause)
{
int i, x, y, key = 0;
WINDOW *dialog;
/* center dialog box on screen */
x = (COLS - width) / 2;
y = (LINES - height) / 2;
draw_shadow (stdscr, y, x, height, width);
dialog = newwin (height, width, y, x);
keypad (dialog, TRUE);
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
if (title != NULL && strlen(title) >= width-2 )
{
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL)
{
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 2);
if (pause)
{
wattrset (dialog, border_attr);
mvwaddch (dialog, height - 3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE);
print_button (dialog, " Ok ",
height - 2, width / 2 - 4, TRUE);
wrefresh (dialog);
while (key != ESC && key != '\n' && key != ' ' &&
key != 'O' && key != 'o' && key != 'X' && key != 'x')
key = wgetch (dialog);
}
else
{
key = '\n';
wrefresh (dialog);
}
delwin (dialog);
return key == ESC ? -1 : 0;
}

View file

@ -0,0 +1,604 @@
/*
* textbox.c -- implements the text box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
static void back_lines (int n);
static void print_page (WINDOW * win, int height, int width);
static void print_line (WINDOW * win, int row, int width);
static char *get_line (void);
static void print_position (WINDOW * win, int height, int width);
static int hscroll = 0, fd, file_size, bytes_read;
static int begin_reached = 1, end_reached = 0, page_length;
static char *buf, *page;
/*
* Display text from a file in a dialog box.
*/
int
dialog_textbox (const char *title, const char *file, int height, int width)
{
int i, x, y, cur_x, cur_y, fpos, key = 0;
int passed_end;
char search_term[MAX_LEN + 1];
WINDOW *dialog, *text;
search_term[0] = '\0'; /* no search term entered yet */
/* Open input file for reading */
if ((fd = open (file, O_RDONLY)) == -1)
{
endwin ();
fprintf (stderr, "\nCan't open input file in dialog_textbox().\n");
exit (-1);
}
/* Get file size. Actually, 'file_size' is the real file size - 1,
since it's only the last byte offset from the beginning */
if ((file_size = lseek (fd, 0, SEEK_END)) == -1) {
endwin ();
fprintf (stderr, "\nError getting file size in dialog_textbox().\n");
exit (-1);
}
/* Restore file pointer to beginning of file after getting file size */
if (lseek (fd, 0, SEEK_SET) == -1) {
endwin ();
fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n");
exit (-1);
}
/* Allocate space for read buffer */
if ((buf = malloc (BUF_SIZE + 1)) == NULL) {
endwin ();
fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n");
exit (-1);
}
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
endwin ();
fprintf (stderr, "\nError reading file in dialog_textbox().\n");
exit (-1);
}
buf[bytes_read] = '\0'; /* mark end of valid data */
page = buf; /* page is pointer to start of page to be displayed */
/* center dialog box on screen */
x = (COLS - width) / 2;
y = (LINES - height) / 2;
draw_shadow (stdscr, y, x, height, width);
dialog = newwin (height, width, y, x);
keypad (dialog, TRUE);
/* Create window for text region, used for scrolling text */
text = subwin (dialog, height - 4, width - 2, y + 1, x + 1);
wattrset (text, dialog_attr);
wbkgdset (text, dialog_attr & A_COLOR);
keypad (text, TRUE);
/* register the new window, along with its borders */
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
wbkgdset (dialog, dialog_attr & A_COLOR);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 )
{
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL)
{
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE);
wnoutrefresh (dialog);
getyx (dialog, cur_y, cur_x); /* Save cursor position */
/* Print first page of text */
attr_clear (text, height - 4, width - 2, dialog_attr);
print_page (text, height - 4, width - 2);
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh (dialog);
while ((key != ESC) && (key != '\n')) {
key = wgetch (dialog);
switch (key)
{
case 'E': /* Exit */
case 'e':
case 'X':
case 'x':
delwin (dialog);
free (buf);
close (fd);
return 0;
case 'g': /* First page */
case KEY_HOME:
if (!begin_reached)
{
begin_reached = 1;
/* First page not in buffer? */
if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1)
{
endwin ();
fprintf (stderr,
"\nError moving file pointer in dialog_textbox().\n");
exit (-1);
}
if (fpos > bytes_read)
{ /* Yes, we have to read it in */
if (lseek (fd, 0, SEEK_SET) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer in "
"dialog_textbox().\n");
exit (-1);
}
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1)
{
endwin ();
fprintf (stderr,
"\nError reading file in dialog_textbox().\n");
exit (-1);
}
buf[bytes_read] = '\0';
}
page = buf;
print_page (text, height - 4, width - 2);
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh (dialog);
}
break;
case 'G': /* Last page */
case KEY_END:
end_reached = 1;
/* Last page not in buffer? */
if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1)
{
endwin ();
fprintf (stderr,
"\nError moving file pointer in dialog_textbox().\n");
exit (-1);
}
if (fpos < file_size)
{ /* Yes, we have to read it in */
if (lseek (fd, -BUF_SIZE, SEEK_END) == -1)
{
endwin ();
fprintf (stderr,
"\nError moving file pointer in dialog_textbox().\n");
exit (-1);
}
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1)
{
endwin ();
fprintf (stderr,
"\nError reading file in dialog_textbox().\n");
exit (-1);
}
buf[bytes_read] = '\0';
}
page = buf + bytes_read;
back_lines (height - 4);
print_page (text, height - 4, width - 2);
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh (dialog);
break;
case 'K': /* Previous line */
case 'k':
case KEY_UP:
if (!begin_reached)
{
back_lines (page_length + 1);
/* We don't call print_page() here but use scrolling to ensure
faster screen update. However, 'end_reached' and
'page_length' should still be updated, and 'page' should
point to start of next page. This is done by calling
get_line() in the following 'for' loop. */
scrollok (text, TRUE);
wscrl (text, -1); /* Scroll text region down one line */
scrollok (text, FALSE);
page_length = 0;
passed_end = 0;
for (i = 0; i < height - 4; i++) {
if (!i) {
/* print first line of page */
print_line (text, 0, width - 2);
wnoutrefresh (text);
}
else
/* Called to update 'end_reached' and 'page' */
get_line ();
if (!passed_end)
page_length++;
if (end_reached && !passed_end)
passed_end = 1;
}
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh (dialog);
}
break;
case 'B': /* Previous page */
case 'b':
case KEY_PPAGE:
if (begin_reached)
break;
back_lines (page_length + height - 4);
print_page (text, height - 4, width - 2);
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x);
wrefresh (dialog);
break;
case 'J': /* Next line */
case 'j':
case KEY_DOWN:
if (!end_reached)
{
begin_reached = 0;
scrollok (text, TRUE);
scroll (text); /* Scroll text region up one line */
scrollok (text, FALSE);
print_line (text, height - 5, width - 2);
wnoutrefresh (text);
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh (dialog);
}
break;
case KEY_NPAGE: /* Next page */
case ' ':
if (end_reached)
break;
begin_reached = 0;
print_page (text, height - 4, width - 2);
print_position (dialog, height, width);
wmove (dialog, cur_y, cur_x);
wrefresh (dialog);
break;
case '0': /* Beginning of line */
case 'H': /* Scroll left */
case 'h':
case KEY_LEFT:
if (hscroll <= 0)
break;
if (key == '0')
hscroll = 0;
else
hscroll--;
/* Reprint current page to scroll horizontally */
back_lines (page_length);
print_page (text, height - 4, width - 2);
wmove (dialog, cur_y, cur_x);
wrefresh (dialog);
break;
case 'L': /* Scroll right */
case 'l':
case KEY_RIGHT:
if (hscroll >= MAX_LEN)
break;
hscroll++;
/* Reprint current page to scroll horizontally */
back_lines (page_length);
print_page (text, height - 4, width - 2);
wmove (dialog, cur_y, cur_x);
wrefresh (dialog);
break;
case ESC:
break;
}
}
delwin (dialog);
free (buf);
close (fd);
return -1; /* ESC pressed */
}
/*
* Go back 'n' lines in text file. Called by dialog_textbox().
* 'page' will be updated to point to the desired line in 'buf'.
*/
static void
back_lines (int n)
{
int i, fpos;
begin_reached = 0;
/* We have to distinguish between end_reached and !end_reached
since at end of file, the line is not ended by a '\n'.
The code inside 'if' basically does a '--page' to move one
character backward so as to skip '\n' of the previous line */
if (!end_reached)
{
/* Either beginning of buffer or beginning of file reached? */
if (page == buf)
{
if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer in "
"back_lines().\n");
exit (-1);
}
if (fpos > bytes_read)
{ /* Not beginning of file yet */
/* We've reached beginning of buffer, but not beginning of
file yet, so read previous part of file into buffer.
Note that we only move backward for BUF_SIZE/2 bytes,
but not BUF_SIZE bytes to avoid re-reading again in
print_page() later */
/* Really possible to move backward BUF_SIZE/2 bytes? */
if (fpos < BUF_SIZE / 2 + bytes_read)
{
/* No, move less then */
if (lseek (fd, 0, SEEK_SET) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer in "
"back_lines().\n");
exit (-1);
}
page = buf + fpos - bytes_read;
}
else
{ /* Move backward BUF_SIZE/2 bytes */
if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer "
"in back_lines().\n");
exit (-1);
}
page = buf + BUF_SIZE / 2;
}
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1)
{
endwin ();
fprintf (stderr, "\nError reading file in back_lines().\n");
exit (-1);
}
buf[bytes_read] = '\0';
}
else
{ /* Beginning of file reached */
begin_reached = 1;
return;
}
}
if (*(--page) != '\n')
{ /* '--page' here */
/* Something's wrong... */
endwin ();
fprintf (stderr, "\nInternal error in back_lines().\n");
exit (-1);
}
}
/* Go back 'n' lines */
for (i = 0; i < n; i++)
do {
if (page == buf)
{
if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
endwin ();
fprintf (stderr,
"\nError moving file pointer in back_lines().\n");
exit (-1);
}
if (fpos > bytes_read)
{
/* Really possible to move backward BUF_SIZE/2 bytes? */
if (fpos < BUF_SIZE / 2 + bytes_read)
{
/* No, move less then */
if (lseek (fd, 0, SEEK_SET) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer "
"in back_lines().\n");
exit (-1);
}
page = buf + fpos - bytes_read;
}
else
{ /* Move backward BUF_SIZE/2 bytes */
if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer"
" in back_lines().\n");
exit (-1);
}
page = buf + BUF_SIZE / 2;
}
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1)
{
endwin ();
fprintf (stderr, "\nError reading file in "
"back_lines().\n");
exit (-1);
}
buf[bytes_read] = '\0';
}
else
{ /* Beginning of file reached */
begin_reached = 1;
return;
}
}
} while (*(--page) != '\n');
page++;
}
/*
* Print a new page of text. Called by dialog_textbox().
*/
static void
print_page (WINDOW * win, int height, int width)
{
int i, passed_end = 0;
page_length = 0;
for (i = 0; i < height; i++)
{
print_line (win, i, width);
if (!passed_end)
page_length++;
if (end_reached && !passed_end)
passed_end = 1;
}
wnoutrefresh (win);
}
/*
* Print a new line of text. Called by dialog_textbox() and print_page().
*/
static void
print_line (WINDOW * win, int row, int width)
{
int y, x;
char *line;
line = get_line ();
line += MIN (strlen (line), hscroll); /* Scroll horizontally */
wmove (win, row, 0); /* move cursor to correct line */
waddch (win, ' ');
waddnstr (win, line, MIN (strlen (line), width - 2));
getyx (win, y, x);
/* Clear 'residue' of previous line */
#if OLD_NCURSES
{
int i;
for (i = 0; i < width - x; i++)
waddch (win, ' ');
}
#else
wclrtoeol(win);
#endif
}
/*
* Return current line of text. Called by dialog_textbox() and print_line().
* 'page' should point to start of current line before calling, and will be
* updated to point to start of next line.
*/
static char *
get_line (void)
{
int i = 0, fpos;
static char line[MAX_LEN + 1];
end_reached = 0;
while (*page != '\n')
{
if (*page == '\0')
{
/* Either end of file or end of buffer reached */
if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer in "
"get_line().\n");
exit (-1);
}
if (fpos < file_size)
{
/* Not end of file yet */
/* We've reached end of buffer, but not end of file yet,
so read next part of file into buffer */
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1)
{
endwin ();
fprintf (stderr, "\nError reading file in get_line().\n");
exit (-1);
}
buf[bytes_read] = '\0';
page = buf;
}
else
{
if (!end_reached)
end_reached = 1;
break;
}
}
else if (i < MAX_LEN)
line[i++] = *(page++);
else
{
/* Truncate lines longer than MAX_LEN characters */
if (i == MAX_LEN)
line[i++] = '\0';
page++;
}
}
if (i <= MAX_LEN)
line[i] = '\0';
if (!end_reached)
page++; /* move pass '\n' */
return line;
}
/*
* Print current position
*/
static void
print_position (WINDOW * win, int height, int width)
{
int fpos, percent;
if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1)
{
endwin ();
fprintf (stderr, "\nError moving file pointer in print_position().\n");
exit (-1);
}
wattrset (win, position_indicator_attr);
wbkgdset (win, position_indicator_attr & A_COLOR);
percent = !file_size ? 100 : ((fpos - bytes_read + page - buf) * 100) / file_size;
wmove (win, height - 3, width - 9);
wprintw (win, "(%3d%%)", percent);
}

View file

@ -0,0 +1,374 @@
/*
* util.c
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
/* use colors by default? */
bool use_colors = 1;
const char *backtitle = NULL;
const char *dialog_result;
/*
* Attribute values, default is for mono display
*/
chtype attributes[] =
{
A_NORMAL, /* screen_attr */
A_NORMAL, /* shadow_attr */
A_NORMAL, /* dialog_attr */
A_BOLD, /* title_attr */
A_NORMAL, /* border_attr */
A_REVERSE, /* button_active_attr */
A_DIM, /* button_inactive_attr */
A_REVERSE, /* button_key_active_attr */
A_BOLD, /* button_key_inactive_attr */
A_REVERSE, /* button_label_active_attr */
A_NORMAL, /* button_label_inactive_attr */
A_NORMAL, /* inputbox_attr */
A_NORMAL, /* inputbox_border_attr */
A_NORMAL, /* searchbox_attr */
A_BOLD, /* searchbox_title_attr */
A_NORMAL, /* searchbox_border_attr */
A_BOLD, /* position_indicator_attr */
A_NORMAL, /* menubox_attr */
A_NORMAL, /* menubox_border_attr */
A_NORMAL, /* item_attr */
A_REVERSE, /* item_selected_attr */
A_BOLD, /* tag_attr */
A_REVERSE, /* tag_selected_attr */
A_BOLD, /* tag_key_attr */
A_REVERSE, /* tag_key_selected_attr */
A_BOLD, /* check_attr */
A_REVERSE, /* check_selected_attr */
A_BOLD, /* uarrow_attr */
A_BOLD /* darrow_attr */
};
#include "colors.h"
/*
* Table of color values
*/
int color_table[][3] =
{
{SCREEN_FG, SCREEN_BG, SCREEN_HL},
{SHADOW_FG, SHADOW_BG, SHADOW_HL},
{DIALOG_FG, DIALOG_BG, DIALOG_HL},
{TITLE_FG, TITLE_BG, TITLE_HL},
{BORDER_FG, BORDER_BG, BORDER_HL},
{BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL},
{BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL},
{BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL},
{BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL},
{BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL},
{BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG,
BUTTON_LABEL_INACTIVE_HL},
{INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL},
{INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL},
{SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL},
{SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL},
{SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL},
{POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL},
{MENUBOX_FG, MENUBOX_BG, MENUBOX_HL},
{MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL},
{ITEM_FG, ITEM_BG, ITEM_HL},
{ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL},
{TAG_FG, TAG_BG, TAG_HL},
{TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL},
{TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL},
{TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL},
{CHECK_FG, CHECK_BG, CHECK_HL},
{CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL},
{UARROW_FG, UARROW_BG, UARROW_HL},
{DARROW_FG, DARROW_BG, DARROW_HL},
}; /* color_table */
/*
* Set window to attribute 'attr'
*/
void
attr_clear (WINDOW * win, int height, int width, chtype attr)
{
int i, j;
wattrset (win, attr);
for (i = 0; i < height; i++)
{
wmove (win, i, 0);
for (j = 0; j < width; j++)
waddch (win, ' ');
}
touchwin (win);
}
void dialog_clear (void)
{
attr_clear (stdscr, LINES, COLS, screen_attr);
/* Display background title if it exists ... - SLH */
if (backtitle != NULL) {
int i;
wattrset (stdscr, screen_attr);
mvwaddstr (stdscr, 0, 1, (char *)backtitle);
wmove (stdscr, 1, 1);
for (i = 1; i < COLS - 1; i++)
waddch (stdscr, ACS_HLINE);
}
wnoutrefresh (stdscr);
}
/*
* Do some initialization for dialog
*/
void
init_dialog (void)
{
initscr (); /* Init curses */
keypad (stdscr, TRUE);
cbreak ();
noecho ();
if (use_colors) /* Set up colors */
color_setup ();
dialog_clear ();
}
/*
* Setup for color display
*/
void
color_setup (void)
{
int i;
if (has_colors ())
{ /* Terminal supports color? */
start_color ();
/* Initialize color pairs */
for (i = 0; i < ATTRIBUTE_COUNT; i++)
init_pair (i + 1, color_table[i][0], color_table[i][1]);
/* Setup color attributes */
for (i = 0; i < ATTRIBUTE_COUNT; i++)
attributes[i] = C_ATTR (color_table[i][2], i + 1);
}
}
/*
* End using dialog functions.
*/
void
end_dialog (void)
{
endwin ();
}
/*
* Print a string of text in a window, automatically wrap around to the
* next line if the string is too long to fit on one line. Newline
* characters '\n' are replaced by spaces. We start on a new line
* if there is no room for at least 4 nonblanks following a double-space.
*/
void
print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
{
int newl, cur_x, cur_y;
int i, prompt_len, room, wlen;
char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
strcpy (tempstr, prompt);
prompt_len = strlen(tempstr);
/*
* Remove newlines
*/
for(i=0; i<prompt_len; i++) {
if(tempstr[i] == '\n') tempstr[i] = ' ';
}
if (prompt_len <= width - x * 2)
{ /* If prompt is short */
wmove (win, y, (width - prompt_len) / 2);
waddstr (win, tempstr);
}
else
{
cur_x = x;
cur_y = y;
newl = 1;
word = tempstr;
while (word && *word)
{
sp = index(word, ' ');
if (sp)
*sp++ = 0;
/* Wrap to next line if either the word does not fit,
or it is the first word of a new sentence, and it is
short, and the next word does not fit. */
room = width - cur_x;
wlen = strlen(word);
if (wlen > room
|| (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room
&& (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room)))
{
cur_y++;
cur_x = x;
}
wmove (win, cur_y, cur_x);
waddstr (win, word);
getyx (win, cur_y, cur_x);
cur_x++;
if (sp && *sp == ' ')
{
cur_x++; /* double space */
while (*++sp == ' ');
newl = 1;
}
else
{
newl = 0;
}
word = sp;
}
}
}
/*
* Print a button
*/
void
print_button (WINDOW * win, const char *label, int y, int x, int selected)
{
int i, temp;
wmove (win, y, x);
wattrset (win, selected ? button_active_attr : button_inactive_attr);
waddstr (win, "<");
temp = strspn (label, " ");
label += temp;
wattrset (win, selected ? button_label_active_attr
: button_label_inactive_attr);
for (i = 0; i < temp; i++)
waddch (win, ' ');
wattrset (win, selected ? button_key_active_attr
: button_key_inactive_attr);
waddch (win, label[0]);
wattrset (win, selected ? button_label_active_attr
: button_label_inactive_attr);
waddstr (win, (char *)label + 1);
wattrset (win, selected ? button_active_attr : button_inactive_attr);
waddstr (win, ">");
wmove (win, y, x + temp + 1);
}
/*
* Draw a rectangular box with line drawing characters
*/
void
draw_box (WINDOW * win, int y, int x, int height, int width,
chtype box, chtype border)
{
int i, j;
wattrset (win, 0);
for (i = 0; i < height; i++)
{
wmove (win, y + i, x);
for (j = 0; j < width; j++)
if (!i && !j)
waddch (win, border | ACS_ULCORNER);
else if (i == height - 1 && !j)
waddch (win, border | ACS_LLCORNER);
else if (!i && j == width - 1)
waddch (win, box | ACS_URCORNER);
else if (i == height - 1 && j == width - 1)
waddch (win, box | ACS_LRCORNER);
else if (!i)
waddch (win, border | ACS_HLINE);
else if (i == height - 1)
waddch (win, box | ACS_HLINE);
else if (!j)
waddch (win, border | ACS_VLINE);
else if (j == width - 1)
waddch (win, box | ACS_VLINE);
else
waddch (win, box | ' ');
}
}
/*
* Draw shadows along the right and bottom edge to give a more 3D look
* to the boxes
*/
void
draw_shadow (WINDOW * win, int y, int x, int height, int width)
{
int i;
if (has_colors ())
{ /* Whether terminal supports color? */
wattrset (win, shadow_attr);
wmove (win, y + height, x + 2);
for (i = 0; i < width; i++)
waddch (win, winch (win) & A_CHARTEXT);
for (i = y + 1; i < y + height + 1; i++)
{
wmove (win, i, x + width);
waddch (win, winch (win) & A_CHARTEXT);
waddch (win, winch (win) & A_CHARTEXT);
}
wnoutrefresh (win);
}
}
/*
* Return the position of the first alphabetic character in a string.
*/
int
first_alpha(const char *string, const char *exempt)
{
int i, in_paren=0, c;
for (i = 0; i < strlen(string); i++)
{
c = tolower(string[i]);
if (strchr("<[(", c)) ++in_paren;
if (strchr(">])", c)) --in_paren;
if ((! in_paren) && isalpha(c)
&& strchr(exempt, c) == 0)
return i;
}
return 0;
}

View file

@ -0,0 +1,121 @@
/*
* yesno.c -- implements the yes/no box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
/*
* Display termination buttons
*/
static void
print_buttons(WINDOW *dialog, int height, int width, int selected)
{
int x = width / 2 - 10;
int y = height - 2;
print_button (dialog, " Yes ", y, x, selected == 0);
print_button (dialog, " No ", y, x + 13, selected == 1);
wmove(dialog, y, x+1 + 13*selected );
wrefresh (dialog);
}
/*
* Display a dialog box with two buttons - Yes and No
*/
int
dialog_yesno (const char *title, const char *prompt, int height, int width)
{
int i, x, y, key = 0, button = 0;
WINDOW *dialog;
/* center dialog box on screen */
x = (COLS - width) / 2;
y = (LINES - height) / 2;
draw_shadow (stdscr, y, x, height, width);
dialog = newwin (height, width, y, x);
keypad (dialog, TRUE);
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 )
{
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL)
{
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 3);
print_buttons(dialog, height, width, 0);
while (key != ESC)
{
key = wgetch (dialog);
switch (key) {
case 'Y':
case 'y':
delwin (dialog);
return 0;
case 'N':
case 'n':
delwin (dialog);
return 1;
case TAB:
case KEY_LEFT:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 1 : (button > 1 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh (dialog);
break;
case ' ':
case '\n':
delwin (dialog);
return button;
case ESC:
break;
}
}
delwin (dialog);
return -1; /* ESC pressed */
}

View file

@ -0,0 +1,94 @@
# FILE: tail.tk
# This file is boilerplate TCL/TK function definitions for 'make xconfig'.
#
# CHANGES
# =======
#
# 8 January 1998, Michael Elizabeth Chastain, <mec@shout.net>
# Arrange buttons in three columns for better screen fitting.
#
#
# Read the user's settings from .config. These will override whatever is
# in config.in. Don't do this if the user specified a -D to force
# the defaults.
#
if { [file readable .config] == 1} then {
if { $argc > 0 } then {
if { [lindex $argv 0] != "-D" } then {
read_config .config
}
else
{
read_config $defaults
}
} else {
read_config .config
}
} else {
read_config $defaults
}
update_define 1 $total_menus 0
update_mainmenu
global autoconf_file
if {( $autoconf_file == "")} then {
set autoconf_file "/dev/null"
}
button .f0.right.save -anchor w -text "Save and Exit" \
-command {
catch {exec cp -f .config .config.old}
writeconfig .config $autoconf_file;
exit
}
button .f0.right.quit -anchor w -text "Quit Without Saving" \
-command { maybe_exit .maybe }
button .f0.right.load -anchor w -text "Load Configuration from File" \
-command { load_configfile .load "Load Configuration from file" read_config_file
}
button .f0.right.store -anchor w -text "Store Configuration to File" \
-command { load_configfile .load "Store Configuration to file" write_config_file }
#
# Now pack everything.
#
pack .f0.right.store .f0.right.load .f0.right.quit .f0.right.save \
-padx 0 -pady 0 -side bottom -fill x
pack .f0.left .f0.middle .f0.right -side left -padx 5 -pady 0 -fill y
pack .f0 -padx 5 -pady 5
update idletasks
set winy [expr 10 + [winfo reqheight .f0]]
set scry [lindex [wm maxsize .] 1]
set winx [expr 10 + [winfo reqwidth .f0]]
set scrx [lindex [wm maxsize .] 0]
if {$winx < $scrx} then {set maxx -1} else {set maxx $winx}
if {$winy < $scry} then {set maxy -1} else {set maxy $winy}
.f0 configure -width $winx -height $winy
wm maxsize . $maxx $maxy
#
# If we cannot write our config files, disable the write button.
#
if { [file exists .config] == 1 } then {
if { [file writable .config] == 0 } then {
.f0.right.save configure -state disabled
}
} else {
if { [file writable .] == 0 } then {
.f0.right.save configure -state disabled
}
}
if { [file exists $autoconf_file] == 1 } then {
if { [file writable $autoconf_file] == 0 } then {
.f0.right.save configure -state disabled
}
}

View file

@ -0,0 +1,605 @@
/*
* tkcond.c
*
* Eric Youngdale was the original author of xconfig.
* Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
*
* This file takes the tokenized statement list and transforms 'if ...'
* statements. For each simple statement, I find all of the 'if' statements
* that enclose it, and attach the aggregate conditionals of those 'if'
* statements to the cond list of the simple statement.
*
* 14 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
* - Steam-clean this file. I tested this by generating kconfig.tk for
* every architecture and comparing it character-for-character against
* the output of the old tkparse.
*
* 07 July 1999, Andrzej M. Krzysztofowicz <ankry@mif.pg.gda.pl>
* - kvariables removed; all variables are stored in a single table now
* - some elimination of options non-valid for current architecture
* implemented.
* - negation (!) eliminated from conditions
*
* TO DO:
* - xconfig is at the end of its life cycle. Contact <mec@shout.net> if
* you are interested in working on the replacement.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tkparse.h"
/*
* Mark variables which are defined anywhere.
*/
static void mark_variables( struct kconfig * scfg )
{
struct kconfig * cfg;
int i;
for ( i = 1; i <= max_varnum; i++ )
vartable[i].defined = 0;
for ( cfg = scfg; cfg != NULL; cfg = cfg->next )
{
if ( cfg->token == token_bool
|| cfg->token == token_choice_item
|| cfg->token == token_define_bool
|| cfg->token == token_define_hex
|| cfg->token == token_define_int
|| cfg->token == token_define_string
|| cfg->token == token_define_tristate
|| cfg->token == token_dep_bool
|| cfg->token == token_dep_mbool
|| cfg->token == token_dep_tristate
|| cfg->token == token_hex
|| cfg->token == token_int
|| cfg->token == token_string
|| cfg->token == token_tristate
|| cfg->token == token_unset )
{
if ( cfg->nameindex > 0 ) /* paranoid */
{
vartable[cfg->nameindex].defined = 1;
}
}
}
}
static void free_cond( struct condition *cond )
{
struct condition *tmp, *tmp1;
for ( tmp = cond; tmp; tmp = tmp1 )
{
tmp1 = tmp->next;
free( (void*)tmp );
}
}
/*
* Remove the bang operator from a condition to avoid priority problems.
* "!" has different priorities as "test" command argument and in
* a tk script.
*/
static struct condition * remove_bang( struct condition * condition )
{
struct condition * conda, * condb, * prev = NULL;
for ( conda = condition; conda; conda = conda->next )
{
if ( conda->op == op_bang && conda->next &&
( condb = conda->next->next ) )
{
if ( condb->op == op_eq || condb->op == op_neq )
{
condb->op = (condb->op == op_eq) ? op_neq : op_eq;
conda->op = op_nuked;
if ( prev )
{
prev->next = conda->next;
}
else
{
condition = conda->next;
}
conda->next = NULL;
free_cond( conda );
conda = condb;
}
}
prev = conda;
}
return condition;
}
/*
* Make a new condition chain by joining the current condition stack with
* the "&&" operator for glue.
*/
static struct condition * join_condition_stack( struct condition * conditions [],
int depth )
{
struct condition * cond_list;
struct condition * cond_last;
int i, is_first = 1;
cond_list = cond_last = NULL;
for ( i = 0; i < depth; i++ )
{
if ( conditions[i]->op == op_false )
{
struct condition * cnew;
/* It is always false condition */
cnew = malloc( sizeof(*cnew) );
memset( cnew, 0, sizeof(*cnew) );
cnew->op = op_false;
cond_list = cond_last = cnew;
goto join_done;
}
}
for ( i = 0; i < depth; i++ )
{
struct condition * cond;
struct condition * cnew;
int add_paren;
/* omit always true conditions */
if ( conditions[i]->op == op_true )
continue;
/* if i have another condition, add an '&&' operator */
if ( !is_first )
{
cnew = malloc( sizeof(*cnew) );
memset( cnew, 0, sizeof(*cnew) );
cnew->op = op_and;
cond_last->next = cnew;
cond_last = cnew;
}
if ( conditions[i]->op != op_lparen )
{
/* add a '(' */
add_paren = 1;
cnew = malloc( sizeof(*cnew) );
memset( cnew, 0, sizeof(*cnew) );
cnew->op = op_lparen;
if ( cond_last == NULL )
{
cond_list = cond_last = cnew;
}
else
{
cond_last->next = cnew; cond_last = cnew;
}
}
else
{
add_paren = 0;
}
/* duplicate the chain */
for ( cond = conditions [i]; cond != NULL; cond = cond->next )
{
cnew = malloc( sizeof(*cnew) );
cnew->next = NULL;
cnew->op = cond->op;
cnew->str = cond->str ? strdup( cond->str ) : NULL;
cnew->nameindex = cond->nameindex;
if ( cond_last == NULL )
{ cond_list = cond_last = cnew; }
else
{ cond_last->next = cnew; cond_last = cnew; }
}
if ( add_paren )
{
/* add a ')' */
cnew = malloc( sizeof(*cnew) );
memset( cnew, 0, sizeof(*cnew) );
cnew->op = op_rparen;
cond_last->next = cnew;
cond_last = cnew;
}
is_first = 0;
}
/*
* Remove duplicate conditions.
*/
struct condition *cond1, *cond1b, *cond1c, *cond1d, *cond1e, *cond1f;
for ( cond1 = cond_list; cond1 != NULL; cond1 = cond1->next )
{
if ( cond1->op == op_lparen )
{
cond1b = cond1 ->next; if ( cond1b == NULL ) break;
cond1c = cond1b->next; if ( cond1c == NULL ) break;
cond1d = cond1c->next; if ( cond1d == NULL ) break;
cond1e = cond1d->next; if ( cond1e == NULL ) break;
cond1f = cond1e->next; if ( cond1f == NULL ) break;
if ( cond1b->op == op_variable
&& ( cond1c->op == op_eq || cond1c->op == op_neq )
&& cond1d->op == op_constant
&& cond1e->op == op_rparen )
{
struct condition *cond2, *cond2b, *cond2c, *cond2d, *cond2e, *cond2f;
for ( cond2 = cond1f->next; cond2 != NULL; cond2 = cond2->next )
{
if ( cond2->op == op_lparen )
{
cond2b = cond2 ->next; if ( cond2b == NULL ) break;
cond2c = cond2b->next; if ( cond2c == NULL ) break;
cond2d = cond2c->next; if ( cond2d == NULL ) break;
cond2e = cond2d->next; if ( cond2e == NULL ) break;
cond2f = cond2e->next;
/* look for match */
if ( cond2b->op == op_variable
&& cond2b->nameindex == cond1b->nameindex
&& cond2c->op == cond1c->op
&& cond2d->op == op_constant
&& strcmp( cond2d->str, cond1d->str ) == 0
&& cond2e->op == op_rparen )
{
/* one of these must be followed by && */
if ( cond1f->op == op_and
|| ( cond2f != NULL && cond2f->op == op_and ) )
{
/* nuke the first duplicate */
cond1 ->op = op_nuked;
cond1b->op = op_nuked;
cond1c->op = op_nuked;
cond1d->op = op_nuked;
cond1e->op = op_nuked;
if ( cond1f->op == op_and )
cond1f->op = op_nuked;
else
cond2f->op = op_nuked;
}
}
}
}
}
}
}
join_done:
return cond_list;
}
static char * current_arch = NULL;
/*
* Eliminating conditions with ARCH = <not current>.
*/
static struct condition *eliminate_other_arch( struct condition *list )
{
struct condition *cond1a = list, *cond1b = NULL, *cond1c = NULL, *cond1d = NULL;
if ( current_arch == NULL )
current_arch = getenv( "ARCH" );
if ( current_arch == NULL )
{
fprintf( stderr, "error: ARCH undefined\n" );
exit( 1 );
}
if ( cond1a->op == op_variable
&& ! strcmp( vartable[cond1a->nameindex].name, "ARCH" ) )
{
cond1b = cond1a->next; if ( cond1b == NULL ) goto done;
cond1c = cond1b->next; if ( cond1c == NULL ) goto done;
cond1d = cond1c->next;
if ( cond1c->op == op_constant && cond1d == NULL )
{
if ( (cond1b->op == op_eq && strcmp( cond1c->str, current_arch ))
|| (cond1b->op == op_neq && ! strcmp( cond1c->str, current_arch )) )
{
/* This is for another architecture */
cond1a->op = op_false;
cond1a->next = NULL;
free_cond( cond1b );
return cond1a;
}
else if ( (cond1b->op == op_neq && strcmp( cond1c->str, current_arch ))
|| (cond1b->op == op_eq && ! strcmp( cond1c->str, current_arch )) )
{
/* This is for current architecture */
cond1a->op = op_true;
cond1a->next = NULL;
free_cond( cond1b );
return cond1a;
}
}
else if ( cond1c->op == op_constant && cond1d->op == op_or )
{
if ( (cond1b->op == op_eq && strcmp( cond1c->str, current_arch ))
|| (cond1b->op == op_neq && ! strcmp( cond1c->str, current_arch )) )
{
/* This is for another architecture */
cond1b = cond1d->next;
cond1d->next = NULL;
free_cond( cond1a );
return eliminate_other_arch( cond1b );
}
else if ( (cond1b->op == op_neq && strcmp( cond1c->str, current_arch ))
|| (cond1b->op == op_eq && ! strcmp( cond1c->str, current_arch )) )
{
/* This is for current architecture */
cond1a->op = op_true;
cond1a->next = NULL;
free_cond( cond1b );
return cond1a;
}
}
else if ( cond1c->op == op_constant && cond1d->op == op_and )
{
if ( (cond1b->op == op_eq && strcmp( cond1c->str, current_arch ))
|| (cond1b->op == op_neq && ! strcmp( cond1c->str, current_arch )) )
{
/* This is for another architecture */
int l_par = 0;
for ( cond1c = cond1d->next; cond1c; cond1c = cond1c->next )
{
if ( cond1c->op == op_lparen )
l_par++;
else if ( cond1c->op == op_rparen )
l_par--;
else if ( cond1c->op == op_or && l_par == 0 )
/* Expression too complex - don't touch */
return cond1a;
else if ( l_par < 0 )
{
fprintf( stderr, "incorrect condition: programming error ?\n" );
exit( 1 );
}
}
cond1a->op = op_false;
cond1a->next = NULL;
free_cond( cond1b );
return cond1a;
}
else if ( (cond1b->op == op_neq && strcmp( cond1c->str, current_arch ))
|| (cond1b->op == op_eq && ! strcmp( cond1c->str, current_arch )) )
{
/* This is for current architecture */
cond1b = cond1d->next;
cond1d->next = NULL;
free_cond( cond1a );
return eliminate_other_arch( cond1b );
}
}
}
if ( cond1a->op == op_variable && ! vartable[cond1a->nameindex].defined )
{
cond1b = cond1a->next; if ( cond1b == NULL ) goto done;
cond1c = cond1b->next; if ( cond1c == NULL ) goto done;
cond1d = cond1c->next;
if ( cond1c->op == op_constant
&& ( cond1d == NULL || cond1d->op == op_and ) ) /*???*/
{
if ( cond1b->op == op_eq && strcmp( cond1c->str, "" ) )
{
cond1a->op = op_false;
cond1a->next = NULL;
free_cond( cond1b );
return cond1a;
}
}
else if ( cond1c->op == op_constant && cond1d->op == op_or )
{
if ( cond1b->op == op_eq && strcmp( cond1c->str, "" ) )
{
cond1b = cond1d->next;
cond1d->next = NULL;
free_cond( cond1a );
return eliminate_other_arch( cond1b );
}
}
}
done:
return list;
}
/*
* This is the main transformation function.
*/
void fix_conditionals( struct kconfig * scfg )
{
struct kconfig * cfg;
/*
* Transform op_variable to op_kvariable.
*/
mark_variables( scfg );
/*
* Walk the statement list, maintaining a stack of current conditions.
* token_if push its condition onto the stack.
* token_else invert the condition on the top of the stack.
* token_endif pop the stack.
*
* For a simple statement, create a condition chain by joining together
* all of the conditions on the stack.
*/
{
struct condition * cond_stack [32];
int depth = 0;
struct kconfig * prev = NULL;
for ( cfg = scfg; cfg != NULL; cfg = cfg->next )
{
int good = 1;
switch ( cfg->token )
{
default:
break;
case token_if:
cond_stack [depth++] =
remove_bang( eliminate_other_arch( cfg->cond ) );
cfg->cond = NULL;
break;
case token_else:
{
/*
* Invert the condition chain.
*
* Be careful to transfrom op_or to op_and1, not op_and.
* I will need this later in the code that removes
* duplicate conditions.
*/
struct condition * cond;
for ( cond = cond_stack [depth-1];
cond != NULL;
cond = cond->next )
{
switch( cond->op )
{
default: break;
case op_and: cond->op = op_or; break;
case op_or: cond->op = op_and1; break;
case op_neq: cond->op = op_eq; break;
case op_eq: cond->op = op_neq; break;
case op_true: cond->op = op_false;break;
case op_false:cond->op = op_true; break;
}
}
}
break;
case token_fi:
--depth;
break;
case token_bool:
case token_choice_item:
case token_choice_header:
case token_comment:
case token_define_bool:
case token_define_hex:
case token_define_int:
case token_define_string:
case token_define_tristate:
case token_endmenu:
case token_hex:
case token_int:
case token_mainmenu_option:
case token_string:
case token_tristate:
case token_unset:
cfg->cond = join_condition_stack( cond_stack, depth );
if ( cfg->cond && cfg->cond->op == op_false )
{
good = 0;
if ( prev )
prev->next = cfg->next;
else
scfg = cfg->next;
}
break;
case token_dep_bool:
case token_dep_mbool:
case token_dep_tristate:
/*
* Same as the other simple statements, plus an additional
* condition for the dependency.
*/
if ( cfg->cond )
{
cond_stack [depth] = eliminate_other_arch( cfg->cond );
cfg->cond = join_condition_stack( cond_stack, depth+1 );
}
else
{
cfg->cond = join_condition_stack( cond_stack, depth );
}
if ( cfg->cond && cfg->cond->op == op_false )
{
good = 0;
if ( prev )
prev->next = cfg->next;
else
scfg = cfg->next;
}
break;
}
if ( good )
prev = cfg;
}
}
}
#if 0
void dump_condition( struct condition *list )
{
struct condition *tmp;
for ( tmp = list; tmp; tmp = tmp->next )
{
switch (tmp->op)
{
default:
break;
case op_variable:
printf( " %s", vartable[tmp->nameindex].name );
break;
case op_constant:
printf( " %s", tmp->str );
break;
case op_eq:
printf( " =" );
break;
case op_bang:
printf( " !" );
break;
case op_neq:
printf( " !=" );
break;
case op_and:
case op_and1:
printf( " -a" );
break;
case op_or:
printf( " -o" );
break;
case op_true:
printf( " TRUE" );
break;
case op_false:
printf( " FALSE" );
break;
case op_lparen:
printf( " (" );
break;
case op_rparen:
printf( " )" );
break;
}
}
printf( "\n" );
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,842 @@
/*
* tkparse.c
*
* Eric Youngdale was the original author of xconfig.
* Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
*
* Parse a config.in file and translate it to a wish script.
* This task has three parts:
*
* tkparse.c tokenize the input
* tkcond.c transform 'if ...' statements
* tkgen.c generate output
*
* Change History
*
* 7 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
* - Teach dep_tristate about a few literals, such as:
* dep_tristate 'foo' CONFIG_FOO m
* Also have it print an error message and exit on some parse failures.
*
* 14 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
* - Don't fclose stdin. Thanks to Tony Hoyle for nailing this one.
*
* 14 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
* - Steam-clean this file. I tested this by generating kconfig.tk for
* every architecture and comparing it character-for-character against
* the output of the old tkparse.
*
* 23 January 1999, Michael Elizabeth Chastain, <mec@shout.net>
* - Remove bug-compatible code.
*
* 07 July 1999, Andrzej M. Krzysztofowicz, <ankry@mif.pg.gda.pl>
* - Submenus implemented,
* - plenty of option updating/displaying fixes,
* - dep_bool, define_hex, define_int, define_string, define_tristate and
* undef implemented,
* - dep_tristate fixed to support multiple dependencies,
* - handling of variables with an empty value implemented,
* - value checking for int and hex fields,
* - more checking during condition parsing; choice variables are treated as
* all others now,
*
* TO DO:
* - xconfig is at the end of its life cycle. Contact <mec@shout.net> if
* you are interested in working on the replacement.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tkparse.h"
static struct kconfig * config_list = NULL;
static struct kconfig * config_last = NULL;
static const char * current_file = "<unknown file>";
static int lineno = 0;
static void do_source( const char * );
#undef strcmp
int my_strcmp( const char * s1, const char * s2 ) { return strcmp( s1, s2 ); }
#define strcmp my_strcmp
/*
* Report a syntax error.
*/
static void syntax_error( const char * msg )
{
fprintf( stderr, "%s: %d: %s\n", current_file, lineno, msg );
exit( 1 );
}
/*
* Find index of a specyfic variable in the symbol table.
* Create a new entry if it does not exist yet.
*/
#define VARTABLE_SIZE 8192
struct variable vartable[VARTABLE_SIZE];
int max_varnum = 0;
int get_varnum( char * name )
{
int i;
for ( i = 1; i <= max_varnum; i++ )
if ( strcmp( vartable[i].name, name ) == 0 )
return i;
if (max_varnum > VARTABLE_SIZE-1)
syntax_error( "Too many variables defined." );
vartable[++max_varnum].name = malloc( strlen( name )+1 );
strcpy( vartable[max_varnum].name, name );
return max_varnum;
}
/*
* Get a string.
*/
static const char * get_string( const char * pnt, char ** label )
{
const char * word;
word = pnt;
for ( ; ; )
{
if ( *pnt == '\0' || *pnt == ' ' || *pnt == '\t' )
break;
pnt++;
}
*label = malloc( pnt - word + 1 );
memcpy( *label, word, pnt - word );
(*label)[pnt - word] = '\0';
if ( *pnt != '\0' )
pnt++;
return pnt;
}
/*
* Get a quoted string.
* Insert a '\' before any characters that need quoting.
*/
static const char * get_qstring( const char * pnt, char ** label )
{
char quote_char;
#define NEWLABELLEN 16384
char newlabel [NEWLABELLEN];
char * pnt1;
/* advance to the open quote */
for ( ; ; )
{
if ( *pnt == '\0' )
return pnt;
quote_char = *pnt++;
if ( quote_char == '"' || quote_char == '\'' )
break;
}
/* copy into an intermediate buffer */
pnt1 = newlabel;
for ( ; ; )
{
if ( *pnt == '\0' )
syntax_error( "unterminated quoted string" );
if ( *pnt == quote_char && pnt[-1] != '\\' )
break;
/* watch for overruns */
if ((pnt1 - newlabel) >= (NEWLABELLEN - 2))
syntax_error( "Buffer overrun - increase NEWLABELLEN." );
/* copy the character, quoting if needed */
if ( *pnt == '"' || *pnt == '\'' || *pnt == '[' || *pnt == ']' )
*pnt1++ = '\\';
*pnt1++ = *pnt++;
}
/* copy the label into a permanent location */
*pnt1++ = '\0';
*label = (char *) malloc( pnt1 - newlabel );
memcpy( *label, newlabel, pnt1 - newlabel );
/* skip over last quote and next whitespace */
pnt++;
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
return pnt;
}
/*
* Get a quoted or unquoted string. It is recognized by the first
* non-white character. '"' and '"' are not allowed inside the string.
*/
static const char * get_qnqstring( const char * pnt, char ** label )
{
char quote_char;
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
if ( *pnt == '\0' )
return pnt;
quote_char = *pnt;
if ( quote_char == '"' || quote_char == '\'' )
return get_qstring( pnt, label );
else
return get_string( pnt, label );
}
/*
* Tokenize an 'if' statement condition.
*/
static struct condition * tokenize_if( const char * pnt )
{
struct condition * list;
struct condition * last;
struct condition * prev;
/* eat the open bracket */
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
if ( *pnt != '[' )
syntax_error( "bad 'if' condition" );
pnt++;
list = last = NULL;
for ( ; ; )
{
struct condition * cond;
/* advance to the next token */
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
if ( *pnt == '\0' )
syntax_error( "unterminated 'if' condition" );
if ( *pnt == ']' )
return list;
/* allocate a new token */
cond = malloc( sizeof(*cond) );
memset( cond, 0, sizeof(*cond) );
if ( last == NULL )
{ list = last = cond; prev = NULL; }
else
{ prev = last; last->next = cond; last = cond; }
/* determine the token value */
if ( *pnt == '-' && pnt[1] == 'a' )
{
if ( ! prev || ( prev->op != op_variable && prev->op != op_constant ) )
syntax_error( "incorrect argument" );
cond->op = op_and; pnt += 2; continue;
}
if ( *pnt == '-' && pnt[1] == 'o' )
{
if ( ! prev || ( prev->op != op_variable && prev->op != op_constant ) )
syntax_error( "incorrect argument" );
cond->op = op_or; pnt += 2; continue;
}
if ( *pnt == '!' && pnt[1] == '=' )
{
if ( ! prev || ( prev->op != op_variable && prev->op != op_constant ) )
syntax_error( "incorrect argument" );
cond->op = op_neq; pnt += 2; continue;
}
if ( *pnt == '=' )
{
if ( ! prev || ( prev->op != op_variable && prev->op != op_constant ) )
syntax_error( "incorrect argument" );
cond->op = op_eq; pnt += 1; continue;
}
if ( *pnt == '!' )
{
if ( prev && ( prev->op != op_and && prev->op != op_or
&& prev->op != op_bang ) )
syntax_error( "incorrect argument" );
cond->op = op_bang; pnt += 1; continue;
}
if ( *pnt == '"' )
{
const char * word;
if ( prev && ( prev->op == op_variable || prev->op == op_constant ) )
syntax_error( "incorrect argument" );
/* advance to the word */
pnt++;
if ( *pnt == '$' )
{
cond->op = op_variable; pnt++;
}
else
{
cond->op = op_constant;
}
/* find the end of the word */
word = pnt;
for ( ; ; )
{
if ( *pnt == '\0' )
syntax_error( "unterminated double quote" );
if ( *pnt == '"' )
break;
pnt++;
}
/* store a copy of this word */
{
char * str = malloc( pnt - word + 1 );
memcpy( str, word, pnt - word );
str [pnt - word] = '\0';
if ( cond->op == op_variable )
{
cond->nameindex = get_varnum( str );
free( str );
}
else /* op_constant */
{
cond->str = str;
}
}
pnt++;
continue;
}
/* unknown token */
syntax_error( "bad if condition" );
}
}
/*
* Tokenize a choice list. Choices appear as pairs of strings;
* note that I am parsing *inside* the double quotes. Ugh.
*/
static const char * tokenize_choices( struct kconfig * cfg_choose,
const char * pnt )
{
int default_checked = 0;
for ( ; ; )
{
struct kconfig * cfg;
char * buffer = malloc( 64 );
/* skip whitespace */
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
if ( *pnt == '\0' )
return pnt;
/* allocate a new kconfig line */
cfg = malloc( sizeof(*cfg) );
memset( cfg, 0, sizeof(*cfg) );
if ( config_last == NULL )
{ config_last = config_list = cfg; }
else
{ config_last->next = cfg; config_last = cfg; }
/* fill out the line */
cfg->token = token_choice_item;
cfg->cfg_parent = cfg_choose;
pnt = get_string( pnt, &cfg->label );
if ( ! default_checked &&
! strncmp( cfg->label, cfg_choose->value, strlen( cfg_choose->value ) ) )
{
default_checked = 1;
free( cfg_choose->value );
cfg_choose->value = cfg->label;
}
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
pnt = get_string( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
}
if ( ! default_checked )
syntax_error( "bad 'choice' default value" );
return pnt;
}
/*
* Tokenize one line.
*/
static void tokenize_line( const char * pnt )
{
static struct kconfig * last_menuoption = NULL;
enum e_token token;
struct kconfig * cfg;
struct dependency ** dep_ptr;
char * buffer = malloc( 64 );
/* skip white space */
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
/*
* categorize the next token
*/
#define match_token(t, s) \
if (strncmp(pnt, s, strlen(s)) == 0) { token = t; pnt += strlen(s); break; }
token = token_UNKNOWN;
switch ( *pnt )
{
default:
break;
case '#':
case '\0':
return;
case 'b':
match_token( token_bool, "bool" );
break;
case 'c':
match_token( token_choice_header, "choice" );
match_token( token_comment, "comment" );
break;
case 'd':
match_token( token_define_bool, "define_bool" );
match_token( token_define_hex, "define_hex" );
match_token( token_define_int, "define_int" );
match_token( token_define_string, "define_string" );
match_token( token_define_tristate, "define_tristate" );
match_token( token_dep_bool, "dep_bool" );
match_token( token_dep_mbool, "dep_mbool" );
match_token( token_dep_tristate, "dep_tristate" );
break;
case 'e':
match_token( token_else, "else" );
match_token( token_endmenu, "endmenu" );
break;
case 'f':
match_token( token_fi, "fi" );
break;
case 'h':
match_token( token_hex, "hex" );
break;
case 'i':
match_token( token_if, "if" );
match_token( token_int, "int" );
break;
case 'm':
match_token( token_mainmenu_name, "mainmenu_name" );
match_token( token_mainmenu_option, "mainmenu_option" );
break;
case 's':
match_token( token_source, "source" );
match_token( token_string, "string" );
break;
case 't':
match_token( token_then, "then" );
match_token( token_tristate, "tristate" );
break;
case 'u':
match_token( token_unset, "unset" );
break;
}
#undef match_token
if ( token == token_source )
{
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
do_source( pnt );
return;
}
if ( token == token_then )
{
if ( config_last != NULL && config_last->token == token_if )
return;
syntax_error( "bogus 'then'" );
}
#if 0
if ( token == token_unset )
{
fprintf( stderr, "Ignoring 'unset' command\n" );
return;
}
#endif
if ( token == token_UNKNOWN )
{
char *msg = malloc(strlen(pnt) + 20);
sprintf(msg, "unknown command: %s", pnt);
syntax_error( msg );
free(msg);
}
/*
* Allocate an item.
*/
cfg = malloc( sizeof(*cfg) );
memset( cfg, 0, sizeof(*cfg) );
if ( config_last == NULL )
{
config_last = config_list = cfg;
}
else
{
config_last->next = cfg; config_last = cfg;
}
/*
* Tokenize the arguments.
*/
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
cfg->token = token;
switch ( token )
{
default:
syntax_error( "unknown token" );
case token_bool:
case token_tristate:
pnt = get_qstring ( pnt, &cfg->label );
pnt = get_string ( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
break;
case token_choice_header:
{
static int choose_number = 0;
char * choice_list;
pnt = get_qstring ( pnt, &cfg->label );
pnt = get_qstring ( pnt, &choice_list );
pnt = get_string ( pnt, &cfg->value );
cfg->nameindex = -(choose_number++);
tokenize_choices( cfg, choice_list );
free( choice_list );
}
break;
case token_comment:
pnt = get_qstring(pnt, &cfg->label);
if ( last_menuoption != NULL )
{
pnt = get_qstring(pnt, &cfg->label);
if (cfg->label == NULL)
syntax_error( "missing comment text" );
last_menuoption->label = cfg->label;
last_menuoption = NULL;
}
break;
case token_define_bool:
case token_define_tristate:
pnt = get_string( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
if ( ( pnt[0] == 'Y' || pnt[0] == 'M' || pnt[0] == 'N'
|| pnt[0] == 'y' || pnt[0] == 'm' || pnt[0] == 'n' )
&& ( pnt[1] == '\0' || pnt[1] == ' ' || pnt[1] == '\t' ) )
{
if ( *pnt == 'n' || *pnt == 'N' ) cfg->value = strdup( "CONSTANT_N" );
else if ( *pnt == 'y' || *pnt == 'Y' ) cfg->value = strdup( "CONSTANT_Y" );
else if ( *pnt == 'm' || *pnt == 'M' ) cfg->value = strdup( "CONSTANT_M" );
}
else if ( *pnt == '$' )
{
pnt++;
pnt = get_string( pnt, &cfg->value );
}
else
{
syntax_error( "unknown define_bool value" );
}
get_varnum( cfg->value );
break;
case token_define_hex:
case token_define_int:
pnt = get_string( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
pnt = get_string( pnt, &cfg->value );
break;
case token_define_string:
pnt = get_string( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
pnt = get_qnqstring( pnt, &cfg->value );
if (cfg->value == NULL)
syntax_error( "missing value" );
break;
case token_dep_bool:
case token_dep_mbool:
case token_dep_tristate:
pnt = get_qstring ( pnt, &cfg->label );
pnt = get_string ( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
dep_ptr = &(cfg->depend);
do {
*dep_ptr = (struct dependency *) malloc( sizeof( struct dependency ) );
(*dep_ptr)->next = NULL;
if ( ( pnt[0] == 'Y' || pnt[0] == 'M' || pnt[0] == 'N'
|| pnt[0] == 'y' || pnt[0] == 'm' || pnt[0] == 'n' )
&& ( pnt[1] == '\0' || pnt[1] == ' ' || pnt[1] == '\t' ) )
{
/* dep_tristate 'foo' CONFIG_FOO m */
if ( pnt[0] == 'Y' || pnt[0] == 'y' )
(*dep_ptr)->name = strdup( "CONSTANT_Y" );
else if ( pnt[0] == 'N' || pnt[0] == 'n' )
(*dep_ptr)->name = strdup( "CONSTANT_N" );
else
(*dep_ptr)->name = strdup( "CONSTANT_M" );
pnt++;
get_varnum( (*dep_ptr)->name );
}
else if ( *pnt == '$' )
{
pnt++;
pnt = get_string( pnt, &(*dep_ptr)->name );
get_varnum( (*dep_ptr)->name );
}
else
{
syntax_error( "can't handle dep_bool/dep_mbool/dep_tristate condition" );
}
dep_ptr = &(*dep_ptr)->next;
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
} while ( *pnt );
/*
* Create a conditional for this object's dependencies.
*/
{
char fake_if [8192];
struct dependency * dep;
struct condition ** cond_ptr;
int first = 1;
cond_ptr = &(cfg->cond);
for ( dep = cfg->depend; dep; dep = dep->next )
{
if ( token == token_dep_tristate
&& !strcmp( dep->name, "CONSTANT_M" ) )
{
continue;
}
if (first)
{
first = 0;
}
else
{
*cond_ptr = malloc( sizeof(struct condition) );
memset( *cond_ptr, 0, sizeof(struct condition) );
(*cond_ptr)->op = op_and;
cond_ptr = &(*cond_ptr)->next;
}
*cond_ptr = malloc( sizeof(struct condition) );
memset( *cond_ptr, 0, sizeof(struct condition) );
(*cond_ptr)->op = op_lparen;
if ( token == token_dep_bool )
sprintf( fake_if, "[ \"$%s\" = \"y\" -o \"$%s\" = \"\" ]; then",
dep->name, dep->name );
else
sprintf( fake_if, "[ \"$%s\" = \"y\" -o \"$%s\" = \"m\" -o \"$%s\" = \"\" ]; then",
dep->name, dep->name, dep->name );
(*cond_ptr)->next = tokenize_if( fake_if );
while ( *cond_ptr )
cond_ptr = &(*cond_ptr)->next;
*cond_ptr = malloc( sizeof(struct condition) );
memset( *cond_ptr, 0, sizeof(struct condition) );
(*cond_ptr)->op = op_rparen;
cond_ptr = &(*cond_ptr)->next;
}
}
break;
case token_else:
case token_endmenu:
case token_fi:
break;
case token_hex:
case token_int:
pnt = get_qstring ( pnt, &cfg->label );
pnt = get_string ( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
pnt = get_string ( pnt, &cfg->value );
break;
case token_string:
pnt = get_qstring ( pnt, &cfg->label );
pnt = get_string ( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
pnt = get_qnqstring ( pnt, &cfg->value );
if (cfg->value == NULL) {
fprintf(stderr, "%s", cfg->label);
syntax_error( "missing initial value" );
}
break;
case token_if:
cfg->cond = tokenize_if( pnt );
break;
case token_mainmenu_name:
pnt = get_qstring( pnt, &cfg->label );
break;
case token_mainmenu_option:
if ( strncmp( pnt, "next_comment", 12 ) == 0 )
last_menuoption = cfg;
else
pnt = get_qstring( pnt, &cfg->label );
break;
case token_unset:
pnt = get_string( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
while (*pnt)
{
cfg->next = (struct kconfig *) malloc( sizeof(struct kconfig) );
memset( cfg->next, 0, sizeof(struct kconfig) );
cfg = cfg->next;
cfg->token = token_unset;
pnt = get_string( pnt, &buffer );
cfg->nameindex = get_varnum( buffer );
while ( *pnt == ' ' || *pnt == '\t' )
pnt++;
}
break;
}
return;
}
/*
* Implement the "source" command.
*/
static void do_source( const char * filename )
{
char buffer [16384];
FILE * infile;
const char * old_file;
int old_lineno;
int offset;
/* open the file */
if ( strcmp( filename, "-" ) == 0 )
infile = stdin;
else
infile = fopen( filename, "r" );
/* if that failed, try ../filename */
if ( infile == NULL )
{
sprintf( buffer, "../%s", filename );
infile = fopen( buffer, "r" );
}
if ( infile == NULL )
{
sprintf( buffer, "unable to open %s", filename );
syntax_error( buffer );
}
/* push the new file name and line number */
old_file = current_file;
old_lineno = lineno;
current_file = filename;
lineno = 0;
/* read and process lines */
for ( offset = 0; ; )
{
char * pnt;
/* read a line */
fgets( buffer + offset, sizeof(buffer) - offset, infile );
if ( feof( infile ) )
break;
lineno++;
/* strip the trailing return character */
pnt = buffer + strlen(buffer) - 1;
if ( *pnt == '\n' )
*pnt-- = '\0';
/* eat \ NL pairs */
if ( *pnt == '\\' )
{
offset = pnt - buffer;
continue;
}
/* tokenize this line */
tokenize_line( buffer );
offset = 0;
}
/* that's all, folks */
if ( infile != stdin )
fclose( infile );
current_file = old_file;
lineno = old_lineno;
return;
}
/*
* Main program.
*/
int main( int argc, const char * argv [] )
{
do_source ( "-" );
fix_conditionals ( config_list );
dump_tk_script ( config_list );
return 0;
}

View file

@ -0,0 +1,127 @@
/*
* tkparse.h
*/
/*
* Token types (mostly statement types).
*/
enum e_token
{
token_UNKNOWN,
token_bool,
token_choice_header,
token_choice_item,
token_comment,
token_define_bool,
token_define_hex,
token_define_int,
token_define_string,
token_define_tristate,
token_dep_bool,
token_dep_mbool,
token_dep_tristate,
token_else,
token_endmenu,
token_fi,
token_hex,
token_if,
token_int,
token_mainmenu_name,
token_mainmenu_option,
token_source,
token_string,
token_then,
token_tristate,
token_unset,
};
/*
* Operator types for conditionals.
*/
enum operator
{
op_eq,
op_neq,
op_and,
op_and1,
op_or,
op_bang,
op_lparen,
op_rparen,
op_constant,
op_variable,
op_true,
op_false,
op_nuked
};
/*
* Conditions come in linked lists.
* Some operators take strings:
*
* op_constant "foo"
* op_variable "$ARCH", "$CONFIG_PMAC", "$CONFIG_EXPERIMENTAL"
*
* Most "$..." constructs refer to a variable which is defined somewhere
* in the script. Note that it is legal to test variables which are never
* defined, such as variables that are meaningful only on other architectures.
*/
struct condition
{
struct condition * next;
enum operator op;
const char * str; /* op_constant */
int nameindex; /* op_variable */
};
/*
* Dependency list for dep_bool, dep_mbool, dep_tristate
*/
struct dependency
{
char * name;
struct dependency * next;
};
/*
* A statement from a config.in file
*/
struct kconfig
{
struct kconfig * next;
enum e_token token;
int nameindex;
char * label;
char * value;
struct condition * cond;
struct dependency * depend; /* token_dep_tristate */
struct kconfig * cfg_parent; /* token_choice_item */
/* used only in tkgen.c */
int menu_number;
int menu_line;
struct kconfig * menu_next;
};
struct variable
{
char * name;
char defined;
char global_written;
};
extern struct variable vartable[];
extern int max_varnum;
/*
* Prototypes
*/
extern void fix_conditionals ( struct kconfig * scfg ); /* tkcond.c */
extern void dump_tk_script ( struct kconfig * scfg ); /* tkgen.c */
extern int get_varnum ( char * name ); /* tkparse.c */

View file

@ -0,0 +1,289 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition the error number in the SDK.
*
* Feature : error definition
*
*/
#ifndef __COMMON_RT_ERROR_H__
#define __COMMON_RT_ERROR_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/error.h>
/*
* Data Type Declaration
*/
typedef enum rt_error_code_e
{
/*
* 0x0000xxxx for common error code
* symbols defined at rt_error_common_t
*/
/* 0x0001xxxx for vlan */
RT_ERR_VLAN_VID = 0x00010000, /* 0x00010000, invalid vid */
RT_ERR_VLAN_PRIORITY, /* 0x00010001, invalid 1p priority */
RT_ERR_VLAN_EMPTY_ENTRY, /* 0x00010002, emtpy entry of vlan table */
RT_ERR_VLAN_ACCEPT_FRAME_TYPE, /* 0x00010003, invalid accept frame type */
RT_ERR_VLAN_EXIST, /* 0x00010004, vlan is exist */
RT_ERR_VLAN_ENTRY_NOT_FOUND, /* 0x00010005, specified vlan entry not found */
RT_ERR_VLAN_PORT_MBR_EXIST, /* 0x00010006, member port exist in the specified vlan */
RT_ERR_VLAN_FRAME_TYPE, /* 0x00010007, Error frame type */
RT_ERR_VLAN_TPID_INDEX, /* 0x00010008, Error TPID index */
RT_ERR_VLAN_C2SC_BLOCK_MODE, /* 0x00010009, incompatiable block mode, change block mode first */
RT_ERR_VLAN_C2SC_BLOCK_DISABLED, /* 0x0001000A, Ingress VLAN conversion block is disabled, enables it first */
/* 0x0002xxxx */
/* 0x0003xxxx for MSTP */
RT_ERR_MSTI = 0x00030000, /* 0x00030000, invalid msti */
RT_ERR_MSTP_STATE, /* 0x00030001, invalid spanning tree status */
RT_ERR_MSTI_EXIST, /* 0x00030002, MSTI exist */
RT_ERR_MSTI_NOT_EXIST, /* 0x00030003, MSTI not exist */
/* 0x0004xxxx for BUCKET */
RT_ERR_TIMESLOT = 0x00040000, /* 0x00040000, invalid time slot */
RT_ERR_TOKEN, /* 0x00040001, invalid token amount */
RT_ERR_RATE, /* 0x00040002, invalid rate */
/* 0x0005xxxx for RMA */
RT_ERR_RMA_ADDR = 0x00050000, /* 0x00050000, invalid rma mac address */
RT_ERR_RMA_ACTION, /* 0x00050001, invalid rma action */
RT_ERR_RMA_MGMT_TYPE, /* 0x00050002, invalid type of management frame */
RT_ERR_RMA_NOT_SUPPORT_GLOBAL, /* 0x00050003, this RMA is not supported in global configuration */
RT_ERR_RMA_NOT_SUPPORT_PORT, /* 0x00050004, this RMA is not supported in per-port configuration */
/* 0x0006xxxx for L2 */
RT_ERR_L2_HASH_KEY = 0x00060000, /* 0x00060000, invalid L2 Hash key */
RT_ERR_L2_HASH_INDEX, /* 0x00060001, invalid L2 Hash index */
RT_ERR_L2_CAM_INDEX, /* 0x00060002, invalid L2 CAM index */
RT_ERR_L2_ENRTYSEL, /* 0x00060003, invalid EntrySel */
RT_ERR_L2_INDEXTABLE_INDEX, /* 0x00060004, invalid L2 index table(=portMask table) index */
RT_ERR_LIMITED_L2ENTRY_NUM, /* 0x00060005, invalid limited L2 entry number */
RT_ERR_L2_AGGREG_PORT, /* 0x00060006, this aggregated port is not the lowest physical
port of its aggregation group */
RT_ERR_L2_FID, /* 0x00060007, invalid fid */
RT_ERR_L2_RVID, /* 0x00060008, invalid cvid */
RT_ERR_L2_NO_EMPTY_ENTRY, /* 0x00060009, no empty entry in L2 table */
RT_ERR_L2_ENTRY_NOTFOUND, /* 0x0006000a, specified entry not found */
RT_ERR_L2_INDEXTBL_FULL, /* 0x0006000b, the L2 index table is full */
RT_ERR_L2_INVALID_FLOWTYPE, /* 0x0006000c, invalid L2 flow type */
RT_ERR_L2_L2UNI_PARAM, /* 0x0006000d, invalid L2 unicast parameter */
RT_ERR_L2_L2MULTI_PARAM, /* 0x0006000e, invalid L2 multicast parameter */
RT_ERR_L2_IPMULTI_PARAM, /* 0x0006000f, invalid L2 ip multicast parameter */
RT_ERR_L2_PARTIAL_HASH_KEY, /* 0x00060010, invalid L2 partial Hash key */
RT_ERR_L2_EMPTY_ENTRY, /* 0x00060011, the entry is empty(invalid) */
RT_ERR_L2_FLUSH_TYPE, /* 0x00060012, the flush type is invalid */
RT_ERR_L2_NO_CPU_PORT, /* 0x00060013, CPU port not exist */
RT_ERR_L2_MULTI_FWD_INDEX, /* 0x00060014, invalid index of multicast forwarding portmask */
RT_ERR_L2_ENTRY_EXIST, /* 0x00060015, entry already exist */
RT_ERR_L2_EXCEPT_ADDR_TYPE, /* 0x00060016, Invalid exception address type */
RT_ERR_L2_MCAST_FWD_ENTRY_EXIST, /* 0x00060017, mcast forwarding entry already exist */
RT_ERR_L2_MCAST_FWD_ENTRY_NOT_EXIST, /* 0x00060018, mcast forwarding entry not exist */
RT_ERR_L2_IPMCAST_LOOKUP_MODE, /* 0x00060019, invalid IP multicast lookup mode */
RT_ERR_L2_PMSK_NOT_INIT, /* 0x0006001a, flooding portmask is not initialized */
RT_ERR_L2_IP6_CACHETBL_FULL, /* 0x0006001b, the IPv6 cache table is full */
RT_ERR_L2_IP6_HASHKEY_EXIST, /* 0x0006001c, the the same IPv6 hash key has already existed */
RT_ERR_L2_NEXTHOP_EXIST, /* 0x0006001d, this is a nexthop entry */
RT_ERR_L2_NEXTHOP_NOT_EXIST, /* 0x0006001e, nexthop entry doesn't exist */
RT_ERR_L2_N_TO_1_NOT_ENABLED, /* 0x0006001f, N:1 is not enabled */
RT_ERR_L2_PE_NOT_ENABLED, /* 0x00060020, Port Extension is not enabled */
/* 0x0007xxxx for FILTER/PIE/ACL/RANGE CHECK */
RT_ERR_PIE_FIELD_TYPE = 0x00070000, /* 0x00070000, invalid pie field type */
RT_ERR_PIE_PHASE, /* 0x00070001, invalid pie phase */
RT_ERR_PIE_PHASE_NOT_SUPPORTED, /* 0x00070002, pie phase not supported in the chip */
RT_ERR_PIE_BLOCK_INDEX, /* 0x00070003, invalid block index */
RT_ERR_PIE_TEMPLATE_INDEX, /* 0x00070004, invalid template index */
RT_ERR_PIE_FIELD_LOCATION, /* 0x00070005, specify field type to invalid field location */
RT_ERR_PIE_CLEAR_INDEX, /* 0x00070006, end index is lower than start index */
RT_ERR_RANGE_CHECK_TYPE = 0x00071000, /* 0x00071000, invalid range check type */
RT_ERR_ACL_FIELD_TYPE = 0x00072000, /* 0x00072000, invalid ACL field type */
RT_ERR_ACL_TEMPLATE_INCOMPATIBLE, /* 0x00072001, try to map a ACL block to an incompatible template */
RT_ERR_ACL_CLEAR_INDEX, /* 0x00072002, end index is lower than start index */
RT_ERR_ACL_BLOCK_INDEX, /* 0x00072003, invalid block index */
RT_ERR_ACL_PHASE, /* 0x00072004, invalid ACL phase */
#if defined(CONFIG_SDK_RTL8380)
RT_ERR_ACL_AGGR_2, /* 0x00072005, only support first 6 blocks(entry0~767) */
#endif
#if (defined(CONFIG_SDK_RTL8390) || defined(CONFIG_SDK_RTL8380))
RT_ERR_ACL_BLOCK_POWER, /* 0x00073000, the block is power disabled */
/* 0x0008xxxx for ACL Rate Limit */
#endif /* (defined(CONFIG_SDK_RTL8390) || defined(CONFIG_SDK_RTL8380)) */
/* 0x0009xxxx for Link aggregation */
RT_ERR_LA_CPUPORT = 0x00090000, /* 0x00090000, CPU port can not be aggregated port */
RT_ERR_LA_TRUNK_ID, /* 0x00090001, invalid trunk id */
RT_ERR_LA_PORTMASK, /* 0x00090002, invalid port mask */
RT_ERR_LA_HASHMASK, /* 0x00090003, invalid hash mask */
RT_ERR_LA_DUMB, /* 0x00090004, this API should be used in 802.1ad dumb mode */
RT_ERR_LA_PORTNUM_DUMB, /* 0x00090005, it can only aggregate at most four ports when 802.1ad dumb mode */
RT_ERR_LA_PORTNUM_NORMAL, /* 0x00090006, it can only aggregate at most eight ports when 802.1ad normal mode */
RT_ERR_LA_MEMBER_OVERLAP, /* 0x00090007, the specified port mask is overlapped with other group */
RT_ERR_LA_NOT_MEMBER_PORT, /* 0x00090008, the port is not a member port of the trunk */
RT_ERR_LA_TRUNK_NOT_EXIST, /* 0x00090009, the trunk doesn't exist */
RT_ERR_LA_ALGO_ID, /* 0x0009000a, invalid trunk algorithm id */
RT_ERR_LA_ALGO_SHIFT, /* 0x0009000b, invalid trunk algorithm shift */
RT_ERR_LA_STACK_TRUNK_ID, /* 0x0009000c, invalid stack trunk id */
/* 0x000axxxx for storm filter */
RT_ERR_SFC_TICK_PERIOD = 0x000a0000, /* 0x000a0000, invalid SFC tick period */
RT_ERR_SFC_UNKNOWN_GROUP, /* 0x000a0001, Unknown Storm filter group */
/* 0x000bxxxx for pattern match */
RT_ERR_PM_MASK = 0x000b0000, /* 0x000b0000, invalid pattern length. Pattern length should be 8 */
RT_ERR_PM_LENGTH, /* 0x000b0001, invalid pattern match mask, first byte must care */
RT_ERR_PM_MODE, /* 0x000b0002, invalid pattern match mode */
/* 0x000cxxxx for input bandwidth control */
RT_ERR_INBW_TICK_PERIOD = 0x000c0000, /* 0x000c0000, invalid tick period for input bandwidth control */
RT_ERR_INBW_TOKEN_AMOUNT, /* 0x000c0001, invalid amount of token for input bandwidth control */
RT_ERR_INBW_FCON_VALUE, /* 0x000c0002, invalid flow control ON threshold value for input bandwidth control */
RT_ERR_INBW_FCOFF_VALUE, /* 0x000c0003, invalid flow control OFF threshold value for input bandwidth control */
RT_ERR_INBW_FC_ALLOWANCE, /* 0x000c0004, invalid allowance of incomming packet for input bandwidth control */
RT_ERR_INBW_RATE, /* 0x000c0005, invalid input bandwidth */
/* 0x000dxxxx for QoS */
RT_ERR_QOS_1P_PRIORITY = 0x000d0000, /* 0x000d0000, invalid 802.1P priority */
RT_ERR_QOS_DSCP_VALUE, /* 0x000d0001, invalid DSCP value */
RT_ERR_QOS_INT_PRIORITY, /* 0x000d0002, invalid internal priority */
RT_ERR_QOS_SEL_DSCP_PRI, /* 0x000d0003, invalid DSCP selection priority */
RT_ERR_QOS_SEL_PORT_PRI, /* 0x000d0004, invalid port selection priority */
RT_ERR_QOS_SEL_IN_ACL_PRI, /* 0x000d0005, invalid ingress ACL selection priority */
RT_ERR_QOS_SEL_CLASS_PRI, /* 0x000d0006, invalid classifier selection priority */
RT_ERR_QOS_EBW_RATE, /* 0x000d0007, invalid egress bandwidth rate */
RT_ERR_QOS_SCHE_TYPE, /* 0x000d0008, invalid QoS scheduling type */
RT_ERR_QOS_QUEUE_WEIGHT, /* 0x000d0009, invalid Queue weight */
RT_ERR_QOS_DROP_PRECEDENCE, /* 0x000d000a, invalid drop precedence */
RT_ERR_QOS_DEI_VALUE, /* 0x000d000b, invalid DEI value */
/* 0x000exxxx for port ability */
RT_ERR_PHY_PAGE_ID = 0x000e0000, /* 0x000e0000, invalid PHY page id */
RT_ERR_PHY_REG_ID, /* 0x000e0001, invalid PHY reg id */
RT_ERR_PHY_DATAMASK, /* 0x000e0002, invalid PHY data mask */
RT_ERR_PHY_AUTO_NEGO_MODE, /* 0x000e0003, invalid PHY auto-negotiation mode */
RT_ERR_PHY_SPEED, /* 0x000e0004, invalid PHY speed setting */
RT_ERR_PHY_DUPLEX, /* 0x000e0005, invalid PHY duplex setting */
RT_ERR_PHY_FORCE_ABILITY, /* 0x000e0006, invalid PHY force mode ability parameter */
RT_ERR_PHY_FORCE_1000, /* 0x000e0007, invalid PHY force mode 1G speed setting */
RT_ERR_PHY_TXRX, /* 0x000e0008, invalid PHY tx/rx */
RT_ERR_PHY_RTCT_NOT_FINISH, /* 0x000e0009, PHY RTCT in progress */
RT_ERR_PHY_RTCT_TIMEOUT, /* 0x000e000a, PHY RTCT timeout */
RT_ERR_PHY_AUTO_ABILITY, /* 0x000e000b, invalid PHY auto mode ability parameter */
RT_ERR_PHY_FIBER_LINKUP, /* 0x000e000c, Access copper PHY is not permit when fiber is linkup */
RT_ERR_PHY_ACCESS_FAIL, /* 0x000e000d, Access PHY fail */
RT_ERR_PHY_MEDIA, /* 0x000e000e, invalid PHY media */
RT_ERR_PHY_NOT_MATCH, /* 0x000e000f, PHY model type not match */
/* 0x000fxxxx for mirror */
RT_ERR_MIRROR_DIRECTION = 0x000f0000, /* 0x000f0000, invalid error mirror direction */
RT_ERR_MIRROR_SESSION_FULL, /* 0x000f0001, mirroring session is full */
RT_ERR_MIRROR_SESSION_NOEXIST, /* 0x000f0002, mirroring session not exist */
RT_ERR_MIRROR_PORT_EXIST, /* 0x000f0003, mirroring port already exists */
RT_ERR_MIRROR_PORT_NOT_EXIST, /* 0x000f0004, mirroring port does not exists */
RT_ERR_MIRROR_PORT_FULL, /* 0x000f0005, Exceeds maximum number of supported mirroring port */
RT_ERR_MIRROR_ID, /* 0x000f0006, Invalid mirror ID */
RT_ERR_MIRROR_DP_IN_SPM_DPM, /* 0x000f0007, mirroring port can not be in ingress or egress mirrored portmask of any mirroring set */
/* 0x0010xxxx for stat */
RT_ERR_STAT_INVALID_GLOBAL_CNTR = 0x00100000, /* 0x00100000, Invalid Global Counter */
RT_ERR_STAT_INVALID_PORT_CNTR, /* 0x00100001, Invalid Port Counter */
RT_ERR_STAT_GLOBAL_CNTR_FAIL, /* 0x00100002, Could not retrieve/reset Global Counter */
RT_ERR_STAT_PORT_CNTR_FAIL, /* 0x00100003, Could not retrieve/reset Port Counter */
RT_ERR_STAT_INVALID_SMON_CNTR, /* 0x00100004, Invalid SMON Counter */
RT_ERR_STAT_SMON_CNTR_FAIL, /* 0x00100005, Could not retrieve/reset SMON Counter */
/* 0x0011xxxx */
/* 0x0012xxxx for ptp */
RT_ERR_PTP_INVALID_TIMESTAMP = 0x00120000, /* 0x00120000, Invalid PTP timestamp */
RT_ERR_PTP_SEQUENCE_ID, /* 0x00120001, not correct sequence id */
/* 0x0013xxxx for avb */
RT_ERR_AVB_INVALID_SR_CLASS = 0x00130000, /* 0x00130000, Invalid SR Class */
/* 0x0014xxxx for port related */
RT_ERR_PORT_VLAN_ISO_VID_EXIST_IN_OTHER_IDX = 0x00140000, /* 0x00140000, VID exists in other entry */
RT_ERR_PORT_VLAN_ISO_VID_NOT_FOUND, /* 0x00140001, VID not found */
RT_ERR_PORT_VLAN_ISO_NO_EMPTY_ENTRY, /* 0x00140002, No VLAN isolation entry is empty */
/* 0x0015xxxx for L3 routing */
RT_ERR_INTF_MTU_VARIETY_EXCEEDS = 0x00150000, /* 0x00150000, interface MTU variety exceeds the maximum */
RT_ERR_MCAST_GROUP_NOT_FOUND, /* 0x00150001, group not found */
RT_ERR_MCAST_GROUP_UNBIND, /* 0x00150002, group not bind */
RT_ERR_IPMC_ADDR, /* 0x00150003, invalid multicat ip address */
RT_ERR_INTF_NOT_EXIST, /* 0x00150004, interface ID not exsit */
RT_ERR_NEXTHOP_NOT_EXIST, /* 0x00150005, Path ID (next-hop index) not exsit */
RT_ERR_MTU_EXCEED, /* 0x00150006, interface MTU value is too big (over maximum) */
RT_ERR_TTL_EXCEED, /* 0x00150007, interface TTL value is too big (over maximum) */
/* 0x0016xxxx for OpenFlow related */
RT_ERR_OF_FIELD_TYPE = 0x00160000, /* 0x00160000, Invalid match field type */
RT_ERR_OF_FT_PHASE, /* 0x00160001, Invalid Flow Table phase */
RT_ERR_OF_SET_FIELD_ID, /* 0x00160002, Invalid set field ID */
RT_ERR_OF_SET_FIELD_TYPE, /* 0x00160003, Invalid set field type */
RT_ERR_VALID_ENTRY_EXIST, /* 0x00160004, Valid entry is existed */
RT_ERR_OF_BLOCK_PHASE, /* 0x00160005, The block is not belonged to Flow Table */
/* 0x0018xxxx for stacking related */
RT_ERR_STACK_DEV_ID = 0x00180000, /* 0x00180000, Invalid stacking device ID */
RT_ERR_STACK_PORT_ID, /* 0x00180001, Invalid stacking port ID */
RT_ERR_STACK_PORT_NUM, /* 0x00180002, Number of stacking ports exceeds the maximum */
RT_ERR_STACK_PORT_RX_EN, /* 0x00180003, MAC RX disabled serdes port can't be configured as stacking port */
/* 0x0019xxxx for BPE related */
RT_ERR_BPE_NO_EMPTY_ENTRY = 0x00190000, /* 0x00190000, no empty entry */
RT_ERR_END /* The symbol is the latest symbol */
} rt_error_code_t;
/*
* Macro Definition
*/
#define RT_ERR_XLATE_RET(ret)\
do {\
if (ret) {\
return rtk_error_translate(ret);\
}\
} while (0)
/*
* Function Declaration
*/
extern int32
rtk_error_translate(int32 errCode);
/* Function Name:
* rt_error_numToStr
* Description:
* Convert error number to readable string.
* Input:
* err_num --- error number
* Output:
* None.
* Return:
* error string
* Note:
* None.
*/
extern const uint8 *rt_error_numToStr(int32 err_num);
#endif /* __COMMON_RT_ERROR_H__ */

View file

@ -0,0 +1,369 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition the basic types in the SDK.
*
* Feature : type definition
*
*/
#ifndef __COMMON_RT_TYPE_H__
#define __COMMON_RT_TYPE_H__
/*
* Include Files
*/
#include <common/rt_autoconf.h>
#include <common/type.h>
#include <common/util/rt_bitop.h>
/*
* Symbol Definition
*/
/* for system */
#define RTK_MAX_NUM_OF_UNIT_LOCAL 6 /* the maximum number of units in one CPU system (usually in a hardware board) */
#define RTK_MAX_NUM_OF_UNIT 16 /* the maximum number of units in whole stacking system */
#define RTK_MAX_NUM_OF_DEV 16 /* the maximum number of devices in whole stacking system */
#define RTK_MAX_UNIT_ID (RTK_MAX_NUM_OF_UNIT - 1)
#define RTK_LOADER_UNIT_ID 0
#define RTK_MAX_PORT_PER_UNIT 64 /* max number of ports supported by a chip */
#define RTK_MAX_NUM_OF_PORT (RTK_MAX_PORT_PER_UNIT * RTK_MAX_NUM_OF_UNIT) /* max number of ports supported by whole stacking system */
#define RTK_MAX_PORT_ID_PER_UNIT (RTK_MAX_PORT_PER_UNIT - 1)
#define RTK_MAX_NUM_OF_PORTS RTK_MAX_PORT_PER_UNIT /* this one will be replaced by RTK_MAX_PORT_PER_UNIT later, once we have time free */
#define RTK_MAX_SDS_PER_UNIT 24 /* max number of SERDES supported by a chip */
#define RTK_MAX_SC_PER_UNIT 8 /* max number of SerDes Converter connected by a chip */
#define RTK_MAX_PHY_PER_UNIT 16 /* max number of PHY connected by a chip */
#define RTK_MAX_LED_PER_PORT 5 /* max number of led connected by a port */
#define RTK_MAX_LED_MOD 4 /* max number of led mode */
#define RTK_MAX_SDS_PER_PHY 3 /* max SerDes number of a PHY */
#define RTK_MAX_MACSEC_SA_PER_PORT 64 /* max number of Secure Association by a port*/
#define RTK_MAX_MACSEC_SC_PER_PORT RTK_MAX_MACSEC_SA_PER_PORT/4 /* max number of Secure Channel by a port (4 AN per SC) */
#define RTK_TOTAL_NUM_OF_BYTE_FOR_1BIT_PORT_LIST ((RTK_MAX_PORT_PER_UNIT+7)/8)
#define RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST BITMAP_ARRAY_CNT(RTK_MAX_PORT_PER_UNIT)
#define RTK_MAX_TRUNK_PER_UNIT 128 /* max number of trunk by a chip */
#define RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_TRUNK_LIST BITMAP_ARRAY_CNT(RTK_MAX_TRUNK_PER_UNIT)
/* for modules */
#define RTK_MAX_NUM_OF_VLAN_GROUPS 16
#define RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_VLAN_GROUP BITMAP_ARRAY_CNT(RTK_MAX_NUM_OF_VLAN_GROUPS)
#define RTK_MAX_NUM_OF_MIRRORING_PORT 1
#define RTK_MAX_NUM_OF_TRUNK_HASH_VAL 32
#define RTK_MAX_NUM_OF_VLAN_ID 4096
#define RTK_VLAN_ID_MIN 0
#define RTK_VLAN_ID_MAX 4095
#define RTK_FID_MIN 0
#define RTK_FID_MAX 4095
#define RTK_ETHERTYPE_MAX 0xFFFF
#if defined(CONFIG_SDK_RTL9310) ||defined(CONFIG_SDK_RTL9300)
#define RTK_MAX_NUM_OF_QUEUE 32
#define RTK_IP_MTU_MAX 0xFFFF
#define RTK_IP_TTL_MAX 255
#else
#define RTK_MAX_NUM_OF_QUEUE 8
#endif
#define RTK_MAX_NUM_OF_PRIORITY 8
#define RTK_VALUE_OF_DEI_MAX 1
#define RTK_VALUE_OF_DEI_MIN 0
#define RTK_VALUE_OF_DSCP_MAX 63
#define RTK_VALUE_OF_DSCP_MIN 0
#define RTK_VALUE_OF_IP_PRECEDENCE_MAX 7
#define RTK_VALUE_OF_TOS_MAX 0xFF
#define RTK_DOT1P_PRIORITY_MAX 7
#define RTK_DOT1P_DEI_MAX 1
#define RTK_DOT1P_CFI_MAX 1
#define RTK_DROP_PRECEDENCE_MAX 2
#define RTK_LINKMON_SCAN_INTERVAL_MIN 10000
#define RTK_LOSMON_SCAN_INTERVAL_MIN 1000000
#define RTK_WA_SCAN_INTERVAL_MIN 500000
#define RTK_MACMON_SCAN_INTERVAL_MIN 1000000
#define RTK_EEE_TX_SLEEP_RATE_FE_MAX 3125
#define RTK_EEE_TX_SLEEP_RATE_GE_MAX 31250
#define RTK_TPID_MAX 0xFFFF
#define RTK_MAX_NUM_OF_SERDES 14
#define RTK_MAX_SERDES_ID (RTK_MAX_NUM_OF_SERDES - 1)
#define RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_SERDES_LIST BITMAP_ARRAY_CNT(RTK_MAX_NUM_OF_SERDES)
#define RTK_PORT_SPEC_CONGEST_TIME_MAX 0xF
#define RTK_MAX_NUM_OF_LINKMON_CB 4
#define RTK_MAX_MPLS_LABEL 0xFFFFF
#define RTK_EYE_MON_X_MAX 64
#define RTK_EYE_MON_Y_MAX 64
#define RTK_EYE_MON_ARXIS_Y_MAX (RTK_EYE_MON_Y_MAX << 1)
#define RTK_EYE_MON_FRAME_MAX 16
#define RTK_EYE_MON_DATA_POS(_f, _x, _y) ((RTK_EYE_MON_X_MAX * RTK_EYE_MON_Y_MAX * _f) + (RTK_EYE_MON_Y_MAX *_x) + _y)
#define RTK_EYE_MON_YAXIS_CHK_OFST 10
#define CODE_TBC 0
/*
* Data Type Declaration
*/
typedef uint32 rtk_vlan_t; /* vlan id type */
typedef uint32 rtk_fid_t; /* filter id type */
typedef uint32 rtk_stg_t; /* spanning tree instance id type */
typedef uint32 rtk_port_t; /* port id type */
typedef uint32 rtk_trunk_t; /* trunk id type */
typedef uint32 rtk_intf_id_t; /* interface id type */
typedef uint32 rtk_vrf_id_t; /* VRF id type */
typedef uint32 rtk_pri_t; /* priority vlaue */
typedef uint32 rtk_qid_t; /* queue id type */
typedef uint32 rtk_filter_id_t; /* filter id type */
typedef uint32 rtk_pie_id_t; /* PIE id type */
typedef uint32 rtk_acl_id_t; /* ACL id type */
typedef uint32 rtk_trk_t; /* trunk id type */
typedef uint32 rtk_stk_trk_t; /* stacking port trunk id type */
typedef uint32 rtk_bpe_ecid_t; /* e-channel id of port extension */
typedef enum rtk_port_media_e
{
PORT_MEDIA_COPPER = 0,
PORT_MEDIA_FIBER,
PORT_MEDIA_END
} rtk_port_media_t;
/* This enum is used for some specified PHY that have supported 1000BASE-X
* and 100BASE-FX auto detection. Ex: RTL8212B/RTL8214B//RTL8214FB
*/
typedef enum rtk_port_fiber_media_e
{
PORT_FIBER_MEDIA_1000 = 0,
PORT_FIBER_MEDIA_100,
PORT_FIBER_MEDIA_AUTO,
PORT_FIBER_MEDIA_END
} rtk_port_fiber_media_t;
/* rtk_portmask_t is a per-unit data structure. That is, a port-bit-map of a unit */
typedef struct rtk_portmask_s
{
rtk_bitmap_t bits[RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST];
} rtk_portmask_t;
typedef struct rtk_trkmask_s
{
rtk_bitmap_t bits[RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_TRUNK_LIST];
} rtk_trkmask_t;
typedef struct rtk_vlan_groupMask_s
{
rtk_bitmap_t bits[RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_VLAN_GROUP];
} rtk_vlan_groupMask_t;
typedef struct rt_portType_info_s
{
uint32 portNum;
rtk_portmask_t portmask;
} rt_portType_info_t;
/* frame type of protocol vlan - reference 802.1v standard */
typedef enum rtk_vlan_protoVlan_frameType_e
{
FRAME_TYPE_UNKNOWN = 0,
FRAME_TYPE_ETHERNET,
FRAME_TYPE_RFC1042,
FRAME_TYPE_SNAP8021H,/* Not supported by any chip */
FRAME_TYPE_SNAPOTHER,/* Not supported by any chip */
FRAME_TYPE_LLCOTHER,
FRAME_TYPE_END
} rtk_vlan_protoVlan_frameType_t;
/* Protocol-and-port-based Vlan structure */
typedef struct rtk_vlan_protoAndPortInfo_s
{
uint32 proto_type;
rtk_vlan_protoVlan_frameType_t frame_type;
rtk_vlan_t cvid;
rtk_pri_t cpri;
}rtk_vlan_protoAndPortInfo_t;
#define IPV6_ADDR_LEN 16
typedef uint32 rtk_ip_addr_t;
typedef struct
{
uint8 octet[IPV6_ADDR_LEN];
} rtk_ipv6_addr_t;
typedef enum rtk_l4Proto_e
{
L4PROTO_TCP = 0,
L4PROTO_UDP,
L4PROTO_END
} rtk_l4Proto_t;
typedef enum rtk_action_e
{
ACTION_FORWARD = 0,
ACTION_DROP,
ACTION_TRAP2CPU,
ACTION_COPY2CPU,
ACTION_TRAP2MASTERCPU,
ACTION_COPY2MASTERCPU,
ACTION_FLOOD_IN_VLAN,
ACTION_LOOPBACK,
ACTION_LINK_FAULT_DETECT,
ACTION_END
} rtk_action_t;
typedef enum rtk_pktType_e
{
ETHERNET_II_PACKET = 0,
SNAP_PACKET,
PKT_TYPE_END
} rtk_pktType_t;
typedef enum rtk_vlanType_e
{
INNER_VLAN = 0,
OUTER_VLAN,
VLAN_TYPE_END
} rtk_vlanType_t;
typedef enum rtk_snapMode_e
{
SNAP_MODE_AAAA03000000 = 0, /* compare 0xAAAA03000000 */
SNAP_MODE_AAAA03, /* compare 0xAAAA03 */
SNAP_MODE_END
} rtk_snapMode_t;
typedef enum rtk_pktFormat_e
{
ORIGINAL_PACKET = 0,
MODIFIED_PACKET,
PKT_FORMAT_NOP,
PKT_FORMAT_END
} rtk_pktFormat_t;
/* Reference Time */
typedef struct rtk_time_timeStamp_s
{
uint64 sec;
uint32 nsec;
} rtk_time_timeStamp_t;
/* Message Type */
typedef enum rtk_time_ptpMsgType_e
{
PTP_MSG_TYPE_SYNC = 0,
PTP_MSG_TYPE_DELAY_REQ = 1,
PTP_MSG_TYPE_PDELAY_REQ = 2,
PTP_MSG_TYPE_PDELAY_RESP = 3,
} rtk_time_ptpMsgType_t;
/* trap packet target */
typedef enum rtk_trapTarget_e
{
RTK_TRAP_LOCAL,
RTK_TRAP_MASTER,
RTK_TRAP_END,
} rtk_trapTarget_t;
/* TIME packet identifier */
typedef struct rtk_time_ptpIdentifier_s
{
rtk_time_ptpMsgType_t msgType;
uint32 sequenceId;
} rtk_time_ptpIdentifier_t;
typedef enum rtk_time_oper_e
{
TIME_OPER_START = 0,
TIME_OPER_STOP,
TIME_OPER_LATCH,
TIME_OPER_CMD_EXEC,
TIME_OPER_FREQ_APPLY,
TIME_OPER_END
} rtk_time_oper_t;
typedef struct rtk_time_operCfg_s
{
rtk_time_oper_t oper;
rtk_enable_t rise_tri;
rtk_enable_t fall_tri;
} rtk_time_operCfg_t;
typedef struct rtk_dev_port_s {
uint32 devID;
rtk_port_t port;
} rtk_dev_port_t;
typedef struct rtk_text_s
{
char text[64];
}rtk_text_t;
typedef struct {
unsigned int reg;
unsigned int val;
} confcode_mac_regval_t;
typedef struct rtk_regFieldId_s
{
uint32 reg;
uint32 field;
} rtk_regFieldId_t;
typedef enum drv_smi_mdxProtoSel_e
{
DRV_SMI_MDX_PROTO_C22 = 0,
DRV_SMI_MDX_PROTO_C45,
DRV_SMI_MDX_PROTO_END,
}drv_smi_mdxProtoSel_t;
typedef struct rtk_sds_eyeParam_s
{
uint32 impedance;
uint32 pre_amp;
uint32 main_amp;
uint32 post_amp;
uint32 post2_amp;
rtk_enable_t pre_en;
rtk_enable_t post_en;
rtk_enable_t post2_en;
rtk_enable_t main_en;
}rtk_sds_eyeParam_t;
typedef struct rtk_sds_rxCaliConf_s {
#if defined(CONFIG_SDK_RTL9300)
uint32 dacLongCableOffset;
uint16 tap0_init_val;
uint16 vth_min;
uint16 eqHoldEnable;
#endif /* CONFIG_SDK_RTL9300 */
uint16 dfeTap1_4Enable;
#if defined(CONFIG_SDK_RTL9310)
uint32 ofst;
uint8 dfeAuto;
uint8 leqAuto;
#endif /* CONFIG_SDK_RTL9310 */
} rtk_sds_rxCaliConf_t;
typedef struct rt_eye_monBmap_s {
rtk_bitmap_t arr[BITMAP_ARRAY_CNT(RTK_EYE_MON_ARXIS_Y_MAX)];
} rtk_eye_monBmap_t;
#endif /* __COMMON_RT_TYPE_H__ */

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition the version information in the SDK.
*
* Feature : Version information
*
*/
#ifndef __COMMON_RT_VERSION_H__
#define __COMMON_RT_VERSION_H__
/*
* Symbol Definition
*/
#define RT_VERSION_SDK "3.6.9.55156"
#endif /* __COMMON_RT_VERSION_H__ */

View file

@ -0,0 +1,289 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : BIT operation utility
*
* Feature :
*
*/
#ifndef __COMMON_RT_BITOP_H__
#define __COMMON_RT_BITOP_H__
/*
* Include Files
*/
#include <common/type.h>
/*
* Symbol Definition
*/
#define MASK_BIT_LEN 32
/* bit masp */
#define BITMASK_1B 0x00000001
#define BITMASK_2B 0x00000003
#define BITMASK_3B 0x00000007
#define BITMASK_4B 0x0000000F
#define BITMASK_5B 0x0000001F
#define BITMASK_6B 0x0000003F
#define BITMASK_7B 0x0000007F
#define BITMASK_8B 0x000000FF
#define BITMASK_9B 0x000001FF
#define BITMASK_10B 0x000003FF
#define BITMASK_11B 0x000007FF
#define BITMASK_12B 0x00000FFF
#define BITMASK_13B 0x00001FFF
#define BITMASK_14B 0x00003FFF
#define BITMASK_15B 0x00007FFF
#define BITMASK_16B 0x0000FFFF
#define BITMASK_17B 0x0001FFFF
#define BITMASK_18B 0x0003FFFF
#define BITMASK_19B 0x0007FFFF
#define BITMASK_20B 0x000FFFFF
#define BITMASK_21B 0x001FFFFF
#define BITMASK_22B 0x003FFFFF
#define BITMASK_23B 0x007FFFFF
#define BITMASK_24B 0x00FFFFFF
#define BITMASK_25B 0x01FFFFFF
#define BITMASK_26B 0x03FFFFFF
#define BITMASK_27B 0x07FFFFFF
#define BITMASK_28B 0x0FFFFFFF
#define BITMASK_29B 0x1FFFFFFF
#define BITMASK_30B 0x3FFFFFFF
#define BITMASK_31B 0x7FFFFFFF
#define BITMASK_32B 0xFFFFFFFF
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/* structure of bitmap */
typedef uint32 rtk_bitmap_t;
/* bitmap width in bits */
#define BITMAP_WIDTH (sizeof(rtk_bitmap_t) * 8)
/* Input number of indexes to this macro, it returns maximum number of rtk_bitmap_t that required for the array.
* E.g. rtk_bitmap_t xxx[BITMAP_ARRAY_CNT(XXX_MAX_NUM)];
*/
#define BITMAP_ARRAY_CNT(_num_of_indexes) ((_num_of_indexes + (BITMAP_WIDTH - 1)) / BITMAP_WIDTH)
/* Input number of indexes to this macro, it returns total array size in bytes.
* E.g. rtk_bitmap_t *pxxx = osal_alloc(BITMAP_ARRAY_SIZE(XXX_MAX_NUM));
*/
#define BITMAP_ARRAY_SIZE(_num_of_indexes) (BITMAP_ARRAY_CNT(_num_of_indexes) * sizeof(rtk_bitmap_t))
/*
* Bitmap operations
* array - rtk_bitmap_t array.
* index - index number.
* length - bitmap array size.
*/
#define BITMAP_IS_SET(array, index)\
(array[index/BITMAP_WIDTH] & (0x1 << (index%BITMAP_WIDTH)))
#define BITMAP_IS_CLEAR(array, index)\
!(array[index/BITMAP_WIDTH] & (0x1 << (index%BITMAP_WIDTH)))
#define BITMAP_SET(array, index) do {\
array[index/BITMAP_WIDTH] = \
(array[index/BITMAP_WIDTH] | (0x1 << (index%BITMAP_WIDTH))); } while(0)
#define BITMAP_CLEAR(array, index) do {\
array[index/BITMAP_WIDTH] = \
(array[index/BITMAP_WIDTH] & ~(0x1 << (index%BITMAP_WIDTH))); } while(0)
#define BITMAP_ASSIGN(dstArray, srcArray, length) \
do { \
osal_memcpy(dstArray, srcArray, length*sizeof(rtk_bitmap_t)); \
} while(0)
#define BITMAP_RESET(dstArray, length) \
do { \
osal_memset(dstArray, 0, length*sizeof(rtk_bitmap_t)); \
} while(0)
#define BITMAP_COMPARE(dstArray, srcArray, length) osal_memcmp(dstArray, srcArray, length*sizeof(rtk_bitmap_t))
#define BITMAP_AND(dstArray, srcArray, length) \
do { \
uint32 array_index;\
for (array_index = 0; array_index < length; array_index++)\
{\
dstArray[array_index] &= srcArray[array_index];\
}\
} while(0)
#define BITMAP_OR(dstArray, srcArray, length) \
do { \
uint32 array_index;\
for (array_index = 0; array_index < length; array_index++)\
{\
dstArray[array_index] |= srcArray[array_index];\
}\
} while(0)
#define BITMAP_XOR(dstArray, srcArray, length) \
do { \
uint32 array_index;\
for (array_index = 0; array_index < length; array_index++)\
{\
dstArray[array_index] ^= srcArray[array_index];\
}\
} while(0)
#define BITMAP_REMOVE(dstArray, srcArray, length) \
do { \
uint32 array_index;\
for (array_index = 0; array_index < length; array_index++)\
{\
dstArray[array_index] &= ~srcArray[array_index];\
}\
} while(0)
#define BITMAP_REVERT(dstArray, length) \
do { \
uint32 array_index;\
for (array_index = 0; array_index < length; array_index++)\
{\
dstArray[array_index] = ~dstArray[array_index];\
}\
} while(0)
/*
* Function Declaration
*/
/* Function Name:
* bitop_numberOfSetBits
* Description:
* caculate how much bit is set in this word
* Input:
* value - the word to be handled
* Output:
* None
* Return:
* number bits are set
* Note:
* None
*/
extern uint32
rt_bitop_numberOfSetBits(rtk_bitmap_t value);
/* Function Name:
* bitop_numberOfSetBitsInArray
* Description:
* caculate how much bit is set in this array
* Input:
* pArray - the word to be handled
* arraySize - Size of Array
* Output:
* None
* Return:
* number bits are set
* Note:
* None
*/
extern uint32
bitop_numberOfSetBitsInArray(rtk_bitmap_t *pArray, uint32 arraySize);
/* Function Name:
* rt_bitop_findFirstBit
* Description:
* find first bits
* Input:
* value - the word to be handled
* Output:
* None
* Return:
* position of first bit
* if not bit is set, will return (-1)
* Note:
* None
*/
extern int32
rt_bitop_findFirstBit(rtk_bitmap_t value);
/* Function Name:
* rt_bitop_findFirstBitInArray
* Description:
* find first bits in Array
* Input:
* pArray - the array to be handled
* Output:
* None
* Return:
* position of first bit
* if not bit is set, will return (-1)
* Note:
* None
*/
extern int32
rt_bitop_findFirstBitInAaray(rtk_bitmap_t *pArray, uint32 arraySize);
/* Function Name:
* rt_bitop_findFirstZeroBitInAaray
* Description:
* find first zero bit in Array
* Input:
* pArray - the array to be handled
* Output:
*
* Return:
* position of first zero bit
* if not bit is set, will return (-1)
* Note:
* None
*/
extern int32
rt_bitop_findFirstZeroBitInAaray(rtk_bitmap_t *pArray, uint32 arraySize);
/* Function Name:
* rt_bitop_findLastBitInArray
* Description:
* find last bits in Array
* Input:
* pArray - the array to be handled
* Output:
* None
* Return:
* position of last bit
* if not bit is set, will return (-1)
* Note:
* None
*/
extern int32
rt_bitop_findLastBitInAaray(rtk_bitmap_t *pArray, uint32 arraySize);
/* Function Name:
* rt_bitop_findIdxBitInAaray
* Description:
* find the idx bits in Array
* Input:
* pArray - the array to be handled
* Output:
*
* Return:
* position of the idx bit
* if not bit is set, will return (-1)
* Note:
* None
*/
extern int32
rt_bitop_findIdxBitInAaray(rtk_bitmap_t *pArray, uint32 arraySize, uint32 idx);
#endif /* __COMMON_RT_BITOP_H__ */

View file

@ -0,0 +1,177 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : linked list utility
*
* Feature :
*
*/
#ifndef __COMMON_RT_LIST_H__
#define __COMMON_RT_LIST_H__
/*
* Include Files
*/
#include <common/type.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/* Doubly-linked list related macros */
#define RTK_LIST_DEF(_structName, _listName) \
struct { \
struct _structName *pHead; \
struct _structName *pTail; \
uint32 length; \
} _listName
#define RTK_LIST_INIT(_pList) \
do { \
(_pList)->pHead = NULL; \
(_pList)->pTail = NULL; \
(_pList)->length = 0; \
} while (0)
#define RTK_LIST_NODE_REF_DEF(_structName, _refField) \
struct { \
struct _structName *pPrev; \
struct _structName *pNext; \
} _refField
#define RTK_LIST_NODE_REF_INIT(_pNode, _refField) \
do { \
(_pNode)->_refField.pPrev = NULL; \
(_pNode)->_refField.pNext = NULL; \
} while (0)
#define RTK_LIST_EMPTY(_pList) ((_pList)->length == 0)
#define RTK_LIST_LENGTH(_pList) ((_pList)->length)
#define RTK_LIST_NODE_INSERT_BEFORE(_pList, _pBase, _pNode, _refField) \
do { \
(_pNode)->_refField.pPrev = (_pBase)->_refField.pPrev; \
(_pNode)->_refField.pNext = (_pBase); \
if ((_pBase)->_refField.pPrev == NULL) \
{ \
(_pBase)->_refField.pPrev = (_pNode); \
(_pList)->pHead = (_pNode); \
} else { \
(_pBase)->_refField.pPrev->_refField.pNext = (_pNode); \
(_pBase)->_refField.pPrev = (_pNode); \
} \
(_pList)->length ++; \
} while (0)
#define RTK_LIST_NODE_INSERT_AFTER(_pList, _pBase, _pNode, _refField) \
do { \
(_pNode)->_refField.pPrev = (_pBase); \
(_pNode)->_refField.pNext = (_pBase)->_refField.pNext; \
if ((_pBase)->_refField.pNext == NULL) \
{ \
(_pBase)->_refField.pNext = (_pNode); \
(_pList)->pTail = (_pNode); \
} else { \
(_pBase)->_refField.pNext->_refField.pPrev = (_pNode); \
(_pBase)->_refField.pNext = (_pNode); \
} \
(_pList)->length ++; \
} while (0)
#define RTK_LIST_NODE_INSERT_HEAD(_pList, _pNode, _refField) \
do { \
if ((_pList)->pHead == NULL) \
{ \
(_pList)->pHead = (_pNode); \
(_pList)->pTail = (_pNode); \
(_pNode)->_refField.pPrev = NULL; \
(_pNode)->_refField.pNext = NULL; \
(_pList)->length ++; \
} else { \
RTK_LIST_NODE_INSERT_BEFORE(_pList, (_pList)->pHead, _pNode, _refField); \
} \
} while (0)
#define RTK_LIST_NODE_INSERT_TAIL(_pList, _pNode, _refField) \
do { \
if ((_pList)->pTail == NULL) \
{ \
RTK_LIST_NODE_INSERT_HEAD(_pList, _pNode, _refField); \
} else { \
RTK_LIST_NODE_INSERT_AFTER(_pList, (_pList)->pTail, _pNode, _refField); \
} \
} while (0)
#define RTK_LIST_NODE_REMOVE(_pList, _pNode, _refField) \
do { \
if ((_pNode)->_refField.pPrev == NULL) \
{ \
(_pList)->pHead = (_pNode)->_refField.pNext; \
} else { \
(_pNode)->_refField.pPrev->_refField.pNext = (_pNode)->_refField.pNext; \
} \
if ((_pNode)->_refField.pNext == NULL) \
{ \
(_pList)->pTail = (_pNode)->_refField.pPrev; \
} else { \
(_pNode)->_refField.pNext->_refField.pPrev = (_pNode)->_refField.pPrev; \
} \
(_pList)->length --; \
} while (0)
#define RTK_LIST_NODE_HEAD(_pList) ((_pList)->pHead)
#define RTK_LIST_NODE_TAIL(_pList) ((_pList)->pTail)
#define RTK_LIST_NODE_PREV(_pNode, _refField) ((_pNode)->_refField.pPrev)
#define RTK_LIST_NODE_NEXT(_pNode, _refField) ((_pNode)->_refField.pNext)
#define RTK_LIST_FOREACH(_pList, _pNode, _refField) \
for ((_pNode)=RTK_LIST_NODE_HEAD(_pList); \
(_pNode); \
(_pNode)=RTK_LIST_NODE_NEXT(_pNode, _refField))
#define RTK_LIST_FOREACH_REVERSE(_pList, _pNode, _refField) \
for ((_pNode)=RTK_LIST_NODE_TAIL(_pList); \
(_pNode); \
(_pNode)=RTK_LIST_NODE_PREV(_pNode, _refField))
/*
* these macros are safe for removing node during iteration
*/
#define RTK_LIST_FOREACH_SAFE(_pList, _pNode, _pTemp, _refField) \
for ((_pNode)=RTK_LIST_NODE_HEAD(_pList); \
(_pNode) && ((_pTemp) = RTK_LIST_NODE_NEXT(_pNode, _refField), 1); \
(_pNode)=(_pTemp))
#define RTK_LIST_FOREACH_REVERSE_SAFE(_pList, _pNode, _pTemp, _refField) \
for ((_pNode)=RTK_LIST_NODE_TAIL(_pList); \
(_pNode) && ((_pTemp) = RTK_LIST_NODE_PREV(_pNode, _refField), 1); \
(_pNode)=(_pTemp))
/*
* Function Declaration
*/
#endif /* __COMMON_RT_LIST_H__ */

View file

@ -0,0 +1,570 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Define the utility macro and function in the SDK.
*
* Feature : SDK common utility
*
*/
#ifndef __RT_UTIL_H__
#define __RT_UTIL_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/util.h>
#include <common/util/rt_bitop.h>
#include <osal/lib.h>
/*
* Symbol Definition
*/
/* rtk_portmask_t print fromat: "[1]00000000 [0]00000000" */
#define RTK_PORTMASK_PRINT_STRING_LEN ((8+4) * RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
/*
* Data Type Declaration
*/
typedef struct rtk_valRangeStep_s
{
uint32 start;
uint32 end;
uint32 step;
}rt_valRangeStep_t;
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/* print portmask to buffer. strBuf: string buffer, size should be RTK_PORTMASK_PRINT_STRING_LEN */
#define RTK_PORTMASK_SPRINTF(strBuf, portmask) \
do { \
int32 _j, _len = 0; \
strBuf[0] = 0; \
for (_j = (RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST-1); _j >= 0; _j--) \
{ \
_len += osal_sprintf(&strBuf[_len], "[%d]%08x", _j, (portmask).bits[_j]); \
if (_j != 0) \
_len += osal_sprintf(&strBuf[_len], " "); \
} \
}while(0)
/* print portmask format and arguments */
#define PMSK_FMT "0x%08x 0x%08x"
#define PMSK_ARG(_m) (_m).bits[0], (_m).bits[1]
#define RTK_PORTMASK_PORT_SET(portmask, port) \
do {\
if ((port) <= RTK_MAX_PORT_ID_PER_UNIT) {BITMAP_SET((portmask).bits, (port));}\
} while (0)
#define RTK_PORTMASK_PORT_CLEAR(portmask, port) \
do {\
if ((port) <= RTK_MAX_PORT_ID_PER_UNIT) {BITMAP_CLEAR((portmask).bits, (port));}\
} while (0)
#define RTK_PORTMASK_WORD_SET(portmask, word, value) \
do { \
if (word < RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST) \
(portmask).bits[(word)] = value; \
else \
osal_printf("%s,%d:RTK_PORTMASK_WORD_SET %s word%d exceed maximum number\n", __FUNCTION__, __LINE__, #portmask,(word)); \
}while(0)
#define RTK_PORTMASK_WORD_GET(portmask, word) \
((word < RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)?(portmask).bits[(word)]:0x5E5E5E5E)
#define RTK_PORTMASK_IS_PORT_SET(portmask, port) \
(((port) <= RTK_MAX_PORT_ID_PER_UNIT)?BITMAP_IS_SET((portmask).bits, (port)): 0)
#define RTK_PORTMASK_IS_PORT_CLEAR(portmask, port) \
(((port) <= RTK_MAX_PORT_ID_PER_UNIT)?BITMAP_IS_CLEAR((portmask).bits, (port)): 0)
#define RTK_PORTMASK_SCAN(portmask, port) \
for (port = 0; port <= RTK_MAX_NUM_OF_PORTS; port++) \
if(RTK_PORTMASK_IS_PORT_SET(portmask, port))
#define RTK_PORTMASK_ASSIGN(dstPortmask, srcPortmask) \
BITMAP_ASSIGN((dstPortmask).bits, (srcPortmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_RESET(portmask) \
BITMAP_RESET((portmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_COMPARE(dstPortmask, srcPortmask) \
BITMAP_COMPARE((dstPortmask).bits, (srcPortmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_GET_FIRST_PORT(portmask) \
rt_bitop_findFirstBitInAaray((portmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_GET_LAST_PORT(portmask) \
rt_bitop_findLastBitInAaray((portmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_GET_IDX_PORT(portmask,idx) \
rt_bitop_findIdxBitInAaray((portmask).bits, idx,RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_GET_PORT_COUNT(portmask)\
(bitop_numberOfSetBitsInArray((portmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST))
#define RTK_PORTMASK_OR(dstPortmask, srcPortmask) \
BITMAP_OR((dstPortmask).bits, (srcPortmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_AND(dstPortmask, srcPortmask) \
BITMAP_AND((dstPortmask).bits, (srcPortmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_XOR(dstPortmask, srcPortmask) \
BITMAP_XOR((dstPortmask).bits, (srcPortmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_REMOVE(dstPortmask, srcPortmask) \
BITMAP_REMOVE((dstPortmask).bits, (srcPortmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_REVERT(portmask) \
BITMAP_REVERT((portmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST)
#define RTK_PORTMASK_IS_ALL_ZERO(portmask) \
((bitop_numberOfSetBitsInArray((portmask).bits, RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST) == 0) ? 1: 0)
#define RTK_PORTMASK_FOR_EACH_WORDS(arrIdx) \
for (arrIdx = 0; arrIdx < RTK_TOTAL_NUM_OF_WORD_FOR_1BIT_PORT_LIST; arrIdx++)
#define RTK_DSCPMASK_IS_DSCP_SET(dscpmask, dscp) \
(((dscp) <= RTK_VALUE_OF_DSCP_MAX)?BITMAP_IS_SET((dscpmask).bits, (dscp)): 0)
#define RT_UTIL_ACTLIST_INDEX_GET(_actArray, _value, _action) \
rt_util_actListIndex_get(_actArray, (sizeof(_actArray)/sizeof(uint32)), &(_value), _action)
#define RT_UTIL_ACTLIST_ACTION_GET(_actArray, _action, _value) \
rt_util_actListAction_get(_actArray, (sizeof(_actArray)/sizeof(uint32)), &(_action), _value)
#define RTK_TRUNKMASK_IS_TRUNK_SET(trunkmask, trunk) \
(((trunk) < RTK_MAX_TRUNK_PER_UNIT)?BITMAP_IS_SET((trunkmask).bits, (trunk)): 0)
/* Serdes mask utility */
#define SDS_MASK_BIT (31) /* for indicating the sds_idx is using the bit-mask format */
#define SDS_BIT(s) (1 << s)
#define SBM(n) (SDS_BIT(SDS_MASK_BIT) | SDS_BIT(n)) /* mark the uint32 as serdes bit-mask format (set bit 31 as 1) and set n (serdes index) to corresponding bit as 1 */
#define SDS_IS_MASK(sds) (sds & SDS_BIT(SDS_MASK_BIT)) /* check "sds" is serdes bit-mask format or serdes-index format. */
#define SDS_IS_BIT_SET(bm, s) (bm & SDS_BIT(s)) /* check "s" is set in the serdes bit-mask "bm" or not. */
/* WAIT_COMPLETE macros are using together to perform an for-loop with timeout time.
* Timeout unit is microsecond.
* For time that larger than 4294967295 (0xFFFFFFFF), use seconds version macro.
* Usage example of polling a register with 100 microsecond timeout time:
* int32 example_func()
* {
* WAIT_COMPLETE_VAR();
*
* WAIT_COMPLETE(100) {
* reg_read(x);
* if(x=0x5A)
* break;
* }
*
* if(WAIT_COMPLETE_IS_TIMEOUT())
* return ERROR;
* . . .
* }
*/
#if defined(CONFIG_SDK_RTKSIM)
#define WAIT_COMPLETE_VAR()
#define WAIT_COMPLETE(_timeout_us) \
while(0)
#define WAIT_COMPLETE_IS_TIMEOUT() (0)
#else
#define WAIT_COMPLETE_VAR() \
osal_usecs_t _t, _now, _t_wait=0, _timeout; \
int32 _chkCnt=0;
#define WAIT_COMPLETE(_timeout_us) \
_timeout = _timeout_us; \
for(osal_time_usecs_get(&_t),osal_time_usecs_get(&_now),_t_wait=0,_chkCnt=0 ; \
(_t_wait <= _timeout); \
osal_time_usecs_get(&_now), _chkCnt++, _t_wait += ((_now >= _t) ? (_now - _t) : (0xFFFFFFFF - _t + _now)),_t = _now \
)
#define WAIT_COMPLETE_IS_TIMEOUT() (_t_wait > _timeout)
#endif
/*
* Function Declaration
*/
/* Function Name:
* rt_util_macCmp
* Description:
* Compare two mac address
* Input:
* mac1 - mac address 1
* mac2 - mac address 2
* Output:
* None
* Return:
* RT_ERR_OK - two address is same
* RT_ERR_FAILED - two address is different
* Note:
*/
extern int32
rt_util_macCmp(const uint8 *mac1, const uint8 *mac2);
/* Function Name:
* rt_util_actListIndex_get
* Description:
* Get the index (value) of the action (uint32) according to a specified action (uint32) array.
* Input:
* pActList - pointer to the array of the actions
* actNum - number of actions (size of the action array)
* pIndex - pointer to the buffer address of the value
* action - object of action
* Output:
* pValue - pointer to the returned value
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - parameter is a null pointer
* RT_ERR_INPUT - invalid parameter
* RT_ERR_CHIP_NOT_SUPPORTED - chip not support this action (action is not found)
* Note:
*/
extern int32
rt_util_actListIndex_get(uint32 *pActList, uint32 actNum, uint32 *pIndex, uint32 action);
/* Function Name:
* rt_util_actListAction_get
* Description:
* Get the mapped action (uint32) of an index (value) according to a specified action (uint32) array.
* Input:
* pActList - pointer to the array of the actions
* actNum - number of actions (size of the action array)
* pAction - pointer to the buffer address of the action
* value - object of value
* Output:
* pValue - pointer to the returned value
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - parameter is a null pointer
* RT_ERR_INPUT - invalid parameter
* RT_ERR_CHIP_UNDEFINED_VALUE - input value has not been defined
* Note:
*/
extern int32
rt_util_actListAction_get(uint32 *pActList, uint32 actNum, uint32 *pAction, uint32 value);
/* Function Name:
* rt_util_ipLength2Mask_ret
* Description:
* Convert an IPv4 prefix length to the corresponding mask
* Input:
* length - prefix length of IPv4
* Output:
* None
* Return:
* IPv4 address mask of the type of rtk_ip_addr_t
* Note:
*/
extern rtk_ip_addr_t
rt_util_ipLength2Mask_ret(uint32 length);
/* Function Name:
* rt_util_ip6Length2Mask_ret
* Description:
* Convert an IPv6 prefix length to the corresponding mask
* Input:
* ipLength - prefix length of IPv6
* Output:
* None
* Return:
* IPv6 address mask of the type of rtk_ipv6_addr_t
* Note:
*/
extern rtk_ipv6_addr_t
rt_util_ip6Length2Mask_ret(uint32 length);
/* Function Name:
* rt_util_ipMask2Length_ret
* Description:
* Return the length of an IPv4 mask
* Input:
* ip - IPv4 address
* Output:
* None
* Return:
* length in uint32 type
* Note:
*/
extern uint32
rt_util_ipMask2Length_ret(rtk_ip_addr_t ip);
/* Function Name:
* rt_util_ip6Mask2Length_ret
* Description:
* Return the length of an IPv6 mask
* Input:
* pIp6 - pointer to IPv6 address
* Output:
* None
* Return:
* length in uint32 type
* Note:
*/
extern uint32
rt_util_ip6Mask2Length_ret(rtk_ipv6_addr_t *pIp6);
/* Function Name:
* rt_util_ipMaxMatchLength_ret
* Description:
* Return the longest match length of two IPv4 addresses
* Input:
* ip1 - IPv4 address 1
* ip2 - IPv4 address 2
* maxLen - maximum comparing length
* Output:
* None
* Return:
* longest match length in int32 type
* Note:
*/
extern int32
rt_util_ipMaxMatchLength_ret(rtk_ip_addr_t ip1, rtk_ip_addr_t ip2, uint32 maxLen);
/* Function Name:
* rt_util_ipv6MaxMatchLength_ret
* Description:
* Return the longest match length of two IPv6 addresses
* Input:
* pIp1 - pointer to IPv6 address 1
* pIp2 - pointer to IPv6 address 2
* maxLen - maximum comparing length
* Output:
* None
* Return:
* longest match length in int32 type
* Note:
*/
extern int32
rt_util_ipv6MaxMatchLength_ret(rtk_ipv6_addr_t *pIp1, rtk_ipv6_addr_t *pIp2, uint32 maxLen);
/* Function Name:
* rt_util_ipv6IsZero_ret
* Description:
* Check if the IPv6 address is zero or not.
* Input:
* pIp6 - pointer to an IPv6 address
* Output:
* None
* Return:
* boolean (TRUE/FALSE)
* Note:
*/
extern int32
rt_util_ipv6IsZero_ret(rtk_ipv6_addr_t *pIp6);
/* Function Name:
* rt_util_ipv6IsAllOnes_ret
* Description:
* Check if the IPv6 address is all-1s or not.
* Input:
* pIp6 - pointer to an IPv6 address
* Output:
* None
* Return:
* boolean (TRUE/FALSE)
* Note:
*/
extern int32
rt_util_ipv6IsAllOnes_ret(rtk_ipv6_addr_t *pIp6);
/* Function Name:
* rt_util_ipv6Cmp
* Description:
* Compare two IPv6 addresses
* Input:
* pIp1 - pointer to the 1st IPv6 address
* pIp2 - pointer to the 2nd IPv6 address
* Output:
* None
* Return:
* RT_ERR_OK - same
* RT_ERR_FAILED - different
* Note:
*/
extern int32
rt_util_ipv6Cmp(rtk_ipv6_addr_t *pIp1, rtk_ipv6_addr_t *pIp2);
/* Function Name:
* rt_util_grayToBinary
* Description:
* Converting Gray code to binary for 32 or fewer bits
* Input:
* gray_code - gray code
* Output:
* None
* Return:
* Binary number
* Note:
* None
*/
extern uint32
rt_util_grayToBinary(uint32 gray_code);
/* Function Name:
* rt_util_upinkPort_mask2Reg
* Description:
* Mapping RTK portmast structure to register port bitmap for uplink ports
* Input:
* unit - unit ID
* pPortmask - Address pointer RTK portmask
* Output:
* pRegVal - Address pointer of register value
* Return:
* None
* Note:
*/
extern void
rt_util_upinkPort_mask2Reg(uint32 unit, rtk_portmask_t *pPortmask, uint32 *pRegVal);
/* Function Name:
* rt_util_upinkPort_reg2Mask
* Description:
* Mapping register port bitmap to RTK portmast structure for uplink ports
* Input:
* unit - unit ID
* pRegVal - Address pointer of register value
* Output:
* pPortmask - Address pointer RTK portmask
* Return:
* None
* Note:
*/
extern void
rt_util_upinkPort_reg2Mask(uint32 unit, uint32 *pRegVal, rtk_portmask_t *pPortmask);
/* Function Name:
* rt_util_portmask_portReg2Portmask
* Description:
* Mapping register port bitmap to RTK portmast structure.
* Input:
* pRegVal - Address pointer of register value
* macIdStart - start mac ID of the register value mapping to.
* macIdEnd - end mac ID of the portmask that are going to map to register.
* Output:
* pPortmask - Address pointer RTK portmask
* Return:
* None
* Note:
*/
extern void
rt_util_portmask_portReg2Portmask(uint32 *pRegVal, rtk_portmask_t *pPortmask, uint32 macIdStart, uint32 macIdEnd);
/* Function Name:
* rt_util_portmask_portmask2PortReg
* Description:
* Mapping RTK portmast structure to register port bitmap.
* Input:
* pPortmask - Address pointer RTK portmask
* macIdStart - start mac ID of the portmask that are going to map to register.
* macIdEnd - end mac ID of the portmask that are going to map to register.
* Output:
* pRegVal - Address pointer of register value
* Return:
* None
* Note:
*/
extern void
rt_util_portmask_portmask2PortReg(rtk_portmask_t *pPortmask, uint32 *pRegVal, uint32 macIdStart, uint32 macIdEnd);
/* Function Name:
* rtk_portmask2bitPortmask_get
* Description:
* Transfer rtk_portmask_t to SPM/DPM
* Input:
* unit - unit id
* portmask - RTK portmask structure
* byteSize - byte of bitPortmask
* Output:
* bitPortmask - SPM/DPM format
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Applicable:
* 8390, 8380, 9300, 9310
* Note:
*
*/
/* Function Name:
* rt_util_tblEntry2Field
* Description:
* Get the specified field from a table entry
* Input:
* unit - unit id
* table - table id
* field - field index
* pEntry - pointer to entry data
* Output:
* pField - pointer of field data
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Applicable:
* 8380, 8390, 9300, 9310
* Note:
* None
* Changes:
* None
*/
extern int32
rt_util_tblEntry2Field(uint32 unit,uint32 table,uint32 field,uint32 * pField,uint32 * pEntry);
/* Function Name:
* rt_util_field2TblEntry
* Description:
* Set the specified field to a table entry
* Input:
* unit - unit id
* table - table id
* field - field index
* pField - pointer of field data
* pEntry - pointer to entry data
* Output:
* pEntry - pointer to entry data
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Applicable:
* 8380, 8390, 9300, 9310
* Note:
* None
* Changes:
* None
*/
extern int32
rt_util_field2TblEntry(uint32 unit,uint32 table,uint32 field,uint32 * pField,uint32 * pEntry);
extern int32
rtk_portmask2bitPortmask_get(uint32 unit, rtk_portmask_t *portmask,
uint8 *bitPortmask, uint32 byteSize);
#endif /* __RT_UTIL_H__ */

View file

@ -0,0 +1,117 @@
/*
* Copyright (C) 2009-2015 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision:
* $Date:
*
* Purpose : Define the led utility macro and function in the SDK.
*
* Feature : SDK common utility
*
*/
#ifndef __RT_UTIL_LED_H__
#define __RT_UTIL_LED_H__
/*
* Include Files
*/
#include <hal/chipdef/allreg.h>
#include <private/drv/rtl8231/rtl8231.h>
/*
* Symbol Definition
*/
#define RTL9300_BOX_ID_LED_NUM (4)
#define RTL9300_BOX_ID_LED_GPIO_BASE (15)
#define RTL9300_BOX_ID_LED_GPIO_DEVID (1)
/*
* Data Type Declaration
*/
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* rtk_swled_on
* Description:
* light on the led in runtime
* Input:
* unit - unit id
* start - start port
* range - the range of light on led
* index - the led index of the port
* Output:
* None
* Return:
* None
* Note:
*/
extern void rtk_swled_on(uint32 unit, uint32 start, uint32 range, uint32 index);
/* Function Name:
* rtk_boxID_led_set
* Description:
* Set the box id led.
* Input:
* unit - unit id
* box - box id
* Output:
* None
* Return:
* RT_ERR_OK
* Note:
*/
int32 rtk_boxID_led_set(uint32 unit, uint32 boxId);
/* Function Name:
* rtk_boxID_led_init
* Description:
* Initial box id led.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* Note:
*/
int32 rtk_boxID_led_init(uint32 unit);
/* Function Name:
* rtk_masterLedEnable_set
* Description:
* Set stacking master led state.
* Input:
* unit - unit id.
* enable - master led state.
* Output:
* None
* Return:
* RT_ERR_OK
* Note:
*/
int32 rtk_masterLedEnable_set(uint32 unit, rtk_enable_t enable);
#endif /* __RT_UTIL_LED_H__ */

View file

@ -0,0 +1,157 @@
/*
* Copyright (C) 2009-2019 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision:
* $Date:
*
* Purpose : Define the serdes utility in the SDK.
*
* Feature : SDK common utility
*
*/
#ifndef __RT_UTIL_SERDES_H__
#define __RT_UTIL_SERDES_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/util.h>
#include <rtk/sds.h>
/*
* Symbol Definition
*/
/*
* Data Type Declaration
*/
/* Seres in MAC/PHY */
typedef enum serdes_type_e
{
SERDES_IN_MAC = 0,
SERDES_IN_PHY = 1,
SERDES_IN_END
} rt_serdes_type_t;
typedef struct rt_sds_s
{
rt_serdes_type_t type;
/* for type SERDES_IN_MAC */
int mac_sdsId;
/* for type SERDES_IN_PHY */
rtk_port_t base_port;
int phy_sdsId;
}rt_sds_t;
/* Serdes TX scan option */
#define RT_SDS_TX_SCAN_OPT_PAIR_TST 0x1
#define RT_SDS_TX_SCAN_OPT_RX_CALI 0x2
#define RT_SDS_TX_SCAN_OPT_MANUAL_LEQ 0x4
#define RT_SDS_TX_SCAN_OPT_VERBOSE 0x8
/* Serdes TX scan result */
#define RT_SDS_TXSCAN_PASS 'o'
#define RT_SDS_TXSCAN_FAIL 'x'
#define RT_SDS_TXSCAN_FAIL_CALI 'c'
#define RT_SDS_TXSCAN_FAIL_LEQ 'q'
#define RT_SDS_TXSCAN_FAIL_LINK 'd'
/* Serdes TX scan test method */
typedef enum rt_util_txScanMethod_e
{
RT_UTIL_TXSCAN_NIC_TX = 0,
RT_UTIL_TXSCAN_SERDES_TEST,
RT_UTIL_TXSCAN_EYE_MON,
RT_UTIL_TXSCAN_END
} rt_util_txScanMethod_t;
typedef struct rtk_sdsTxScanParam_s
{
/* Specify the test/peer port number and serdes */
rtk_port_t testPort;
rtk_port_t peerPort;
rt_sds_t testSerdes;
rt_sds_t peerSerdes;
uint32 option;
rtk_sds_leq_t leqValue; //manual Leq value; if leq option is enabled
rt_util_txScanMethod_t txScanMethod;
/* for method NIC_TX */
uint32 pktCnt;
uint32 pktLen;
/* for method SERDES_TEST */
rtk_sds_testMode_t sdsTestMode;
uint32 sdsTestTime; //second
/* for method eye monitor */
uint32 frameNum;
/* Scan TX AMP range and step */
uint32 mainAmp;
rt_valRangeStep_t preAmpRangeStep; // 1 dimension
rt_valRangeStep_t postAmpRangeStep; // 2 dimension
}rt_sdsTxScanParam_t;
#define RT_SDS_AMP_RANGE 32
typedef struct rt_sdsTxScanChart_s
{
rt_sds_t testSerdes;
rt_sds_t peerSerdes;
uint8 rMap[RT_SDS_AMP_RANGE][RT_SDS_AMP_RANGE];
uint8 eyeHeight[RT_SDS_AMP_RANGE][RT_SDS_AMP_RANGE];
uint8 eyeWidth[RT_SDS_AMP_RANGE][RT_SDS_AMP_RANGE];
}rt_sdsTxScanChart_t;
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* rt_util_serdesTxEyeParam_scan
* Description:
* Perform the serdes TX scan procedure and get the result back
* The procedure is as follows:
* 1. Foreach pre/post AMP param, do
* 2.1 Set serdes TX eye param (pre/main/post AMP)
* 2.2 Do the serdes RX side calibration or set leq
* 2.3 Perform one of three test methods: cpu-tx, serdes test mode, eye-monitor
* 2.4 Get the result
* Input:
* unit - unit id
* txScanParam - param needed by serdes TX scan procedure
* Output:
* scanResult - TX scan result
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Applicable:
* 8380, 8390, 9300, 9310
* Note:
* None
* Changes:
* None
*/
extern int32
rt_util_serdesTxEyeParam_scan(uint32 unit,rt_sdsTxScanParam_t * txScanParam,
rt_sdsTxScanChart_t * scanResult);
#endif /* __RT_UTIL_SERDES_H__ */

View file

@ -0,0 +1,130 @@
/*
* Copyright (C) 2009-2015 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision:
* $Date:
*
* Purpose : Define the test method utility macro and function in the SDK.
*
* Feature : SDK common utility
*
*/
#ifndef __RT_UTIL_TEST_H__
#define __RT_UTIL_TEST_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/util.h>
#include <common/util/rt_util_serdes.h>
#include <rtk/l2.h>
/*
* Symbol Definition
*/
/*
* Data Type Declaration
*/
typedef enum rt_test_result_e
{
RT_TEST_PASS = 0,
RT_TEST_FAIL = -1,
}rt_test_result_t;
#define RT_TEST_OPT_VERBASE 0x1
#define RT_TEST_OPT_BIDIR 0x2 //bidirectinal test
/* RT_TEST_NIC_TX */
typedef struct rt_test_nicTxTestData_s
{
/* param */
uint32 unit;
rtk_port_t txPort;
rtk_port_t rxPort;
uint32 pktCnt;
uint32 pktLen;
uint32 testOption;
/* backup config */
rtk_l2_newMacLrnMode_t testPortLrnMode, peerPortLrnMode;
rtk_action_t testPortAct, peerPortAct;
/* result */
rt_test_result_t result;
}rt_test_nicTxTestData_t;
/* RT_TEST_SERDES_MODE */
typedef struct rt_test_sdsTestData_s
{
/* param */
uint32 unit;
rt_sds_t txSds;
rt_sds_t rxSds;
rtk_sds_testMode_t mode;
uint32 msec;
uint32 testOption;
uint32 cntRecord;
/* result */
rt_test_result_t result;
}rt_test_sdsTestData_t;
typedef enum rt_test_testId_e
{
RT_TEST_NIC_TX = 0,
RT_TEST_SERDES_MODE,
RT_TEST_END
}rt_test_testId_t;
typedef struct rt_test_proc_s
{
char *testName;
int32 (*test_init)(void *);
int32 (*do_test)(void *);
int32 (*test_done_cb)(void *);
int32 (*test_iter)(void *, const int32 const *, int32 *);
int32 (*test_cleanup)(void *);
}rt_test_proc_t;
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* rt_test_run
* Description:
* Run RTK test
* Input:
* test_id - test id
* data - includes test param and the output of the test
* Output:
* None
* Return:
* None
* Note:
*/
extern int32 rt_test_run(int32 test_id, void *data);
#endif /* __RT_UTIL_LED_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,125 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public global APIs and its data type in the SDK.
*
* Feature : Parameter settings for the system-wise view
*
*/
#ifndef __DAL_CYPRESS_COMMON_H__
#define __DAL_CYPRESS_COMMON_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <rtk/trap.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
typedef enum rtk_q_empty_e
{
Q_EMPTY_SCHED_ALGO = 0,
Q_EMPTY_RATE,
Q_EMPTY_END,
} rtk_q_empty_t;
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_switch_init
* Description:
* Initialize switch module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_common_init(uint32 unit);
/* Function Name:
* dal_cypress_common_portEgrQueueEmpty_start
* Description:
* Empty egress queues of specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* Note:
* After using the API, dal_cypress_common_portEgrQueueEmpty_end must
* be called to free semaphore.
*/
extern int32
dal_cypress_common_portEgrQueueEmpty_start(
uint32 unit,
rtk_port_t port,
uint32 *pState,
uint32 *pRate,
rtk_trap_oam_action_t *pTrap_action,
rtk_action_t *pAction);
/* Function Name:
* dal_cypress_common_portEgrQueueEmpty_end
* Description:
* Restore egress queues of specified port
* Input:
* unit - unit id
* port - port id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* Note:
* Before using the API, dal_cypress_common_portEgrQueueEmpty_start must
* be called to lock semaphore.
*/
extern int32
dal_cypress_common_portEgrQueueEmpty_end(
uint32 unit,
rtk_port_t port,
rtk_q_empty_t type,
uint32 state,
uint32 rate,
rtk_trap_oam_action_t trap_action,
rtk_action_t action);
#endif /* __DAL_CYPRESS_COMMON_H__ */

View file

@ -0,0 +1,44 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : The data for setting MAC Serdes parameters
*
* Feature : The data struct of MAC Serdes parameters
*
*/
#ifndef __DAL_CYPRESS_CONSTRUCT_H__
#define __DAL_CYPRESS_CONSTRUCT_H__
#include <dal/dal_construct.h>
void MacRegSetCheck(uint32 unit, uint32 reg,uint32 val);
void Serdes_patch_set_chk(uint32 unit, confcode_serdes_patch_t _in);
void Serdes_set(uint32 unit, uint32 _reg,uint32 _endBit,uint32 _startBit,uint32 _inVal);
void rtl839x_serdes_patch_init(uint32 unit);
void rtl839x_5x_serdes_patch_init(uint32 unit);
void rtl839x_serdesReset(const uint32 sds_num);
void rtl839x_93m_rst_sys(uint32 unit);
void rtl839x_53m_rst_sys(uint32 unit);
void rtl8390_serdes_eee_enable(uint32 unit, const int sds_num);
int rtl8390_serdes_chk(uint32 unit, const int sdsId);
void dal_cypress_construct_default_init(uint32 unit);
void dal_cypress_construct_phyConfig_init(uint32 unit);
void dal_cypress_construct_serdesConfig_init(uint32 unit);
void rtl8390_sfp_speed_set(uint32 unit, int port, int speed);
void dal_cypress_construct_phy_reset(uint32 unit);
#endif //__DAL_CYPRESS_CONSTRUCT_H__

View file

@ -0,0 +1,361 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public Port APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) Diag
*
*/
#ifndef __DAL_CYPRESS_DIAG_H__
#define __DAL_CYPRESS_DIAG_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <dal/dal_common.h>
#include <rtk/diag.h>
#include <dal/dal_mapper.h>
/*
* Data Declaration
*/
/*
* Macro Definition
*/
#define L2ENTRY_USEDFIELD_MASK_24B 0x00FFFFFF
#define L2ENTRY_USEDFIELD_MASK_20B 0x000FFFFF
#define L2ENTRY_USEDFIELD_MASK_8B 0x000000FF
#define L2INDEX_HASH_MASK_12B 0x00000FFF
#define L2ENTRY_MASK_8B 0x000000FF
#define L2ENTRY_TYPE_L2 0x00000000
#define L2ENTRY_TYPE_IP 0x00000001
#define L2ENTRY_REVERSE_INVALID 0x0
#define L2ENTRY_REVERSE_VALID 0x1
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_diagMapper_init
* Description:
* Hook diag module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook diag module before calling any diag APIs.
*/
extern int32
dal_cypress_diagMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_diag_init
* Description:
* Initialize diagnostic module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_diag_init(uint32 unit);
/* Function Name:
* dal_cypress_diag_serdes5gRemoteLoopbackEnable_get
* Description:
* Get the 5G serdes remote loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* Output:
* pEnable - - pointer to the enable status of serdes remote loopback
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes remote loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Remote loopback is used to loopback packet RX to switch core back to the outer interface.
*/
extern int32
dal_cypress_diag_serdes5gRemoteLoopbackEnable_get(uint32 unit, uint32 serdesId, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_diag_serdes5gRemoteLoopbackEnable_set
* Description:
* Set the 5G serdes remote loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* enable - enable status of serdes remote loopback
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes remote loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Remote loopback is used to loopback packet RX to switch core back to the outer interface.
*/
extern int32
dal_cypress_diag_serdes5gRemoteLoopbackEnable_set(uint32 unit, uint32 serdesId, rtk_enable_t enable);
/* Function Name:
* dal_cypress_diag_serdes5gLocalLoopbackEnable_get
* Description:
* Get the 5G serdes local loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* Output:
* pEnable - - pointer to the enable status of serdes local loopback
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes local loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Local loopback is used to loopback packet TX from switch core back to switch core.
*/
extern int32
dal_cypress_diag_serdes5gLocalLoopbackEnable_get(uint32 unit, uint32 serdesId, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_diag_serdes5gLocalLoopbackEnable_set
* Description:
* Set the 5G serdes local loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* enable - enable status of serdes local loopback
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes local loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Local loopback is used to loopback packet TX from switch core back to switch core.
*/
extern int32
dal_cypress_diag_serdes5gLocalLoopbackEnable_set(uint32 unit, uint32 serdesId, rtk_enable_t enable);
/* Function Name:
* dal_cypress_diag_serdes10gRemoteLoopbackEnable_get
* Description:
* Get the 5G serdes remote loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* Output:
* pEnable - - pointer to the enable status of serdes remote loopback
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes remote loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Remote loopback is used to loopback packet RX to switch core back to the outer interface.
*/
extern int32
dal_cypress_diag_serdes10gRemoteLoopbackEnable_get(uint32 unit, uint32 serdesId, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_diag_serdes10gRemoteLoopbackEnable_set
* Description:
* Set the 5G serdes remote loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* enable - enable status of serdes remote loopback
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes remote loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Remote loopback is used to loopback packet RX to switch core back to the outer interface.
*/
extern int32
dal_cypress_diag_serdes10gRemoteLoopbackEnable_set(uint32 unit, uint32 serdesId, rtk_enable_t enable);
/* Function Name:
* dal_cypress_diag_serdes10gLocalLoopbackEnable_get
* Description:
* Get the 5G serdes local loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* Output:
* pEnable - - pointer to the enable status of serdes local loopback
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes local loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Local loopback is used to loopback packet TX from switch core back to switch core.
*/
extern int32
dal_cypress_diag_serdes10gLocalLoopbackEnable_get(uint32 unit, uint32 serdesId, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_diag_serdes10gLocalLoopbackEnable_set
* Description:
* Set the 5G serdes local loopback enable status of the specific serdes
* Input:
* unit - unit id
* serdesId - serdes id
* enable - enable status of serdes local loopback
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The serdes local loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Local loopback is used to loopback packet TX from switch core back to switch core.
*/
extern int32
dal_cypress_diag_serdes10gLocalLoopbackEnable_set(uint32 unit, uint32 serdesId, rtk_enable_t enable);
/* Function Name:
* dal_cypress_diag_portRtctResult_get
* Description:
* Get test result of RTCT.
* Input:
* unit - unit id
* port - the port for retriving RTCT test result
* Output:
* pRtctResult - RTCT result
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_PHY_RTCT_NOT_FINISH - RTCT not finish. Need to wait a while.
* RT_ERR_TIMEOUT - RTCT test timeout in this port.
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* If linkType is PORT_SPEED_1000M, test result will be stored in ge_result.
* If linkType is PORT_SPEED_10M or PORT_SPEED_100M, test result will be stored in fe_result.
*/
extern int32
dal_cypress_diag_portRtctResult_get(uint32 unit, rtk_port_t port, rtk_rtctResult_t *pRtctResult);
/* Function Name:
* dal_cypress_diag_rtct_start
* Description:
* Start RTCT for ports.
* When enable RTCT, the port won't transmit and receive normal traffic.
* Input:
* unit - unit id
* pPortmask - the ports for RTCT test
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_diag_rtct_start(uint32 unit, rtk_portmask_t *pPortmask);
/* Module Name : Diag */
/* Sub-module Name: Global */
/* Function Name:
* dal_cypress_diag_table_read
* Description:
* Read one specified table entry by table index.
* Input:
* unit - unit id
* table - table index
* addr - entry address of the table
* pData - pointer buffer for read back table entry
* pRev_vaild - used to sure the revbits is vaild.
* pRevbits - pointer buffer for read reverse bits which are not contain in entry.
* Output:
* pData - pointer buffer for read back table entry
* pRev_vaild - used to sure the revbits is vaild.
* pRevbits - pointer buffer for read reverse bits which are not contain in entry.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* Note:
* 1. Basically, this is a transparent API for table read.
* 2. For L2 hash table, this API will converse the hiding 12-bits,
* and provide to upper layer by pRevbits parameter.
* 3. addr format :
* From RTK and realchip view : hash_key[13:2]location[1:0]
*/
extern int32
dal_cypress_diag_table_read(uint32 unit, uint32 table, uint32 addr, uint32 *pData, uint32 *pRev_vaild, uint32 *pRevbits);
#endif /* __DAL_CYPRESS_DIAG_H__ */

View file

@ -0,0 +1,216 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public EEE routing APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) EEE enable/disable
*/
#ifndef __DAL_CYPRESS_EEE_H__
#define __DAL_CYPRESS_EEE_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/eee.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_eeeMapper_init
* Description:
* Hook eee module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook eee module before calling any eee APIs.
*/
extern int32
dal_cypress_eeeMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_eee_init
* Description:
* Initialize EEE module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* Must initialize EEE module before calling any EEE APIs.
*/
extern int32
dal_cypress_eee_init(uint32 unit);
/* Module Name : EEE */
/* Sub-module Name: EEE enable/disable */
/* Function Name:
* dal_cypress_eee_portEnable_get
* Description:
* Get enable status of EEE function in the specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to enable status of EEE
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_eee_portEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_eee_portEnable_set
* Description:
* Set enable status of EEE function in the specified port.
* Input:
* unit - unit id
* port - port id
* enable - enable status of EEE
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_eee_portEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_eee_portState_get
* Description:
* Get the EEE nego result state of a port.
* Input:
* unit - unit id
* port - port id
* Output:
* pState - pointer to the EEE port nego result state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_eee_portState_get(
uint32 unit,
rtk_port_t port,
rtk_enable_t *pState);
/* Function Name:
* dal_cypress_eee_portPowerState_get
* Description:
* Get the EEE power state of a port.
* Input:
* unit - unit id
* port - port id
* direction - ingress or egress direction
* Output:
* pState - pointer to the EEE port power state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_eee_portPowerState_get(uint32 unit, rtk_port_t port, rtk_eee_direction_t direction, rtk_eee_power_state_t *pState);
/* Function Name:
* dal_cypress_eeep_portEnable_get
* Description:
* Get enable status of EEEP function in the specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to enable status of EEEP
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32 dal_cypress_eeep_portEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_eeep_portEnable_set
* Description:
* Set enable status of EEEP function in the specified port.
* Input:
* unit - unit id
* port - port id
* enable - enable status of EEEP
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32 dal_cypress_eeep_portEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
#endif /* __DAL_CYPRESS_EEE_H__ */

View file

@ -0,0 +1,821 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public global APIs and its data type in the SDK.
*
* Feature : (1) Include chip-supported conditions for flow control on/off
* (2) Get/set the threshold parameters for the flow control on/off
*
*/
#ifndef __DAL_CYPRESS_FLOWCTRL_H__
#define __DAL_CYPRESS_FLOWCTRL_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/flowctrl.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
#define FLOWCTRL_HALF_BKPRES_MTHD (0) /* JAM mode */
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_flowctrlMapper_init
* Description:
* Hook flowctrl module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook flowctrl module before calling any flowctrl APIs.
*/
extern int32
dal_cypress_flowctrlMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_flowctrl_init
* Description:
* Initialize flowctrl module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_flowctrl_init(uint32 unit);
/*
* Flow Control ON
*/
/* Function Name:
* dal_cypress_flowctrl_portPauseOnAction_get
* Description:
* Get action when packet keeps receiving after pause on frame is sent.
* Input:
* unit - unit id
* port - port id
* Output:
* pAction - pointer to action of packet receive
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Action of packet receive is as following
* - PAUSE_ON_RECEIVE
* - PAUSE_ON_DROP
*/
extern int32
dal_cypress_flowctrl_portPauseOnAction_get(
uint32 unit,
rtk_port_t port,
rtk_flowctrl_pauseOnAction_t *pAction);
/* Function Name:
* dal_cypress_flowctrl_portPauseOnAction_set
* Description:
* Set action when packet keeps receiving after pause on frame is sent.
* Input:
* unit - unit id
* port - port id
* action - action of packet receive
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* Action of packet receive is as following
* - PAUSE_ON_RECEIVE
* - PAUSE_ON_DROP
*/
extern int32
dal_cypress_flowctrl_portPauseOnAction_set(
uint32 unit,
rtk_port_t port,
rtk_flowctrl_pauseOnAction_t action);
/* Function Name:
* dal_cypress_flowctrl_pauseOnAllowedPktLen_get
* Description:
* Get number of allowed packet length after pause on frame is sent.
* Input:
* unit - unit id
* port - port id
* Output:
* pPktLen - pointer to number of received packet length (unit: bytes)
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The length unit is byte.
*/
extern int32
dal_cypress_flowctrl_pauseOnAllowedPktLen_get(uint32 unit, rtk_port_t port, uint32 *pPktLen);
/* Function Name:
* dal_cypress_flowctrl_pauseOnAllowedPktLen_set
* Description:
* Set number of allowed packet length after pause on frame is sent.
* Input:
* unit - unit id
* port - port id
* pktLen - number of received packet length (unit: bytes)
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* The length unit is byte.
*/
extern int32
dal_cypress_flowctrl_pauseOnAllowedPktLen_set(uint32 unit, rtk_port_t port, uint32 pktLen);
/* Function Name:
* dal_cypress_flowctrl_pauseOnAllowedPktNum_get
* Description:
* Get number of allowed packet when pause on frame sent.
* Input:
* unit - unit id
* port - port id
* Output:
* pPktNum - pointer to number of received packet
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_pauseOnAllowedPktNum_get(uint32 unit, rtk_port_t port, uint32 *pPktNum);
/* Function Name:
* dal_cypress_flowctrl_pauseOnAllowedPktNum_set
* Description:
* Set number of allowed packet when pause on frame sent.
* Input:
* unit - unit id
* port - port id
* pktNum - number of received packet
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_pauseOnAllowedPktNum_set(uint32 unit, rtk_port_t port, uint32 pktNum);
/* Function Name:
* dal_cypress_flowctrl_igrSystemPauseThresh_get
* Description:
* Get ingress system used page high/low threshold paramters of the specific unit
* Input:
* unit - unit id
* Output:
* pThresh - pointer to the threshold structure in the system used page count
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_igrSystemPauseThresh_get(uint32 unit, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_igrSystemPauseThresh_set
* Description:
* Set ingress system used page high/low threshold paramters of the specific unit
* Input:
* unit - unit id
* pThresh - pointer to the threshold structure in the system used page count
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_igrSystemPauseThresh_set(uint32 unit, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_igrPauseThreshGroup_get
* Description:
* Get ingress port used page high/low threshold for the specified threshold group
* Input:
* unit - unit id
* grp_idx - index of threshold group
* Output:
* pThresh - pointer to the threshold structure for the port used page count
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_igrPauseThreshGroup_get(uint32 unit, uint32 grp_idx, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_igrPauseThreshGroup_set
* Description:
* Set ingress port used page high/low threshold for the specified threshold group
* Input:
* unit - unit id
* grp_idx - index of threshold group
* pThresh - pointer to the threshold structure for the port used page count
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* RT_ERR_INPUT - invalid input parameter
* Note:
* lowOff thresholds is unused.
*/
extern int32
dal_cypress_flowctrl_igrPauseThreshGroup_set(uint32 unit, uint32 grp_idx, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_portIgrPortThreshGroupSel_get
* Description:
* Get ingress port used page pause and drop threshold group for the specified port
* Input:
* unit - unit id
* port - port id
* Output:
* pGrp_idx - pointer to the index of threshold group
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_portIgrPortThreshGroupSel_get(uint32 unit, rtk_port_t port, uint32 *pGrp_idx);
/* Function Name:
* dal_cypress_flowctrl_portIgrPortThreshGroupSel_set
* Description:
* Set ingress port used page pause and congest threshold group for the specified port
* Input:
* unit - unit id
* port - port id
* grp_idx - index of threshold group
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_portIgrPortThreshGroupSel_set(uint32 unit, rtk_port_t port, uint32 grp_idx);
/*
* Flow Control OFF
*/
/* Function Name:
* dal_cypress_flowctrl_igrSystemCongestThresh_get
* Description:
* Get system used page high/low drop threshold paramters of the specific unit
* Input:
* unit - unit id
* Output:
* pThresh - pointer to the threshold structure in the public used page count
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_igrSystemCongestThresh_get(uint32 unit, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_igrSystemCongestThresh_set
* Description:
* Set system used page high/low threshold paramters of the specific unit
* Input:
* unit - unit id
* pThresh - pointer to the threshold structure in the public used page count
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_igrSystemCongestThresh_set(uint32 unit, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_igrCongestThreshGroup_get
* Description:
* Get used page high drop threshold for the specified threahold group
* Input:
* unit - unit id
* grp_idx - the index of threshold group
* Output:
* pThresh - pointer to the threshold structure for the port used page count
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Support in RTL8390 only
*/
extern int32
dal_cypress_flowctrl_igrCongestThreshGroup_get(uint32 unit, uint32 grp_idx, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_igrCongestThreshGroup_set
* Description:
* Set used page high drop threshold for the specified threahold group
* Input:
* unit - unit id
* grp_idx - the index of threshold group
* pThresh - pointer to the threshold structure for the port used page count
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. Support in RTL8390 only
* 2. For RTL8390 lowOn and lowOff threshold should be set to the same value,
* otherwise RT_ERR_INPUT will be returned
*/
extern int32
dal_cypress_flowctrl_igrCongestThreshGroup_set(uint32 unit, uint32 grp_idx, rtk_flowctrl_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrSystemDropThresh_get
* Description:
* Get egress system drop threshold for the specified unit
* Input:
* unit - unit id
* Output:
* pThresh - pointer to the drop threshold
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrSystemDropThresh_get(uint32 unit, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrSystemDropThresh_set
* Description:
* Set egress drop threshold for the specified egress port
* Input:
* unit - unit id
* pThresh - pointer to the drop threshold
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrSystemDropThresh_set(uint32 unit, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrPortDropThresh_get
* Description:
* Get egress drop threshold for the specified egress port
* Input:
* unit - unit id
* port - port id
* Output:
* pThresh - pointer to the drop threshold
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrPortDropThresh_get(uint32 unit, rtk_port_t port, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrPortDropThresh_set
* Description:
* Set egress drop threshold for the specified egress port
* Input:
* unit - unit id
* port - port id
* pThresh - pointer to the drop threshold
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* Low threshold is unused.
*/
extern int32
dal_cypress_flowctrl_egrPortDropThresh_set(uint32 unit, rtk_port_t port, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_portEgrDropRefCongestEnable_get
* Description:
* Get enable status of refering source port congest status for egress drop
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to enable status of refering source port congest status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_portEgrDropRefCongestEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_flowctrl_portEgrDropRefCongestEnable_set
* Description:
* Set enable status of refering source port congest status for egress drop
* Input:
* unit - unit id
* port - port id
* enable - enable status of refering source port congest status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_portEgrDropRefCongestEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_flowctrl_egrPortQueueDropEnable_get
* Description:
* Get egress queue drop ability for the specified port
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - status of egress queue drop ability
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrPortQueueDropEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_flowctrl_egrPortQueueDropEnable_set
* Description:
* Set egress queue drop ability for the specified port
* Input:
* unit - unit id
* port - port id
* enable - status of egress queue drop ability
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrPortQueueDropEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_flowctrl_egrQueueDropThresh_get
* Description:
* Get egress global drop threshold for the egress queue
* Input:
* unit - unit id
* queue - queue id
* Output:
* pThresh - pointer to the global drop threshold
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrQueueDropThresh_get(uint32 unit, rtk_qid_t queue, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrQueueDropThresh_set
* Description:
* Set egress gloabl drop threshold for the egress queue
* Input:
* unit - unit id
* queue - queue id
* pThresh - pointer to the drop threshold
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrQueueDropThresh_set(uint32 unit, rtk_qid_t queue, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrCpuQueueDropThresh_get
* Description:
* Get egress global drop threshold for the egress queue of CPU port
* Input:
* unit - unit id
* queue - queue id
* Output:
* pThresh - pointer to the global drop threshold
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrCpuQueueDropThresh_get(uint32 unit, rtk_qid_t queue, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_egrCpuQueueDropThresh_set
* Description:
* Set egress gloabl drop threshold for the egress queue of CPU port
* Input:
* unit - unit id
* queue - queue id
* pThresh - pointer to the drop threshold
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_egrCpuQueueDropThresh_set(uint32 unit, rtk_qid_t queue, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_portHolTrafficDropEnable_get
* Description:
* Get dropping ability for dropping flooding traffic when flow control is enabled.
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - enable state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* (1) Per ingress port can enable the drop function to drop flooding traffic.
* (2) The function takes effect only if the flow control of ingress port is enabled.
* (3) Refer to rtk_flowctrl_holTrafficTypeDropEnable_set for dropping specific traffic type.
*/
extern int32
dal_cypress_flowctrl_portHolTrafficDropEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_flowctrl_portHolTrafficDropEnable_set
* Description:
* Set dropping ability for dropping flooding traffic when flow control is enabled.
* Input:
* unit - unit id
* port - port id
* enable - enable state
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* (1) Enable the function to prevent HOL by flooding traffic when flow control is enabled.
* (2) Per ingress port can enable the drop function to drop flooding traffic at the congested
* egress port.
* (3) Refer to rtk_flowctrl_holTrafficTypeDropEnable_set for dropping specific traffic type.
*/
extern int32
dal_cypress_flowctrl_portHolTrafficDropEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_flowctrl_holTrafficTypeDropEnable_get
* Description:
* Get dropping ability for specific traffic type when flow control is enabled.
* Input:
* unit - unit id
* type - traffic type
* Output:
* pEnable - enable state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* (1) Each traffic type can enable the drop function individually.
* (2) The function takes effect if rtk_flowctrl_portHolTrafficDropEnable_set is enabled.
*/
extern int32
dal_cypress_flowctrl_holTrafficTypeDropEnable_get(uint32 unit, rtk_flowctrl_holTrafficType_t type, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_flowctrl_holTrafficTypeDropEnable_set
* Description:
* Set dropping ability for specific traffic type when flow control is enabled.
* Input:
* unit - unit id
* type - traffic type
* enable - enable state
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* (1) Each traffic type can enable the drop function individually.
* (2) The function takes effect if rtk_flowctrl_portHolTrafficDropEnable_set is enabled.
*/
extern int32
dal_cypress_flowctrl_holTrafficTypeDropEnable_set(uint32 unit, rtk_flowctrl_holTrafficType_t type, rtk_enable_t enable);
/* Function Name:
* dal_cypress_flowctrl_specialCongestThreshold_get
* Description:
* Get special congstion threshold
* Input:
* unit - unit id
* Output:
* pThresh - pointer to the threshold structure for special congstion
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_flowctrl_specialCongestThreshold_get(uint32 unit, rtk_flowctrl_drop_thresh_t *pThresh);
/* Function Name:
* dal_cypress_flowctrl_specialCongestThreshold_set
* Description:
* Set special congstion threshold
* Input:
* unit - unit id
* pThresh - the pointer to threshold structure for special congstion
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
int32
dal_cypress_flowctrl_specialCongestThreshold_set(uint32 unit, rtk_flowctrl_drop_thresh_t *pThresh);
#endif /* __DAL_CYPRESS_FLOWCTRL_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,156 @@
/*
* Copyright(c) Realtek Semiconductor Corporation, 2008
* All rights reserved.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public L3 APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) L3 routing
*
*/
#ifndef __DAL_CYPRESS_L3_H__
#define __DAL_CYPRESS_L3_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/l3.h>
#include <dal/dal_mapper.h>
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_l3Mapper_init
* Description:
* Hook l3 module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook l3 module before calling any l3 APIs.
*/
extern int32
dal_cypress_l3Mapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_l3_init
* Description:
* Initialize L3 module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize L3 module before calling any L3 APIs.
*/
extern int32
dal_cypress_l3_init(uint32 unit);
/* Module Name : Layer3 routing */
/* Function Name:
* dal_cypress_l3_routeEntry_get
* Description:
* Get L3 rounting entry.
* Input:
* unit - unit id
* index - index of host MAC address
* Output:
* pEntry - L3 route entry
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The route entry is indexed by L2 NextHop entry.
* Valid index range:
* - 0~2047 in 8390
* - 0~511 in 8380
*/
extern int32
dal_cypress_l3_routeEntry_get(uint32 unit, uint32 index, rtk_l3_routeEntry_t *pEntry);
/* Function Name:
* dal_cypress_l3_routeEntry_set
* Description:
* Set L3 rounting entry.
* Input:
* unit - unit id
* index - index of host MAC address
* pEntry - L3 route entry
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None.
*/
extern int32
dal_cypress_l3_routeEntry_set(uint32 unit, uint32 index, rtk_l3_routeEntry_t *pEntry);
/* Function Name:
* dal_cypress_l3_routeSwitchMacAddr_get
* Description:
* Get rounting switch MAC address.
* Input:
* unit - unit id
* index - index of switch MAC address
* Output:
* pMac - pointer to switch MAC address
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_l3_routeSwitchMacAddr_get(uint32 unit, uint32 index, rtk_mac_t *pMac);
/* Function Name:
* dal_cypress_l3_routeSwitchMacAddr_set
* Description:
* Set rounting switch MAC address.
* Input:
* unit - unit id
* index - index of switch MAC address
* pMac - pointer to switch MAC address
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_l3_routeSwitchMacAddr_set(uint32 unit, uint32 index, rtk_mac_t *pMac);
#endif /*__DAL_CYPRESS_L3_H__*/

View file

@ -0,0 +1,348 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public LED APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) LED
*
*/
#ifndef __DAL_CYPRESS_LED_H__
#define __DAL_CYPRESS_LED_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <rtk/led.h>
#include <dal/dal_mapper.h>
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_ledMapper_init
* Description:
* Hook led module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook led module before calling any led APIs.
*/
extern int32
dal_cypress_ledMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_led_init
* Description:
* Initialize LED module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_led_init(uint32 unit);
/* Function Name:
* dal_cypress_led_portLedEntitySwCtrlEnable_get
* Description:
* Get LED status on specified port and LED entity.
* Input:
* unit - unit id
* port - port id
* entity - LED entity id
* Output:
* pEnable - LED status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_led_portLedEntitySwCtrlEnable_get(uint32 unit, rtk_port_t port,
uint32 entity, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_led_portLedEntitySwCtrlEnable_set
* Description:
* Set LED status on specified port and LED entity.
* Input:
* unit - unit id
* port - port id
* entity - LED entity id
* enable - LED status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_led_portLedEntitySwCtrlEnable_set(uint32 unit, rtk_port_t port,
uint32 entity, rtk_enable_t enable);
/* Function Name:
* dal_cypress_led_swCtrl_start
* Description:
* Start to apply LED configuration.
* Input:
* unit - unit id
* port - port id
* entity - LED entity id
* enable - LED status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* Note:
* None
*/
extern int32
dal_cypress_led_swCtrl_start(uint32 unit);
/* Function Name:
* dal_cypress_led_portLedEntitySwCtrlMode_get
* Description:
* Get LED display mode on specified port, LED entity and media.
* Input:
* unit - unit id
* port - port id
* entity - LED entity id
* media - media type
* Output:
* pMode - LED display mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* 1. Media type only supports PORT_MEDIA_COPPER and PORT_MEDIA_FIBER.
* 2. System software control mode only support:
* - RTK_LED_SWCTRL_MODE_OFF,
* - RTK_LED_SWCTRL_MODE_BLINKING_32MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_64MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_128MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_256MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_512MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_1024MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_CONTINUE,
*/
extern int32
dal_cypress_led_portLedEntitySwCtrlMode_get(uint32 unit, rtk_port_t port,
uint32 entity, rtk_port_media_t media, rtk_led_swCtrl_mode_t *pMode);
/* Function Name:
* dal_cypress_led_portLedEntitySwCtrlMode_set
* Description:
* Set LED display mode on specified port, LED entity and media.
* Input:
* unit - unit id
* port - port id
* entity - LED entity id
* media - media type
* mode - LED display mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. Media type only supports PORT_MEDIA_COPPER and PORT_MEDIA_FIBER.
* 2. System software control mode only support:
* - RTK_LED_SWCTRL_MODE_OFF,
* - RTK_LED_SWCTRL_MODE_BLINKING_32MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_64MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_128MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_256MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_512MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_1024MS,
* - RTK_LED_SWCTRL_MODE_BLINKING_CONTINUE,
*/
extern int32
dal_cypress_led_portLedEntitySwCtrlMode_set(uint32 unit, rtk_port_t port,
uint32 entity, rtk_port_media_t media, rtk_led_swCtrl_mode_t mode);
/* Function Name:
* dal_cypress_led_sysMode_get
* Description:
* Get system LED display mode.
* Input:
* unit - unit id
* Output:
* pMode - LED display mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* System software control mode only support:
* - RTK_LED_SWCTRL_MODE_OFF
* - RTK_LED_SWCTRL_MODE_BLINKING_64MS
* - RTK_LED_SWCTRL_MODE_BLINKING_1024MS
* - RTK_LED_SWCTRL_MODE_BLINKING_CONTINUE
*/
extern int32
dal_cypress_led_sysMode_get(uint32 unit, rtk_led_swCtrl_mode_t *pMode);
/* Function Name:
* dal_cypress_led_sysMode_set
* Description:
* Set system LED display mode.
* Input:
* unit - unit id
* mode - LED display mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* System software control mode only support:
* - RTK_LED_SWCTRL_MODE_OFF
* - RTK_LED_SWCTRL_MODE_BLINKING_64MS
* - RTK_LED_SWCTRL_MODE_BLINKING_1024MS
* - RTK_LED_SWCTRL_MODE_BLINKING_CONTINUE
*/
extern int32
dal_cypress_led_sysMode_set(uint32 unit, rtk_led_swCtrl_mode_t mode);
/* Function Name:
* dal_cypress_led_sysEnable_get
* Description:
* Get led status on specified type.
* Input:
* unit - unit id
* type - system led type
* Output:
* pEnable - pointer to the led status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* LED type only supports LED_TYPE_SYS.
*/
extern int32
dal_cypress_led_sysEnable_get(uint32 unit, rtk_led_type_t type,
rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_led_sysEnable_set
* Description:
* Set led status on specified type.
* Input:
* unit - unit id
* type - system led type
* enable - led status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* LED type only supports LED_TYPE_SYS.
*/
extern int32
dal_cypress_led_sysEnable_set(uint32 unit, rtk_led_type_t type,
rtk_enable_t enable);
/* Function Name:
* dal_cypress_led_blinkTime_get
* Description:
* Get LED blinking cycle time
* Input:
* unit - unit id
* Output:
* pTime - cycle time
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_led_blinkTime_get(uint32 unit, rtk_led_blinkTime_t *pTime);
/* Function Name:
* dal_cypress_led_blinkTime_set
* Description:
* Set LED blinking cycle time
* Input:
* unit - unit id
* time - cycle time
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_led_blinkTime_set(uint32 unit, rtk_led_blinkTime_t time);
#endif /* __DAL_CYPRESS_LED_H__ */

View file

@ -0,0 +1,80 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Smart Switch RTK API mapper table
*
* Feature :
*
*/
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
extern dal_mapper_t dal_cypress_mapper;
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Module Name : */
/* Function Name:
* dal_cypress_init
* Description:
* Initilize DAL of smart switch
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_FAILED - initialize fail
* RT_ERR_OK - initialize success
* Note:
* RTK must call this function before do other kind of action.
*/
extern int32 dal_cypress_init(uint32 unit);
/* Function Name:
* dal_cypressMapper_init
* Description:
* Initilize DAL of smart switch
* Input:
* pMapper - pointer of mapper
* Output:
* None
* Return:
* None
* Note:
* RTK must call this function before do other kind of action.
*/
extern void
dal_cypressMapper_init(dal_mapper_t *pMapper);

View file

@ -0,0 +1,486 @@
/*
* Copyright(c) Realtek Semiconductor Corporation, 2009
* All rights reserved.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public MIRROR APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) Port-based mirror
* 2) Group-based mirror
* 3) RSPAN
* 4) Mirror-based SFLOW
* 5) Port-based SFLOW
*/
#ifndef __DAL_CYPRESS_MIRROR_H__
#define __DAL_CYPRESS_MIRROR_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/mirror.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Module Name : Mirror */
/* Function Name:
* dal_cypress_mirrorMapper_init
* Description:
* Hook mirror module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook mirror module before calling any mirror APIs.
*/
extern int32
dal_cypress_mirrorMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_mirror_init
* Description:
* Initialize the mirroring database.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* Note:
* Must initialize Mirror module before calling any Mirror APIs.
*/
extern int32
dal_cypress_mirror_init(uint32 unit);
/* Module Name : Mirror */
/* Sub-module Name: Group-based mirror */
/* Function Name:
* dal_cypress_mirror_group_init
* Description:
* Initialization mirror group entry.
* Input:
* unit - unit id
* pMirrorEntry - mirror entry
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MIRROR_ID - invalid mirror id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_group_init(
uint32 unit,
rtk_mirror_entry_t *pMirrorEntry);
/* Function Name:
* dal_cypress_mirror_group_get
* Description:
* Get mirror group entry.
* Input:
* unit - unit id
* mirror_id - mirror id
* Output:
* pMirrorEntry - mirror entry
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MIRROR_ID - invalid mirror id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_group_get(
uint32 unit,
uint32 mirror_id,
rtk_mirror_entry_t *pMirrorEntry);
/* Function Name:
* dal_cypress_mirror_group_set
* Description:
* Set mirror group entry.
* Input:
* unit - unit id
* mirror_id - mirror id
* pMirrorEntry - mirror entry
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MIRROR_ID - invalid mirror id
* RT_ERR_PORT_ID - invalid mirroring port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_MIRROR_DP_IN_SPM_DPM - mirroring port can not be in ingress or egress mirrored portmask of any mirroring set
* Note:
* None
*/
extern int32
dal_cypress_mirror_group_set(
uint32 unit,
uint32 mirror_id,
rtk_mirror_entry_t *pMirrorEntry);
/* Module Name : Mirror */
/* Sub-module Name: RSPAN */
/* Function Name:
* dal_cypress_mirror_rspanIgrMode_get
* Description:
* Get ingress mode of RSPAN on specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* Output:
* pIgrMode - pointer to ingress mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Ingress mode is as following:
* - RSPAN_IGR_HANDLE_RSPAN_TAG
* - RSPAN_IGR_IGNORE_RSPAN_TAG
*/
extern int32
dal_cypress_mirror_rspanIgrMode_get(uint32 unit, uint32 mirror_id, rtk_mirror_rspanIgrMode_t *pIgrMode);
/* Function Name:
* dal_cypress_mirror_rspanIgrMode_set
* Description:
* Set ingress mode of RSPAN on specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* igrMode - ingress mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* Ingress mode is as following:
* - RSPAN_IGR_HANDLE_RSPAN_TAG
* - RSPAN_IGR_IGNORE_RSPAN_TAG
*/
extern int32
dal_cypress_mirror_rspanIgrMode_set(uint32 unit, uint32 mirror_id, rtk_mirror_rspanIgrMode_t igrMode);
/* Function Name:
* dal_cypress_mirror_rspanEgrMode_get
* Description:
* Get egress mode of RSPAN on specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* Output:
* pEgrMode - pointer to egress mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Ingress mode is as following:
* - RSPAN_EGR_REMOVE_TAG
* - RSPAN_EGR_ADD_TAG
* - RSPAN_EGR_NO_MODIFY
*/
extern int32
dal_cypress_mirror_rspanEgrMode_get(uint32 unit, uint32 mirror_id, rtk_mirror_rspanEgrMode_t *pEgrMode);
/* Function Name:
* dal_cypress_mirror_rspanEgrMode_set
* Description:
* Set egress mode of RSPAN on specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* egrMode - egress mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_MIRROR_ID - invalid mirror ID
* Note:
* Ingress mode is as following:
* - RSPAN_EGR_HANDLE_RSPAN_TAG
* - RSPAN_EGR_IGNORE_RSPAN_TAG
*/
extern int32
dal_cypress_mirror_rspanEgrMode_set(uint32 unit, uint32 mirror_id, rtk_mirror_rspanEgrMode_t egrMode);
/* Function Name:
* dal_cypress_mirror_rspanTag_get
* Description:
* Get content of RSPAN tag on specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* Output:
* pTag - pointer to content of RSPAN tag
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_rspanTag_get(uint32 unit, uint32 mirror_id, rtk_mirror_rspanTag_t *pTag);
/* Function Name:
* dal_cypress_mirror_rspanTag_set
* Description:
* Set content of RSPAN tag on specified mirroring group.
* Input:
* unit - unit id
* mirror_id - mirror id
* pTag - content of RSPAN tag
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_MIRROR_ID - invalid mirror ID
* RT_ERR_PRIORITY - invalid priority
* RT_ERR_VLAN_VID - invalid vid
* Note:
* None
*/
extern int32
dal_cypress_mirror_rspanTag_set(uint32 unit, uint32 mirror_id, rtk_mirror_rspanTag_t *pTag);
/* Module Name : Mirror */
/* Sub-module Name: Mirror-based SFLOW */
/* Function Name:
* dal_cypress_mirror_sflowMirrorSampleRate_get
* Description:
* Get sampling rate of specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* Output:
* pRate - pointer to sampling rate
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MIRROR_ID - invalid mirror id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowMirrorSampleRate_get(uint32 unit, uint32 mirror_id, uint32 *pRate);
/* Function Name:
* dal_cypress_mirror_sflowMirrorSampleRate_set
* Description:
* Set sampling rate of specified mirror group.
* Input:
* unit - unit id
* mirror_id - mirror id
* rate - sampling rate
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MIRROR_ID - invalid mirror id
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowMirrorSampleRate_set(uint32 unit, uint32 mirror_id,
uint32 rate);
/* Module Name : Mirror */
/* Sub-module Name: Port-based SFLOW */
/* Function Name:
* dal_cypress_mirror_sflowSampleCtrl_get
* Description:
* Get sampling control status for simple hit ingress and egress
* which direction take hit at first.
* Input:
* unit - unit id
* port - port id
* Output:
* pCtrl - pointer to sampling preference
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowSampleCtrl_get(uint32 unit, rtk_sflowSampleCtrl_t *pCtrl);
/* Function Name:
* dal_cypress_mirror_sflowSampleCtrl_set
* Description:
* Set sampling control status for simple hit ingress and egress
* which direction take hit at first.
* Input:
* unit - unit id
* rate - status of sampling preference
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowSampleCtrl_set(uint32 unit, rtk_sflowSampleCtrl_t ctrl);
/* Function Name:
* dal_cypress_mirror_sflowPortIgrSampleRate_get
* Description:
* Get sampling rate of ingress sampling on specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pRate - pointer to sampling rate of ingress sampling
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowPortIgrSampleRate_get(uint32 unit, rtk_port_t port,
uint32 *pRate);
/* Function Name:
* dal_cypress_mirror_sflowPortIgrSampleRate_set
* Description:
* Set sampling rate of ingress sampling on specified port.
* Input:
* unit - unit id
* port - port id
* rate - sampling rate of ingress sampling
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowPortIgrSampleRate_set(uint32 unit, rtk_port_t port,
uint32 rate);
/* Function Name:
* dal_cypress_mirror_sflowPortEgrSampleRate_get
* Description:
* Get sampling rate of egress sampling on specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pRate - pointer to sampling rate of egress sampling
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowPortEgrSampleRate_get(uint32 unit, rtk_port_t port,
uint32 *pRate);
/* Function Name:
* dal_cypress_mirror_sflowPortEgrSampleRate_set
* Description:
* Set sampling rate of egress sampling on specified port.
* Input:
* unit - unit id
* port - port id
* rate - sampling rate of egress sampling
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_mirror_sflowPortEgrSampleRate_set(uint32 unit, rtk_port_t port,
uint32 rate);
#endif /* __DAL_CYPRESS_MIRROR_H__ */

View file

@ -0,0 +1,211 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public MPLS routing APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) MPLS
*/
#ifndef __DAL_CYPRESS_MPLS_H__
#define __DAL_CYPRESS_MPLS_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <rtk/mpls.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Module Name : MPLS */
/* Function Name:
* dal_cypress_mplsMapper_init
* Description:
* Hook mpls module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook mpls module before calling any mpls APIs.
*/
extern int32
dal_cypress_mplsMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_mpls_init
* Description:
* Initialize mpls module of the specified device.
* Input:
* unit - Device number
* Output:
* None
* Return:
* RT_ERR_OK
* Note:
* None
*/
extern int32
dal_cypress_mpls_init(uint32 unit);
/* Function Name:
* dal_cypress_mpls_ttlInherit_get
* Description:
* Get MPLS TTL inherit properties
* Input:
* unit - Device number
* Output:
* inherit - MPLS TTL inherit information
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mpls_ttlInherit_get(uint32 unit, rtk_mpls_ttlInherit_t *inherit);
/* Function Name:
* dal_cypress_mpls_ttlInherit_set
* Description:
* Set MPLS TTL inherit properties
* Input:
* unit - Device number
* inherit - MPLS TTL inherit information
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_mpls_ttlInherit_set(uint32 unit, rtk_mpls_ttlInherit_t inherit);
/* Function Name:
* dal_cypress_mpls_encap_get
* Description:
* Get MPLS encapsulation properties
* Input:
* unit - Device number
* lib_idx - the index of MPLS table
* Output:
* info - MPLS encapsulation information
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* Note:
* None.
*/
extern int32
dal_cypress_mpls_encap_get(uint32 unit, uint32 lib_idx,
rtk_mpls_encap_t *info);
/* Function Name:
* dal_cypress_mpls_encap_set
* Description:
* Set MPLS encapsulation properties
* Input:
* unit - Device number
* info - MPLS encapsulation information
* lib_idx - the index of MPLS table
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_mpls_encap_set(uint32 unit, uint32 lib_idx,
rtk_mpls_encap_t *info);
/* Function Name:
* dal_cypress_mpls_enable_get
* Description:
* Get MPLS state
* Input:
* unit - Device number
* Output:
* pEnable - MPLS state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_mpls_enable_get(uint32 unit, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_mpls_enable_set
* Description:
* Set MPLS state
* Input:
* unit - Device number
* enable - state of MPLS
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_mpls_enable_set(uint32 unit, rtk_enable_t enable);
#endif /* __DAL_CYPRESS_MPLS_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,857 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public Port APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) Port
*
*/
#ifndef __DAL_CYPRESS_PORT_H__
#define __DAL_CYPRESS_PORT_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <dal/dal_common.h>
#include <rtk/port.h>
#include <dal/dal_mapper.h>
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_portMapper_init
* Description:
* Hook port module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook port module before calling any port APIs.
*/
extern int32
dal_cypress_portMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_port_init
* Description:
* Initialize port module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_port_init(uint32 unit);
/* Function Name:
* dal_cypress_port_link_get
* Description:
* Get the link status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pStatus - pointer to the link status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The link status of the port is as following:
* - LINKDOWN
* - LINKUP
*/
extern int32
dal_cypress_port_link_get(uint32 unit, rtk_port_t port, rtk_port_linkStatus_t *pStatus);
/* Function Name:
* dal_cypress_port_txEnable_set
* Description:
* Set the TX enable status of the specific port
* Input:
* unit - unit id
* port - port id
* enable - enable status of TX
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* The TX enable status of the port is as following:
* - DISABLE
* - ENABLE
*/
extern int32
dal_cypress_port_txEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_port_rxEnable_set
* Description:
* Set the RX enable status of the specific port
* Input:
* unit - unit id
* port - port id
* enable - enable status of RX
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* The RX enable status of the port is as following:
* - DISABLE
* - ENABLE
*/
extern int32
dal_cypress_port_rxEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_port_txEnable_get
* Description:
* Get the TX enable status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to the port TX status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The TX enable status of the port is as following:
* - DISABLE
* - ENABLE
*/
extern int32
dal_cypress_port_txEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_port_rxEnable_get
* Description:
* Get the RX enable status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to the port RX status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The RX enable status of the port is as following:
* - DISABLE
* - ENABLE
*/
extern int32
dal_cypress_port_rxEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_port_specialCongest_get
* Description:
* Get the congest seconds of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pSecond - pointer to congest timer (seconds)
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* Note:
* None
*/
extern int32
dal_cypress_port_specialCongest_get(uint32 unit, rtk_port_t port, uint32* pSecond);
/* Function Name:
* dal_cypress_port_specialCongest_set
* Description:
* Set the congest seconds of the specific port
* Input:
* unit - unit id
* port - port id
* second - congest timer (seconds)
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_port_specialCongest_set(uint32 unit, rtk_port_t port, uint32 second);
/* Function Name:
* dal_cypress_port_speedDuplex_get
* Description:
* Get the negotiated port speed and duplex status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pSpeed - pointer to the port speed
* pDuplex - pointer to the port duplex
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_PORT_LINKDOWN - link down port status
* Note:
* 1. The speed type of the port is as following:
* - PORT_SPEED_10M
* - PORT_SPEED_100M
* - PORT_SPEED_1000M
*
* 2. The duplex mode of the port is as following:
* - HALF_DUPLEX
* - FULL_DUPLEX
*/
extern int32
dal_cypress_port_speedDuplex_get(
uint32 unit,
rtk_port_t port,
rtk_port_speed_t *pSpeed,
rtk_port_duplex_t *pDuplex);
/* Function Name:
* dal_cypress_port_flowctrl_get
* Description:
* Get the negotiated flow control status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pTxStatus - pointer to the negotiation result of the Tx flow control
* pRxStatus - pointer to the negotiation result of the Rx flow control
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_PORT_LINKDOWN - link down port status
* Note:
* None
*/
int32
dal_cypress_port_flowctrl_get(
uint32 unit,
rtk_port_t port,
uint32 *pTxStatus,
uint32 *pRxStatus);
/* Function Name:
* dal_cypress_port_cpuPortId_get
* Description:
* Get CPU port id of the specific unit
* Input:
* unit - unit id
* Output:
* pPort - pointer to CPU port id
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_port_cpuPortId_get(uint32 unit, rtk_port_t *pPort);
/* Function Name:
* dal_cypress_port_isolation_get
* Description:
* Get the portmask of the port isolation
* Input:
* unit - unit id
* port - port id
* Output:
* pPortmask - pointer to the portmask
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* 1. Default value of each port is 1
* 2. Enable port isolation in the certain ports if relative portmask bits are set to 1
*/
extern int32
dal_cypress_port_isolation_get(uint32 unit, rtk_port_t port, rtk_portmask_t *pPortmask);
/* Function Name:
* dal_cypress_port_isolation_set
* Description:
* Set the portmask of the port isolation
* Input:
* unit - unit id
* port - port id
* pPortmask - pointer to the portmask
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_PORT_MASK - invalid port mask
* Note:
* 1. Default value of each port is 1
* 2. Enable port isolation in the certain ports if relative portmask bits are set to 1
*/
extern int32
dal_cypress_port_isolation_set(uint32 unit, rtk_port_t port, rtk_portmask_t *pPortmask);
/* Function Name:
* dal_cypress_port_isolation_add
* Description:
* Add an isolation port to the certain port
* Input:
* unit - unit id
* port - port id
* iso_port - isolation port id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* Note:
* 1. Default value of each port is 1
* 2. Port and iso_port will be isolated when this API is called
* 3. The iso_port to the relative portmask bit will be set to 1
*/
extern int32
dal_cypress_port_isolation_add(uint32 unit, rtk_port_t port, rtk_port_t iso_port);
/* Function Name:
* dal_cypress_port_isolation_del
* Description:
* Delete an existing isolation port of the certain port
* Input:
* unit - unit id
* port - port id
* iso_port - isolation port id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* Note:
* 1. Default value of each port is 1
* 2. Isolated status between the port and the iso_port is removed when this API is called
* 3. The iso_port to the relative portmask bit will be set to 0
*/
extern int32
dal_cypress_port_isolation_del(uint32 unit, rtk_port_t port, rtk_port_t iso_port);
/* Function Name:
* dal_cypress_port_adminEnable_get
* Description:
* Get port admin status of the specific port
* Input:
* unit - unit id
* port - port id
* pEnabled - pointer to the port admin status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_port_adminEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnabled);
/* Function Name:
* dal_cypress_port_adminEnable_set
* Description:
* Set port admin configuration of the specific port
* Input:
* unit - unit id
* port - port id
* enabled - port admin configuration
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_port_adminEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enabled);
/* Function Name:
* dal_cypress_port_backpressureEnable_get
* Description:
* Get the half duplex backpressure enable status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - - pointer to the enable status of backpressure in half duplex mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* 1. The mac local loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Used to support backpressure in half mode.
*/
extern int32
dal_cypress_port_backpressureEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_port_backpressureEnable_set
* Description:
* Set the half duplex backpressure enable status of the specific port
* Input:
* unit - unit id
* port - port id
* enable - enable status of backpressure in half duplex mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* 1. The mac local loopback enable status of the port is as following:
* - DISABLE
* - ENABLE
* 2. Used to support backpressure in half mode.
*/
extern int32
dal_cypress_port_backpressureEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_port_linkChange_register
* Description:
* Register callback function for notification of link change
* Input:
* unit - unit id
* link_change_callback - Callback function for link change
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_port_linkChange_register(uint32 unit, dal_link_change_callback_f link_change_callback);
/* Function Name:
* dal_cypress_port_linkChange_register
* Description:
* Unregister callback function for notification of link change
* Input:
* unit - unit id
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* Note:
*/
extern int32
dal_cypress_port_linkChange_unregister(uint32 unit);
/* Function Name:
* dal_cypress_port_vlanBasedIsolationEntry_get
* Description:
* Set the statue of linkdown green feature of the specific port in the specific unit
* Input:
* unit - unit id
* index - index id
* Output:
* pEntry - pointer to vlan-based port isolation entry
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* None
*/
extern int32
dal_cypress_port_vlanBasedIsolationEntry_get(uint32 unit, uint32 index, rtk_port_vlanIsolationEntry_t* pEntry);
/* Function Name:
* dal_cypress_port_vlanBasedIsolationEntry_set
* Description:
* Set VLAN-based port isolation entry
* Input:
* unit - unit id
* index - index id
* pEntry - pointer to vlan-based port isolation entry
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - NULL pointer
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_VLAN_VID - invalid vid
* RT_ERR_PORT_VLAN_ISO_VID_EXIST_IN_OTHER_IDX - vid exists in other entry
* Note:
* None
*/
extern int32
dal_cypress_port_vlanBasedIsolationEntry_set(uint32 unit, uint32 index, rtk_port_vlanIsolationEntry_t* pEntry);
/* Function Name:
* dal_cypress_port_vlanBasedIsolation_vlanSource_get
* Description:
* Get comparing VID type of VLAN-based port isolation
* Input:
* unit - unit id
* port - port id
* enable - status of linkdown green feature
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* None
*/
extern int32
dal_cypress_port_vlanBasedIsolation_vlanSource_get(uint32 unit, rtk_port_vlanIsolationSrc_t *pVlanSrc);
/* Function Name:
* dal_cypress_port_vlanBasedIsolation_vlanSource_set
* Description:
* Set comparing VID type of VLAN-based port isolation
* Input:
* unit - unit id
* port - port id
* enable - status of linkdown green feature
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_port_vlanBasedIsolation_vlanSource_set(uint32 unit, rtk_port_vlanIsolationSrc_t vlanSrc);
/* Function Name:
* dal_cypress_port_flowCtrlEnable_get
* Description:
* Get the flow control status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to the status of the flow control
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The API get the flow control status by port based, no matter N-WAY is enabled or disabled.
*/
extern int32
dal_cypress_port_flowCtrlEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_port_flowCtrlEnable_set
* Description:
* Set the flow control status to the specific port
* Input:
* unit - unit id
* port - port id
* enable - enable status of flow control
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The API is apply the flow control status by port based, no matter N-WAY is enabled or disabled.
*/
extern int32
dal_cypress_port_flowCtrlEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_port_linkMedia_get
* Description:
* Get link status and media
* Input:
* unit - unit id
* port - port id
* enable - status of link-down power saving
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_port_linkMedia_get(uint32 unit, rtk_port_t port,
rtk_port_linkStatus_t *pStatus, rtk_port_media_t *pMedia);
#if defined(CONFIG_SDK_WA_SERDES_WATCHDOG)
/* Function Name:
* dal_cypress_port_serdes_watchdog
* Description:
* Monitor for serdes link statuse.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* The API is monitor serdes link down and patch it.
* Protect PHY page by port semaphore.
*/
int32
dal_cypress_port_serdes_watchdog(uint32 unit);
#endif
/* Function Name:
* dal_cypress_port_pktbuf_watchdog
* Description:
* Monitor for packet buffer problem.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* The API is monitor for detect packet buffer problem and patch it.
* Protect PHY page by port semaphore.
*/
extern int32
dal_cypress_port_pktbuf_watchdog(uint32 unit);
/* Function Name:
* dal_cypress_port_fiberOAMLoopBackEnable_set
* Description:
* Set OAM Loopback featrue of the specific Fiber-port
* Input:
* unit - unit id
* port - port id
* enable - fiber down speed status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* Note:
* None
*/
extern int32
dal_cypress_port_fiberOAMLoopBackEnable_set(uint32 unit, rtk_port_t port,
rtk_enable_t enable);
/* Function Name:
* dal_cypress_port_init_check
* Description:
* Check Port module init flag
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_NOT_INIT
* Note:
* None
*/
extern int32 dal_cypress_port_init_check(uint32 unit);
/* Function Name:
* _dal_cypress_port_swMacPollPhy
* Description:
* polling 8295R link status for 96M
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* Note:
* None
*/
extern int32
_dal_cypress_port_swMacPollPhy(uint32 unit, rtk_port_t port);
/* Function Name:
* dal_cypress_port_sem_lock
* Description:
* Lock Port Module Sem
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_SEM_LOCK_FAILED
* Note:
* None
*/
extern int32 dal_cypress_port_sem_lock(uint32 unit);
/* Function Name:
* dal_cypress_port_sem_unlock
* Description:
* Unlock Port Module Sem
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_SEM_LOCK_FAILED
* Note:
* None
*/
extern int32 dal_cypress_port_sem_unlock(uint32 unit);
/* Function Name:
* dal_cypress_port_phyForceModeAbility_set
* Description:
* Set the port speed/duplex mode/pause/asy_pause in the PHY force mode
* Input:
* unit - unit id
* port - port id
* speed - port speed
* duplex - port duplex mode
* flowControl - enable flow control
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_PHY_SPEED - invalid PHY speed setting
* RT_ERR_PHY_DUPLEX - invalid PHY duplex setting
* RT_ERR_INPUT - invalid input parameter
* Note:
*
*/
extern int32
dal_cypress_port_phyForceModeAbility_set(
uint32 unit,
rtk_port_t port,
rtk_port_speed_t speed,
rtk_port_duplex_t duplex,
rtk_enable_t flowControl);
/* Function Name:
* dal_cypress_port_phyAutoNegoEnable_set
* Description:
* Set PHY ability of the specific port
* Input:
* unit - unit id
* port - port id
* enable - enable PHY auto negotiation
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - input parameter out of range
* Note:
* 1. ENABLED : switch to PHY auto negotiation mode
* DISABLED: switch to PHY force mode
* 2. Once the abilities of both auto-nego and force mode are set,
* you can freely swtich the mode without calling ability setting API again
*/
extern int32
dal_cypress_port_phyAutoNegoEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
#endif /* __DAL_CYPRESS_PORT_H__ */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,100 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision: 81289 $
* $Date: 2017-08-15 20:45:44 +0800 (Tue, 15 Aug 2017) $
*
* Purpose : The data for setting MAC Serdes parameters
*
* Feature : The data struct of MAC Serdes parameters
*
*/
#ifndef __DAL_CYPRESS_SDS_H__
#define __DAL_CYPRESS_SDS_H__
#include <dal/dal_mapper.h>
/* Function Name:
* dal_cypress_sdsMapper_init
* Description:
* Hook SerDes module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook SerDes module before calling any port APIs.
*/
extern int32
dal_cypress_sdsMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_sds_init
* Description:
* Initialize switch module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_sds_init(uint32 unit);
/* Function Name:
* dal_cypress_sds_symErr_get
* Description:
* Get the SerDes symbol error count.
* Input:
* unit - unit id
* unit - SerDes id
* Output:
* info - symbol error count information
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sds_symErr_get(uint32 unit, uint32 sds, rtk_sds_symErr_t *info);
/* Function Name:
* dal_cypress_sds_linkSts_get
* Description:
* Get the SerDes link status.
* Input:
* unit - unit id
* sds - SerDes id
* Output:
* info - link status information
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sds_linkSts_get(uint32 unit, uint32 sds, rtk_sds_linkSts_t *info);
#endif /* __DAL_CYPRESS_SDS_H__ */

View file

@ -0,0 +1,442 @@
/*
* Copyright(c) Realtek Semiconductor Corporation, 2009
* All rights reserved.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public security APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) Attack prevention
*/
#ifndef __DAL_CYPRESS_SEC_H__
#define __DAL_CYPRESS_SEC_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/sec.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_secMapper_init
* Description:
* Hook sec module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook sec module before calling any sec APIs.
*/
extern int32
dal_cypress_secMapper_init(dal_mapper_t *pMapper);
/* Module Name : Security */
/* Function Name:
* dal_cypress_sec_init
* Description:
* Initialize security module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize security module before calling any sec APIs.
*/
extern int32
dal_cypress_sec_init(uint32 unit);
/* Module Name : Security */
/* Sub-module Name: Attack prevention */
/* Function Name:
* dal_cypress_sec_portAttackPrevent_get
* Description:
* Get action for each kind of attack on specified port.
* Input:
* unit - unit id
* port - port id
* attack_type - type of attack
* Output:
* pAction - pointer to action for attack
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Type of attack is as following:
* - ARP_INVALID
* - GRATUITOUS_ARP
*
* Action is as following:
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
*/
extern int32
dal_cypress_sec_portAttackPrevent_get(
uint32 unit,
rtk_port_t port,
rtk_sec_attackType_t attack_type,
rtk_action_t *pAction);
/* Function Name:
* dal_cypress_sec_portAttackPrevent_set
* Description:
* Set action for each kind of attack on specified port.
* Input:
* unit - unit id
* port - port id
* attack_type - type of attack
* action - action for attack
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_FWD_ACTION - invalid forwarding action
* RT_ERR_INPUT - invalid input parameter
* Note:
* Type of attack is as following:
* - ARP_INVALID
* - GRATUITOUS_ARP
*
* Action is as following:
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
*/
extern int32
dal_cypress_sec_portAttackPrevent_set(
uint32 unit,
rtk_port_t port,
rtk_sec_attackType_t attack_type,
rtk_action_t action);
/* Function Name:
* dal_cypress_sec_portAttackPreventEnable_get
* Description:
* Get the attack prevention status of the specific port
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to the status of the attack prevention
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sec_portAttackPreventEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_sec_portAttackPreventEnable_set
* Description:
* Set the attack prevention status of the specific port
* Input:
* unit - unit id
* port - port id
* enable - pointer to the status of the attack prevention
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_sec_portAttackPreventEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_sec_attackPreventAction_get
* Description:
* Get action for each kind of attack.
* Input:
* unit - unit id
* attack_type - type of attack
* Output:
* pAction - pointer to action for attack
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Type of attack is as following:
* - TCP_FRAG_OFF_MIN_CHECK
* - SYNRST_DENY
* - SYNFIN_DENY
* - XMA_DENY
* - XMA_DENY
* - SYN_SPORTL1024_DENY
* - TCPHDR_MIN_CHECK
* - SMURF_DENY
* - ICMPV6_PING_MAX_CHECK
* - ICMPV4_PING_MAX_CHECK
* - ICMP_FRAG_PKTS_DENY
* - IPV6_MIN_FRAG_SIZE_CHECK
* - POD_DENY
* - TCPBLAT_DENY
* - UDPBLAT_DENY
* - LAND_DENY
* - DAEQSA_DENY
*
* Action is as following:
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
*/
extern int32
dal_cypress_sec_attackPreventAction_get(
uint32 unit,
rtk_sec_attackType_t attack_type,
rtk_action_t *pAction);
/* Function Name:
* dal_cypress_sec_attackPreventAction_set
* Description:
* Set action for each kind of attack on specified port.
* Input:
* unit - unit id
* attack_type - type of attack
* action - action for attack
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_FWD_ACTION - invalid forwarding action
* RT_ERR_INPUT - invalid input parameter
* Note:
* Type of attack is as following:
* - TCP_FRAG_OFF_MIN_CHECK
* - SYNRST_DENY
* - SYNFIN_DENY
* - XMA_DENY
* - XMA_DENY
* - SYN_SPORTL1024_DENY
* - TCPHDR_MIN_CHECK
* - SMURF_DENY
* - ICMPV6_PING_MAX_CHECK
* - ICMPV4_PING_MAX_CHECK
* - ICMP_FRAG_PKTS_DENY
* - IPV6_MIN_FRAG_SIZE_CHECK
* - POD_DENY
* - TCPBLAT_DENY
* - UDPBLAT_DENY
* - LAND_DENY
* - DAEQSA_DENY
*
* Action is as following:
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
*/
extern int32
dal_cypress_sec_attackPreventAction_set(
uint32 unit,
rtk_sec_attackType_t attack_type,
rtk_action_t action);
/* Function Name:
* dal_cypress_sec_minIPv6FragLen_get
* Description:
* Get minimum length of IPv6 fragments.
* Input:
* unit - unit id
* Output:
* pLength - pointer to minimum length of IPv6 fragments
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sec_minIPv6FragLen_get(uint32 unit, uint32 *pLength);
/* Function Name:
* dal_cypress_sec_minIPv6FragLen_set
* Description:
* Set minimum length of IPv6 fragments on specified port.
* Input:
* unit - unit id
* length - minimum length of IPv6 fragments
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_sec_minIPv6FragLen_set(uint32 unit, uint32 length);
/* Function Name:
* dal_cypress_sec_maxPingLen_get
* Description:
* Get maximum length of ICMP packet on specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pLength - pointer to maximum length of ICMP packet
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sec_maxPingLen_get(uint32 unit, uint32 *pLength);
/* Function Name:
* dal_cypress_sec_maxPingLen_set
* Description:
* Set maximum length of ICMP packet.
* Input:
* unit - unit id
* length - maximum length of ICMP packet
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_sec_maxPingLen_set(uint32 unit, uint32 length);
/* Function Name:
* dal_cypress_sec_minTCPHdrLen_get
* Description:
* Get minimum length of TCP header.
* Input:
* unit - unit id
* Output:
* pLength - pointer to minimum length of TCP header
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sec_minTCPHdrLen_get(uint32 unit, uint32 *pLength);
/* Function Name:
* dal_cypress_sec_minTCPHdrLen_set
* Description:
* Set minimum length of TCP header on specified port.
* Input:
* unit - unit id
* length - minimum length of TCP header
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_sec_minTCPHdrLen_set(uint32 unit, uint32 length);
/* Function Name:
* dal_cypress_sec_smurfNetmaskLen_get
* Description:
* Get netmask length for preventing SMURF attack.
* Input:
* unit - unit id
* Output:
* pLength - pointer to netmask length
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_sec_smurfNetmaskLen_get(uint32 unit, uint32 *pLength);
/* Function Name:
* dal_cypress_sec_smurfNetmaskLen_set
* Description:
* Set netmask length for preventing SMURF attack on specified port.
* Input:
* unit - unit id
* length - netmask length
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
extern int32
dal_cypress_sec_smurfNetmaskLen_set(uint32 unit, uint32 length);
#endif /* __DAL_cypress_SEC_H__ */

View file

@ -0,0 +1,274 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public statistic APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) statistic counter reset
* 2) statistic counter get
*
*/
#ifndef __DAL_CYPRESS_STAT_H__
#define __DAL_CYPRESS_STAT_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <rtk/stat.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Module Name : STAT */
/* Function Name:
* dal_cypress_statMapper_init
* Description:
* Hook stat module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook stat module before calling any stat APIs.
*/
int32
dal_cypress_statMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_stat_init
* Description:
* Initialize stat module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize stat module before calling any vlan APIs.
*/
extern int32
dal_cypress_stat_init(uint32 unit);
/* Function Name:
* dal_cypress_stat_global_reset
* Description:
* Reset the global counters in the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* None
*/
extern int32
dal_cypress_stat_global_reset(uint32 unit);
/* Function Name:
* dal_cypress_stat_port_reset
* Description:
* Reset the specified port counters in the specified device.
* Input:
* unit - unit id
* port - port id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* Note:
* None
*/
extern int32
dal_cypress_stat_port_reset(uint32 unit, rtk_port_t port);
/* Function Name:
* dal_cypress_stat_global_get
* Description:
* Get one specified global counter in the specified device.
* Input:
* unit - unit id
* cntr_idx - specified global counter index
* Output:
* pCntr - pointer buffer of counter value
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_STAT_GLOBAL_CNTR_FAIL - Could not retrieve/reset Global Counter
* RT_ERR_STAT_INVALID_GLOBAL_CNTR - Invalid Global Counter
* Note:
* None
*/
extern int32
dal_cypress_stat_global_get(uint32 unit, rtk_stat_global_type_t cntr_idx, uint64 *pCntr);
/* Function Name:
* dal_cypress_stat_global_getAll
* Description:
* Get all global counters in the specified device.
* Input:
* unit - unit id
* Output:
* pGlobal_cntrs - pointer buffer of global counter structure
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_STAT_INVALID_GLOBAL_CNTR - Invalid Global Counter
* Note:
* None
*/
extern int32
dal_cypress_stat_global_getAll(uint32 unit, rtk_stat_global_cntr_t *pGlobal_cntrs);
/* Function Name:
* _dal_cypress_stat_portMibVal_ret
* Description:
* Return one specified port counter in the specified device for internal use.
* Input:
* unit - unit id
* port - port id
* reg - register address
* field_H - high bits field name
* field_L - low bits field name
* bits - assign the number of counter bits: 32 or 64
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* RT_ERR_STAT_PORT_CNTR_FAIL - Could not retrieve/reset Port Counter
* Note:
* None
*/
extern uint64
_dal_cypress_stat_portMibVal_ret(uint32 unit, rtk_port_t port, uint32 reg, uint32 field_H, uint32 field_L, uint32 bits);
/* Function Name:
* dal_cypress_stat_port_get
* Description:
* Get one specified port counter in the specified device.
* Input:
* unit - unit id
* port - port id
* cntr_idx - specified port counter index
* Output:
* pCntr - pointer buffer of counter value
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* RT_ERR_INPUT - Invalid input parameter
* RT_ERR_STAT_INVALID_PORT_CNTR - Invalid Port Counter
* Note:
* None
*/
extern int32
dal_cypress_stat_port_get(uint32 unit, rtk_port_t port, rtk_stat_port_type_t cntr_idx, uint64 *pCntr);
/* Function Name:
* dal_cypress_stat_port_getAll
* Description:
* Get all counters of one specified port in the specified device.
* Input:
* unit - unit id
* port - port id
* Output:
* pPort_cntrs - pointer buffer of counter value
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_STAT_INVALID_PORT_CNTR - Invalid Port Counter
* Note:
* None
*/
extern int32
dal_cypress_stat_port_getAll(uint32 unit, rtk_port_t port, rtk_stat_port_cntr_t *pPort_cntrs);
/* Function Name:
* dal_cypress_stat_tagLenCntIncEnable_get
* Description:
* Get RX/TX counter to include or exclude tag length in the specified device.
* Input:
* unit - unit id
* tagCnt_type - specified RX counter or TX counter
* Output:
* pEnable - pointer buffer of including/excluding tag length
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_stat_tagLenCntIncEnable_get(uint32 unit, rtk_stat_tagCnt_type_t tagCnt_type, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_stat_tagLenCntIncEnable_set
* Description:
* Set RX/TX counter to include or exclude tag length in the specified device.
* Input:
* unit - unit id
* tagCnt_type - specified RX counter or TX counter
* enable - include/exclude Tag length
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_stat_tagLenCntIncEnable_set(uint32 unit, rtk_stat_tagCnt_type_t tagCnt_type, rtk_enable_t enable);
#endif /* __DAL_CYPRESS_STAT_H__ */

View file

@ -0,0 +1,258 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public STP APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) spanning tree (1D, 1w and 1s)
*
*/
#ifndef __DAL_CYPRESS_STP_H__
#define __DAL_CYPRESS_STP_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/stp.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Module Name : STP */
/* Function Name:
* dal_cypress_stpMapper_init
* Description:
* Hook stp module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook stp module before calling any stp APIs.
*/
extern int32
dal_cypress_stpMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_stp_init
* Description:
* Initialize stp module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize stp module before calling any stp APIs.
*/
extern int32
dal_cypress_stp_init(uint32 unit);
/* Function Name:
* dal_cypress_stp_mstpInstance_create
* Description:
* Create one specified mstp instance of the specified device.
* Input:
* unit - unit id
* msti - mstp instance
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MSTI - invalid msti
* RT_ERR_MSTI_EXIST - MSTI is already exist.
* Note:
* The msti valid range is 0 .. RTK_STP_INSTANCE_ID_MAX-1
*/
extern int32
dal_cypress_stp_mstpInstance_create(uint32 unit, uint32 msti);
/* Function Name:
* dal_cypress_stp_mstpInstance_destroy
* Description:
* Destroy one specified mstp instance from the specified device.
* Input:
* unit - unit id
* msti - mstp instance
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MSTI - invalid msti
* RT_ERR_MSTI_NOT_EXIST - msti is not exist
* Note:
* The msti valid range is 0 .. RTK_STP_INSTANCE_ID_MAX-1
*/
extern int32
dal_cypress_stp_mstpInstance_destroy(uint32 unit, uint32 msti);
/* Function Name:
* dal_cypress_stp_isMstpInstanceExist_get
* Description:
* Check one specified mstp instance is existing or not in the specified device.
* Input:
* unit - unit id
* msti - mstp instance
* Output:
* pMsti_exist - mstp instance exist or not?
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MSTI - invalid msti
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The pMsti_exist value as following:
* 0: this mstp instance not exist
* 1: this mstp instance exist
*/
extern int32
dal_cypress_stp_isMstpInstanceExist_get(uint32 unit, uint32 msti, uint32 *pMsti_exist);
/* Function Name:
* dal_cypress_stp_mstpState_get
* Description:
* Get port spanning tree state of the msti from the specified device.
* Input:
* unit - unit id
* msti - multiple spanning tree instance
* port - port id
* Output:
* pStp_state - pointer buffer of spanning tree state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MSTI - invalid msti
* RT_ERR_MSTI_NOT_EXIST - MSTI is not exist
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* 1. For single spanning tree mode, input CIST0 (msti=0).
* 2. Spanning tree state as following
* - STP_STATE_DISABLED
* - STP_STATE_BLOCKING
* - STP_STATE_LEARNING
* - STP_STATE_FORWARDING
*/
extern int32
dal_cypress_stp_mstpState_get(uint32 unit, uint32 msti, rtk_port_t port, rtk_stp_state_t *pStp_state);
/* Function Name:
* dal_cypress_stp_mstpState_set
* Description:
* Set port spanning tree state of the msti to the specified device.
* Input:
* unit - unit id
* msti - multiple spanning tree instance
* port - port id
* stp_state - spanning tree state
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_MSTI - invalid msti
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_MSTP_STATE - invalid spanning tree status
* Note:
* 1. For single spanning tree mode, input CIST0 (msti=0).
* 2. Spanning tree state as following
* - STP_STATE_DISABLED
* - STP_STATE_BLOCKING
* - STP_STATE_LEARNING
* - STP_STATE_FORWARDING
*/
extern int32
dal_cypress_stp_mstpState_set(uint32 unit, uint32 msti, rtk_port_t port, rtk_stp_state_t stp_state);
/* Function Name:
* dal_cypress_stp_mstpInstanceMode_get
* Description:
* Get mstp instance source
* Input:
* unit - unit id
* Output:
* pMsti_mode - mstp instance mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* MSTI is either from VLAN table lookup or always be 0.
*/
extern int32
dal_cypress_stp_mstpInstanceMode_get(uint32 unit, rtk_stp_mstiMode_t *pMsti_mode);
/* Function Name:
* dal_cypress_stp_mstpInstanceMode_set
* Description:
* Set mstp instance source
* Input:
* unit - unit id
* msti_mode - mstp instance mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* MSTI is either from VLAN table lookup or always be 0.
*/
extern int32
dal_cypress_stp_mstpInstanceMode_set(uint32 unit, rtk_stp_mstiMode_t msti_mode);
#endif /* __DAL_CYPRESS_STP_H__ */

View file

@ -0,0 +1,632 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public global APIs and its data type in the SDK.
*
* Feature : Parameter settings for the system-wise view
*
*/
#ifndef __DAL_CYPRESS_SWITCH_H__
#define __DAL_CYPRESS_SWITCH_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <rtk/switch.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Function Name:
* dal_cypress_switchMapper_init
* Description:
* Hook switch module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook switch module before calling any switch APIs.
*/
extern int32
dal_cypress_switchMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_switch_init
* Description:
* Initialize switch module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* 1. Module must be initialized before using all of APIs in this module
*/
extern int32
dal_cypress_switch_init(uint32 unit);
/* Function Name:
* dal_cypress_switch_cpuMaxPktLen_get
* Description:
* Get the max packet length setting on CPU port of the specific unit
* Input:
* unit - unit id
* dir - direction of packet
* Output:
* pLen - pointer to the max packet length
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_INPUT - invalid packet direction
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_switch_cpuMaxPktLen_get(uint32 unit, rtk_switch_pktDir_t dir, uint32 *pLen);
/* Function Name:
* dal_cypress_switch_cpuMaxPktLen_set
* Description:
* Set the max packet length setting on CPU port of the specific unit
* Input:
* unit - unit id
* dir - direction of packet
* len - max packet length
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_INPUT - invalid packet direction
* RT_ERR_OUT_OF_RANGE - invalid packet length
* Note:
* None
*/
extern int32
dal_cypress_switch_cpuMaxPktLen_set(uint32 unit, rtk_switch_pktDir_t dir, uint32 len);
/* Function Name:
* dal_cypress_switch_maxPktLenLinkSpeed_get
* Description:
* Get the max packet length setting of the specific speed type
* Input:
* unit - unit id
* speed - speed type
* Output:
* pLen - pointer to the max packet length
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid enum speed type
* Note:
* Max packet length setting speed type
* - MAXPKTLEN_LINK_SPEED_FE
* - MAXPKTLEN_LINK_SPEED_GE
*/
extern int32
dal_cypress_switch_maxPktLenLinkSpeed_get(uint32 unit, rtk_switch_maxPktLen_linkSpeed_t speed, uint32 *pLen);
/* Function Name:
* dal_cypress_switch_maxPktLenLinkSpeed_set
* Description:
* Set the max packet length of the specific speed type
* Input:
* unit - unit id
* speed - speed type
* len - max packet length
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid enum speed type
* RT_ERR_OUT_OF_RANGE - invalid packet length
* Note:
* Max packet length setting speed type
* - MAXPKTLEN_LINK_SPEED_FE
* - MAXPKTLEN_LINK_SPEED_GE
*/
extern int32
dal_cypress_switch_maxPktLenLinkSpeed_set(uint32 unit, rtk_switch_maxPktLen_linkSpeed_t speed, uint32 len);
/* Function Name:
* dal_cypress_switch_maxPktLenLinkSpeed_get
* Description:
* Get include or exclude tag length state of max packet length in the specified device.
* Input:
* unit - unit id
* Output:
* pEnable - pointer buffer of including/excluding tag length
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_switch_maxPktLenTagLenCntIncEnable_get(uint32 unit, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_switch_maxPktLenLinkSpeed_set
* Description:
* Set the max packet length to include or exclude tag length in the specified device.
* Input:
* unit - unit id
* enable - include/exclude Tag length
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_switch_maxPktLenTagLenCntIncEnable_set(uint32 unit, rtk_enable_t enable);
/* Function Name:
* dal_cypress_switch_snapMode_get
* Description:
* Get SNAP mode.
* Input:
* unit - unit id
* Output:
* pSnapMode - pointer to SNAP mode
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* SNAP mode is as following
* - SNAP_MODE_AAAA03000000
* - SNAP_MODE_AAAA03
*/
extern int32
dal_cypress_switch_snapMode_get(uint32 unit, rtk_snapMode_t *pSnapMode);
/* Function Name:
* dal_cypress_switch_snapMode_set
* Description:
* Set SNAP mode.
* Input:
* unit - unit id
* snapMode - SNAP mode
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_INPUT - invalid input parameter
* Note:
* SNAP mode is as following
* - SNAP_MODE_AAAA03000000
* - SNAP_MODE_AAAA03
*/
extern int32
dal_cypress_switch_snapMode_set(uint32 unit, rtk_snapMode_t snapMode);
/* Function Name:
* dal_cypress_switch_chksumFailAction_get
* Description:
* Get forwarding action of checksum error on specified port.
* Input:
* unit - unit id
* port - port id
* failType - checksum fail type
* Output:
* pAction - pointer to forwarding action
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Checksum fail type is as following
* - LAYER2_CHKSUM_FAIL
* - LAYER3_CHKSUM_FAIL
* - LAYER4_CHKSUM_FAIL
*
* Forwarding action is as following
* - ACTION_FORWARD
* - ACTION_DROP
*/
extern int32
dal_cypress_switch_chksumFailAction_get(
uint32 unit,
rtk_port_t port,
rtk_switch_chksum_fail_t failType,
rtk_action_t *pAction);
/* Function Name:
* dal_cypress_switch_chksumFailAction_set
* Description:
* Set forwarding action of checksum error on specified port.
* Input:
* unit - unit id
* port - port id
* failType - checksum fail type
* action - forwarding action
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_FWD_ACTION - invalid error forwarding action
* RT_ERR_INPUT - invalid input parameter
* Note:
* Checksum fail type is as following
* - LAYER2_CHKSUM_FAIL
* - LAYER3_CHKSUM_FAIL
* - LAYER4_CHKSUM_FAIL
*
* Forwarding action is as following
* - ACTION_FORWARD
* - ACTION_DROP
*/
extern int32
dal_cypress_switch_chksumFailAction_set(
uint32 unit,
rtk_port_t port,
rtk_switch_chksum_fail_t failType,
rtk_action_t action);
/* Function Name:
* dal_cypress_switch_recalcCRCEnable_get
* Description:
* Get enable status of recaculate CRC on specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - pointer to enable status of recaculate CRC
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* When enable, mirrored packet with bad CRC will be recaculate at mirroring port.
*/
extern int32
dal_cypress_switch_recalcCRCEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_switch_recalcCRCEnable_set
* Description:
* Set enable status of recaculate CRC on specified port.
* Input:
* unit - unit id
* port - port id
* enable - enable status of recaculate CRC
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* When enable, mirrored packet with bad CRC will be recaculate at mirroring port.
*/
extern int32
dal_cypress_switch_recalcCRCEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_switch_mgmtMacAddr_get
* Description:
* Get Mac address of switch.
* Input:
* unit - unit id
* Output:
* pMac - pointer to Mac address
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*
*/
extern int32
dal_cypress_switch_mgmtMacAddr_get(uint32 unit, rtk_mac_t *pMac);
/* Function Name:
* dal_cypress_switch_mgmtMacAddr_set
* Description:
* Set Mac address of switch.
* Input:
* unit - unit id
* pMac - pointer to Mac address
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_MAC - invalid mac address
* Note:
* None
*/
extern int32
dal_cypress_switch_mgmtMacAddr_set(uint32 unit, rtk_mac_t *pMac);
/* Function Name:
* dal_cypress_switch_pppoeIpParseEnable_get
* Description:
* Get enable status of PPPoE pass-through functionality.
* Input:
* unit - unit id
* Output:
* pEnable - pointer to enable status of PPPoE parse functionality
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_switch_pppoeIpParseEnable_get(uint32 unit, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_switch_pppoeIpParseEnable_set
* Description:
* Set enable status of PPPoE pass-through functionality.
* Input:
* unit - unit id
* enable - enable status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_switch_pppoeIpParseEnable_set(uint32 unit, rtk_enable_t enable);
/* Function Name:
* dal_cypress_switch_IPv4Addr_get
* Description:
* Get IPv4 address of switch.
* Input:
* unit - unit id
* Output:
* pIpAddr - pointer to IPv4 address
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*
*/
extern int32
dal_cypress_switch_IPv4Addr_get(uint32 unit, uint32 *pIpAddr);
/* Function Name:
* dal_cypress_switch_IPv4Addr_set
* Description:
* Set IPv4 address of switch.
* Input:
* unit - unit id
* ipAddr - IPv4 address
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_UNIT_ID - invalid unit id
* RT_ERR_IPV4_ADDRESS - invalid IPv4 address
* Note:
* None
*/
extern int32
dal_cypress_switch_IPv4Addr_set(uint32 unit, uint32 ipAddr);
/* Function Name:
* dal_cypress_switch_pkt2CpuTypeFormat_get
* Description:
* Get the configuration about content state for packet to CPU
* Input:
* unit - unit id
* type - method of packet to CPU
* Output:
* pFormat - type of format
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* The type of packet to CPU:
* - PKT2CPU_TYPE_FORWARD
* - PKT2CPU_TYPE_TRAP
*
* The type of format:
* - TRAP_PKT_ORIGINAL
* - TRAP_PKT_MODIFIED
*/
extern int32
dal_cypress_switch_pkt2CpuTypeFormat_get(uint32 unit, rtk_switch_pkt2CpuType_t type,
rtk_pktFormat_t *pFormat);
/* Function Name:
* dal_cypress_switch_pkt2CpuTypeFormat_set
* Description:
* Set the configuration about content state for packet to CPU
* Input:
* unit - unit id
* type - method of packet to CPU
* format - packet format to CPU
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid input parameter
* Note:
* The type of format:
* - TRAP_PKT_ORIGINAL
* - TRAP_PKT_MODIFIED
*/
extern int32
dal_cypress_switch_pkt2CpuTypeFormat_set(uint32 unit, rtk_switch_pkt2CpuType_t type,
rtk_pktFormat_t format);
/* Function Name:
* dal_cypress_switch_cpuPktTruncateEnable_get
* Description:
* Get CPU port truncation function state.
* Input:
* unit - unit id
* Output:
* pEnable - enable state
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is
* over than the truncation length.
* (2) The truncation length is specified by rtk_switch_cpuPktTruncateLen_set.
*/
extern int32
dal_cypress_switch_cpuPktTruncateEnable_get(uint32 unit, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_switch_cpuPktTruncateEnable_set
* Description:
* Set CPU port truncation function state.
* Input:
* unit - unit id
* enable - enable state
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is
* over than the truncation length.
* (2) The truncation length is specified by rtk_switch_cpuPktTruncateLen_set.
*/
extern int32
dal_cypress_switch_cpuPktTruncateEnable_set(uint32 unit, rtk_enable_t enable);
/* Function Name:
* dal_cypress_switch_cpuPktTruncateLen_get
* Description:
* Get the packet length for CPU port truncation function.
* Input:
* unit - unit id
* Output:
* pLen - packet length to truncate
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is
* over than the truncation length.
* (2) The truncation function takes effect if rtk_switch_cpuPktTruncateEnable_set is enabled.
*/
extern int32
dal_cypress_switch_cpuPktTruncateLen_get(uint32 unit, uint32 *pLen);
/* Function Name:
* dal_cypress_switch_cpuPktTruncateLen_set
* Description:
* Set the packet length for CPU port truncation function.
* Input:
* unit - unit id
* len - packet length to truncate
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_OUT_OF_RANGE - invalid truncation length
* Note:
* (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is
* over than the truncation length.
* (2) The truncation function takes effect if rtk_switch_cpuPktTruncateEnable_set is enabled.
*/
extern int32
dal_cypress_switch_cpuPktTruncateLen_set(uint32 unit, uint32 len);
#endif /* __DAL_CYPRESS_SWITCH_H__ */

View file

@ -0,0 +1,317 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition of TIME API
*
* Feature : The file includes the following modules and sub-modules
* (1) IEEE 1588
*
*/
#ifndef __DAL_CYPRESS_TIME_H__
#define __DAL_CYPRESS_TIME_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/time.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Module Name : TIME */
/* Function Name:
* dal_cypress_timeMapper_init
* Description:
* Hook time module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook time module before calling any time APIs.
*/
extern int32
dal_cypress_timeMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_time_init
* Description:
* Initialize time module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize time module before calling any time APIs.
*/
extern int32
dal_cypress_time_init(uint32 unit);
/* Function Name:
* dal_cypress_time_portPtpEnable_get
* Description:
* Get TIME status of the specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT - invalid port id
* Note:
* None
*/
extern int32
dal_cypress_time_portPtpEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_time_portPtpEnable_set
* Description:
* Set TIME status of the specified port.
* Input:
* unit - unit id
* port - port id
* enable - status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_time_portPtpEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable);
/* Function Name:
* dal_cypress_time_portRxTimestamp_get
* Description:
* Get TIME timstamp of the TIME identifier of the dedicated port from the specified device.
* Input:
* unit - unit id
* port - port id
* identifier - indentifier of TIME packet
* Output:
* pTimeStamp - pointer buffer of TIME timestamp
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_time_portPtpRxTimestamp_get(
uint32 unit,
rtk_port_t port,
rtk_time_ptpIdentifier_t identifier,
rtk_time_timeStamp_t *pTimeStamp);
/* Function Name:
* dal_cypress_time_portTxTimestamp_get
* Description:
* Get TIME Tx timstamp of the TIME identifier of the dedicated port from the specified device.
* Input:
* unit - unit id
* port - port id
* identifier - indentifier of TIME packet
* Output:
* pTimeStamp - pointer buffer of TIME timestamp
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_time_portPtpTxTimestamp_get(
uint32 unit,
rtk_port_t port,
rtk_time_ptpIdentifier_t identifier,
rtk_time_timeStamp_t *pTimeStamp);
/* Function Name:
* dal_cypress_time_portPtpTxTimestampCallback_register
* Description:
* Register TIME transmission callback function of the TIME identifier of the dedicated port to the specified device.
* Input:
* unit - unit id
* port - port id
* identifier - indentifier of TIME packet
* rtk_time_ptpTime_cb_f - callback function
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* Note:
* None
*/
extern int32
dal_cypress_time_portPtpTxTimestampCallback_register(
uint32 unit,
rtk_port_t port,
rtk_time_ptpIdentifier_t identifier,
rtk_time_ptpTime_cb_f *fCb);
/* Function Name:
* dal_cypress_time_portRefTime_get
* Description:
* Get the reference time of TIME of the specified port.
* Input:
* unit - unit id
* port - port id
* Output:
* pTimeStamp - pointer buffer of TIME reference time
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_time_portRefTime_get(uint32 unit, rtk_port_t port, rtk_time_timeStamp_t *pTimeStamp);
/* Function Name:
* dal_cypress_time_portRefTime_set
* Description:
* Set the reference time of TIME of the specified portmask.
* Input:
* unit - unit id
* portmask - portmask
* timeStamp - reference timestamp value
* exec - 0 : do not execute, 1: execute
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_time_portRefTime_set(uint32 unit, rtk_portmask_t portmask, rtk_time_timeStamp_t timeStamp, uint32 exec);
/* Function Name:
* dal_cypress_ptp_portTimeAdjust_set
* Description:
* Adjust TIME reference time.
* Input:
* unit - unit id
* portmask - portmask
* sign - significant
* timeStamp - reference timestamp value
* exec - 0 : do not execute, 1: execute
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_time_portRefTimeAdjust_set(uint32 unit, rtk_portmask_t portmask, uint32 sign, rtk_time_timeStamp_t timeStamp, uint32 exec);
/* Function Name:
* dal_cypress_time_refTimeEnable_get
* Description:
* Get the enable state of reference time of the specified device.
* Input:
* unit - unit id
* port - port id
* Output:
* pEnable - status
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_cypress_time_portRefTimeEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_cypress_time_portRefTimeEnable_set
* Description:
* Set the enable state of reference time of the specified portmask.
* Input:
* unit - unit id
* portmask - portmask
* enable - status
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_cypress_time_portRefTimeEnable_set(uint32 unit, rtk_portmask_t portmask, rtk_enable_t enable);
#endif /* __DAL_CYPRESS_TIME_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,287 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public TRUNK APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) Trunk
*
*/
#ifndef __DAL_CYPRESS_TRUNK_H__
#define __DAL_CYPRESS_TRUNK_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
#include <rtk/trunk.h>
#include <dal/dal_mapper.h>
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Module Name : TRUNK */
/* Function Name:
* dal_cypress_trunkMapper_init
* Description:
* Hook trunk module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must Hook trunk module before calling any trunk APIs.
*/
extern int32
dal_cypress_trunkMapper_init(dal_mapper_t *pMapper);
/* Function Name:
* dal_cypress_trunk_init
* Description:
* Initialize trunk module of the specified device.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize trunk module before calling any vlan APIs.
*/
extern int32
dal_cypress_trunk_init(uint32 unit);
/* Function Name:
* dal_cypress_trunk_distributionAlgorithmBind_get
* Description:
* Get the distribution algorithm ID binded for a trunk group from the specified device.
* Input:
* unit - unit id
* trk_gid - trunk group id
* Output:
* pAlgo_idx - pointer buffer of the distribution algorithm ID
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_TRUNK_ID - invalid trunk ID
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_trunk_distributionAlgorithmBind_get(uint32 unit, uint32 trk_gid, uint32 *pAlgo_idx);
/* Function Name:
* dal_cypress_trunk_distributionAlgorithmBind_set
* Description:
* Set the distribution algorithm ID binded for a trunk group from the specified device.
* Input:
* unit - unit id
* trk_gid - trunk group id
* algo_idx - index the distribution algorithm
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_TRUNK_ID - invalid trunk ID
* RT_ERR_LA_ALGO_ID - invalid trunk algorithm ID
* Note:
*/
extern int32
dal_cypress_trunk_distributionAlgorithmBind_set(uint32 unit, uint32 trk_gid, uint32 algo_idx);
/* Function Name:
* dal_cypress_trunk_distributionAlgorithmParam_get
* Description:
* Get the distribution algorithm by algorithm ID from the specified device.
* Input:
* unit - unit id
* algo_idx - algorithm index
* Output:
* pAlgo_bitmask - pointer buffer of bitmask of the distribution algorithm
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_ALGO_ID - invalid trunk algorithm ID
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_trunk_distributionAlgorithmParam_get(uint32 unit, uint32 algo_idx, uint32 *pAlgo_bitmask);
/* Function Name:
* dal_cypress_trunk_distributionAlgorithmParam_set
* Description:
* Set the distribution algorithm by algorithm ID from the specified device.
* Input:
* unit - unit id
* algo_idx - algorithm index
* algo_bitmask - bitmask of the distribution algorithm
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_ALGO_ID - invalid trunk algorithm ID
* RT_ERR_LA_HASHMASK - invalid hash mask
* Note:
*/
extern int32
dal_cypress_trunk_distributionAlgorithmParam_set(uint32 unit, uint32 algo_idx, uint32 algo_bitmask);
/* Function Name:
* dal_cypress_trunk_distributionAlgorithmShift_get
* Description:
* Get the shift bits of distribution algorithm parameters from the specified device.
* Input:
* unit - unit id
* algo_idx - algorithm index
* Output:
* pShift - pointer buffer of shift bits of the distribution algorithm
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_ALGO_ID - invalid trunk algorithm ID
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_trunk_distributionAlgorithmShift_get(uint32 unit, uint32 algo_idx, rtk_trunk_distAlgoShift_t *pShift);
/* Function Name:
* dal_cypress_trunk_distributionAlgorithmShift_set
* Description:
* Set the shift bits of distribution algorithm parameters from the specified device.
* Input:
* unit - unit id
* algo_idx - algorithm index
* pShift - shift bits of the distribution algorithm parameters
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_ALGO_ID - invalid trunk algorithm ID
* RT_ERR_LA_ALGO_SHIFT - invalid trunk algorithm shift
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_trunk_distributionAlgorithmShift_set(uint32 unit, uint32 algo_idx, rtk_trunk_distAlgoShift_t *pShift);
/* Function Name:
* dal_cypress_trunk_trafficSeparate_get
* Description:
* Get the traffic separation setting of a trunk group from the specified device.
* Input:
* unit - unit id
* trk_gid - trunk group id
* Output:
* pSeparateType - pointer to traffic separation type
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_TRUNK_ID - invalid trunk ID
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_trunk_trafficSeparate_get(uint32 unit, uint32 trk_gid, rtk_trunk_separateType_t *pSeparateType);
/* Function Name:
* dal_cypress_trunk_trafficSeparate_set
* Description:
* Set the traffic separation setting of a trunk group from the specified device.
* Input:
* unit - unit id
* trk_gid - trunk group id
* separateType - traffic separation setting
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_TRUNK_ID - invalid trunk ID
* RT_ERR_INPUT - Invalid input parameter
* Note:
*/
extern int32
dal_cypress_trunk_trafficSeparate_set(uint32 unit, uint32 trk_gid, rtk_trunk_separateType_t separateType);
/* Function Name:
* dal_cypress_trunk_port_get
* Description:
* Get the members of the trunk id from the specified device.
* Input:
* unit - unit id
* trk_gid - trunk group id
* Output:
* pTrunk_member_portmask - pointer buffer of trunk member ports
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_TRUNK_ID - invalid trunk ID
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
*/
extern int32
dal_cypress_trunk_port_get(uint32 unit, uint32 trk_gid, rtk_portmask_t *pTrunk_member_portmask);
/* Function Name:
* dal_cypress_trunk_port_set
* Description:
* Set the members of the trunk id to the specified device.
* Input:
* unit - unit id
* trk_gid - trunk group id
* pTrunk_member_portmask - trunk member ports
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_LA_TRUNK_ID - invalid trunk ID
* RT_ERR_NULL_POINTER - null pointer
* RT_ERR_LA_MEMBER_OVERLAP - the specified port mask is overlapped with other group
* RT_ERR_LA_PORTMASK - error port mask
* RT_ERR_LA_PORTNUM_NORMAL - it can only aggregate at most eight ports when 802.1ad normal mode
* Note:
* None.
*/
extern int32
dal_cypress_trunk_port_set(uint32 unit, uint32 trk_gid, rtk_portmask_t *pTrunk_member_portmask);
#endif /* __DAL_CYPRESS_TRUNK_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : Definition those public waFunc APIs and its data type in the SDK.
*
* Feature : The file have include the following module and sub-modules
* 1) Port
*
*/
#ifndef __DAL_CYPRESS_WAFUNC_H__
#define __DAL_CYPRESS_WAFUNC_H__
/* Function Name:
* dal_cypress_port_phy_watchdog
* Description:
* Monitor for phy problem.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* The API is monitor for phy problem and patch it.
* Protect PHY page by port semaphore.
*/
extern int32
dal_cypress_port_phy_watchdog(uint32 unit);
#if defined(CONFIG_SDK_WA_SERDES_WATCHDOG)
/* Function Name:
* dal_cypress_port_serdes_watchdog
* Description:
* Monitor for serdes link statuse.
* Input:
* unit - unit id
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_UNIT_ID - invalid unit id
* Note:
* The API is monitor serdes link down and patch it.
* Protect PHY page by port semaphore.
*/
int32
dal_cypress_port_serdes_watchdog(uint32 unit);
#endif
#endif /* __DAL_CYPRESS_WAFUNC_H__ */

View file

@ -0,0 +1,60 @@
/*
* Copyright(c) Realtek Semiconductor Corporation, 2008
* All rights reserved.
*
* $Revision$
* $Date$
*
* Purpose : Common API for DAL
*
* Feature : The file have include the following module and sub-modules
* 1) Common unsupported function
*
*/
#ifndef __DAL_COMMON_H__
#define __DAL_COMMON_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <common/rt_error.h>
/*
* Symbol Definition
*/
typedef int32 (*dal_link_change_callback_f)(int32 unit, rtk_portmask_t *pChangedPortmask);
/*
* Data Declaration
*/
/*
* Macro Definition
*/
/*
* Function Declaration
*/
/* Module Name : */
/* Function Name:
* dal_common_unavail
* Description:
* Return chip not support
* Input:
* None
* Output:
* None
* Return:
* RT_ERR_CHIP_NOT_SUPPORTED - functions not supported by this chip model
* Note:
* None
*/
extern int32
dal_common_unavail(void);
#endif /* __DAL_COMMON_H__ */

Some files were not shown because too many files have changed in this diff Show more