BB: update custom inteno packages from IOP3

This commit is contained in:
Sukru Senli 2015-02-23 10:00:13 +01:00 committed by Martin Schröder
parent f3039be41c
commit 471edc0a35
58 changed files with 6731 additions and 579 deletions

View file

@ -24,7 +24,7 @@ MAKE_FLAGS += TARGET="$(target)"
define Package/ami
CATEGORY:=Utilities
DEPENDS:= +libubox +ubus
DEPENDS:= +luci +libubox +ubus
TITLE:=Asterisk management interface listener
endef

208
ami_tool/src/list.h Normal file
View file

@ -0,0 +1,208 @@
/*-
* Copyright (c) 2011 Felix Fietkau <nbd@openwrt.org>
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LINUX_LIST_H_
#define _LINUX_LIST_H_
#include <stddef.h>
#include <stdbool.h>
#define prefetch(x)
#ifndef container_of
#define container_of(ptr, type, member) \
({ \
const typeof(((type *) NULL)->member) *__mptr = (ptr); \
(type *) ((char *) __mptr - offsetof(type, member)); \
})
#endif
struct list_head {
struct list_head *next;
struct list_head *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#undef LIST_HEAD
#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
static inline void
INIT_LIST_HEAD(struct list_head *list)
{
list->next = list->prev = list;
}
static inline bool
list_empty(const struct list_head *head)
{
return (head->next == head);
}
static inline bool
list_is_first(const struct list_head *list,
const struct list_head *head)
{
return list->prev == head;
}
static inline bool
list_is_last(const struct list_head *list,
const struct list_head *head)
{
return list->next == head;
}
static inline void
_list_del(struct list_head *entry)
{
entry->next->prev = entry->prev;
entry->prev->next = entry->next;
}
static inline void
list_del(struct list_head *entry)
{
_list_del(entry);
entry->next = entry->prev = NULL;
}
static inline void
_list_add(struct list_head *_new, struct list_head *prev,
struct list_head *next)
{
next->prev = _new;
_new->next = next;
_new->prev = prev;
prev->next = _new;
}
static inline void
list_del_init(struct list_head *entry)
{
_list_del(entry);
INIT_LIST_HEAD(entry);
}
#define list_entry(ptr, type, field) container_of(ptr, type, field)
#define list_first_entry(ptr, type, field) list_entry((ptr)->next, type, field)
#define list_last_entry(ptr, type, field) list_entry((ptr)->prev, type, field)
#define list_for_each(p, head) \
for (p = (head)->next; p != (head); p = p->next)
#define list_for_each_safe(p, n, head) \
for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
#define list_for_each_entry(p, h, field) \
for (p = list_first_entry(h, typeof(*p), field); &p->field != (h); \
p = list_entry(p->field.next, typeof(*p), field))
#define list_for_each_entry_safe(p, n, h, field) \
for (p = list_first_entry(h, typeof(*p), field), \
n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\
p = n, n = list_entry(n->field.next, typeof(*n), field))
#define list_for_each_entry_reverse(p, h, field) \
for (p = list_last_entry(h, typeof(*p), field); &p->field != (h); \
p = list_entry(p->field.prev, typeof(*p), field))
#define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
#define list_for_each_prev_safe(p, n, h) for (p = (h)->prev, n = p->prev; p != (h); p = n, n = p->prev)
static inline void
list_add(struct list_head *_new, struct list_head *head)
{
_list_add(_new, head, head->next);
}
static inline void
list_add_tail(struct list_head *_new, struct list_head *head)
{
_list_add(_new, head->prev, head);
}
static inline void
list_move(struct list_head *list, struct list_head *head)
{
_list_del(list);
list_add(list, head);
}
static inline void
list_move_tail(struct list_head *entry, struct list_head *head)
{
_list_del(entry);
list_add_tail(entry, head);
}
static inline void
_list_splice(const struct list_head *list, struct list_head *prev,
struct list_head *next)
{
struct list_head *first;
struct list_head *last;
if (list_empty(list))
return;
first = list->next;
last = list->prev;
first->prev = prev;
prev->next = first;
last->next = next;
next->prev = last;
}
static inline void
list_splice(const struct list_head *list, struct list_head *head)
{
_list_splice(list, head, head->next);
}
static inline void
list_splice_tail(struct list_head *list, struct list_head *head)
{
_list_splice(list, head->prev, head);
}
static inline void
list_splice_init(struct list_head *list, struct list_head *head)
{
_list_splice(list, head, head->next);
INIT_LIST_HEAD(list);
}
static inline void
list_splice_tail_init(struct list_head *list, struct list_head *head)
{
_list_splice(list, head->prev, head);
INIT_LIST_HEAD(list);
}
#endif /* _LINUX_LIST_H_ */

View file

@ -77,6 +77,38 @@ void ucix_save_state(struct uci_context *ctx)
uci_save(ctx, NULL);
}
int ucix_get_option_list(struct uci_context *ctx, const char *p,
const char *s, const char *o, struct list_head *l)
{
struct uci_element *e = NULL;
if(ucix_get_ptr(ctx, p, s, o, NULL))
return 1;
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
return 1;
e = ptr.last;
switch (e->type)
{
case UCI_TYPE_OPTION:
switch(ptr.o->type) {
case UCI_TYPE_LIST:
uci_foreach_element(&ptr.o->v.list, e)
{
struct ucilist *ul = malloc(sizeof(struct ucilist));
ul->val = strdup((e->name)?(e->name):(""));
list_add_tail(&ul->list, l);
}
break;
default:
break;
}
break;
default:
return 1;
}
return 0;
}
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
{
struct uci_element *e = NULL;

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=asterisk18-mod
PKG_VERSION:=1.8.10.1
PKG_SOURCE_VERSION:=e6a06b24a4e3d5ff786a4ad55a7c90de1defb49e
PKG_SOURCE_VERSION:=5d132d039a72ca59c250873493f6657537fcf79f
PKG_SOURCE_PROTO:=git
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
PKG_SOURCE_URL:=git@ihgsp.inteno.se:asterisk-aa
@ -45,7 +45,7 @@ define Package/asterisk18-mod
$(call Package/asterisk18-mod/Default)
TITLE:=Complete open source PBX, v1.8x
MENU:=1
DEPENDS:= +natalie-dect-h +PACKAGE_bcmkernel:bcmkernel +PACKAGE_bcmopen:bcmopen +libopenssl +libncurses +libpopt +libpthread +uci +ubus +zlib @!TARGET_avr32
DEPENDS:= +natalie-dect-h +bcmkernel +libopenssl +libncurses +libpopt +libpthread +zlib @!TARGET_avr32
endef
define Package/asterisk18-mod/description

227
bcmkernel/414040.mk Normal file
View file

@ -0,0 +1,227 @@
#
# Copyright (C) 2006-2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# update this based on the Broadcom SDK version, 4.14L.04 -> 414040
BRCM_SDK_VERSION:=414040
PKG_NAME:=bcmkernel-3.4
PKG_VERSION:=4.14
PKG_RELEASE:=$(BRCM_SDK_VERSION)
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.14L.04
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=8216815ced065e527681a079ad0e17fbb007baec
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/image.mk
include $(INCLUDE_DIR)/kernel.mk
export CONFIG_BCM_CHIP_ID
export CONFIG_BCM_KERNEL_PROFILE
export CONFIG_SECURE_BOOT_CFE
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
BCM_KERNEL_VERSION:=3.4.11-rt19
BCM_SDK_VERSION:=bcm963xx
RSTRIP:=true
define Package/bcmkernel/removevoice
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
define Package/bcmkernel/removevoice
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
endif
define Package/bcmkernel/removei2c
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
ifeq ($(CONFIG_BCM_I2C),y)
define Package/bcmkernel/removei2c
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
endif
define Package/bcmkernel/install
$(INSTALL_DIR) $(1)/lib/bcm
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/etc/adsl
$(INSTALL_DIR) $(1)/etc/wlan
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
# Install header files
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
# create symlink to kernel build directory
rm -f $(BUILD_DIR)/bcmkernel
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
# Install binaries
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
rm -f $(1)/usr/sbin/dhcp6c
rm -f $(1)/usr/sbin/dhcp6s
rm -f $(1)/usr/sbin/dhcpc
rm -f $(1)/usr/sbin/dhcpd
rm -f $(1)/usr/sbin/dnsproxy
rm -f $(1)/usr/sbin/httpd
rm -f $(1)/usr/sbin/openssl
rm -f $(1)/usr/sbin/racoon
rm -f $(1)/usr/sbin/ripd
rm -f $(1)/usr/sbin/send_cms_msg
rm -f $(1)/usr/sbin/sshd
rm -f $(1)/usr/sbin/ssk
rm -f $(1)/usr/sbin/telnetd
rm -f $(1)/usr/sbin/tr64c
rm -f $(1)/usr/sbin/tr69c
rm -f $(1)/usr/sbin/ubi*
rm -f $(1)/usr/sbin/udhcpd
rm -f $(1)/usr/sbin/upnp
rm -f $(1)/usr/sbin/upnpd
rm -f $(1)/usr/sbin/vodsl
rm -f $(1)/usr/sbin/wlmngr
rm -f $(1)/usr/sbin/zebra
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
# Install libraries
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
mv $(1)/usr/lib/ld-uClibc.so.0 $(1)/lib/bcm/
mv $(1)/usr/lib/libc.so.0 $(1)/lib/bcm/
mv $(1)/usr/lib/libdl.so.0 $(1)/lib/bcm/
mv $(1)/usr/lib/libgcc_s.so.1 $(1)/lib/bcm/
mv $(1)/usr/lib/libpthread.so.0 $(1)/lib/bcm/
rm -f $(1)/usr/lib/libcrypt.so.0
rm -f $(1)/usr/lib/libm.so.0
rm -f $(1)/usr/lib/libutil.so.0
rm -f $(1)/usr/lib/libcms_boardctl.so
rm -f $(1)/usr/lib/libcms_msg.so
rm -f $(1)/usr/lib/libcms_util.so
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
rm -f $(1)/usr/lib/libssl.so.0.9.7
rm -f $(1)/usr/lib/libnvram.so
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
rm -rf $(1)/usr/lib/modules
rm -rf $(1)/usr/lib/private
rm -rf $(1)/usr/lib/public
rm -rf $(1)/usr/lib/gpl
# Install kernel modules
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
mkdir -p $(1)/lib/
mkdir -p $(1)/lib/modules/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/*_map.bin $(1)/etc/wlan
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
# bootloader nor
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
# ram part of the bootloader for nand boot
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
$(call Package/bcmkernel/removevoice,$(1))
$(call Package/bcmkernel/removei2c,$(1))
endef

262
bcmkernel/416021.mk Normal file
View file

@ -0,0 +1,262 @@
#
# Copyright (C) 2006-2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# update this based on the Broadcom SDK version, 4.16L.02 -> 416020
# 4.16L.02A -> 416021
BRCM_SDK_VERSION:=416021
PKG_NAME:=bcmkernel-3.4
PKG_VERSION:=4.16
PKG_RELEASE:=$(BRCM_SDK_VERSION)
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.02A
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=00e673bd751d19059cb3ed5fd2dbf3831a7e0401
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/image.mk
include $(INCLUDE_DIR)/kernel.mk
export CONFIG_BCM_CHIP_ID
export CONFIG_BCM_KERNEL_PROFILE
export CONFIG_SECURE_BOOT_CFE
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
BCM_KERNEL_VERSION:=3.4.11-rt19
BCM_SDK_VERSION:=bcm963xx
RSTRIP:=true
define Package/bcmkernel/removevoice
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
define Package/bcmkernel/removevoice
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
endif
define Package/bcmkernel/removesound
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
endef
ifeq ($(BCM_USBSOUND_MODULES),y)
define Package/bcmkernel/removesound
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
endef
endif
define Package/bcmkernel/removei2c
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
ifeq ($(CONFIG_BCM_I2C),y)
define Package/bcmkernel/removei2c
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
endif
define Package/bcmkernel/removebluetooth
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bnep.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/btusb.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/rfcomm.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/hci_uart.ko
endef
ifeq ($(CONFIG_BCM_BLUETOOTH),y)
define Package/bcmkernel/removebluetooth
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko etc...
endef
endif
define Package/bcmkernel/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/etc/adsl
$(INSTALL_DIR) $(1)/etc/wlan
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
# Install header files
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
# create symlink to kernel build directory
rm -f $(BUILD_DIR)/bcmkernel
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
# Install binaries
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
rm -f $(1)/usr/sbin/dhcp6c
rm -f $(1)/usr/sbin/dhcp6s
rm -f $(1)/usr/sbin/dhcpc
rm -f $(1)/usr/sbin/dhcpd
rm -f $(1)/usr/sbin/dnsproxy
rm -f $(1)/usr/sbin/httpd
rm -f $(1)/usr/sbin/openssl
rm -f $(1)/usr/sbin/racoon
rm -f $(1)/usr/sbin/ripd
rm -f $(1)/usr/sbin/send_cms_msg
rm -f $(1)/usr/sbin/sshd
rm -f $(1)/usr/sbin/ssk
rm -f $(1)/usr/sbin/telnetd
rm -f $(1)/usr/sbin/tr64c
rm -f $(1)/usr/sbin/tr69c
rm -f $(1)/usr/sbin/ubi*
rm -f $(1)/usr/sbin/udhcpd
rm -f $(1)/usr/sbin/upnp
rm -f $(1)/usr/sbin/upnpd
rm -f $(1)/usr/sbin/vodsl
rm -f $(1)/usr/sbin/wlmngr
rm -f $(1)/usr/sbin/zebra
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
# Install libraries
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
rm -f $(1)/usr/lib/ld-uClibc.so.0
rm -f $(1)/usr/lib/libc.so.0
rm -f $(1)/usr/lib/libdl.so.0
rm -f $(1)/usr/lib/libgcc_s.so.1
rm -f $(1)/usr/lib/libpthread.so.0
rm -f $(1)/usr/lib/libm.so.0
rm -f $(1)/usr/lib/libutil.so.0
rm -f $(1)/usr/lib/libcms_boardctl.so
rm -f $(1)/usr/lib/libcms_msg.so
rm -f $(1)/usr/lib/libcms_util.so
rm -f $(1)/usr/lib/libnvram.so
rm -f $(1)/usr/lib/libcrypt.so.0
rm -f $(1)/usr/lib/libcrypto.so
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so.0.9.7
rm -f $(1)/usr/lib/libssl.so
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so
rm -f $(1)/usr/lib/libssl.so.0.9.7
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so.0.9.7
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
rm -rf $(1)/usr/lib/modules
rm -rf $(1)/usr/lib/private
rm -rf $(1)/usr/lib/public
rm -rf $(1)/usr/lib/gpl
# Install kernel modules
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
mkdir -p $(1)/lib/
mkdir -p $(1)/lib/modules/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
# bootloader nor
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
# ram part of the bootloader for nand boot
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
$(call Package/bcmkernel/removevoice,$(1))
$(call Package/bcmkernel/removesound,$(1))
# $(call Package/bcmkernel/removei2c,$(1))
endef

263
bcmkernel/416030.mk Normal file
View file

@ -0,0 +1,263 @@
#
# Copyright (C) 2006-2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# update this based on the Broadcom SDK version, 4.16L.03 -> 416030
BRCM_SDK_VERSION:=416030
PKG_NAME:=bcmkernel-3.4
PKG_VERSION:=4.16
PKG_RELEASE:=$(BRCM_SDK_VERSION)
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.03
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=dac270de1d80552e7bc39a8dc8980532948eba81
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/image.mk
include $(INCLUDE_DIR)/kernel.mk
export CONFIG_BCM_CHIP_ID
export CONFIG_BCM_KERNEL_PROFILE
export CONFIG_SECURE_BOOT_CFE
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
BCM_KERNEL_VERSION:=3.4.11-rt19
BCM_SDK_VERSION:=bcm963xx
RSTRIP:=true
define Package/bcmkernel/removevoice
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
define Package/bcmkernel/removevoice
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
endif
define Package/bcmkernel/removesound
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
endef
ifeq ($(BCM_USBSOUND_MODULES),y)
define Package/bcmkernel/removesound
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
endef
endif
define Package/bcmkernel/removei2c
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
ifeq ($(CONFIG_BCM_I2C),y)
define Package/bcmkernel/removei2c
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
endif
define Package/bcmkernel/removebluetooth
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bnep.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/btusb.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/rfcomm.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/hci_uart.ko
endef
ifeq ($(CONFIG_BCM_BLUETOOTH),y)
define Package/bcmkernel/removebluetooth
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko etc...
endef
endif
define Package/bcmkernel/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/etc/adsl
$(INSTALL_DIR) $(1)/etc/wlan
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
# Install header files
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
# create symlink to kernel build directory
rm -f $(BUILD_DIR)/bcmkernel
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
# Install binaries
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
rm -f $(1)/usr/sbin/dhcp6c
rm -f $(1)/usr/sbin/dhcp6s
rm -f $(1)/usr/sbin/dhcpc
rm -f $(1)/usr/sbin/dhcpd
rm -f $(1)/usr/sbin/dnsproxy
rm -f $(1)/usr/sbin/httpd
rm -f $(1)/usr/sbin/openssl
rm -f $(1)/usr/sbin/racoon
rm -f $(1)/usr/sbin/ripd
rm -f $(1)/usr/sbin/send_cms_msg
rm -f $(1)/usr/sbin/sshd
rm -f $(1)/usr/sbin/ssk
rm -f $(1)/usr/sbin/telnetd
rm -f $(1)/usr/sbin/tr64c
rm -f $(1)/usr/sbin/tr69c
rm -f $(1)/usr/sbin/ubi*
rm -f $(1)/usr/sbin/udhcpd
rm -f $(1)/usr/sbin/upnp
rm -f $(1)/usr/sbin/upnpd
rm -f $(1)/usr/sbin/vodsl
rm -f $(1)/usr/sbin/wlmngr
rm -f $(1)/usr/sbin/zebra
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
# Install libraries
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
rm -f $(1)/usr/lib/ld-uClibc.so.0
rm -f $(1)/usr/lib/libc.so.0
rm -f $(1)/usr/lib/libdl.so.0
rm -f $(1)/usr/lib/libgcc_s.so.1
rm -f $(1)/usr/lib/libpthread.so.0
rm -f $(1)/usr/lib/libm.so.0
rm -f $(1)/usr/lib/libutil.so.0
rm -f $(1)/usr/lib/libcms_boardctl.so
rm -f $(1)/usr/lib/libcms_msg.so
rm -f $(1)/usr/lib/libcms_util.so
rm -f $(1)/usr/lib/libnvram.so
rm -f $(1)/usr/lib/libcrypt.so.0
rm -f $(1)/usr/lib/libbcm_crc.so
rm -f $(1)/usr/lib/libbcm_flashutil.so
rm -f $(1)/usr/lib/libcrypto.so
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so.0.9.7
rm -f $(1)/usr/lib/libssl.so
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so
rm -f $(1)/usr/lib/libssl.so.0.9.7
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so.0.9.7
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
rm -rf $(1)/usr/lib/modules
rm -rf $(1)/usr/lib/private
rm -rf $(1)/usr/lib/public
rm -rf $(1)/usr/lib/gpl
# Install kernel modules
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
mkdir -p $(1)/lib/
mkdir -p $(1)/lib/modules/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
# bootloader nor
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
# ram part of the bootloader for nand boot
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
$(call Package/bcmkernel/removevoice,$(1))
$(call Package/bcmkernel/removesound,$(1))
# $(call Package/bcmkernel/removei2c,$(1))
endef

View file

@ -1,40 +1,9 @@
#
# Copyright (C) 2006-2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# Primary/common bcmkernel makefile for all versions of Broadcom SDKs
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bcmkernel-3.4
PKG_VERSION:=4.16
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.02A
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=104638f3401491d5355832641b0334d64e89f9c4
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/image.mk
include $(INCLUDE_DIR)/kernel.mk
export CONFIG_BCM_CHIP_ID
export CONFIG_BCM_KERNEL_PROFILE
export CONFIG_SECURE_BOOT_CFE
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
BCM_KERNEL_VERSION:=3.4.11-rt19
BCM_SDK_VERSION:=bcm963xx
RSTRIP:=true
define Package/bcmkernel
SECTION:=net
CATEGORY:=Base system
@ -51,230 +20,25 @@ define Package/bcmkernel/config
source "$(SOURCE)/Config.in"
endef
define Package/bcmkernel/removevoice
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
define Package/bcmkernel/removevoice
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
endef
# Include SDK version specific makefile based on config selection
ifeq ($(CONFIG_ARCH),)
include $(TOPDIR)/.config
endif
define Package/bcmkernel/removesound
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
endef
ifeq ($(CONFIG_BRCM_SDK_VER_414040),y)
include ./414040.mk
ifeq ($(BCM_USBSOUND_MODULES),y)
define Package/bcmkernel/removesound
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
endef
else ifeq ($(CONFIG_BRCM_SDK_VER_416021),y)
include ./416021.mk
else ifeq ($(CONFIG_BRCM_SDK_VER_416030),y)
include ./416030.mk
else
# Make 'make menuconfig' work even though no SDK version specified
PKG_VERSION:=none
include $(INCLUDE_DIR)/package.mk
endif
define Package/bcmkernel/removei2c
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
ifeq ($(CONFIG_BCM_I2C),y)
define Package/bcmkernel/removei2c
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
endef
endif
#define Package/bcmkernel/prepare
#endif
define Package/bcmkernel/install
$(INSTALL_DIR) $(1)/lib/bcm
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/etc/adsl
$(INSTALL_DIR) $(1)/etc/wlan
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
# Install header files
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
###
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
rm -f $(1)/usr/sbin/dhcp6c
rm -f $(1)/usr/sbin/dhcp6s
rm -f $(1)/usr/sbin/dhcpc
rm -f $(1)/usr/sbin/dhcpd
rm -f $(1)/usr/sbin/dnsproxy
rm -f $(1)/usr/sbin/httpd
rm -f $(1)/usr/sbin/openssl
rm -f $(1)/usr/sbin/racoon
rm -f $(1)/usr/sbin/ripd
rm -f $(1)/usr/sbin/send_cms_msg
rm -f $(1)/usr/sbin/sshd
rm -f $(1)/usr/sbin/ssk
rm -f $(1)/usr/sbin/telnetd
rm -f $(1)/usr/sbin/tr64c
rm -f $(1)/usr/sbin/tr69c
rm -f $(1)/usr/sbin/ubi*
rm -f $(1)/usr/sbin/udhcpd
rm -f $(1)/usr/sbin/upnp
rm -f $(1)/usr/sbin/upnpd
rm -f $(1)/usr/sbin/vodsl
rm -f $(1)/usr/sbin/wlmngr
rm -f $(1)/usr/sbin/zebra
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
mv $(1)/usr/lib/ld-uClibc.so.0 $(1)/lib/bcm/
mv $(1)/usr/lib/libc.so.0 $(1)/lib/bcm/
mv $(1)/usr/lib/libdl.so.0 $(1)/lib/bcm/
mv $(1)/usr/lib/libgcc_s.so.1 $(1)/lib/bcm/
mv $(1)/usr/lib/libpthread.so.0 $(1)/lib/bcm/
# rm -f $(1)/usr/lib/libcrypt.so.0
rm -f $(1)/usr/lib/libm.so.0
rm -f $(1)/usr/lib/libutil.so.0
rm -f $(1)/usr/lib/libcms_boardctl.so
rm -f $(1)/usr/lib/libcms_msg.so
rm -f $(1)/usr/lib/libcms_util.so
# rm -f $(1)/usr/lib/libcrypto.so.0.9.7
# rm -f $(1)/usr/lib/libssl.so.0.9.7
rm -f $(1)/usr/lib/libnvram.so
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
rm -rf $(1)/usr/lib/modules
rm -rf $(1)/usr/lib/private
rm -rf $(1)/usr/lib/public
rm -rf $(1)/usr/lib/gpl
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
mkdir -p $(1)/lib/
mkdir -p $(1)/lib/modules/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/crypto/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/scsi/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/usb/serial/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/usb/storage/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/fs/cifs/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv4/*.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/dns_resolver/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv4/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv6/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/char/hw_random/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/i2c-core.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/i2c-dev.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/algos/i2c-algo-bit.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/busses/i2c-gpio.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/busses/i2c-gpio-custom.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
touch $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/char/adsl/impl1/adsl_phy.bin
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/char/adsl/impl1/adsl_phy.bin $(1)/etc/adsl/adsl_phy.bin
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
# bootloader nor
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
# ram part of the bootloader for nand boot
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.000
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
$(call Package/bcmkernel/removevoice,$(1))
$(call Package/bcmkernel/removesound,$(1))
# $(call Package/bcmkernel/removei2c,$(1))
endef
$(eval $(call BuildPackage,bcmkernel))

View file

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=cwmp
PKG_VERSION:=2.3-2014-12-01
PKG_VERSION:=2.3-2015-02-13
PKG_FIXUP:=autoreconf
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
PKG_SOURCE_URL:=ssh://git@iopsys.inteno.se/freecwmp.git
@ -16,7 +16,7 @@ else
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/freecwmp.git
endif
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=bfdc0ec0ba7f78a8babdcff9a8ccc3a67af07ece
PKG_SOURCE_VERSION:=afdf1008520761c382a7d495314238fd1d5bc9e4
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)

View file

@ -15,15 +15,15 @@ export PLATFORM_INCLUDE:=platforms/iopsys/build.mk
export DATE:=$(shell date +%Y-%m-%d-%H-%M-%S)
export LOGIN:=$(shell whoami)
BASE_PKG_VERSION:=3.3.0
PKG_RELEASE:=RC3
BASE_PKG_VERSION:=3.2.0
PKG_RELEASE:=RC1
PKG_VERSION:=$(BASE_PKG_VERSION)-$(PKG_RELEASE)_$(DATE)_$(LOGIN)
export PKG_VERSION
###########################--RELEASE--################################
PKG_SOURCE_URL:=ssh://git@iopsys.inteno.se/ice-client.git
PKG_SOURCE_VERSION:=e4fe162bf4660c06029b93414cf871476fb3378e
PKG_SOURCE_VERSION:=1f95ce3d1eff1b2403a2357d0fa45063e56ff5e2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(BASE_PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(BASE_PKG_VERSION)-$(PKG_RELEASE).tar.gz
@ -884,133 +884,6 @@ fi
exit 0
endef
# torrent
define Package/ice-client-torrent
$(call Package/ice-client/Default)
TITLE:=torrent
DEPENDS+= +boost-system
# boost Boost C++ source libraries (header-only)
# boost-chrono Boost C++ source libraries (chrono)
# boost-date_time Boost C++ source libraries (date_time)
# boost-filesystem Boost C++ source libraries (filesystem)
# boost-graph Boost C++ source libraries (graph)
# boost-iostreams Boost C++ source libraries (iostreams)
# boost-locale Boost C++ source libraries (locale)
# boost-math Boost C++ source libraries (math)
# boost-program_options Boost C++ source libraries (program_options)
# boost-python Boost C++ source libraries (python)
# boost-random Boost C++ source libraries (random)
# boost-regex Boost C++ source libraries (regex)
# boost-serialization Boost C++ source libraries (serialization)
# boost-signals Boost C++ source libraries (signals)
# boost-timer Boost C++ source libraries (timer)
#boost-wave Boost C++ source libraries (wave)
endef
define Package/ice-client-torrent/description
torrent module for ice-client
endef
define Package/ice-client-torrent/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ ! -f "/tmp/ice.pid" ] ; then exit 0 ; fi
PROC_ID=$$(cat /tmp/ice.pid)
PROC_EXISTS=$$(/usr/bin/pgrep -P $${PROC_ID})
if [ -n "$$PROC_EXISTS" ]; then
read -t 1 <>/tmp/cfout
echo "system moduleRemove topic=torrentMgr" > /tmp/cfin
fi
fi
exit 0
endef
define Package/ice-client-torrent/preinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ ! -f "/tmp/ice.pid" ] ; then exit 0 ; fi
PROC_ID=$$(cat /tmp/ice.pid)
PROC_EXISTS=$$(/usr/bin/pgrep -P $${PROC_ID})
if [ -n "$$PROC_EXISTS" ]; then
read -t 1 <>/tmp/cfout
echo "system moduleRemove topic=torrentMgr" > /tmp/cfin
fi
fi
exit 0
endef
define Package/ice-client-torrent/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/core/lib/torrentService.so.1.0.1 $(1)/usr/lib
endef
define Package/ice-client-torrent/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
read -t 1 <>/tmp/cfout
if [ -f /tmp/ice.pid ]; then
echo "system moduleAdd file=torrentService.so.1.0.1" package="ice-client-torrent" > /tmp/cfin
fi
fi
exit 0
endef
# gigaset
define Package/ice-client-gigaset
$(call Package/ice-client/Default)
TITLE:=gigaset
DEPENDS+=
endef
define Package/ice-client-gigaset/description
gigaset module for ice-client
endef
define Package/ice-client-gigaset/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ ! -f "/tmp/ice.pid" ] ; then exit 0 ; fi
PROC_ID=$$(cat /tmp/ice.pid)
PROC_EXISTS=$$(/usr/bin/pgrep -P $${PROC_ID})
if [ -n "$$PROC_EXISTS" ]; then
read -t 1 <>/tmp/cfout
echo "system moduleRemove topic=gigaset" > /tmp/cfin
fi
fi
exit 0
endef
define Package/ice-client-gigaset/preinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ ! -f "/tmp/ice.pid" ] ; then exit 0 ; fi
PROC_ID=$$(cat /tmp/ice.pid)
PROC_EXISTS=$$(/usr/bin/pgrep -P $${PROC_ID})
if [ -n "$$PROC_EXISTS" ]; then
read -t 1 <>/tmp/cfout
echo "system moduleRemove topic=gigaset" > /tmp/cfin
fi
fi
exit 0
endef
define Package/ice-client-gigaset/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/core/lib/gigasetService.so.1.0.1 $(1)/usr/lib
endef
define Package/ice-client-gigaset/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
read -t 1 <>/tmp/cfout
if [ -f /tmp/ice.pid ]; then
echo "system moduleAdd file=gigasetService.so.1.0.1" package="ice-client-gigaset" > /tmp/cfin
fi
fi
exit 0
endef
# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to

View file

@ -101,7 +101,6 @@ atm_inf_conf() {
xtmctl operate conn --addq 1.$vpi.$vci 0 wrr 1
xtmctl operate conn --createnetdev 1.$vpi.$vci ${ifname%%.*}
xtmctl operate intf --state 1 enable
ifconfig $baseifname up
brcm_virtual_interface_rules "$baseifname" "$ifname" "$bridge"
fi

View file

@ -30,7 +30,6 @@ addethernet() {
config_get baseifname $1 baseifname
config_get ifname $1 ifname
config_get bridge $1 bridge
ifconfig $baseifname up
brcm_virtual_interface_rules "$baseifname" "$ifname" "$bridge"
}

View file

@ -45,7 +45,6 @@ ptm_inf_conf() {
xtmctl operate conn --createnetdev $dslat.$ptmprio ${ifname%%.*}
xtmctl operate intf --state 1 enable
xtmctl start
ifconfig $baseifname up
brcm_virtual_interface_rules "$baseifname" "$ifname" "$bridge"
fi
}

View file

@ -2,7 +2,6 @@
. /usr/share/libubox/jshn.sh
. /lib/network/ebtables.sh
. /lib/brcmaliases.sh
removeall_vlandevices()
{
@ -126,6 +125,9 @@ brcm_virtual_interface_rules ()
local baseifname=$1
local ifname=$2
local bridge=$3
echo '1' > /proc/sys/net/ipv6/conf/$baseifname/disable_ipv6
ifconfig $baseifname up
if [ "x$bridge" = "x" ]; then
bridge=0
fi

View file

@ -1,17 +0,0 @@
#ifndef BRCMDAEMON_H
#define BRCMDAEMON_H 1
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
#include <assert.h>
#include <signal.h>
#define DAEMON_NAME "iopsys_ledmngr"
#define PID_FILE "/var/run/iopsys_ledmngr.pid"
#endif

View file

@ -1,11 +0,0 @@
#ifndef LOG_H
extern int daemonize;
#define DEBUG_PRINT_RAW(...) if (!daemonize) fprintf( stderr, __VA_ARGS__ );
#define DEBUG_PRINT(fmt, args...) \
do { \
if (!daemonize) \
fprintf( stderr,"%-20s: " fmt , __func__, ##args); \
} while(0)
#endif /* LOG_H */

View file

@ -1,41 +0,0 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
*/
#ifndef _UCI_H__
#define _UCI_H__
struct uci_context* ucix_init(const char *config_file);
struct uci_context* ucix_init_path(const char *path, const char *config_file);
void ucix_cleanup(struct uci_context *ctx);
void ucix_save(struct uci_context *ctx);
void ucix_save_state(struct uci_context *ctx);
const char* ucix_get_option(struct uci_context *ctx,
const char *p, const char *s, const char *o);
int ucix_get_option_int(struct uci_context *ctx,
const char *p, const char *s, const char *o, int def);
void ucix_add_section(struct uci_context *ctx,
const char *p, const char *s, const char *t);
void ucix_add_option(struct uci_context *ctx,
const char *p, const char *s, const char *o, const char *t);
void ucix_add_option_int(struct uci_context *ctx,
const char *p, const char *s, const char *o, int t);
int ucix_commit(struct uci_context *ctx, const char *p);
void ucix_revert(struct uci_context *ctx,
const char *p, const char *s, const char *o);
void ucix_del(struct uci_context *ctx, const char *p,
const char *s, const char *o);
#endif

View file

@ -2,8 +2,8 @@ include $(TOPDIR)/rules.mk
PKG_BRANCH:=svn-0.11
PKG_NAME:=luci
PKG_VERSION:=inteno-1.0.145
PKG_SOURCE_VERSION:=5fcc60517dc95e128afa21d2de2a91ffa04e0d56
PKG_VERSION:=inteno-1.0.169
PKG_SOURCE_VERSION:=e5300da360d4ecfa050cc3fb3e3be8e962b36023
PKG_SOURCE_PROTO:=git
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
@ -446,9 +446,6 @@ define Package/luci-app-voice/install
$(INSTALL_DATA) $(LUCI_VOICE_DIR)/dist/etc/config/voice_client $(1)/etc/config/
$(INSTALL_DATA) $(LUCI_VOICE_DIR)/dist/etc/config/voice_codecs $(1)/etc/config/
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) $(LUCI_VOICE_DIR)/dist/etc/idc_cc.cfg $(1)/etc
echo $(PKG_VERSION) > $(1)/etc/iop_luci_version.log
echo $(PKG_SOURCE_VERSION) >> $(1)/etc/iop_luci_version.log
@ -583,10 +580,10 @@ $(eval $(call application,mcpd,LuCI Support for IGMP Proxy,\
+PACKAGE_luci-app-mcpd:mcpd))
$(eval $(call application,sfp,LuCI Support for SFP status,\
+PACKAGE_luci-app-sfp:sfp))
+PACKAGE_luci-app-sfp:sfp))
$(eval $(call application,catv,LuCI Support for CATV Module,\
+PACKAGE_luci-app-catv:catv))
+PACKAGE_luci-app-catv:catv))
$(eval $(call application,mount,LuCI Support for Mount Management,\
+PACKAGE_luci-app-mount))

View file

@ -0,0 +1,60 @@
#
# Copyright (C) 2006-2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=peripheral_manager
PKG_RELEASE:=1
# support parallel build
PKG_BUILD_PARALLEL:=1
#re create configure scripts if not present.
PKG_FIXUP:=autoreconf
# run install target when cross compiling. basically, make install DESTDIR=$(PKG_INSTALL_DIR)
# this way we don't need to pick out the resulting files from the build dir.
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/peripheral_manager
CATEGORY:=Utilities
TITLE:=Application deamon for handling of peripheral
URL:=
DEPENDS:=+libuci +libubus +libblobmsg-json +bcmkernel
endef
define Package/peripheral_manager/description
Application handling peripheral
endef
TARGET_CPPFLAGS := \
-I$(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
$(TARGET_CPPFLAGS)
# In future get the git. unpack it in src.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
$(CP) ./files/* $(PKG_BUILD_DIR)/
endef
define Package/peripheral_manager/install
$(INSTALL_DIR) $(1)/etc/
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/peripheral_manager $(1)/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/etc/init.d/* $(1)/etc/init.d/
endef
$(eval $(call BuildPackage,peripheral_manager))

View file

@ -6,11 +6,11 @@
START=19
start() {
/sbin/ledmngr
/sbin/peripheral_manager
sleep 1
/bin/ubus call led.status set '{"state":"ok"}' &
}
stop() {
killall -9 ledmngr
killall -9 peripheral_manager
}

View file

@ -0,0 +1,43 @@
#PRG_VERSION := $(shell cd @top_srcdir@; if ! git describe --tags ;then echo version-$(PACKAGE_VERSION) ;fi )
AM_CFLAGS = $(OUR_CFLAGS)
bin_PROGRAMS = peripheral_manager
dist_data_DATA = configs/hw
peripheral_manager_SOURCES = \
src/peripheral_manager.c \
src/ucix.c \
src/ucix.h \
src/server.c \
src/server.h \
src/led.c \
src/led.h \
src/sim_led.c \
src/button.h \
src/button.c \
src/sim_button.c \
src/catv.c \
src/catv.h \
src/smbus.c \
src/smbus.h \
src/i2c.c \
src/i2c.h \
src/sfp.c \
src/sfp.h
if BRCM_BOARD
peripheral_manager_SOURCES += \
src/gpio_led.c \
src/gpio_led.h \
src/gpio_button.c \
src/gpio_button.h \
src/gpio.c \
src/gpio.h \
src/touch_sx9512.c \
src/touch_sx9512.h
endif
peripheral_manager_LDADD = $(UCI_LIB) $(UBOX_LIB) $(UBUS_LIB) -lm
peripheral_manager_CFLAGS = $(AM_CFLAGS) -DPRG_VERSION=\"$(PRG_VERSION)\"

View file

@ -0,0 +1,307 @@
config board 'board'
option hardware 'DG301'
option hasAdsl '1'
option hasVdsl '1'
option hasVoice '1'
option hasDect '1'
option VoicePorts '2'
option VoiceLeds '1'
option hasWifi '1'
option ethernetPorts '5'
option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 WAN'
option ethernetPortOrder 'eth4 eth3 eth1 eth2 eth0'
option ethernetLanPorts 'eth1 eth2 eth3 eth4'
option ethernetWanPort 'eth0'
option adslWanPort 'atm0'
option vdslWanPort 'ptm0'
option wpsButtonGpio '22'
option fxsRelayGpio '8'
option hasBrcmAvs '0'
config wifi-chip '435f'
option bands 'b'
config wifi-chip '43a0'
option bands 'a'
option is_ac '1'
config wifi-chip '43a2'
option bands 'a'
option is_ac '1'
config wifi-chip '43bc'
option bands 'a'
option is_ac '1'
option radarthrs '0x6aa 0x30 0x6a8 0x30 0x69c 0x30 0x6aa 0x30 0x6aa 0x30 0x6a2 0x30'
###############################################################################
#
# Button config, start
#
############### gpio buttons, driver config
config gpio_button gpio_buttons
list buttons gpio_reset
list buttons gpio_dect
list buttons gpio_wps
list buttons gpio_info
list buttons gpio_eco
config gpio_button gpio_reset
option addr 32
option active low
config gpio_button gpio_dect
option addr 20
option active low
config gpio_button gpio_wps
option addr 22
option active low
config gpio_button gpio_info
option addr 37
option active low
config gpio_button gpio_eco
option addr 36
option active low
############### function buttons used on board.
config button_map button_map
list buttonnames RESET
list buttonnames DECT
list buttonnames WPS
list buttonnames INFO
list buttonnames ECO
option minpress 100
############### mapping function button to driver button
config button_map RESET
list button gpio_reset
option minpress 5000
option hotplug resetbutton
config button_map DECT
list button gpio_dect
option hotplug dectbutton
config button_map WPS
list button gpio_wps
option hotplug wpsbutton
config button_map INFO
list button gpio_info
option hotplug infobutton
config button_map ECO
list button gpio_eco
option hotplug ecobutton
#
# Button config , end
#
###############################################################################
###############################################################################
#
# Led config, start
#
############### gpio led, driver config
config gpio_led gpio_leds
list leds Ethernet_green
list leds Wireless_green
list leds Voice_green
list leds Broadband_green
list leds Status_blue
list leds Status_green
list leds Status_red
list leds Internet_green
list leds Internet_red
list leds DECT_red
list leds DECT_green
list leds TV_green
list leds WPS_green
list leds WPS_red
list leds WAN_yellow
config gpio_led Ethernet_green
option addr 0
option active hi
option mode csr
config gpio_led Wireless_green
option addr 3
option active hi
option mode csr
config gpio_led Voice_green
option addr 9
option active low
option mode direct
config gpio_led Broadband_green
option addr 6
option active hi
option mode csr
config gpio_led Status_blue
option addr 7
option active hi
option mode csr
config gpio_led Status_green
option addr 39
option active low
option mode direct
config gpio_led Status_red
option addr 38
option active low
option mode direct
config gpio_led Internet_green
option addr 5
option active hi
option mode csr
config gpio_led Internet_red
option addr 4
option active hi
option mode csr
config gpio_led DECT_red
option addr 19
option active low
option mode direct
config gpio_led DECT_green
option addr 15
option active low
option mode direct
config gpio_led TV_green
option addr 35
option active low
option mode direct
config gpio_led WPS_green
option addr 2
option active hi
option mode csr
config gpio_led WPS_red
option addr 1
option active hi
option mode csr
config gpio_led WAN_yellow
option addr 21
option active hi
option mode direct
############### mapping led function to driver led
config led_map led_dsl
list led_action_ok Broadband_green=ON
list led_action_off Broadband_green=OFF
list led_action_notice Broadband_green=FLASH_SLOW
list led_action_alert Broadband_green=FLASH_SLOW
list led_action_error Broadband_green=FLASH_FAST
config led_map led_wifi
list led_action_ok Wireless_green=ON
list led_action_off Wireless_green=OFF
list led_action_notice Wireless_green=FLASH_SLOW
list led_action_alert Wireless_green=FLASH_SLOW
list led_action_error Wireless_green=FLASH_FAST
config led_map led_wps
list led_action_ok 'WPS_green = ON'
list led_action_ok 'WPS_red = OFF'
list led_action_off 'WPS_green = OFF'
list led_action_off 'WPS_red = OFF'
list led_action_notice 'WPS_green = FLASH_SLOW'
list led_action_notice 'WPS_red = OFF'
list led_action_alert 'WPS_green = OFF'
list led_action_alert 'WPS_red = FLASH_SLOW'
list led_action_error 'WPS_green = OFF'
list led_action_error 'WPS_red = FLASH_FAST'
config led_map led_lan
list led_action_ok Ethernet_green=ON
list led_action_off Ethernet_green=OFF
list led_action_notice Ethernet_green=FLASH_SLOW
list led_action_alert Ethernet_green=FLASH_SLOW
list led_action_error Ethernet_green=FLASH_FAST
config led_map led_status
list led_action_ok 'Status_green = ON'
list led_action_ok 'Status_red = OFF'
list led_action_ok 'Status_blue = OFF'
list led_action_off 'Status_green = OFF'
list led_action_off 'Status_red = OFF'
list led_action_off 'Status_blue = OFF'
list led_action_notice 'Status_green = FLASH_SLOW'
list led_action_notice 'Status_red = OFF'
list led_action_notice 'Status_blue = OFF'
list led_action_alert 'Status_green = OFF'
list led_action_alert 'Status_red = FLASH_SLOW'
list led_action_alert 'Status_blue = OFF'
list led_action_error 'Status_green = OFF'
list led_action_error 'Status_red = FLASH_FAST'
list led_action_error 'Status_blue = OFF'
config led_map led_tv
list led_action_ok TV_green=ON
list led_action_off TV_green=OFF
list led_action_notice TV_green=FLASH_SLOW
list led_action_alert TV_green=FLASH_SLOW
list led_action_error TV_green=FLASH_FAST
config led_map led_wan
list led_action_off WAN_yellow=OFF
list led_action_alert WAN_yellow=ON
config led_map led_internet
list led_action_ok 'Internet_green = ON'
list led_action_ok 'Internet_red = OFF'
list led_action_off 'Internet_green = OFF'
list led_action_off 'Internet_red = OFF'
list led_action_notice 'Internet_green = FLASH_SLOW'
list led_action_notice 'Internet_red = OFF'
list led_action_alert 'Internet_green = OFF'
list led_action_alert 'Internet_red = FLASH_SLOW'
list led_action_error 'Internet_green = OFF'
list led_action_error 'Internet_red = ON'
config led_map led_voice1
list led_action_ok Voice_green=ON
list led_action_off Voice_green=OFF
list led_action_notice Voice_green=FLASH_SLOW
list led_action_alert Voice_green=FLASH_SLOW
list led_action_error Voice_green=FLASH_FAST
config led_map led_eco
list led_action_ok Status_blue=ON
list led_action_off Status_blue=OFF
list led_action_notice Status_blue=FLASH_SLOW
list led_action_alert Status_blue=FLASH_SLOW
list led_action_error Status_blue=FLASH_FAST
#
# Led config , end
#
###############################################################################

View file

@ -0,0 +1,349 @@
config board 'board'
option hardware 'CG300'
option hasAdsl '0'
option hasVdsl '0'
option hasVoice '0'
option hasDect '1'
option VoicePorts '0'
option VoiceLeds '0'
option hasWifi '1'
option ethernetPorts '2'
option ethernetPortNames 'LAN WAN'
option ethernetPortOrder 'eth1 eth0'
option ethernetLanPorts 'eth1'
option ethernetWanPort 'eth0'
option adslWanPort ''
option vdslWanPort ''
# option lednames 'Status Internet Wireless WPS DECT WAN'
option lednames 'Status Internet Wireless WPS DECT WAN'
option buttonnames 'RESET Wireless WPS DECT TOUCH_NEAR TOUCH_FAR'
option wpsButtonGpio '0'
option fxsRelayGpio '0'
option i2cGpioCustom 'bus0=0,23,22'
config wifi-chip '435f'
option bands 'b'
config wifi-chip '43a0'
option bands 'a'
option is_ac '1'
config wifi-chip '43a2'
option bands 'a'
option is_ac '1'
config wifi-chip '43bc'
option bands 'a'
option is_ac '1'
option radarthrs '0x6ae 0x30 0x6a8 0x30 0x6a4 0x30 0x6aa 0x30 0x6aa 0x30 0x6a4 0x30'
config buttons 'buttons'
option RESET 'gpio 32 al resetbutton Status_green'
option DECT 'i2c 3 ah dectbutton WPS_green'
option WPS 'i2c 2 ah wpsbutton Wireless_green'
option Wireless 'i2c 1 ah ecobutton Internet_green'
option TOUCH_NEAR 'i2c 8 ah touch_near Wireless_blue'
option TOUCH_FAR 'i2c 9 ah touch_far Internet_red'
config leds 'leds'
option Status_green 'gpio 39 al'
option Status_red 'gpio 38 al'
option Internet_green 'i2c 4 ah'
option Internet_red 'i2c 5 ah'
option Wireless_green 'gpio 37 al'
option Wireless_blue 'gpio 36 al'
option WPS_green 'i2c 2 ah'
option DECT_green 'i2c 3 ah'
option WAN_green 'gpio 9 al'
option WAN_yellow 'gpio 10 al'
# config led_map 'led_map'
# option dsl_ok ''
# option dsl_off ''
# option dsl_notice ''
# option dsl_alert ''
# option dsl_error ''
# option wifi_ok 'Wireless_green=ON Wireless_blue=OFF'
# option wifi_off 'Wireless_green=OFF Wireless_blue=OFF'
# option wifi_notice 'Wireless_green=OFF Wireless_blue=ON'
# option wifi_alert 'Wireless_green=OFF Wireless_blue=ON'
# option wifi_error 'Wireless_green=OFF Wireless_blue=BLINK_FAST'
# option wps_ok 'WPS_green=ON'
# option wps_off 'WPS_green=OFF'
# option wps_notice 'WPS_green=BLINK_SLOW'
# option wps_alert 'WPS_green=OFF'
# option wps_error 'WPS_green=OFF'
# option lan_ok ''
# option lan_off ''
# option lan_notice ''
# option lan_alert ''
# option lan_error ''
# option status_ok 'Status_green=ON Status_red=OFF'
# option status_off 'Status_green=OFF Status_red=OFF'
# option status_notice 'Status_green=BLINK_SLOW Status_red=OFF'
# option status_alert 'Status_green=OFF Status_red=BLINK_SLOW'
# option status_error 'Status_green=OFF Status_red=BLINK_FAST'
# option dect_ok 'DECT_green=ON'
# option dect_off 'DECT_green=OFF'
# option dect_notice 'DECT_green=BLINK_SLOW'
# option dect_alert 'DECT_green=OFF'
# option dect_error 'DECT_green=OFF'
# option tv_ok ''
# option tv_off ''
# option tv_notice ''
# option tv_alert ''
# option tv_error ''
# option usb_ok ''
# option usb_off ''
# option usb_notice ''
# option usb_alert ''
# option usb_error ''
# option wan_ok ''
# option wan_off 'WAN_green=OFF WAN_yellow=OFF'
# option wan_notice 'WAN_green=ON'
# option wan_alert 'WAN_yellow=ON'
# option wan_error ''
# option internet_ok 'Internet_green=ON Internet_red=OFF'
# option internet_off 'Internet_green=OFF Internet_red=OFF'
# option internet_notice 'Internet_green=BLINK_SLOW Internet_red=OFF'
# option internet_alert 'Internet_green=OFF Internet_red=BLINK_SLOW'
# option internet_error 'Internet_green=OFF Internet_red=BLINK_FAST'
# option voice1_ok ''
# option voice1_off ''
# option voice1_notice ''
# option voice1_alert ''
# option voice1_error ''
# option voice2_ok ''
# option voice2_off ''
# option voice2_notice ''
# option voice2_alert ''
# option voice2_error ''
# option eco_ok ''
# option eco_off ''
# option eco_notice ''
# option eco_alert ''
# option eco_error ''
###############################################################################
#
# example for low level button.
#
#
config sim_button sim_buttons
list buttons sim_button_A
list buttons sim_button_B
list buttons sim_button_c
list buttons sim_button_d
list buttons sim_button_e
config sim_button sim_button_A
option addr 10
option active hi
config sim_button sim_button_B
option addr 11
option active low
config sim_button sim_button_c
option addr 12
option active hi
config sim_button sim_button_d
option addr 13
option active hi
config sim_button sim_button_e
option addr 14
option active hi
###############################################################################
#
# example for mapping system button to driver button.
#
# mapping serveral "functions" buttons to one physical can be done with the long press option
# if
#
# this is a list of all button names. perifmanger will read this list then read out the specific button config
config button_map button_map
list buttonnames RESET
list buttonnames Wireless
list buttonnames WPS
list buttonnames DECT
list buttonnames TOUCH_NEAR
list buttonnames TOUCH_FAR
option minpress 100 # default minimum time a button nedes to be pressed.
config button_map RESET
# list button gpio_reset
list button sim_button_A # driver that is used for this button
option minpress 5000 # don't allow button unless pressed for 5 seconds.
option hotplug resetbutton
config button_map Wireless
list button sim_button_B # driver that is used for this button
list button sim_button_c # we support user having to press two at the same time to register a button event.
option minpress 1000
option hotplug ecobutton
# long press example one or the other of touch_near or touch_far will trigger not booth.
config button_map TOUCH_NEAR
list button gpio_reset
# list button sim_button_d # driver that is used for this button
option hotplug touch_near
config button_map TOUCH_FAR
list button sim_button_d # driver that is used for this button
option longpress 3000 # this button has a long press option.
option hotplug touch_far
###############################################################################
#
# example for low level led driver.
# here we list what the led can do and any info the driver needs to know to controll the led.
#
# would proably be smarter to name the leds as the color and not just A B C.
# but this is an example to show there is no connection with the name and what it
# does.
#
config sim_led sim_leds
list leds sim_led_A
list leds sim_led_B
list leds sim_led_C
config sim_led sim_led_A
option addr 1
option color green
option breading no
config sim_led sim_led_B
option addr 7
option color red
option breading no
config sim_led sim_led_C
option addr 3
option color blue
option breading yes
option fadein yes
option fadeout yes
###############################################################################
#
# gpio leds
#
config gpio_led gpio_leds
list leds Status_green
list leds Status_red
list leds Wireless_green
list leds Wireless_blue
list leds WAN_green
list leds WAN_yellow
config gpio_led Status_green
option addr 39
option active low
option mode direct
config gpio_led Status_red
option addr 38
option active low
option mode direct
config gpio_led Wireless_green
option addr 37
option active low
option mode direct
config gpio_led Wireless_blue
option addr 36
option active low
option mode direct
config gpio_led WAN_green
option addr 9
option active low
option mode direct
config gpio_led WAN_yellow
option addr 10
option active low
option mode direct
###############################################################################
#
# gpio buttons
#
config gpio_button gpio_buttons
list buttons gpio_reset
config gpio_button gpio_reset
option addr 32
option active low
# option feedback
###############################################################################
#
# example mapping sim leds to system leds.
#
# the led_action list can be from one entry and up.
#
# led_action, list of leds to set.
# button_action. list of button events to send out
# effect_action, list of special effects to activate. (dim display.....)
#
config led_map led_map
config led_map status_ok
list led_action Status_green=ON
list led_action Status_red=OFF
config led_map status_off
list led_action Status_green=OFF
list led_action Status_red=OFF
config led_map status_notice
list led_action Status_green=FLASH_SLOW
list led_action Status_red=OFF
config led_map status_alert
list led_action Status_green=
list led_action Status_red=FLASH_SLOW
config led_map status_error
list led_action Status_green=OFF
list led_action Status_red=FLASH_FAST
config led_map wifi_ok
list led_action sim_led_A=ON
list led_action sim_led_C=OFF
config led_map wifi_off
list led_action sim_led_A=OFF
list led_action sim_led_C=OFF
config led_map wifi_notice
list led_action sim_led_A=OFF
list led_action sim_led_C=ON
config led_map wifi_alert
list led_action sim_led_A=OFF
list led_action sim_led_C=ON
config led_map wifi_error
list led_action sim_led_A=FLASH_SLOW
list led_action sim_led_C=FLASH_SLOW
config led_map wps_ok
list led_action sim_led_B=ON
config led_map wps_off
list led_action sim_led_B=OFF
config led_map wps_notice
list led_action sim_led_B=ON
config led_map wps_alert
list led_action sim_led_B=ON
config led_map wps_error
list led_action sim_led_B=ON

View file

@ -0,0 +1,77 @@
dnl init stuff needs to be first in file
AC_INIT([peripheral_manager], [0.1], [Kenneth Johansson <kenneth@southpole.se>])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-pipe \
-Wall \
-Wextra \
-Wno-inline \
-Wundef \
"-Wformat=2 -Wformat-security -Wformat-nonliteral" \
-Wlogical-op \
-Wsign-compare \
-Wmissing-include-dirs \
-Wold-style-definition \
-Wpointer-arith \
-Winit-self \
-Wdeclaration-after-statement \
-Wfloat-equal \
-Wsuggest-attribute=noreturn \
-Wmissing-prototypes \
-Wstrict-prototypes \
-Wredundant-decls \
-Wmissing-declarations \
-Wmissing-noreturn \
-Wshadow \
-Wendif-labels \
-Wstrict-aliasing=2 \
-Wwrite-strings \
-Wno-long-long \
-Wno-overlength-strings \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-unused-result \
-Werror=overflow \
-Wdate-time \
-Wnested-externs \
-ffast-math \
-fno-common \
-fdiagnostics-show-option \
-fno-strict-aliasing \
-fvisibility=hidden \
-ffunction-sections \
-fdata-sections \
-fstack-protector \
-fstack-protector-strong \
-fPIE \
--param=ssp-buffer-size=4])
AC_SUBST([OUR_CFLAGS], "$with_cflags")
dnl check for uci , its manadatory
AC_SEARCH_LIBS([uci_load], [uci], [], [AC_MSG_ERROR([*** UCI library not found])])
dnl check ubox , its manadatory
AC_SEARCH_LIBS([uloop_init], [ubox], [], [AC_MSG_ERROR([*** UBOX library not found])])
dnl chek ubus , its manadatory
AC_SEARCH_LIBS([ubus_connect], [ubus], [], [AC_MSG_ERROR([*** UBUS library not found])])
dnl check for board.h file
AC_CHECK_HEADERS(board.h, AM_CONDITIONAL(BRCM_BOARD, true), AM_CONDITIONAL(BRCM_BOARD, false))
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE_NAME $VERSION
CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
])

32
peripheral_manager/src/ledctl Executable file
View file

@ -0,0 +1,32 @@
#!/bin/sh
name=$1
status=$2
name=$(echo $name | tr '[A-Z]' '[a-z]')
status=$(echo $status | tr '[A-Z]' '[a-z]')
case $name in
normal) ubus call leds set '{"state":"normal"}' ;;
proximity) ubus call leds set '{"state":"proximity"}' ;;
test) ubus call leds set '{"state":"test"}' ;;
allon) ubus call leds set '{"state":"allon"}' ;;
alloff) ubus call leds set '{"state":"alloff"}' ;;
production) ubus call leds set '{"state":"production"}' ;;
broadband) db get hw.board.lednames | grep -iq broadband && name="dsl" || exit ;;
ethernet) name="lan" ;;
wireless) name="wifi" ;;
tel*|voice) name="voice1" ;;
video) name="tv" ;;
power) name="status" ;;
esac
case $status in
on) status="ok" ;;
fail) status="error" ;;
blink) status="notice" ;;
esac
ubus -s /tmp/ubus.s call led.$name set '{"state":"'$status'"}' &

View file

@ -0,0 +1,288 @@
dnl Macros to check the presence of generic (non-typed) symbols.
dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
dnl Copyright (c) 2006-2008 xine project
dnl Copyright (c) 2012 Lucas De Marchi <lucas.de.marchi@gmail.com>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
dnl 02110-1301, USA.
dnl
dnl As a special exception, the copyright owners of the
dnl macro gives unlimited permission to copy, distribute and modify the
dnl configure scripts that are the output of Autoconf when processing the
dnl Macro. You need not follow the terms of the GNU General Public
dnl License when using or distributing such scripts, even though portions
dnl of the text of the Macro appear in them. The GNU General Public
dnl License (GPL) does govern all other use of the material that
dnl constitutes the Autoconf Macro.
dnl
dnl This special exception to the GPL applies to versions of the
dnl Autoconf Macro released by this project. When you make and
dnl distribute a modified version of the Autoconf Macro, you may extend
dnl this special exception to the GPL to apply to your modified version as
dnl well.
dnl Check if FLAG in ENV-VAR is supported by compiler and append it
dnl to WHERE-TO-APPEND variable
dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG])
AC_DEFUN([CC_CHECK_FLAG_APPEND], [
AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
AS_TR_SH([cc_cv_$2_$3]),
[eval "AS_TR_SH([cc_save_$2])='${$2}'"
eval "AS_TR_SH([$2])='-Werror $3'"
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; } ])],
[eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
[eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
eval "AS_TR_SH([$2])='$cc_save_$2'"])
AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
[eval "$1='${$1} $3'"])
])
dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2])
AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
for flag in $3; do
CC_CHECK_FLAG_APPEND($1, $2, $flag)
done
])
dnl Check if the flag is supported by linker (cacheable)
dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
AC_DEFUN([CC_CHECK_LDFLAGS], [
AC_CACHE_CHECK([if $CC supports $1 flag],
AS_TR_SH([cc_cv_ldflags_$1]),
[ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $1"
AC_LINK_IFELSE([int main() { return 1; }],
[eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
[eval "AS_TR_SH([cc_cv_ldflags_$1])="])
LDFLAGS="$ac_save_LDFLAGS"
])
AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
[$2], [$3])
])
dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
dnl the current linker to avoid undefined references in a shared object.
AC_DEFUN([CC_NOUNDEFINED], [
dnl We check $host for which systems to enable this for.
AC_REQUIRE([AC_CANONICAL_HOST])
case $host in
dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
dnl are requested, as different implementations are present; to avoid problems
dnl use -Wl,-z,defs only for those platform not behaving this way.
*-freebsd* | *-openbsd*) ;;
*)
dnl First of all check for the --no-undefined variant of GNU ld. This allows
dnl for a much more readable command line, so that people can understand what
dnl it does without going to look for what the heck -z defs does.
for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
break
done
;;
esac
AC_SUBST([LDFLAGS_NOUNDEFINED])
])
dnl Check for a -Werror flag or equivalent. -Werror is the GCC
dnl and ICC flag that tells the compiler to treat all the warnings
dnl as fatal. We usually need this option to make sure that some
dnl constructs (like attributes) are not simply ignored.
dnl
dnl Other compilers don't support -Werror per se, but they support
dnl an equivalent flag:
dnl - Sun Studio compiler supports -errwarn=%all
AC_DEFUN([CC_CHECK_WERROR], [
AC_CACHE_CHECK(
[for $CC way to treat warnings as errors],
[cc_cv_werror],
[CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
[CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
])
])
AC_DEFUN([CC_CHECK_ATTRIBUTE], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
AS_TR_SH([cc_cv_attribute_$1]),
[ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
[eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
[eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
CFLAGS="$ac_save_CFLAGS"
])
AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
[AC_DEFINE(
AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
[Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
)
$4],
[$5])
])
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
CC_CHECK_ATTRIBUTE(
[constructor],,
[void __attribute__((constructor)) ctor() { int a; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
CC_CHECK_ATTRIBUTE(
[format], [format(printf, n, n)],
[void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
CC_CHECK_ATTRIBUTE(
[format_arg], [format_arg(printf)],
[char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
CC_CHECK_ATTRIBUTE(
[visibility_$1], [visibility("$1")],
[void __attribute__((visibility("$1"))) $1_function() { }],
[$2], [$3])
])
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
CC_CHECK_ATTRIBUTE(
[nonnull], [nonnull()],
[void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
CC_CHECK_ATTRIBUTE(
[unused], ,
[void some_function(void *foo, __attribute__((unused)) void *bar);],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
CC_CHECK_ATTRIBUTE(
[sentinel], ,
[void some_function(void *foo, ...) __attribute__((sentinel));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
CC_CHECK_ATTRIBUTE(
[deprecated], ,
[void some_function(void *foo, ...) __attribute__((deprecated));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
CC_CHECK_ATTRIBUTE(
[alias], [weak, alias],
[void other_function(void *foo) { }
void some_function(void *foo) __attribute__((weak, alias("other_function")));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
CC_CHECK_ATTRIBUTE(
[malloc], ,
[void * __attribute__((malloc)) my_alloc(int n);],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_PACKED], [
CC_CHECK_ATTRIBUTE(
[packed], ,
[struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_CONST], [
CC_CHECK_ATTRIBUTE(
[const], ,
[int __attribute__((const)) twopow(int n) { return 1 << n; } ],
[$1], [$2])
])
AC_DEFUN([CC_FLAG_VISIBILITY], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
[cc_cv_flag_visibility],
[cc_flag_visibility_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
cc_cv_flag_visibility='yes',
cc_cv_flag_visibility='no')
CFLAGS="$cc_flag_visibility_save_CFLAGS"])
AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
[AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
[Define this if the compiler supports the -fvisibility flag])
$1],
[$2])
])
AC_DEFUN([CC_FUNC_EXPECT], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if compiler has __builtin_expect function],
[cc_cv_func_expect],
[ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[int some_function() {
int a = 3;
return (int)__builtin_expect(a, 3);
}])],
[cc_cv_func_expect=yes],
[cc_cv_func_expect=no])
CFLAGS="$ac_save_CFLAGS"
])
AS_IF([test "x$cc_cv_func_expect" = "xyes"],
[AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
[Define this if the compiler supports __builtin_expect() function])
$1],
[$2])
])
AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
[cc_cv_attribute_aligned],
[ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
for cc_attribute_align_try in 64 32 16 8 4 2; do
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
int main() {
static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
return c;
}])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
done
CFLAGS="$ac_save_CFLAGS"
])
if test "x$cc_cv_attribute_aligned" != "x"; then
AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
[Define the highest alignment supported])
fi
])

View file

@ -0,0 +1,357 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#include "config.h"
#include <syslog.h>
#include <time.h>
#include "log.h"
#include "button.h"
#include "led.h"
#include "touch_sx9512.h"
/* used to map in the driver buttons to a function button */
struct button_drv_list {
struct list_head list;
struct timespec pressed_time;
struct button_drv *drv;
};
/**/
struct function_button {
struct list_head list;
char *name;
char *hotplug;
int minpress;
int longpress; /* negative value means valid if mintime < time < abs(longpress ) */
/* positive value means valid if time > longpreass */
/* zero value means valid if time > mintime */
struct list_head drv_list; /* list of all driver button that is needed to activate this button function */
};
/* PUT every button from drivers into a list */
struct drv_button_list{
struct list_head list;
struct button_drv *drv;
};
/* list of all driver buttons added by drivers. */
static LIST_HEAD(drv_buttons_list);
/* list containing all function buttons read from config file */
static LIST_HEAD(buttons);
static struct button_drv *get_drv_button(char *name);
//static struct function_button *get_button(char *name);
void button_add( struct button_drv *drv)
{
struct drv_button_list *drv_node = malloc(sizeof(struct drv_button_list));
DBG(1,"called with led name [%s]", drv->name);
drv_node->drv = drv;
list_add(&drv_node->list, &drv_buttons_list);
}
static struct button_drv *get_drv_button(char *name)
{
struct list_head *i;
list_for_each(i, &drv_buttons_list) {
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
if (! strcmp(node->drv->name, name))
return node->drv;
}
return NULL;
}
#if 0
static struct function_button *get_button(char *name)
{
struct list_head *i;
list_for_each(i, &buttons) {
struct function_button *node = list_entry(i, struct function_button, list);
if (! strcmp(node->name, name))
return node;
}
return NULL;
}
#endif
static void dump_drv_list(void)
{
struct list_head *i;
list_for_each(i, &drv_buttons_list) {
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
DBG(1,"button name = [%s]",node->drv->name);
}
}
static void dump_buttons_list(void)
{
struct list_head *i;
list_for_each(i, &buttons) {
struct function_button *node = list_entry(i, struct function_button, list);
DBG(1,"button name = [%s]",node->name);
{
struct list_head *j;
list_for_each(j, &node->drv_list) {
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
if(drv_node->drv != NULL)
DBG(1,"%13s drv button name = [%s]","",drv_node->drv->name);
}
DBG(1,"%13s minpress = %d","",node->minpress);
DBG(1,"%13s longpress = %d","",node->longpress);
}
}
}
static int timer_started(struct button_drv_list *button_drv)
{
if (button_drv->pressed_time.tv_sec == 0 )
if (button_drv->pressed_time.tv_nsec == 0 )
return 0;
return 1;
}
static void timer_start(struct button_drv_list *button_drv)
{
clock_gettime(CLOCK_MONOTONIC, &button_drv->pressed_time);
}
static void timer_stop(struct button_drv_list *button_drv)
{
button_drv->pressed_time.tv_sec = 0;
button_drv->pressed_time.tv_nsec = 0;
}
static int timer_valid(struct button_drv_list *button_drv, int mtimeout, int longpress)
{
struct timespec now;
int sec;
int nsec;
if (timer_started(button_drv)) {
clock_gettime(CLOCK_MONOTONIC, &now);
sec = now.tv_sec - button_drv->pressed_time.tv_sec;
nsec = now.tv_nsec - button_drv->pressed_time.tv_nsec;
if ( mtimeout < (sec*1000 + nsec/1000000)) {
if (longpress == 0)
return 1;
if (longpress < 0) {
longpress = -1 * longpress;
if ( longpress > (sec*1000 + nsec/1000000)) {
return 1;
} else {
return 0;
}
}
if ( longpress < (sec*1000 + nsec/1000000)) {
return 1;
}
}
}
return 0;
}
#define BUTTON_TIMEOUT 100
static void button_handler(struct uloop_timeout *timeout);
static struct uloop_timeout button_inform_timer = { .cb = button_handler };
static void button_handler(struct uloop_timeout *timeout)
{
struct list_head *i;
// DBG(1, "");
#ifdef HAVE_BOARD_H
/* sx9512 driver needs to read out all buttons at once */
/* so call it once at beginning of scanning inputs */
sx9512_check();
#endif
/* clean out indicator status, set by any valid press again if we find it */
led_pressindicator_clear();
list_for_each(i, &buttons) {
struct list_head *j;
struct function_button *node = list_entry(i, struct function_button, list);
list_for_each(j, &node->drv_list) {
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
if (drv_node->drv) {
button_state_t st = drv_node->drv->func->get_state(drv_node->drv);
if (st == PRESSED ) {
if (! timer_started(drv_node)) {
timer_start(drv_node);
DBG(1, " %s pressed", drv_node->drv->name);
}
if ( timer_valid(drv_node, node->minpress, 0)) {
led_pressindicator_set();
}
}
if (st == RELEASED ) {
if (timer_started(drv_node)) {
DBG(1, " %s released", drv_node->drv->name);
if ( timer_valid(drv_node, node->minpress, node->longpress) ) {
char str[512];
DBG(1, "send key %s [%s]to system", node->name, node->hotplug);
snprintf(str,
512,
"ACTION=register INTERFACE=%s /sbin/hotplug-call button &",
node->hotplug);
system(str);
syslog(LOG_INFO, "%s",str);
} else {
// DBG(1, " %s not valid", drv_node->drv->name);
}
}
timer_stop(drv_node);
}
// DBG(1, " %s state = %d", drv_node->drv->name,st);
}
}
}
uloop_timeout_set(&button_inform_timer, BUTTON_TIMEOUT);
}
/* in order to support long press there is a need to go over every function button
and find any driver button that is part of a longpress function.
if found then the longpress time for that button needs to be filled in (but negative)
on any other function button that has the same driver button. This to prevent two
function buttons to trigger on one driver button release.
*/
/* Find functions that use driver (drv) that has a zero longpress time and set it to time */
static void longpress_set(int max_time,struct button_drv *drv) {
struct list_head *i;
list_for_each(i, &buttons) {
struct function_button *node = list_entry(i, struct function_button, list);
struct list_head *j;
list_for_each(j, &node->drv_list) {
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
if(drv_node->drv == drv){
if (node->longpress == 0) {
node->longpress = max_time;
}
}
}
}
}
/* find any use of longpress and set all other to negative longpress time to indicate min max time
for a valid press
*/
static void longpress_find(void) {
struct list_head *i;
list_for_each(i, &buttons) {
struct function_button *node = list_entry(i, struct function_button, list);
struct list_head *j;
list_for_each(j, &node->drv_list) {
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
if(drv_node->drv != NULL){
if (node->longpress > 0) {
DBG(1,"%13s drv button name = [%s]","",drv_node->drv->name);
DBG(1,"%13s longpress = %d","",node->longpress);
longpress_set(node->longpress * -1, drv_node->drv);
}
}
}
}
}
void button_init( struct server_ctx *s_ctx)
{
struct ucilist *node;
LIST_HEAD(buttonnames);
int default_minpress = 0;
char *s;
/* read out default global options */
s = ucix_get_option(s_ctx->uci_ctx, "hw" , "button_map", "minpress");
DBG(1, "default minpress = [%s]", s);
if (s){
default_minpress = strtol(s,0,0);
}
/* read function buttons from section button_map */
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"button_map", "buttonnames", &buttonnames);
list_for_each_entry(node, &buttonnames, list) {
struct function_button *function;
// DBG(1, "value = [%s]",node->val);
function = malloc(sizeof(struct function_button));
memset(function,0,sizeof(struct function_button));
function->name = node->val;
/* read out minpress */
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "minpress");
DBG(1, "minpress = [%s]", s);
if (s){
function->minpress = strtol(s,0,0);
}else
function->minpress = default_minpress;
/* read out long_press */
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "longpress");
DBG(1, "longpress = [%s]", s);
if (s){
function->longpress = strtol(s,0,0);
}
/* read out hotplug option */
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "hotplug");
DBG(1, "hotplug = [%s]", s);
if (s){
function->hotplug = s;
}
INIT_LIST_HEAD(&function->drv_list);
{
struct ucilist *drv_node;
LIST_HEAD(head);
int num = 0;
/* read out all driver buttons that needs to be pressed for this button function. */
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,function->name, "button", &head);
list_for_each_entry(drv_node, &head, list) {
struct button_drv_list *new_button;
num++;
DBG(1,"function %s -> drv button %s", function->name, drv_node->val);
new_button = malloc(sizeof(struct button_drv_list));
memset(new_button,0,sizeof(struct button_drv_list));
new_button->drv = get_drv_button(drv_node->val);
if(new_button->drv == NULL){
syslog(LOG_WARNING, "%s wanted drv button [%s] but it can't be found. check spelling.",
function->name,
drv_node->val);
}
list_add( &new_button->list, &function->drv_list);
}
if (num == 0 )
syslog(LOG_WARNING, "Function %s did not have any mapping to a driver button", function->name);
}
list_add(&function->list, &buttons);
}
uloop_timeout_set(&button_inform_timer, BUTTON_TIMEOUT);
longpress_find();
dump_drv_list();
dump_buttons_list();
}

View file

@ -0,0 +1,25 @@
#ifndef BUTTON_H
#define BUTTON_H
#include "server.h"
typedef enum {
RELEASED,
PRESSED,
} button_state_t;
struct button_drv;
struct button_drv_func {
button_state_t (*get_state)(struct button_drv *); /* Get led state, on,off,flash ... */
};
struct button_drv {
const char *name; /* name, set in the confg file,has to be uniq */
void *priv; /* for use by the driver */
struct button_drv_func *func; /* function pointers for reading the button */
};
void button_add( struct button_drv *drv);
void button_init( struct server_ctx *s_ctx);
#endif /* BUTTON_H */

View file

@ -36,7 +36,7 @@ static struct catv_handler *pcatv;
static int catv_get_type(struct blob_buf *b)
{
int type;
char *s;
const char *s;
type = i2c_smbus_read_byte_data(pcatv->i2c_a0,32);
@ -270,7 +270,7 @@ static int catv_get_serial_method(struct ubus_context *ubus_ctx, struct ubus_obj
static int catv_get_interface(struct blob_buf *b)
{
int type;
char *s;
const char *s;
type = i2c_smbus_read_byte_data(pcatv->i2c_a0,81);
@ -315,7 +315,7 @@ static int catv_get_interface_method(struct ubus_context *ubus_ctx, struct ubus_
static int catv_get_bandwidth(struct blob_buf *b)
{
int type;
char *s;
const char *s;
type = i2c_smbus_read_byte_data(pcatv->i2c_a0,82);
@ -1200,7 +1200,7 @@ static int catv_save_method(struct ubus_context *ubus_ctx, struct ubus_object *o
ucix_add_option(pcatv->ctx, "catv", "catv", "filter", "3");
ucix_save(pcatv->ctx);
ucix_save(pcatv->ctx,"/etc/config");
ucix_commit(pcatv->ctx, "catv");
blobmsg_add_string(&b, "Saved", "/etc/config/catv");
@ -1308,13 +1308,13 @@ static void catv_config_open(struct catv_handler *h)
/* open config file */
again:
h->ctx = ucix_init_path("/etc/config", "catv");
h->ctx = ucix_init_path("/etc/config", "catv", 0);
if (NULL == h->ctx) {
int fd;
syslog(LOG_INFO,"CATV config file not found /etc/config/catv\n");
fd = open("/etc/config/catv",O_RDWR | O_CREAT | O_TRUNC);
fd = open("/etc/config/catv",O_RDWR | O_CREAT | O_TRUNC, 0644);
close(fd);
if (loop++ < 10)
goto again;
@ -1336,7 +1336,7 @@ again:
ucix_add_section(h->ctx,"catv","catv", "service");
ucix_add_option(h->ctx,"catv", "catv", "enable","no");
ucix_add_option(h->ctx,"catv", "catv", "filter","3");
ucix_save(h->ctx);
ucix_save(h->ctx,"/etc/config");
ucix_commit(h->ctx,"catv");
goto again;
}
@ -1352,7 +1352,7 @@ again:
}
struct catv_handler * catv_init(struct uci_context *uci_ctx, char *i2c_bus,int a0_addr,int a2_addr)
struct catv_handler * catv_init(struct uci_context *uci_ctx, const char *i2c_bus,int a0_addr,int a2_addr)
{
struct catv_handler *h;
const char *p;

View file

@ -5,7 +5,7 @@
struct catv_handler;
struct catv_handler * catv_init(struct uci_context *uci_ctx, char * i2c_bus, int i2c_addr_a0,int i2c_addr_a2);
struct catv_handler * catv_init(struct uci_context *uci_ctx, const char * i2c_bus, int i2c_addr_a0,int i2c_addr_a2);
void catv_destroy(struct catv_handler *h);
int catv_ubus_populate(struct catv_handler *h, struct ubus_context *ubus_ctx);

View file

@ -0,0 +1,39 @@
#include <syslog.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include "gpio.h"
#include "log.h"
static int brcmboard = -1;
void gpio_open_ioctl( void ) {
if (brcmboard == -1){
brcmboard = open("/dev/brcmboard", O_RDWR);
if ( brcmboard == -1 ) {
DBG(1,"failed to open: /dev/brcmboard\n");
return;
}
DBG(1, "fd %d allocated\n", brcmboard);
}
return;
}
int board_ioctl(int ioctl_id, int action, int hex, char* string_buf, int string_buf_len, int offset) {
BOARD_IOCTL_PARMS IoctlParms = {0};
IoctlParms.string = string_buf;
IoctlParms.strLen = string_buf_len;
IoctlParms.offset = offset;
IoctlParms.action = action;
IoctlParms.buf = (char*)"";
if ( ioctl(brcmboard, ioctl_id, &IoctlParms) < 0 ) {
syslog(LOG_INFO, "ioctl: %d failed", ioctl_id);
exit(1);
}
return IoctlParms.result;
}

View file

@ -0,0 +1,11 @@
#ifndef GPIO_H
#define GPIO_H
#include <fcntl.h>
#include <sys/ioctl.h>
#include <board.h>
void gpio_open_ioctl(void);
int board_ioctl(int ioctl_id, int action, int hex, char* string_buf, int string_buf_len, int offset);
#endif /* GPIO_H */

View file

@ -0,0 +1,80 @@
#include <syslog.h>
#include <string.h>
#include "button.h"
#include "log.h"
#include "server.h"
#include "gpio.h"
#include <board.h>
void gpio_button_init(struct server_ctx *s_ctx);
struct gpio_data {
int addr;
int active;
int state;
struct button_drv button;
};
static button_state_t gpio_get_state(struct button_drv *drv)
{
// DBG(1, "state for %s", drv->name);
struct gpio_data *p = (struct gpio_data *)drv->priv;
int value;
value = board_ioctl( BOARD_IOCTL_GET_GPIO, 0, 0, NULL, p->addr, 0);
if(p->active)
p->state = value ? PRESSED : RELEASED;
else
p->state = value ? RELEASED : PRESSED;
return p->state;
}
static struct button_drv_func func = {
.get_state = gpio_get_state,
};
void gpio_button_init(struct server_ctx *s_ctx) {
struct ucilist *node;
LIST_HEAD(buttons);
DBG(1, "");
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"gpio_buttons", "buttons", &buttons);
list_for_each_entry(node, &buttons, list) {
struct gpio_data *data;
const char *s;
DBG(1, "value = [%s]",node->val);
data = malloc(sizeof(struct gpio_data));
memset(data,0,sizeof(struct gpio_data));
data->button.name = node->val;
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
DBG(1, "addr = [%s]", s);
if (s){
data->addr = strtol(s,0,0);
}
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "active");
data->active = -1;
if (s){
if (!strncasecmp("hi",s,2))
data->active = 1;
else if (!strncasecmp("low",s,3))
data->active = 0;
}
DBG(1, "active = %d", data->active);
data->button.func = &func;
data->button.priv = data;
button_add(&data->button);
}
gpio_open_ioctl();
}

View file

@ -0,0 +1,169 @@
#include <syslog.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <board.h>
#include "led.h"
#include "log.h"
#include "server.h"
#include "gpio.h"
void gpio_led_init(struct server_ctx *s_ctx);
typedef enum {
UNKNOWN,
LOW,
HI,
} active_t;
typedef enum {
MODE_UNKNOWN,
DIRECT,
SHIFTREG2,
SHIFTREG3,
} gpio_mode_t;
struct gpio_data {
int addr;
active_t active;
int state;
gpio_mode_t mode;
struct led_drv led;
};
#define SR_MAX 16
static int shift_register_state[SR_MAX];
static void shift_register3_set(int address, int bit_val) {
int i;
if (address>=SR_MAX-1) {
DBG(1,"address index %d too large\n", address);
return;
}
// Update internal register copy
shift_register_state[address] = bit_val;
// pull down shift register load (load gpio 23)
board_ioctl(BOARD_IOCTL_SET_GPIO, 0, 0, NULL, 23, 0);
// clock in bits
for (i=0 ; i<SR_MAX ; i++) {
//set clock low
board_ioctl( BOARD_IOCTL_SET_GPIO, 0, 0, NULL, 0, 0);
//place bit on data line
board_ioctl( BOARD_IOCTL_SET_GPIO, 0, 0, NULL, 1, shift_register_state[SR_MAX-1-i]);
//set clock high
board_ioctl( BOARD_IOCTL_SET_GPIO, 0, 0, NULL, 0, 1);
}
// issue shift register load
board_ioctl( BOARD_IOCTL_SET_GPIO, 0, 0, NULL, 23, 1);
}
static int gpio_set_state(struct led_drv *drv, led_state_t state)
{
struct gpio_data *p = (struct gpio_data *)drv->priv;
int bit_val = 0;
if (state == OFF) {
if (p->active == HI)
bit_val = 0;
else if (p->active == LOW)
bit_val = 1;
}else if (state == ON) {
if (p->active == HI)
bit_val = 1;
else if (p->active == LOW)
bit_val = 0;
}
p->state = state;
switch (p->mode) {
case DIRECT :
board_ioctl( BOARD_IOCTL_SET_GPIO, 0, 0, NULL, p->addr, bit_val);
break;
case SHIFTREG2:
board_ioctl( BOARD_IOCTL_LED_CTRL, 0, 0, NULL, p->addr, bit_val);
break;
case SHIFTREG3:
shift_register3_set(p->addr, bit_val);
break;
default:
DBG(1,"access mode not supported [%d]", p->mode);
}
return p->state;
}
static led_state_t gpio_get_state(struct led_drv *drv)
{
struct gpio_data *p = (struct gpio_data *)drv->priv;
DBG(1, "state for %s", drv->name);
return p->state;
}
static struct led_drv_func func = {
.set_state = gpio_set_state,
.get_state = gpio_get_state,
};
void gpio_led_init(struct server_ctx *s_ctx) {
LIST_HEAD(leds);
struct ucilist *node;
DBG(1, "");
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"gpio_leds", "leds", &leds);
list_for_each_entry(node,&leds,list){
struct gpio_data *data;
const char *s;
DBG(1, "value = [%s]",node->val);
data = malloc(sizeof(struct gpio_data));
memset(data,0,sizeof(struct gpio_data));
data->led.name = node->val;
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
DBG(1, "addr = [%s]", s);
if (s) {
data->addr = strtol(s,0,0);
}
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "mode");
DBG(1, "mode = [%s]", s);
if (s) {
if (!strncasecmp("direct",s,3))
data->mode = DIRECT;
else if (!strncasecmp("sr",s,5))
data->mode = SHIFTREG2;
else if (!strncasecmp("csr",s,4))
data->mode = SHIFTREG3;
}
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "active");
DBG(1, "active = [%s]", s);
if (s) {
data->active = UNKNOWN;
if (!strncasecmp("hi",s,3))
data->active = HI;
if (!strncasecmp("low",s,3))
data->active = LOW;
}
data->led.func = &func;
data->led.priv = data;
led_add(&data->led);
}
gpio_open_ioctl();
}

View file

@ -0,0 +1,57 @@
#include <string.h>
#include <syslog.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "smbus.h"
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "i2c.h"
#include "log.h"
void dump_i2c(int fd,int start,int stop)
{
int i;
int res;
for (i=start ; i < stop; i++) {
res = i2c_smbus_read_byte_data(fd,i);
if (res < 0){perror("i2c error\n");}
DBG(1,"/dev/i2c-0 READ %d = 0x%02x\n",i,(unsigned char)res);
}
}
int i2c_open_dev (const char *bus, int addr, unsigned long needed)
{
int fd = open(bus, O_RDWR);
if (fd < 0) {
syslog(LOG_INFO,"%s: could not open /dev/i2c-0\n",__func__);
return -1;
}
if (ioctl(fd, I2C_SLAVE, addr) < 0) {
syslog(LOG_INFO,"%s: could not set address %x for i2c chip\n",
__func__, addr);
error:
close (fd);
return -1;
}
if (needed) {
unsigned long funcs;
if (ioctl(fd, I2C_FUNCS, &funcs) < 0) {
syslog(LOG_INFO,"%s: could not get I2C_FUNCS\n",__func__);
goto error;
}
if ( (funcs & needed) != needed) {
syslog(LOG_INFO,"%s: lacking I2C capabilities, have %lx, need %lx\n",
__func__, funcs, needed);
goto error;
}
}
return fd;
}

View file

@ -1,4 +1,5 @@
#ifndef I2C_H
#define I2C_H
struct i2c_reg_tab {
char addr;

View file

@ -0,0 +1,568 @@
#include <syslog.h>
#include "log.h"
#include "led.h"
static struct blob_buf bblob;
typedef enum {
LED_OFF,
LED_OK,
LED_NOTICE,
LED_ALERT,
LED_ERROR,
LED_CUSTOM,
LED_ACTION_MAX,
} led_action_t;
typedef enum {
LEDS_NORMAL,
LEDS_PROXIMITY,
LEDS_SILENT,
LEDS_INFO,
LEDS_TEST,
LEDS_PROD,
LEDS_RESET,
LEDS_ALLON,
LEDS_ALLOFF,
LEDS_MAX,
} leds_state_t;
/* Names for led_action_t */
static const char * const fn_actions[LED_ACTION_MAX] =
{ "off", "ok", "notice", "alert", "error", "custom"};
#define LED_FUNCTIONS 17
static const char* const led_functions[LED_FUNCTIONS] =
{ "dsl", "wifi", "wps", "lan",
"status", "dect", "tv", "usb",
"wan", "internet", "voice1", "voice2",
"eco", "gbe", "ext", "wan_phy_speed",
"wan_phy_link" };
/* Names for led_state_t */
static const char* const led_states[LED_STATES_MAX] =
{ "off", "on", "flash_slow", "flash_fast","breading", "fadeon", "fadeoff" };
/* Names for leds_state_t */
static const char* const leds_states[LEDS_MAX] =
{ "normal", "proximity", "silent", "info", "test", "production", "reset", "allon" , "alloff"};
/* lowest level, contain states, timers,pointer to driver for a single physical led.*/
struct led {
struct list_head list;
led_state_t state; /* state that this led should have, set from the config file */
struct led_drv *drv;
};
/*middle layer contains lists of leds /buttons/... that should be set to a specific state */
struct function_action {
const char *name; /* If name is set this led action is in use by the board. */
struct list_head led_list;
struct list_head button_list;
};
/* main struct for the function leds.*/
struct function_led {
const char *name; /* If name is set this led function is in use by the board. */
led_action_t state; /* state of the function led. contain what action is currently set */
int press_indicator; /* record if this is part of press indictor */
struct function_action actions[LED_ACTION_MAX];
};
struct function_led leds[LED_FUNCTIONS];
static leds_state_t global_state; /* global state for the leds,overrids individual states */
static leds_state_t press_state; /* global state for the press indicator */
int get_index_by_name(const char *const*array, int max, const char *name);
struct led_drv *get_drv_led(char *name);
static void dump_drv_list(void);
static void dump_led(void);
static void all_leds_off(void);
static void all_leds_on(void);
static void all_leds(led_state_t state);
/* we find out the index for a match in an array of char pointers containing max number of pointers */
int get_index_by_name(const char *const*array, int max, const char *name)
{
int i;
for (i=0; i < max ; i++ ){
if (!strcasecmp(name, array[i]))
return i;
}
return -1;
}
/* PUT every led from drivers into a list */
struct drv_led_list{
struct list_head list;
struct led_drv *drv;
};
LIST_HEAD(drv_leds_list);
void led_add( struct led_drv *drv)
{
struct drv_led_list *drv_node = malloc(sizeof(struct drv_led_list));
DBG(1,"called with led name [%s]", drv->name);
drv_node->drv = drv;
list_add(&drv_node->list, &drv_leds_list);
}
static void all_leds(led_state_t state) {
struct drv_led_list *node;
DBG(1, "set to state %d",state);
list_for_each_entry(node, &drv_leds_list, list) {
node->drv->func->set_state( node->drv, state);
}
}
static void all_leds_off(void) {
all_leds(OFF);
}
static void all_leds_on(void) {
all_leds(ON);
}
#define TEST_TIMEOUT 250
static void test_handler(struct uloop_timeout *timeout);
static struct uloop_timeout test_inform_timer = { .cb = test_handler };
static void test_handler(struct uloop_timeout *timeout) {
static int cnt = 0;
static led_state_t state = OFF;
static struct drv_led_list *led;
DBG(1,"cnt = %d state %d",cnt,state);
/* flash all leads 2 times.*/
if ( cnt < 4) {
cnt++;
if (state == OFF){
all_leds_on();
state = ON;
}else{
all_leds_off();
state = OFF;
}
goto done;
}
if (global_state == LEDS_RESET){
cnt = 0;
goto done;
}
/* cycle through every led once */
if (cnt == 4 ) {
cnt++;
led = list_first_entry(&drv_leds_list, struct drv_led_list, list );
}
if (cnt == 5 ) {
if (state == OFF){
led->drv->func->set_state(led->drv, ON);
state = ON;
}else{
led->drv->func->set_state(led->drv, OFF);
/* was this the last led ? if so stop */
if ( list_is_last(&led->list, &drv_leds_list) ){
cnt = 0;
state = OFF;
goto done;
}else{ /* nope more leds in list. get next and turn it on */
led = (struct drv_led_list *)led->list.next;
led->drv->func->set_state(led->drv, ON);
state = ON;
}
}
}
done:
if (global_state == LEDS_TEST || global_state == LEDS_RESET)
uloop_timeout_set(&test_inform_timer, TEST_TIMEOUT);
else{
cnt = 0;
state = OFF;
}
}
/* go over the driver list for any led name that matches name and returna pointer to driver. */
struct led_drv *get_drv_led(char *name)
{
struct list_head *i;
list_for_each(i, &drv_leds_list) {
struct drv_led_list *node = list_entry(i, struct drv_led_list, list);
if (!strcmp(node->drv->name, name))
return node->drv;
}
return NULL;
}
static void dump_drv_list(void)
{
struct list_head *i;
list_for_each(i, &drv_leds_list) {
struct drv_led_list *node = list_entry(i, struct drv_led_list, list);
DBG(1,"led name = [%s]",node->drv->name);
}
}
static void dump_led(void)
{
int i,j;
for (i = 0; i < LED_FUNCTIONS ; i++) {
for (j = 0 ; j < LED_ACTION_MAX; j++ ) {
if ( leds[i].actions[j].name != NULL ) {
struct led *led;
list_for_each_entry(led, &leds[i].actions[j].led_list, list) {
DBG(1,"%-15s %-8s %-15s %-10s",
leds[i].name,
leds[i].actions[j].name,
led->drv->name,
led_states[led->state]);
}}}}}
static void set_function_led(const char* fn_name, const char* action) {
int led_idx = get_index_by_name(led_functions, LED_FUNCTIONS , fn_name);
int act_idx = get_index_by_name(fn_actions , LED_ACTION_MAX, action );
if(led_idx == -1) {
syslog(LOG_WARNING, "called over ubus with non valid led name [%s]", fn_name);
return;
}
if(act_idx == -1) {
syslog(LOG_WARNING, "called over ubus with non valid action [%s] for led [%s]", action, fn_name);
return;
}
leds[led_idx].state = act_idx;
if ( leds[led_idx].actions[act_idx].name != NULL ) {
struct led *led;
list_for_each_entry(led, &leds[led_idx].actions[act_idx].led_list, list) {
if (led->drv){
led->drv->func->set_state(led->drv, led->state);
}
}
}else
syslog(LOG_WARNING, "led set on [%s] has no valid [%s] handler registered.", fn_name, action);
}
enum {
LED_STATE,
__LED_MAX
};
static const struct blobmsg_policy led_policy[] = {
[LED_STATE] = { .name = "state", .type = BLOBMSG_TYPE_STRING },
};
static int led_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__LED_MAX];
char* state;
blobmsg_parse(led_policy, ARRAY_SIZE(led_policy), tb, blob_data(msg), blob_len(msg));
if (tb[LED_STATE]) {
char *fn_name = strchr(obj->name, '.') + 1;
state = blobmsg_data(tb[LED_STATE]);
DBG(1,"set led [%s]->[%s]", fn_name, state);
// syslog(LOG_INFO, "Led %s method: %s state %s", fn_name, method, state);
set_function_led(fn_name, state);
}else
DBG(1,"(%s) not implemented",method);
return 0;
}
static int led_status_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
char *fn_name = strchr(obj->name, '.') + 1;
int led_idx = get_index_by_name(led_functions, LED_FUNCTIONS , fn_name);
DBG(1,"for led %s",leds[led_idx].name);
blob_buf_init (&bblob, 0);
blobmsg_add_string(&bblob, "state",fn_actions[leds[led_idx].state]);
ubus_send_reply(ubus_ctx, req, bblob.head);
return 0;
}
static int leds_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__LED_MAX];
blobmsg_parse(led_policy, ARRAY_SIZE(led_policy), tb, blob_data(msg), blob_len(msg));
if (tb[LED_STATE]) {
char* state;
int state_idx;
state = blobmsg_data(tb[LED_STATE]);
state_idx = get_index_by_name(leds_states, LEDS_MAX , state);
if (state_idx == -1) {
syslog(LOG_WARNING, "leds_set_method: Unknown state %s.", state);
return 0;
}
global_state = state_idx;
if (global_state == LEDS_INFO) {
all_leds_off();
}
if (global_state == LEDS_PROD) {
all_leds_off();
}
if (global_state == LEDS_TEST || global_state == LEDS_RESET) {
all_leds_off();
uloop_timeout_set(&test_inform_timer, TEST_TIMEOUT);
}
if (global_state == LEDS_ALLON) {
all_leds_on();
}
if (global_state == LEDS_ALLOFF) {
all_leds_off();
}
DBG(1,"led global state set to [%s] wanted [%s]", leds_states[global_state], state);
}else
syslog(LOG_WARNING, "Unknown attribute [%s]", blob_data(msg));
return 0;
}
static int leds_status_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
blob_buf_init (&bblob, 0);
blobmsg_add_string(&bblob, "state", leds_states[global_state]);
DBG(1,"leds global state is [%s]",leds_states[global_state]);
ubus_send_reply(ubus_ctx, req, bblob.head);
return 0;
}
static const struct ubus_method led_methods[] = {
UBUS_METHOD("set", led_set_method, led_policy),
{ .name = "status", .handler = led_status_method },
};
static struct ubus_object_type led_object_type =
UBUS_OBJECT_TYPE("led", led_methods);
static const struct ubus_method leds_methods[] = {
UBUS_METHOD("set", leds_set_method, led_policy),
{ .name = "status", .handler = leds_status_method },
// { .name = "proximity", .handler = leds_proximity_method },
};
static struct ubus_object_type leds_object_type =
UBUS_OBJECT_TYPE("leds", leds_methods);
#define LED_OBJECTS (LED_FUNCTIONS + 1)
static struct ubus_object led_objects[LED_OBJECTS] = {
{ .name = "leds", .type = &leds_object_type, .methods = leds_methods, .n_methods = ARRAY_SIZE(leds_methods), },
{ .name = "led.dsl", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.wifi", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.wps", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.lan", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.status", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.dect", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.tv", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.usb", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.wan", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.internet", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.voice1", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.voice2", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.eco", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.gbe", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.ext", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.wan_phy_speed", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
{ .name = "led.wan_phy_link", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), },
};
#define FLASH_TIMEOUT 250
static void flash_handler(struct uloop_timeout *timeout);
static struct uloop_timeout flash_inform_timer = { .cb = flash_handler };
static void flash_handler(struct uloop_timeout *timeout)
{
static int counter = 1; /* bit 0 is fast flash bit 2 is slow flash */
int i;
led_state_t slow=OFF,fast=OFF;
counter++;
if (counter & 1 )
fast = ON;
if (counter & 4 )
slow = ON;
if (global_state == LEDS_NORMAL ||
global_state == LEDS_INFO ) {
/* BUG we should check if the driver support flash in hardware and only do this on simple on/off leds */
for (i = 0; i < LED_FUNCTIONS ; i++) {
struct led *led;
if (leds[i].press_indicator & press_state) {
// DBG(1,"INDICATE_PRESS on %s",leds[i].name);
list_for_each_entry(led, &leds[i].actions[leds[i].state].led_list, list) {
if (led->drv)
led->drv->func->set_state(led->drv, fast);
}
/* normal operation, flash else reset state */
} else {
led_action_t action_state = leds[i].state;
/* in case of info mode suppress OK state. that is if OK -> turn it into OFF */
if (global_state == LEDS_INFO) {
if (action_state == LED_OK)
action_state = LED_OFF;
}
list_for_each_entry(led, &leds[i].actions[action_state].led_list, list) {
if (led->state == FLASH_FAST){
if (led->drv)
led->drv->func->set_state(led->drv, fast);
}else if (led->state == FLASH_SLOW){
if (led->drv)
led->drv->func->set_state(led->drv, slow);
}else{
if (led->drv)
led->drv->func->set_state(led->drv, led->state);
}
}
}
}
}
uloop_timeout_set(&flash_inform_timer, FLASH_TIMEOUT);
}
void led_pressindicator_set(void){
press_state = 1;
}
void led_pressindicator_clear(void){
press_state = 0;
}
void led_init( struct server_ctx *s_ctx)
{
int i,j,ret;
dump_drv_list();
/* register leds with ubus */
for (i=0 ; i<LED_OBJECTS ; i++) {
ret = ubus_add_object(s_ctx->ubus_ctx, &led_objects[i]);
if (ret)
DBG(1,"Failed to add object: %s", ubus_strerror(ret));
}
/* we create a top list of led functions */
/* that list contains a new list of actions */
/* every action contains led actions lists */
/* the led states is attached to the drv_leds lists */
// led_names = ucix_get_option(s_ctx->uci_ctx, "hw", "board", "lednames");
for (i = 0; i < LED_FUNCTIONS ; i++) {
for (j = 0 ; j < LED_ACTION_MAX; j++ ) {
char led_fn_name[256];
char led_action[256];
LIST_HEAD(led_action_list);
struct ucilist *node;
snprintf(led_fn_name, 256, "led_%s", led_functions[i]);
snprintf(led_action, 256, "led_action_%s", fn_actions[j]);
ucix_get_option_list( s_ctx->uci_ctx, "hw", led_fn_name, led_action , &led_action_list);
// DBG(2,"ken: hw %s %s",led_fn_name, led_action);
INIT_LIST_HEAD( &leds[i].actions[j].led_list );
if (!list_empty(&led_action_list)) {
/* Found led with action, init structs */
leds[i].name = led_functions[i];
leds[i].state = LED_OFF;
leds[i].actions[j].name = fn_actions[j];
/* fill in led actions */
DBG(2,"%-15s has led actions -> ",led_fn_name);
list_for_each_entry(node, &led_action_list, list) {
char led_name[256],led_state[256];
struct led *led;
struct led_drv *drv;
char *s = strdup(node->val);
led_name[0]=0;
led_state[0]=0;
/* get pointer to low level led driver.*/
*strchr(s,'=') = ' ';
sscanf(s, "%s %s", led_name, led_state);
drv = get_drv_led(led_name);
if (drv) {
led = malloc(sizeof(struct led));
led->drv = drv;
led->state = get_index_by_name(led_states, LED_STATES_MAX, led_state);
list_add(&led->list, &leds[i].actions[j].led_list);
}else {
syslog(LOG_ERR,"Config specified use of led name [%s]. But it's not registerd with a led driver.", led_name);
}
DBG(2, "%-35s%s","",node->val);
free(s);
}
/* fill in button actions */
/* fill in xxx actions */
}
}
}
{
struct ucilist *node;
/* read function buttons from section button_map */
LIST_HEAD(press_indicator);
/* read in generic configuration. press indicator list, dimm list default params..... */
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"led_map", "press_indicator", &press_indicator);
list_for_each_entry(node, &press_indicator, list) {
char *s;
int ix;
s = node->val;
s +=4; /*remove 'led_' from string */
DBG(1,"press indicator %s [%s]",node->val, s);
ix = get_index_by_name(led_functions,LED_FUNCTIONS, s);
// DBG(1,"press indicator %s [%s]->%d",node->val, s, ix);
leds[ix].press_indicator = 1;
}
}
uloop_timeout_set(&flash_inform_timer, FLASH_TIMEOUT);
dump_led();
all_leds_off();
}

View file

@ -0,0 +1,47 @@
#ifndef LED_H
#define LED_H
#include "server.h"
typedef enum {
OFF,
ON,
FLASH_SLOW,
FLASH_FAST,
BREADING,
FADEON,
FADEOFF,
LED_STATES_MAX,
} led_state_t;
typedef enum {
NONE,
RED,
GREEN,
BLUE,
YELLOW,
WHITE,
} led_color_t;
struct led_drv;
struct led_drv_func{
int (*set_state)(struct led_drv *, led_state_t); /* Set led state, on,off,flash ... */
led_state_t (*get_state)(struct led_drv *); /* Get led state, on,off,flash ... */
int (*set_color)(struct led_drv *, led_color_t); /* Set led color */
led_color_t (*get_color)(struct led_drv *); /* Get led color */
};
struct led_drv {
const char *name; /* name, set in the confg file,has to be uniq */
void *priv; /* for use by the driver */
struct led_drv_func *func; /* function pointers for controlling the led */
};
void led_add( struct led_drv *);
void led_init(struct server_ctx *);
void led_pressindicator_set(void);
void led_pressindicator_clear(void);
#endif /* LED_H */

View file

@ -0,0 +1,14 @@
#ifndef LOG_H
#define LOG_H
/* Use this */
extern int debug_level;
#define DBG_RAW(...) fprintf( stderr, __VA_ARGS__ );
#define DBG(level,fmt, args...) \
do { \
if (level <= debug_level) \
syslog( LOG_DEBUG,"%-20s: " fmt , __func__, ##args); \
} while(0)
#endif /* LOG_H */

View file

@ -0,0 +1,175 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <libgen.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
#include <config.h>
#include <getopt.h>
#include "log.h"
#include "ucix.h"
#include <libubox/uloop.h>
#include <libubus.h>
#include "server.h"
int debug_level = 0;
static const char *config_path = "/lib/db/config";
static const char *config_file = "hw";
static char *ubus_socket;
void print_usage(char *prg_name);
void print_usage(char *prg_name) {
printf("Usage: %s -h -f\n", prg_name);
printf(" Options: \n");
printf(" -f, --foreground\tDon't fork off as a daemon.\n");
printf(" -d, --debug=NUM\tSet debug level. Higher = more output\n");
printf(" -c, --config=FILE\tConfig file to use. default = %s/%s\n", config_path, config_file);
printf(" -s, --socket=FILE\tSet the unix domain socket to connect to for ubus\n");
printf(" -h\t\tShow this help screen.\n");
printf("\n");
}
int main(int argc, char **argv)
{
int ch;
int daemonize = 1;
pid_t pid, sid;
struct uci_context *uci_ctx = NULL;
static struct ubus_context *ubus_ctx = NULL;
while (1) {
int option_index = 0;
static struct option long_options[] = {
{"foreground", no_argument, 0, 'f'},
{"verbose", no_argument, 0, 'v'},
{"debug", required_argument, 0, 'd'},
{"config",required_argument, 0, 'c'},
{"socket",required_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
ch = getopt_long(argc, argv, "hvfhd:c:s:",
long_options, &option_index);
if (ch == -1)
break;
switch (ch) {
case 'f':
daemonize = 0;
break;
case 'd':
debug_level = strtol(optarg, 0, 0);
break;
case 'c':
config_file = basename(optarg);
config_path = dirname(optarg);
break;
case 's':
ubus_socket = optarg;
break;
case 'h':
default:
print_usage(argv[0]);
exit(0);
}
}
if (optind < argc) {
printf("Extra arguments discarded: ");
while (optind < argc)
printf("%s ", argv[optind++]);
printf("\n");
}
/* Setup logging */
if (daemonize) {
setlogmask(LOG_UPTO(LOG_INFO));
openlog(PACKAGE, LOG_CONS, LOG_USER);
syslog(LOG_INFO, "%s daemon starting up", PACKAGE);
} else {
setlogmask(LOG_UPTO(LOG_DEBUG));
openlog(PACKAGE, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID, LOG_USER);
syslog(LOG_INFO, "%s program starting up", PACKAGE);
}
/* daemonize */
if (daemonize) {
syslog(LOG_INFO, "starting the daemonizing process");
/* Fork off the parent process */
pid = fork();
if (pid < 0) {
exit(EXIT_FAILURE);
}
/* If we got a good PID, then
we can exit the parent process. */
if (pid > 0) {
exit(EXIT_SUCCESS);
}
/* Change the file mode mask */
umask(0);
/* Create a new SID for the child process */
sid = setsid();
if (sid < 0) {
/* Log the failure */
exit(EXIT_FAILURE);
}
/* Change the current working directory */
if ((chdir("/")) < 0) {
/* Log the failure */
exit(EXIT_FAILURE);
}
/* Close out the standard file descriptors */
//close(STDIN_FILENO);
//close(STDOUT_FILENO);
//close(STDERR_FILENO);
}
/* open configuration file */
uci_ctx = ucix_init_path(config_path , config_file, 0 );
if (! uci_ctx ) {
syslog(LOG_ERR,"Failed to load config file \"%s/%s\"\n", config_path, config_file);
exit(1);
}
/* connect to ubus */
ubus_ctx = ubus_connect(ubus_socket);
if (!ubus_ctx) {
syslog(LOG_ERR,"Failed to connect to ubus. Can't continue.\n");
exit(EXIT_FAILURE);
}
/* connect ubus handler to ubox evenet loop */
if (uloop_init() != 0) {
syslog(LOG_ERR,"Could not init event loop, Can't continue.\n");
exit(EXIT_FAILURE);
}
ubus_add_uloop(ubus_ctx);
server_start(uci_ctx, ubus_ctx);
ubus_free(ubus_ctx);
DBG(1,"testing\n");
syslog(LOG_INFO, "%s exiting", PACKAGE);
uloop_done();
return 0;
}

View file

@ -0,0 +1,57 @@
#include "config.h"
#include <syslog.h>
#include "log.h"
#include "server.h"
#include "led.h"
#include "button.h"
#include "catv.h"
#include "sfp.h"
#include "touch_sx9512.h"
struct server_ctx server;
void sim_led_init(struct server_ctx *);
void sim_button_init(struct server_ctx *);
void gpio_led_init(struct server_ctx *);
void gpio_button_init(struct server_ctx *);
struct catv_handler *catv_h;
struct sfp_handler *sfp_h;
void server_start(struct uci_context *uci_ctx, struct ubus_context *ubus_ctx)
{
DBG(1, "init server context.");
server.uci_ctx = uci_ctx;
server.ubus_ctx = ubus_ctx;
DBG(1, "run init function for all hardware drivers.");
sim_led_init(&server);
sim_button_init(&server);
#ifdef HAVE_BOARD_H
gpio_led_init(&server);
gpio_button_init(&server);
sx9512_init(&server);
#endif
DBG(1, "connect generic buttons/leds to hardware drivers.");
led_init(&server);
button_init(&server);
sfp_h = sfp_init(uci_ctx);
if (sfp_h) {
sfp_ubus_populate(sfp_h, ubus_ctx);
}
catv_h = catv_init(uci_ctx, "/dev/i2c-0", 0x50, 0x51);
if (catv_h){
catv_ubus_populate(catv_h, ubus_ctx);
}
DBG(1, "give control to uloop main loop.");
uloop_run();
}

View file

@ -0,0 +1,13 @@
#ifndef SERVER_H
#define SERVER_H
#include <libubus.h>
#include "ucix.h"
struct server_ctx {
struct uci_context *uci_ctx;
struct ubus_context *ubus_ctx;
};
void server_start( struct uci_context *uci_ctx, struct ubus_context *ubus_ctx);
#endif /* SERVER_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,191 @@
#include <syslog.h>
#include <string.h>
#include "button.h"
#include "log.h"
#include "server.h"
void sim_button_init(struct server_ctx *s_ctx);
struct sim_data {
int addr;
int active;
int state;
struct button_drv button;
};
struct drv_button_list{
struct list_head list;
struct button_drv *drv;
};
static button_state_t sim_get_state(struct button_drv *drv)
{
// DBG(1, "state for %s", drv->name);
struct sim_data *p = (struct sim_data *)drv->priv;
return p->state;
}
static struct button_drv_func func = {
.get_state = sim_get_state,
};
static LIST_HEAD(sim_buttons);
enum {
SIM_NAME,
SIM_STATE,
__SIM_MAX
};
static const struct blobmsg_policy sim_policy[] = {
[SIM_NAME] = { .name = "name", .type = BLOBMSG_TYPE_STRING },
[SIM_STATE] = { .name = "state", .type = BLOBMSG_TYPE_STRING },
};
static struct button_drv *get_drv_button(char *name)
{
struct list_head *i;
list_for_each(i, &sim_buttons) {
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
if (! strcmp(node->drv->name, name))
return node->drv;
}
return NULL;
}
static int sim_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__SIM_MAX];
DBG(1, "");
blobmsg_parse(sim_policy, ARRAY_SIZE(sim_policy), tb, blob_data(msg), blob_len(msg));
if ( tb[SIM_NAME] ) {
if ( tb[SIM_STATE] ) {
struct button_drv *bt = get_drv_button((char *)blobmsg_data(tb[SIM_NAME]));
DBG(1," name = %s",(char *)blobmsg_data(tb[SIM_NAME]));
DBG(1," state = %s",(char *)blobmsg_data(tb[SIM_STATE]));
if (bt) {
struct sim_data *p = (struct sim_data *)bt->priv;
if(!strcasecmp("pressed", (char *)blobmsg_data(tb[SIM_STATE]))){
p->state = PRESSED;
}
if(!strcasecmp("released", (char *)blobmsg_data(tb[SIM_STATE]))){
p->state = RELEASED;
}
}else
DBG(1," button = %s not found",(char *)blobmsg_data(tb[SIM_NAME]));
}
}
return 0;
}
static int sim_status_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_buf blob;
struct list_head *i;
DBG(1, "");
memset(&blob,0,sizeof(struct blob_buf));
blob_buf_init(&blob, 0);
list_for_each(i, &sim_buttons) {
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
const char *state;
struct sim_data *p = (struct sim_data *)node->drv->priv;
if(p->state == RELEASED)
state = "Released";
else
state = "Pressed";
blobmsg_add_string(&blob, node->drv->name, state);
}
ubus_send_reply(ubus_ctx, req, blob.head);
return 0;
}
static const struct ubus_method sim_methods[] = {
UBUS_METHOD("set", sim_set_method, sim_policy),
{ .name = "status",
.handler = sim_status_method },
};
static struct ubus_object_type sim_object_type =
UBUS_OBJECT_TYPE("sim", sim_methods);
#define SIM_OBJECTS 1
static struct ubus_object sim_objects[SIM_OBJECTS] = {
{ .name = "button",
.type = &sim_object_type,
.methods = sim_methods,
.n_methods = ARRAY_SIZE(sim_methods),
},
};
void sim_button_init(struct server_ctx *s_ctx) {
int i,ret;
struct ucilist *node;
LIST_HEAD(buttons);
DBG(1, "");
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"sim_buttons", "buttons", &buttons);
list_for_each_entry(node, &buttons, list) {
struct sim_data *data;
const char *s;
DBG(1, "value = [%s]",node->val);
data = malloc(sizeof(struct sim_data));
memset(data,0,sizeof(struct sim_data));
data->button.name = node->val;
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
DBG(1, "addr = [%s]", s);
if (s){
data->addr = strtol(s,0,0);
}
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "active");
data->active = -1;
if (s){
if (!strncasecmp("hi",s,2))
data->active = 1;
else if (!strncasecmp("low",s,3))
data->active = 0;
}
DBG(1, "active = %d", data->active);
data->button.func = &func;
data->button.priv = data;
button_add(&data->button);
{ /* save button in internal list, we need this for ubus set/status */
struct drv_button_list *bt = malloc(sizeof(struct drv_button_list));
memset(bt, 0, sizeof(struct drv_button_list));
bt->drv = &data->button;
list_add(&bt->list, &sim_buttons);
}
}
for (i=0 ; i<SIM_OBJECTS ; i++) {
ret = ubus_add_object(s_ctx->ubus_ctx, &sim_objects[i]);
if (ret)
DBG(1,"Failed to add object: %s", ubus_strerror(ret));
}
}

View file

@ -0,0 +1,99 @@
#include <syslog.h>
#include <string.h>
#include "led.h"
#include "log.h"
#include "server.h"
void sim_led_init(struct server_ctx *s_ctx);
static int sim_set_state(struct led_drv *drv, led_state_t state)
{
DBG(1, "state %x on %s", state, drv->name);
return 0;
}
static led_state_t sim_get_state(struct led_drv *drv)
{
DBG(1, "state for %s", drv->name);
return 0;
}
static int sim_set_color(struct led_drv *drv, led_color_t color)
{
DBG(1, "color %d on %s", color, drv->name);
return 0;
}
static led_color_t sim_get_color(struct led_drv *drv)
{
DBG(1, "color for %s", drv->name);
return 0;
}
static struct led_drv_func func = {
.set_state = sim_set_state,
.get_state = sim_get_state,
.set_color = sim_set_color,
.get_color = sim_get_color,
};
struct sim_data {
int addr;
led_color_t color;
int state;
int breading;
struct led_drv led;
};
void sim_led_init(struct server_ctx *s_ctx) {
LIST_HEAD(leds);
struct ucilist *node;
DBG(1, "");
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"sim_leds", "leds", &leds);
list_for_each_entry(node,&leds,list){
struct sim_data *data;
const char *s;
DBG(1, "value = [%s]",node->val);
data = malloc(sizeof(struct sim_data));
memset(data,0,sizeof(struct sim_data));
data->led.name = node->val;
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
DBG(1, "addr = [%s]", s);
if (s){
data->addr = strtol(s,0,0);
}
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "color");
if (s){
if (!strncasecmp("red",s,3))
data->color = RED;
else if (!strncasecmp("green",s,5))
data->color = GREEN;
else if (!strncasecmp("blue",s,4))
data->color = BLUE;
else if (!strncasecmp("yellow",s,6))
data->color = YELLOW;
else if (!strncasecmp("white",s,5))
data->color = WHITE;
}
DBG(1, "color = [%s]=(%d)", s,data->color);
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "breading");
DBG(1, "breading = [%s]", s);
if (s){
if (!strncasecmp("yes",s,3))
data->breading = 1;
}
data->led.func = &func;
data->led.priv = data;
led_add(&data->led);
}
}

View file

@ -0,0 +1,653 @@
#include <syslog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <board.h>
#include "button.h"
#include "led.h"
#include "log.h"
#include "server.h"
#include "smbus.h"
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "ucix.h"
#include "i2c.h"
#include "touch_sx9512.h"
#include "gpio.h"
/* register names, from page 29, */
#define SX9512_IRQSRC 0
#define SX9512_TOUCHSTATUS 1
#define SX9512_PROXSTATUS 2
#define SX9512_LEDMAP1 0xC
#define SX9512_LEDMAP2 0xD
#define SX9512_IRQ_RESET 1<<7
#define SX9512_IRQ_TOUCH 1<<6
#define SX9512_IRQ_RELEASE 1<<5
#define SX9512_IRQ_NEAR 1<<4
#define SX9512_IRQ_FAR 1<<3
#define SX9512_IRQ_COM 1<<2
#define SX9512_IRQ_CONV 1<<1
/* CG300 config:
BL0: Proximity
BL1: Wireless button
BL2: WPS button, WPS LED
BL3: Dect button, Dect LED
BL4: Internet green LED
BL5: Internet red LED
BL6, BL7: Unused.
*/
struct i2c_reg_tab {
char addr;
char value;
char range; /* if set registers starting from addr to addr+range will be set to the same value */
};
struct i2c_touch{
int dev;
int shadow_irq;
int shadow_touch;
int shadow_proximity;
int addr;
int irq_button;
const struct i2c_reg_tab *init_tab;
int init_tab_len;
const char *name;
};
struct led_data {
int addr;
led_state_t state;
struct led_drv led;
};
struct sx9512_list{
struct list_head list;
struct led_data *drv;
};
/* holds all leds that is configured to be used. needed for reset */
static LIST_HEAD(sx9512_leds);
static struct i2c_touch *i2c_touch_current; /* pointer to current active table */
static void do_init_tab( struct i2c_touch *i2c_touch);
static struct i2c_touch * i2c_init(struct uci_context *uci_ctx, const char* i2c_dev_name, struct i2c_touch* i2c_touch_list, int len);
static int sx9512_led_set_state(struct led_drv *drv, led_state_t state);
static led_state_t sx9512_led_get_state(struct led_drv *drv);
static int sx9512_set_state(struct led_data *p, led_state_t state);
/*addr,value,range*/
static const struct i2c_reg_tab i2c_init_tab_cg300[]={
{0xFF, 0xDE, 0x00 }, /* Reset chip */
{0xFF, 0x00, 0x00 }, /* Reset chip */
{0x04, 0x00, 0x00 }, /* NVM Control */
{0x07, 0x00, 0x00 }, /* SPO2, set as interrupt */
{0x08, 0x00, 0x00 }, /* Power key ctrl */
{0x09, 0x78, 0x00 }, /* Irq MASK */
{0x0C, 0x01, 0x00 }, /* LED map 1, BL0 (why?) */
{0x0D, 0x3c, 0x00 }, /* LED map 2 BL2 -> BL5*/
{0x0E, 0x10, 0x00 }, /* LED Pwm Frq */
{0x0F, 0x00, 0x00 }, /* LED Mode */
{0x10, 0xFF, 0x00 }, /* Led Idle LED on */
{0x11, 0x00, 0x00 }, /* Led 1 off delay */
{0x12, 0xFF, 0x00 }, /* Led 1 on */
{0x13, 0x00, 0x00 }, /* Led 1 fade */
{0x14, 0xFF, 0x00 }, /* Led 2 on */
{0x15, 0x00, 0x00 }, /* Led 2 fade */
{0x16, 0xFF, 0x00 }, /* Led Pwr Idle */
{0x17, 0xFF, 0x00 }, /* Led Pwr On */
{0x18, 0x00, 0x00 }, /* Led Pwr Off */
{0x19, 0x00, 0x00 }, /* Led Pwr fade */
{0x1A, 0x00, 0x00 }, /* Led Pwr On Pw */
{0x1B, 0x00, 0x00 }, /* Disable BL7 as power button */
{0x1E, 0x0F, 0x00 }, /* Cap sens enabled, bl0-bl3 */
{0x1F, 0x43, 0x00 }, /* Cap sens BL0 */
{0x20, 0x41, 0x07 }, /* Cap sens range 20-27 BL1->BL7 */
{0x28, 0x02, 0x00 }, /* Cap sens thresh BL 0 */
{0x29, 0x04, 0x07 }, /* Cap sens thresh 28-30 */
{0x31, 0x54, 0x00 }, /* Cap sens Op */
{0x32, 0x70, 0x00 }, /* Cap Sens Mode, filter 1-1/8, report all */
{0x33, 0x01, 0x00 }, /* Cap Sens Debounce */
{0x34, 0x80, 0x00 }, /* Cap Sens Neg Comp Thresh */
{0x35, 0x80, 0x00 }, /* Cap Sens Pos Comp Thresh */
{0x36, 0x17, 0x00 }, /* Cap Sens Pos Filt, hyst 2, debounce 4, 1-1/128 */
{0x37, 0x15, 0x00 }, /* Cap Sens Neg Filt, hyst 2, debounce 4, 1-1/32 */
{0x38, 0x00, 0x00 }, /* Cap Sens */
{0x39, 0x00, 0x00 }, /* Cap Sens Frame Skip */
{0x3A, 0x00, 0x00 }, /* Cap Sens Misc */
{0x3B, 0x00, 0x00 }, /* Prox Comb Chan Mask */
{0x3E, 0xFF, 0x00 }, /* SPO Chan Map */
{0x00, 0x04, 0x00 }, /* Trigger compensation */
};
/* CG301 config:
BL0: Proximity, Status white LED
BL1: Service button, Service white LED
BL2: Service red LED
BL3: Pair button, Pair white LED
BL4: Cancel button, Cancel red LED
BL5: Communication button, Communication white LED
BL6: Communication red LED
BL7: Unused.
*/
static const struct i2c_reg_tab i2c_init_tab_cg301[]={
{0xFF, 0xDE, 0x00 }, /* Reset chip */
{0xFF, 0x00, 0x00 }, /* Reset chip */
{0x04, 0x00, 0x00 }, /* NVM Control */
{0x07, 0x00, 0x00 }, /* SPO2, set as interrupt */
{0x08, 0x00, 0x00 }, /* Power key ctrl */
{0x09, 0x78, 0x00 }, /* Irq MASK, touch+release+near+far */
{0x0C, 0x00, 0x00 }, /* LED map 1, none */
{0x0D, 0x7f, 0x00 }, /* LED map 2, BL0 -> BL6 */
{0x0E, 0x10, 0x00 }, /* LED Pwm Frq */
{0x0F, 0x00, 0x00 }, /* LED Mode */
{0x10, 0xFF, 0x00 }, /* Led Idle LED on */
{0x11, 0x00, 0x00 }, /* Led 1 off delay */
{0x12, 0xFF, 0x00 }, /* Led 1 on */
{0x13, 0x00, 0x00 }, /* Led 1 fade */
{0x14, 0xFF, 0x00 }, /* Led 2 on */
{0x15, 0x00, 0x00 }, /* Led 2 fade */
{0x16, 0xFF, 0x00 }, /* Led Pwr Idle */
{0x17, 0xFF, 0x00 }, /* Led Pwr On */
{0x18, 0x00, 0x00 }, /* Led Pwr Off */
{0x19, 0x00, 0x00 }, /* Led Pwr fade */
{0x1A, 0x00, 0x00 }, /* Led Pwr On Pw */
{0x1B, 0x00, 0x00 }, /* Disable BL7 as power button */
{0x1E, 0x3b, 0x00 }, /* Cap sens enabled, bl0,bl1,bl3-bl5 */
{0x1F, 0x43, 0x00 }, /* Cap sens range BL0 */
{0x20, 0x41, 0x07 }, /* Cap sens range BL1->BL7 [20-27] */
{0x28, 0x02, 0x00 }, /* Cap sens thresh BL0 */
{0x29, 0x04, 0x07 }, /* Cap sens thresh BL1->BL7 [29-30] */
{0x31, 0x54, 0x00 }, /* Cap sens Op */
{0x32, 0x70, 0x00 }, /* Cap Sens Mode, filter 1-1/8, report all */
{0x33, 0x01, 0x00 }, /* Cap Sens Debounce */
{0x34, 0x80, 0x00 }, /* Cap Sens Neg Comp Thresh */
{0x35, 0x80, 0x00 }, /* Cap Sens Pos Comp Thresh */
{0x36, 0x17, 0x00 }, /* Cap Sens Pos Filt, hyst 2, debounce 4, 1-1/128 */
{0x37, 0x15, 0x00 }, /* Cap Sens Neg Filt, hyst 2, debounce 4, 1-1/32 */
{0x38, 0x00, 0x00 }, /* Cap Sens */
{0x39, 0x00, 0x00 }, /* Cap Sens Frame Skip */
{0x3A, 0x00, 0x00 }, /* Cap Sens Misc */
{0x3B, 0x00, 0x00 }, /* Prox Comb Chan Mask */
{0x3E, 0xFF, 0x00 }, /* SPO Chan Map */
{0x00, 0x04, 0x00 }, /* Trigger compensation */
};
/* EG300 config:
BL0: Proximity, WAN green LED
BL1: Wireless button, WAN yellow LED
BL2: WPS button, WPS LED
BL3: Dect button, Dect LED
BL4: Internet green LED
BL5: Internet red LED
BL6: Ethernet LED
BL7: Voice LED
Only the led 1 and led2 maps differ from CG300.
*/
static const struct i2c_reg_tab i2c_init_tab_eg300[]={
{0xFF, 0xDE, 0x00 }, /* Reset chip */
{0xFF, 0x00, 0x00 }, /* Reset chip */
{0x04, 0x00, 0x00 }, /* NVM Control */
{0x07, 0x00, 0x00 }, /* SPO2, set as interrupt */
{0x08, 0x00, 0x00 }, /* Power key ctrl */
{0x09, 0x78, 0x00 }, /* Irq MASK */
{0x0C, 0x00, 0x00 }, /* LED map 1, none */
{0x0D, 0xff, 0x00 }, /* LED map 2, all */
{0x0E, 0x10, 0x00 }, /* LED Pwm Frq */
{0x0F, 0x00, 0x00 }, /* LED Mode */
{0x10, 0xFF, 0x00 }, /* Led Idle LED on */
{0x11, 0x00, 0x00 }, /* Led 1 off delay */
{0x12, 0xFF, 0x00 }, /* Led 1 on */
{0x13, 0x00, 0x00 }, /* Led 1 fade */
{0x14, 0xFF, 0x00 }, /* Led 2 on */
{0x15, 0x00, 0x00 }, /* Led 2 fade */
{0x16, 0xFF, 0x00 }, /* Led Pwr Idle */
{0x17, 0xFF, 0x00 }, /* Led Pwr On */
{0x18, 0x00, 0x00 }, /* Led Pwr Off */
{0x19, 0x00, 0x00 }, /* Led Pwr fade */
{0x1A, 0x00, 0x00 }, /* Led Pwr On Pw */
{0x1B, 0x00, 0x00 }, /* Disable BL7 as power button */
{0x1E, 0x0F, 0x00 }, /* Cap sens enabled, bl0-bl3 */
{0x1F, 0x43, 0x00 }, /* Cap sens BL0 */
{0x20, 0x43, 0x07 }, /* Cap sens range 20-27 BL1->BL7 */
{0x28, 0x02, 0x00 }, /* Cap sens thresh BL 0 */
{0x29, 0x04, 0x07 }, /* Cap sens thresh 28-30 */
{0x31, 0x54, 0x00 }, /* Cap sens Op */
{0x32, 0x70, 0x00 }, /* Cap Sens Mode, filter 1-1/8, report all */
{0x33, 0x01, 0x00 }, /* Cap Sens Debounce */
{0x34, 0x80, 0x00 }, /* Cap Sens Neg Comp Thresh */
{0x35, 0x80, 0x00 }, /* Cap Sens Pos Comp Thresh */
{0x36, 0x17, 0x00 }, /* Cap Sens Pos Filt, hyst 2, debounce 4, 1-1/128 */
{0x37, 0x15, 0x00 }, /* Cap Sens Neg Filt, hyst 2, debounce 4, 1-1/32 */
{0x38, 0x00, 0x00 }, /* Cap Sens */
{0x39, 0x00, 0x00 }, /* Cap Sens Frame Skip */
{0x3A, 0x00, 0x00 }, /* Cap Sens Misc */
{0x3B, 0x00, 0x00 }, /* Prox Comb Chan Mask */
{0x3E, 0xFF, 0x00 }, /* SPO Chan Map */
{0x00, 0x04, 0x00 }, /* Trigger compensation */
};
static struct i2c_touch i2c_touch_list[] = {
{.addr = 0x2b,
.name = "CG300",
.irq_button = 1,
.init_tab = i2c_init_tab_cg300,
.init_tab_len = sizeof(i2c_init_tab_cg300)/sizeof(struct i2c_reg_tab),
},
{.addr = 0x2b,
.name = "CG301",
.irq_button = 1,
.init_tab = i2c_init_tab_cg301,
.init_tab_len = sizeof(i2c_init_tab_cg301)/sizeof(struct i2c_reg_tab),
},
{.addr = 0x2b,
.name = "EG300",
.irq_button = 1,
.init_tab = i2c_init_tab_eg300,
.init_tab_len = sizeof(i2c_init_tab_eg300)/sizeof(struct i2c_reg_tab),
}
};
static void do_init_tab( struct i2c_touch *i2c_touch)
{
const struct i2c_reg_tab *tab;
int i;
tab = i2c_touch->init_tab;
for (i = 0 ; i < i2c_touch->init_tab_len ; i++){
int y;
int ret;
for ( y = 0 ; y <= tab[i].range; y++ ){
DBG(3,"%s: addr %02X = %02X ",__func__,(unsigned char)tab[i].addr+y, (unsigned char)tab[i].value);
ret = i2c_smbus_write_byte_data(i2c_touch->dev, tab[i].addr+y, tab[i].value);
if (ret < 0){
perror("write to i2c dev\n");
}
}
}
// dump_i2c(i2c_touch->dev,0,13);
}
static struct i2c_touch * i2c_init(struct uci_context *uci_ctx, const char* i2c_dev_name, struct i2c_touch* touch_list, int len)
{
const char *p;
int i;
struct i2c_touch *i2c_touch;
p = ucix_get_option(uci_ctx, "hw", "board", "hardware");
if (p == 0){
syslog(LOG_INFO, "%s: Missing Hardware identifier in configuration. I2C is not started\n",__func__);
return 0;
}
/* Here we match the hardware name to a init table, and get the
i2c chip address */
i2c_touch = NULL;
for (i = 0; i < len; i++) {
if (!strcmp(touch_list[i].name, p)) {
DBG(1,"I2C hardware platform %s found.\n", p);
i2c_touch = &touch_list[i];
break;
}
}
if (!i2c_touch) {
DBG(1,"No I2C hardware found: %s.\n", p);
return 0;
}
i2c_touch->dev = i2c_open_dev(i2c_dev_name, i2c_touch->addr,
I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE);
if (i2c_touch->dev < 0) {
syslog(LOG_INFO,"%s: could not open i2c touch device\n",__func__);
i2c_touch->dev = 0;
return 0;
}
DBG(1,"Opened device and selected address %x \n", i2c_touch->addr);
do_init_tab(i2c_touch);
return i2c_touch;
}
extern struct uloop_timeout i2c_touch_reset_timer;
/* sx9512 needs a reset every 30 minutes. to recalibrate the touch detection */
#define I2C_RESET_TIME (1000 * 60 * 30) /* 30 min in ms */
static void sx9512_reset_handler(struct uloop_timeout *timeout);
struct uloop_timeout i2c_touch_reset_timer = { .cb = sx9512_reset_handler };
static void sx9512_reset_handler(struct uloop_timeout *timeout)
{
struct list_head *i;
do_init_tab(i2c_touch_current);
list_for_each(i, &sx9512_leds) {
struct sx9512_list *node = list_entry(i, struct sx9512_list, list);
sx9512_set_state(node->drv, node->drv->state);
}
uloop_timeout_set(&i2c_touch_reset_timer, I2C_RESET_TIME);
}
/* set state regardless of previous state */
static int sx9512_set_state(struct led_data *p, led_state_t state)
{
int ret;
int bit = 1 << p->addr;
ret = i2c_smbus_read_byte_data(i2c_touch_current->dev, SX9512_LEDMAP2);
if (ret < 0 )
syslog(LOG_ERR, "Could not read from i2c device, LedMap2 register\n");
if (state == ON)
ret = ret | bit;
else if (state == OFF)
ret = ret & ~bit;
else{
syslog(LOG_ERR,"%s: Led %s: Set to not supported state %d\n",__func__, p->led.name, state);
return -1;
}
p->state = state;
ret = i2c_smbus_write_byte_data(i2c_touch_current->dev, SX9512_LEDMAP2, ret);
if (ret < 0 ) {
syslog(LOG_ERR, "Could not write to i2c device, LedMap2 register\n");
return -1;
}
return state;
}
/* set state if not same as current state */
static int sx9512_led_set_state(struct led_drv *drv, led_state_t state)
{
struct led_data *p = (struct led_data *)drv->priv;
if (!i2c_touch_current || !i2c_touch_current->dev)
return -1;
if (p->addr > 7){
DBG(1,"Led %s:with address %d outside range 0-7\n",drv->name, p->addr);
return -1;
}
if (state == p->state ) {
DBG(3,"skipping set");
return state;
}
return sx9512_set_state(p, state);
}
static led_state_t sx9512_led_get_state(struct led_drv *drv)
{
struct led_data *p = (struct led_data *)drv->priv;
DBG(1, "state for %s", drv->name);
return p->state;
}
static struct led_drv_func led_func = {
.set_state = sx9512_led_set_state,
.get_state = sx9512_led_get_state,
};
struct button_data {
int addr;
int state;
struct button_drv button;
};
void sx9512_check(void)
{
// DBG(1, "state for %s", drv->name);
int got_irq = 0;
int ret;
if (!i2c_touch_current || !i2c_touch_current->dev)
return;
if (i2c_touch_current->irq_button) {
int button;
button = board_ioctl( BOARD_IOCTL_GET_GPIO, 0, 0, NULL, i2c_touch_current->irq_button, 0);
if (button == 0)
got_irq = 1;
}
if ( got_irq ) {
ret = i2c_smbus_read_byte_data(i2c_touch_current->dev, SX9512_IRQSRC);
if (ret < 0 )
syslog(LOG_ERR, "Could not read from i2c device, irq status register\n");
i2c_touch_current->shadow_irq = ret;
ret = i2c_smbus_read_byte_data(i2c_touch_current->dev, SX9512_TOUCHSTATUS);
if (ret < 0 )
syslog(LOG_ERR, "Could not read from i2c device, touch register\n");
i2c_touch_current->shadow_touch = ret;
ret = i2c_smbus_read_byte_data(i2c_touch_current->dev, SX9512_PROXSTATUS);
if (ret < 0 )
syslog(LOG_ERR, "Could not read from i2c device, proximity register\n");
i2c_touch_current->shadow_proximity = ret;
}
#if 0
DEBUG_PRINT("%02x %02x %02x: irq ->",
i2c_touch->shadow_irq ,
i2c_touch->shadow_touch,
i2c_touch->shadow_proximity);
if (i2c_touch->shadow_irq & SX9512_IRQ_RESET )
DEBUG_PRINT_RAW(" Reset ");
if (i2c_touch->shadow_irq & SX9512_IRQ_TOUCH )
DEBUG_PRINT_RAW(" Touch ");
if (i2c_touch->shadow_irq & SX9512_IRQ_RELEASE )
DEBUG_PRINT_RAW(" Release ");
if (i2c_touch->shadow_irq & SX9512_IRQ_NEAR )
DEBUG_PRINT_RAW(" Near ");
if (i2c_touch->shadow_irq & SX9512_IRQ_FAR )
DEBUG_PRINT_RAW(" Far ");
if (i2c_touch->shadow_irq & SX9512_IRQ_COM )
DEBUG_PRINT_RAW(" Com ");
if (i2c_touch->shadow_irq & SX9512_IRQ_CONV )
DEBUG_PRINT_RAW(" Conv ");
DEBUG_PRINT_RAW("\n");
#endif
return ;
}
/*
button address 0- 7 maps to touch event 0-7
button address 8 proximity BL0 NEAR
button address 9 proximity BL0 FAR
return RELEASED = no action on this button
return PRESSED = button pressed
return -1 = error
*/
static button_state_t sx9512_button_get_state(struct button_drv *drv)
{
struct button_data *p = (struct button_data *)drv->priv;
int bit = 1 << p->addr;
if (!i2c_touch_current || !i2c_touch_current->dev)
return -1;
if (p->addr < 8) {
if ( bit & i2c_touch_current->shadow_touch ) {
i2c_touch_current->shadow_touch = i2c_touch_current->shadow_touch & ~bit;
p->state = PRESSED;
return PRESSED;
}
/* if the button was already pressed and we don't have a release irq report it as still pressed */
if( p->state == PRESSED){
if (! (i2c_touch_current->shadow_irq & SX9512_IRQ_RELEASE) ) {
return PRESSED;
}
}
p->state = RELEASED;
return RELEASED;
/* proximity NEAR */
}else if (p->addr == 8 ) {
bit = 1<<7;
if( i2c_touch_current->shadow_irq & SX9512_IRQ_NEAR ) {
i2c_touch_current->shadow_irq &= ~SX9512_IRQ_NEAR;
if ( bit & i2c_touch_current->shadow_proximity ) {
i2c_touch_current->shadow_proximity = i2c_touch_current->shadow_proximity & ~bit;
p->state = PRESSED;
return PRESSED;
}
}
return RELEASED;
/* proximity FAR */
}else if (p->addr == 9) {
if( i2c_touch_current->shadow_irq & SX9512_IRQ_FAR ) {
i2c_touch_current->shadow_irq &= ~SX9512_IRQ_FAR;
p->state = PRESSED;
return PRESSED;
}
return RELEASED;
}else {
DBG(1,"Button address out of range %d\n",p->addr);
return RELEASED;
}
}
static struct button_drv_func button_func = {
.get_state = sx9512_button_get_state,
};
static void sx9512_button_init(struct server_ctx *s_ctx)
{
struct ucilist *node;
LIST_HEAD(buttons);
DBG(1, "");
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"9512_buttons", "buttons", &buttons);
list_for_each_entry(node, &buttons, list) {
struct button_data *data;
const char *s;
DBG(1, "value = [%s]",node->val);
data = malloc(sizeof(struct button_data));
memset(data,0,sizeof(struct button_data));
data->button.name = node->val;
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
DBG(1, "addr = [%s]", s);
if (s){
data->addr = strtol(s,0,0);
}
data->button.func = &button_func;
data->button.priv = data;
button_add(&data->button);
}
}
static void sx9512_led_init(struct server_ctx *s_ctx) {
LIST_HEAD(leds);
struct ucilist *node;
DBG(1, "");
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"9512_leds", "leds", &leds);
list_for_each_entry(node,&leds,list){
struct led_data *data;
const char *s;
DBG(1, "value = [%s]",node->val);
data = malloc(sizeof(struct led_data));
memset(data,0,sizeof(struct led_data));
data->led.name = node->val;
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
DBG(1, "addr = [%s]", s);
if (s) {
data->addr = strtol(s,0,0);
}
data->led.func = &led_func;
data->led.priv = data;
led_add(&data->led);
{ /* save leds in internal list, we need this for handling reset, we need to restore state */
struct sx9512_list *ll = malloc(sizeof(struct sx9512_list));
memset(ll, 0, sizeof( struct sx9512_list));
ll->drv = data;
list_add(&ll->list, &sx9512_leds);
}
}
}
void sx9512_init(struct server_ctx *s_ctx) {
struct list_head *i;
DBG(1, "");
i2c_touch_current = i2c_init(s_ctx->uci_ctx,
"/dev/i2c-0",
i2c_touch_list,
sizeof(i2c_touch_list)/sizeof(i2c_touch_list[0]));
if (i2c_touch_current != 0) {
sx9512_button_init(s_ctx);
sx9512_led_init(s_ctx);
/* Force set of initial state for leds. */
list_for_each(i, &sx9512_leds) {
struct sx9512_list *node = list_entry(i, struct sx9512_list, list);
sx9512_set_state(node->drv, node->drv->state);
}
/* start reset timer */
uloop_timeout_set(&i2c_touch_reset_timer, I2C_RESET_TIME);
}
}

View file

@ -0,0 +1,9 @@
#ifndef TOUCH_SX9512_H
#define TOUCH_SX9512_H
#include "server.h"
void sx9512_init(struct server_ctx *);
void sx9512_check(void);
#endif /* TOUCH_SX9512_H */

View file

@ -0,0 +1,176 @@
/*
* ucix
* Copyright (C) 2010 John Crispin <blogic@openwrt.org>
* Copyright (C) 2010 Steven Barth <steven@midlink.org>
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <string.h>
#include <stdlib.h>
#include "ucix.h"
struct uci_ptr uci_ptr;
int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
{
memset(&uci_ptr, 0, sizeof(uci_ptr));
uci_ptr.package = p;
uci_ptr.section = s;
uci_ptr.option = o;
uci_ptr.value = t;
return uci_lookup_ptr(ctx, &uci_ptr, NULL, true);
}
struct uci_context* ucix_init(const char *config_file, int state)
{
struct uci_context *ctx = uci_alloc_context();
uci_set_confdir(ctx, "/etc/config");
if(state)
uci_set_savedir(ctx, "/var/state/");
else
uci_set_savedir(ctx, "/tmp/.uci/");
if(uci_load(ctx, config_file, NULL) != UCI_OK)
{
printf("%s/%s is missing or corrupt\n", ctx->confdir, config_file);
return NULL;
}
return ctx;
}
struct uci_context* ucix_init_path(const char *vpath, const char *config_file, int state)
{
struct uci_context *ctx;
char buf[256];
if(!vpath)
return ucix_init(config_file, state);
ctx = uci_alloc_context();
buf[255] = '\0';
snprintf(buf, 255, "%s", vpath);
uci_set_confdir(ctx, buf);
// snprintf(buf, 255, "%s%s", vpath, (state)?("/var/state"):("/tmp/.uci"));
// uci_add_delta_path(ctx, buf);
if(uci_load(ctx, config_file, NULL) != UCI_OK)
{
printf("%s/%s is missing or corrupt\n", ctx->confdir, config_file);
return NULL;
}
return ctx;
}
int ucix_get_option_list(struct uci_context *ctx, const char *p,
const char *s, const char *o, struct list_head *l)
{
struct uci_element *e = NULL;
if(ucix_get_ptr(ctx, p, s, o, NULL))
return 1;
if (!(uci_ptr.flags & UCI_LOOKUP_COMPLETE))
return 1;
e = uci_ptr.last;
switch (e->type)
{
case UCI_TYPE_OPTION:
switch(uci_ptr.o->type) {
case UCI_TYPE_LIST:
uci_foreach_element(&uci_ptr.o->v.list, e)
{
struct ucilist *ul = malloc(sizeof(struct ucilist));
ul->val = strdup((e->name)?(e->name):(""));
list_add_tail(&ul->list, l);
}
break;
default:
break;
}
break;
default:
return 1;
}
return 0;
}
char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
{
struct uci_element *e = NULL;
const char *value = NULL;
if(ucix_get_ptr(ctx, p, s, o, NULL))
return NULL;
if (!(uci_ptr.flags & UCI_LOOKUP_COMPLETE))
return NULL;
e = uci_ptr.last;
switch (e->type)
{
case UCI_TYPE_SECTION:
value = uci_to_section(e)->type;
break;
case UCI_TYPE_OPTION:
switch(uci_ptr.o->type) {
case UCI_TYPE_STRING:
value = uci_ptr.o->v.string;
break;
default:
value = NULL;
break;
}
break;
default:
return 0;
}
return (value) ? (strdup(value)):(NULL);
}
void ucix_add_list(struct uci_context *ctx, const char *p, const char *s, const char *o, struct list_head *vals)
{
struct list_head *q;
list_for_each(q, vals)
{
struct ucilist *ul = container_of(q, struct ucilist, list);
if(ucix_get_ptr(ctx, p, s, o, (ul->val)?(ul->val):("")))
return;
uci_add_list(ctx, &uci_ptr);
}
}
void ucix_for_each_section_type(struct uci_context *ctx,
const char *p, const char *t,
void (*cb)(const char*, void*), void *priv)
{
struct uci_element *e;
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
return;
uci_foreach_element(&uci_ptr.p->sections, e)
if (!strcmp(t, uci_to_section(e)->type))
cb(e->name, priv);
}
void ucix_for_each_section_option(struct uci_context *ctx,
const char *p, const char *s,
void (*cb)(const char*, const char*, void*), void *priv)
{
struct uci_element *e;
if(ucix_get_ptr(ctx, p, s, NULL, NULL))
return;
uci_foreach_element(&uci_ptr.s->options, e)
{
struct uci_option *o = uci_to_option(e);
cb(o->e.name, o->v.string, priv);
}
}

View file

@ -0,0 +1,140 @@
/*
* ucix
* Copyright (C) 2010 John Crispin <blogic@openwrt.org>
* Copyright (C) 2010 Steven Barth <steven@midlink.org>
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _UCI_H__
#define _UCI_H__
#include <uci.h>
#include <libubox/list.h>
#include <stdlib.h>
#ifndef uci_to_delta
// Support older version of uci, where this function was named
// differently
#define uci_add_delta_path uci_add_history_path
#endif
struct ucilist {
struct list_head list;
char *val;
};
extern struct uci_ptr uci_ptr;
int ucix_get_ptr(struct uci_context *ctx, const char *p,
const char *s, const char *o, const char *t);
struct uci_context* ucix_init(const char *config_file, int state);
struct uci_context* ucix_init_path(const char *vpath, const char *config_file, int state);
int ucix_save_state(struct uci_context *ctx, const char *p);
char* ucix_get_option(struct uci_context *ctx,
const char *p, const char *s, const char *o);
int ucix_get_option_list(struct uci_context *ctx, const char *p,
const char *s, const char *o, struct list_head *l);
void ucix_for_each_section_type(struct uci_context *ctx,
const char *p, const char *t,
void (*cb)(const char*, void*), void *priv);
void ucix_for_each_section_option(struct uci_context *ctx,
const char *p, const char *s,
void (*cb)(const char*, const char*, void*), void *priv);
void ucix_add_list(struct uci_context *ctx, const char *p,
const char *s, const char *o, struct list_head *vals);
static inline void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o)
{
if (!ucix_get_ptr(ctx, p, s, o, NULL))
uci_delete(ctx, &uci_ptr);
}
static inline void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o)
{
if (!ucix_get_ptr(ctx, p, s, o, NULL))
uci_revert(ctx, &uci_ptr);
}
static inline void ucix_add_list_single(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
{
if (ucix_get_ptr(ctx, p, s, o, t))
return;
uci_add_list(ctx, &uci_ptr);
}
static inline void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
{
if (ucix_get_ptr(ctx, p, s, o, t))
return;
uci_set(ctx, &uci_ptr);
}
static inline void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t)
{
if(ucix_get_ptr(ctx, p, s, NULL, t))
return;
uci_set(ctx, &uci_ptr);
}
static inline void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
{
char tmp[64];
snprintf(tmp, 64, "%d", t);
ucix_add_option(ctx, p, s, o, tmp);
}
static inline void ucix_add_list_single_int(struct uci_context *ctx, const char *p, const char *s, const char *o, const int t)
{
char tmp[64];
snprintf(tmp, 64, "%d", t);
ucix_add_list_single(ctx, p, s, o, tmp);
}
static inline int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def)
{
char *tmp = ucix_get_option(ctx, p, s, o);
int ret = def;
if (tmp)
{
ret = atoi(tmp);
free(tmp);
}
return ret;
}
static inline int ucix_save(struct uci_context *ctx, const char *p)
{
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
return 1;
uci_save(ctx, uci_ptr.p);
return 0;
}
static inline int ucix_commit(struct uci_context *ctx, const char *p)
{
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
return 1;
return uci_commit(ctx, &uci_ptr.p, false);
}
static inline void ucix_cleanup(struct uci_context *ctx)
{
uci_free_context(ctx);
}
#endif

View file

@ -2,20 +2,14 @@
START=14
USE_PROCD=1
NAME=questd
PROG=/sbin/questd
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
start_service() {
procd_open_instance
procd_set_param command "$PROG"
procd_close_instance
start() {
service_start /sbin/questd
}
stop() {
service_stop /sbin/questd
}
reload() {
service_reload /sbin/questd
}

View file

@ -2,8 +2,8 @@ CC = gcc
CFLAGS = -g -Wall
LOCLIBS =
LIBS = -luci -lubus -lubox -lpthread
OBJS = questd.o dumper.o port.o arping.o usb.o ndisc.o dslstats.o
SRCS = questd.c dumper.c port.c arping.c usb.c ndisc.c dslstats.c
OBJS = questd.o dumper.o port.o arping.o usb.o ndisc.o
SRCS = questd.c dumper.c port.c arping.c usb.c ndisc.c
LIBSRCS =
ISRCS = questd.h

View file

@ -1,3 +1,22 @@
/*
* arping -- arping tool for questd
*
* Author: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
* Author: Sukru Senli sukru.senli@inteno.se
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
@ -149,9 +168,7 @@ arping(char *targetIP, char *device)
cc = recvfrom(sock_fd, packet, sizeof(packet), 0, (struct sockaddr *) &from, &alen);
}
if (cc < 0)
perror("recvfrom");
else
if (cc >= 0)
connected = recv_pack(packet, cc, &from);
close(sock_fd);

507
questd/src/ndisc.c Normal file
View file

@ -0,0 +1,507 @@
/*
* ndisc.c - ICMPv6 neighbour discovery command line tool
*
* Author: Rémi Denis-Courmont
* questd port: Sukru Senli sukru.senli@inteno.se
*
* Copyright © 2004-2007 Rémi Denis-Courmont.
* This program is free software: you can redistribute and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, versions 2 of the license.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h> /* div() */
#include <inttypes.h> /* uint8_t */
#include <limits.h> /* UINT_MAX */
#include <locale.h>
#include <stdbool.h>
#include <errno.h> /* EMFILE */
#include <sys/types.h>
#include <unistd.h> /* close() */
#include <time.h> /* clock_gettime() */
#include <poll.h> /* poll() */
#include <sys/socket.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/times.h> /* times() fallback */
#include <netdb.h> /* getaddrinfo() */
#include <arpa/inet.h> /* inet_ntop() */
#include <net/if.h> /* if_nametoindex() */
#include <netinet/in.h>
#include <netinet/icmp6.h>
#ifndef IPV6_RECVHOPLIMIT
/* Using obsolete RFC 2292 instead of RFC 3542 */
# define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT
#endif
#ifndef AI_IDN
# define AI_IDN 0
#endif
enum ndisc_flags
{
NDISC_VERBOSE1=0x1,
NDISC_VERBOSE2=0x2,
NDISC_VERBOSE3=0x3,
NDISC_VERBOSE =0x3,
NDISC_NUMERIC =0x4,
NDISC_SINGLE =0x8,
};
#if defined (CLOCK_HIGHRES) && !defined (CLOCK_MONOTONIC)
# define CLOCK_MONOTONIC CLOCK_HIGHRES
#endif
static inline void
mono_gettime (struct timespec *ts)
{
#ifdef CLOCK_MONOTONIC
if (clock_gettime (CLOCK_MONOTONIC, ts))
#endif
{
static long freq = 0;
if (freq == 0)
freq = sysconf (_SC_CLK_TCK);
struct tms dummy;
clock_t t = times (&dummy);
ts->tv_sec = t / freq;
ts->tv_nsec = (t % freq) * (1000000000 / freq);
}
}
static int
getipv6byname (const char *name, const char *ifname, int numeric, struct sockaddr_in6 *addr)
{
struct addrinfo hints, *res;
memset (&hints, 0, sizeof (hints));
hints.ai_family = PF_INET6;
hints.ai_socktype = SOCK_DGRAM; /* dummy */
hints.ai_flags = numeric ? AI_NUMERICHOST : 0;
int val = getaddrinfo (name, NULL, &hints, &res);
if (val)
{
fprintf (stderr, "%s: %s\n", name, gai_strerror (val));
return -1;
}
memcpy (addr, res->ai_addr, sizeof (struct sockaddr_in6));
freeaddrinfo (res);
val = if_nametoindex (ifname);
if (val == 0)
{
perror (ifname);
return -1;
}
addr->sin6_scope_id = val;
return 0;
}
static inline int
sethoplimit (int fd, int value)
{
return (setsockopt (fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
&value, sizeof (value))
|| setsockopt (fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
&value, sizeof (value))) ? -1 : 0;
}
static char MACADDR[24];
void
clear_macaddr() {
memset(MACADDR, '\0', sizeof(MACADDR));
}
char *
get_macaddr()
{
return MACADDR;
}
static void
printmacaddress (const uint8_t *ptr, size_t len)
{
char mac[4];
while (len > 1)
{
sprintf(mac, "%02X:", *ptr);
strcat(MACADDR, mac);
ptr++;
len--;
}
if (len == 1) {
sprintf(mac, "%02X", *ptr);
strcat(MACADDR, mac);
}
}
# ifdef __linux__
# include <sys/ioctl.h>
# endif
static int
getmacaddress (const char *ifname, uint8_t *addr)
{
# ifdef SIOCGIFHWADDR
struct ifreq req;
memset (&req, 0, sizeof (req));
if (((unsigned)strlen (ifname)) >= (unsigned)IFNAMSIZ)
return -1; /* buffer overflow = local root */
strcpy (req.ifr_name, ifname);
int fd = socket (AF_INET6, SOCK_DGRAM, 0);
if (fd == -1)
return -1;
if (ioctl (fd, SIOCGIFHWADDR, &req))
{
perror (ifname);
close (fd);
return -1;
}
close (fd);
memcpy (addr, req.ifr_hwaddr.sa_data, 6);
return 0;
# else
(void)ifname;
(void)addr;
return -1;
# endif
}
static const uint8_t nd_type_advert = ND_NEIGHBOR_ADVERT;
static const unsigned nd_delay_ms = 1000;
static const unsigned ndisc_default = NDISC_VERBOSE1 | NDISC_SINGLE;
typedef struct
{
struct nd_neighbor_solicit hdr;
struct nd_opt_hdr opt;
uint8_t hw_addr[6];
} solicit_packet;
static ssize_t
buildsol (solicit_packet *ns, struct sockaddr_in6 *tgt, const char *ifname)
{
/* builds ICMPv6 Neighbor Solicitation packet */
ns->hdr.nd_ns_type = ND_NEIGHBOR_SOLICIT;
ns->hdr.nd_ns_code = 0;
ns->hdr.nd_ns_cksum = 0; /* computed by the kernel */
ns->hdr.nd_ns_reserved = 0;
memcpy (&ns->hdr.nd_ns_target, &tgt->sin6_addr, 16);
/* determines actual multicast destination address */
memcpy (tgt->sin6_addr.s6_addr, "\xff\x02\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x01\xff", 13);
/* gets our own interface's link-layer address (MAC) */
if (getmacaddress (ifname, ns->hw_addr))
return sizeof (ns->hdr);
ns->opt.nd_opt_type = ND_OPT_SOURCE_LINKADDR;
ns->opt.nd_opt_len = 1; /* 8 bytes */
return sizeof (*ns);
}
static int
parseadv (const uint8_t *buf, size_t len, const struct sockaddr_in6 *tgt, bool verbose)
{
const struct nd_neighbor_advert *na =
(const struct nd_neighbor_advert *)buf;
const uint8_t *ptr;
/* checks if the packet is a Neighbor Advertisement, and
* if the target IPv6 address is the right one */
if ((len < sizeof (struct nd_neighbor_advert))
|| (na->nd_na_type != ND_NEIGHBOR_ADVERT)
|| (na->nd_na_code != 0)
|| memcmp (&na->nd_na_target, &tgt->sin6_addr, 16))
return -1;
len -= sizeof (struct nd_neighbor_advert);
/* looks for Target Link-layer address option */
ptr = buf + sizeof (struct nd_neighbor_advert);
while (len >= 8)
{
uint16_t optlen;
optlen = ((uint16_t)(ptr[1])) << 3;
if (optlen == 0)
break; /* invalid length */
if (len < optlen) /* length > remaining bytes */
break;
len -= optlen;
/* skips unrecognized option */
if (ptr[0] != ND_OPT_TARGET_LINKADDR)
{
ptr += optlen;
continue;
}
/* Found! displays link-layer address */
ptr += 2;
optlen -= 2;
if (verbose)
fputs ("Target link-layer address: ", stdout);
printmacaddress (ptr, optlen);
return 0;
}
return -1;
}
static ssize_t
recvfromLL (int fd, void *buf, size_t len, int flags, struct sockaddr_in6 *addr)
{
char cbuf[CMSG_SPACE (sizeof (int))];
struct iovec iov =
{
.iov_base = buf,
.iov_len = len
};
struct msghdr hdr =
{
.msg_name = addr,
.msg_namelen = sizeof (*addr),
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_control = cbuf,
.msg_controllen = sizeof (cbuf)
};
ssize_t val = recvmsg (fd, &hdr, flags);
if (val == -1)
return val;
/* ensures the hop limit is 255 */
struct cmsghdr *cmsg;
for (cmsg = CMSG_FIRSTHDR (&hdr);
cmsg != NULL;
cmsg = CMSG_NXTHDR (&hdr, cmsg))
{
if ((cmsg->cmsg_level == IPPROTO_IPV6)
&& (cmsg->cmsg_type == IPV6_HOPLIMIT))
{
if (255 != *(int *)CMSG_DATA (cmsg))
{
// pretend to be a spurious wake-up
errno = EAGAIN;
return -1;
}
}
}
return val;
}
static ssize_t
recvadv (int fd, const struct sockaddr_in6 *tgt, unsigned wait_ms, unsigned flags)
{
struct timespec now, end;
unsigned responses = 0;
/* computes deadline time */
mono_gettime (&now);
{
div_t d;
d = div (wait_ms, 1000);
end.tv_sec = now.tv_sec + d.quot;
end.tv_nsec = now.tv_nsec + (d.rem * 1000000);
}
/* receive loop */
for (;;)
{
/* waits for reply until deadline */
ssize_t val = 0;
if (end.tv_sec >= now.tv_sec)
{
val = (end.tv_sec - now.tv_sec) * 1000
+ (int)((end.tv_nsec - now.tv_nsec) / 1000000);
if (val < 0)
val = 0;
}
val = poll (&(struct pollfd){ .fd = fd, .events = POLLIN }, 1, val);
if (val < 0)
break;
if (val == 0)
return responses;
/* receives an ICMPv6 packet */
// TODO: use interface MTU as buffer size
union
{
uint8_t b[1460];
uint64_t align;
} buf;
struct sockaddr_in6 addr;
val = recvfromLL (fd, &buf, sizeof (buf), MSG_DONTWAIT, &addr);
if (val == -1)
{
if (errno != EAGAIN)
perror ("Receiving ICMPv6 packet");
continue;
}
/* ensures the response came through the right interface */
if (addr.sin6_scope_id
&& (addr.sin6_scope_id != tgt->sin6_scope_id))
continue;
if (parseadv (buf.b, val, tgt, (flags & NDISC_VERBOSE) != 0) == 0)
{
if (flags & NDISC_VERBOSE)
{
char str[INET6_ADDRSTRLEN];
if (inet_ntop (AF_INET6, &addr.sin6_addr, str,
sizeof (str)) != NULL)
printf (" from %s\n", str);
}
if (responses < INT_MAX)
responses++;
if (flags & NDISC_SINGLE)
return 1 /* = responses */;
}
mono_gettime (&now);
}
return -1; /* error */
}
bool
ndisc (const char *name, const char *ifname, unsigned flags, unsigned retry, unsigned wait_ms)
{
struct sockaddr_in6 tgt;
int fd = socket (PF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
if (fd == -1)
{
perror ("Raw IPv6 socket");
return false;
}
fcntl (fd, F_SETFD, FD_CLOEXEC);
/* set ICMPv6 filter */
{
struct icmp6_filter f;
ICMP6_FILTER_SETBLOCKALL (&f);
ICMP6_FILTER_SETPASS (nd_type_advert, &f);
setsockopt (fd, IPPROTO_ICMPV6, ICMP6_FILTER, &f, sizeof (f));
}
setsockopt (fd, SOL_SOCKET, SO_DONTROUTE, &(int){ 1 }, sizeof (int));
/* sets Hop-by-hop limit to 255 */
sethoplimit (fd, 255);
setsockopt (fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
&(int){ 1 }, sizeof (int));
/* resolves target's IPv6 address */
if (getipv6byname (name, ifname, (flags & NDISC_NUMERIC) ? 1 : 0, &tgt))
goto error;
else
{
char s[INET6_ADDRSTRLEN];
inet_ntop (AF_INET6, &tgt.sin6_addr, s, sizeof (s));
if (flags & NDISC_VERBOSE)
printf ("Soliciting %s (%s) on %s...\n", name, s, ifname);
}
{
solicit_packet packet;
struct sockaddr_in6 dst;
ssize_t plen;
memcpy (&dst, &tgt, sizeof (dst));
plen = buildsol (&packet, &dst, ifname);
if (plen == -1)
goto error;
while (retry > 0)
{
/* sends a Solitication */
if (sendto (fd, &packet, plen, 0,
(const struct sockaddr *)&dst,
sizeof (dst)) != plen)
{
//perror ("Sending ICMPv6 packet");
goto error;
}
retry--;
/* receives an Advertisement */
ssize_t val = recvadv (fd, &tgt, wait_ms, flags);
if (val > 0)
{
close (fd);
return true;
}
else
if (val == 0)
{
if (flags & NDISC_VERBOSE)
puts ("Timed out.");
}
else
goto error;
}
}
close (fd);
if (flags & NDISC_VERBOSE)
puts ("No response.");
return false;
error:
close (fd);
return false;
}

View file

@ -48,6 +48,7 @@ static Key keys;
static Spec spec;
static USB usb[MAX_USB];
/* POLICIES */
enum {
QUEST_NAME,
@ -346,32 +347,20 @@ handle_client(Client *clnt)
}
static bool
wireless_sta(Client *clnt, Detail *dtl)
wireless_sta(Client *clnt)
{
FILE *stainfo;
char cmnd[64];
char line[128];
int i = 0;
bool there = false;
char tab[16];
int ret, tmp;
for (i = 0; wireless[i].device; i++) {
sprintf(cmnd, "wlctl -i %s sta_info %s 2>/dev/null", wireless[i].vif, clnt->macaddr);
sprintf(cmnd, "wlctl -i %s sta_info %s 2>/dev/null | grep ASSOCIATED", wireless[i].vif, clnt->macaddr);
if ((stainfo = popen(cmnd, "r"))) {
while(fgets(line, sizeof(line), stainfo) != NULL)
{
remove_newline(line);
if(sscanf(line, "%sstate: AUTHENTICATED ASSOCIATED AUTHORIZED", tab)) {
there = true;
strncpy(clnt->wdev, wireless[i].vif, sizeof(clnt->wdev));
}
ret = sscanf(line, "\t idle %d seconds", &(dtl->idle));
ret = sscanf(line, "\t in network %d seconds", &(dtl->in_network));
ret = sscanf(line, "\t tx total bytes: %ld\n", &(dtl->tx_bytes));
ret = sscanf(line, "\t rx data bytes: %ld", &(dtl->rx_bytes));
ret = sscanf(line, "\t rate of last tx pkt: %d kbps - %d kbps", &tmp, &(dtl->tx_rate));
ret = sscanf(line, "\t rate of last rx pkt: %d kbps", &(dtl->rx_rate));
if(fgets(line, sizeof(line), stainfo) != NULL) {
there = true;
strncpy(clnt->wdev, wireless[i].vif, sizeof(clnt->wdev));
}
pclose(stainfo);
}
@ -393,7 +382,6 @@ populate_clients()
char mask[64];
int i;
bool there;
int toms = 1000;
memset(clients_new, '\0', sizeof(clients));
@ -408,10 +396,10 @@ populate_clients()
clients[cno].exists = true;
clients[cno].dhcp = true;
handle_client(&clients[cno]);
if((clients[cno].connected = wireless_sta(&clients[cno], &details[cno])))
if((clients[cno].connected = wireless_sta(&clients[cno])))
clients[cno].wireless = true;
else if(!(clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device, toms)))
recalc_sleep_time(true, toms);
else
clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device);
cno++;
}
}
@ -446,10 +434,10 @@ populate_clients()
if(clients[cno].local) {
clients[cno].exists = true;
clients[cno].dhcp = false;
if((clients[cno].connected = wireless_sta(&clients[cno], &details[cno])))
if((clients[cno].connected = wireless_sta(&clients[cno])))
clients[cno].wireless = true;
else if(!(clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device, toms)))
recalc_sleep_time(true, toms);
else
clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device);
cno++;
}
}
@ -496,7 +484,6 @@ populate_clients6()
char line[512];
int cno = 0;
int iaid, ts, id, length;
int toms = 500;
if ((hosts6 = fopen("/tmp/hosts/6relayd", "r"))) {
while(fgets(line, sizeof(line), hosts6) != NULL)
@ -505,11 +492,11 @@ populate_clients6()
clients6[cno].exists = false;
clients6[cno].wireless = false;
memset(clients6[cno].hostname, '\0', 64);
if (sscanf(line, "# %s %s %x %s %d %x %d %s", clients6[cno].device, clients6[cno].duid, iaid, clients6[cno].hostname, &ts, &id, &length, clients6[cno].ip6addr)) {
if (sscanf(line, "# %s %s %d %s %d %x %d %s", clients6[cno].device, clients6[cno].duid, &iaid, clients6[cno].hostname, &ts, &id, &length, clients6[cno].ip6addr)) {
clients6[cno].exists = true;
clear_macaddr();
if(!(clients6[cno].connected = ndisc (clients6[cno].hostname, clients6[cno].device, 0x8, 1, toms)))
recalc_sleep_time(true, toms);
if(!(clients6[cno].connected = ndisc (clients6[cno].hostname, clients6[cno].device, 0x8, 1, 500)))
recalc_sleep_time(true, 500000);
sprintf(clients6[cno].macaddr, get_macaddr());
if(clients6[cno].connected && wireless_sta6(&clients6[cno]))
clients6[cno].wireless = true;
@ -692,12 +679,6 @@ router_dump_clients(struct blob_buf *b)
blobmsg_add_u8(b, "wireless", clients[i].wireless);
if(clients[i].wireless) {
blobmsg_add_string(b, "wdev", clients[i].wdev);
blobmsg_add_u32(b, "idle", details[i].idle);
blobmsg_add_u32(b, "in_network", details[i].in_network);
blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes);
blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes);
blobmsg_add_u32(b, "tx_rate", details[i].tx_rate);
blobmsg_add_u32(b, "rx_rate", details[i].rx_rate);
}
blobmsg_close_table(b, t);
num++;
@ -728,12 +709,6 @@ router_dump_connected_clients(struct blob_buf *b)
blobmsg_add_u8(b, "wireless", clients[i].wireless);
if(clients[i].wireless) {
blobmsg_add_string(b, "wdev", clients[i].wdev);
blobmsg_add_u32(b, "idle", details[i].idle);
blobmsg_add_u32(b, "in_network", details[i].in_network);
blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes);
blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes);
blobmsg_add_u32(b, "tx_rate", details[i].tx_rate);
blobmsg_add_u32(b, "rx_rate", details[i].rx_rate);
}
blobmsg_close_table(b, t);
num++;
@ -765,12 +740,6 @@ router_dump_network_clients(struct blob_buf *b, char *net)
blobmsg_add_u8(b, "wireless", clients[i].wireless);
if(clients[i].wireless) {
blobmsg_add_string(b, "wdev", clients[i].wdev);
blobmsg_add_u32(b, "idle", details[i].idle);
blobmsg_add_u32(b, "in_network", details[i].in_network);
blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes);
blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes);
blobmsg_add_u32(b, "tx_rate", details[i].tx_rate);
blobmsg_add_u32(b, "rx_rate", details[i].rx_rate);
}
blobmsg_close_table(b, t);
num++;
@ -857,12 +826,6 @@ router_dump_stas(struct blob_buf *b)
if(strstr(clients[i].device, "br-"))
blobmsg_add_string(b, "bridge", clients[i].device);
blobmsg_add_string(b, "wdev", clients[i].wdev);
blobmsg_add_u32(b, "idle", details[i].idle);
blobmsg_add_u32(b, "in_network", details[i].in_network);
blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes);
blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes);
blobmsg_add_u32(b, "tx_rate", details[i].tx_rate);
blobmsg_add_u32(b, "rx_rate", details[i].rx_rate);
blobmsg_close_table(b, t);
num++;
}
@ -903,12 +866,6 @@ router_dump_wireless_stas(struct blob_buf *b, char *wname, bool vif)
blobmsg_add_string(b, "bridge", clients[i].device);
if(!vif)
blobmsg_add_string(b, "wdev", clients[i].wdev);
blobmsg_add_u32(b, "idle", details[i].idle);
blobmsg_add_u32(b, "in_network", details[i].in_network);
blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes);
blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes);
blobmsg_add_u32(b, "tx_rate", details[i].tx_rate);
blobmsg_add_u32(b, "rx_rate", details[i].rx_rate);
blobmsg_close_table(b, t);
num++;
}
@ -1420,15 +1377,14 @@ quest_reload(struct ubus_context *ctx, struct ubus_object *obj,
static struct ubus_method router_object_methods[] = {
UBUS_METHOD_NOARG("info", quest_router_info),
UBUS_METHOD("quest", quest_router_specific, quest_policy),
UBUS_METHOD_NOARG("networks", quest_router_networks),
UBUS_METHOD_NOARG("dslstats", dslstats_rpc),
{ .name = "networks", .handler = quest_router_networks },
UBUS_METHOD("client", quest_router_network_clients, network_policy),
UBUS_METHOD_NOARG("clients", quest_router_clients),
UBUS_METHOD_NOARG("clients6", quest_router_clients6),
UBUS_METHOD_NOARG("connected", quest_router_connected_clients),
UBUS_METHOD_NOARG("connected6", quest_router_connected_clients6),
{ .name = "clients", .handler = quest_router_clients },
{ .name = "clients6", .handler = quest_router_clients6 },
{ .name = "connected", .handler = quest_router_connected_clients },
{ .name = "connected6", .handler = quest_router_connected_clients6 },
UBUS_METHOD("sta", quest_router_wireless_stas, wl_policy),
UBUS_METHOD_NOARG("stas", quest_router_stas),
{ .name = "stas", .handler = quest_router_stas },
UBUS_METHOD("ports", quest_router_ports, network_policy),
UBUS_METHOD("leases", quest_network_leases, network_policy),
UBUS_METHOD("host", quest_host_status, host_policy),

View file

@ -12,16 +12,6 @@
#include <uci.h>
#include <libubox/blobmsg.h>
#include <libubox/uloop.h>
#include <libubox/ustream.h>
#include <libubox/utils.h>
#include <libubus.h>
#include "dslstats.h"
#define MAX_VIF 8
#define MAX_NETWORK 16
#define MAX_CLIENT 128
@ -35,16 +25,6 @@ typedef struct {
const char *network;
} Wireless;
typedef struct {
int idle;
int in_network;
long tx_bytes;
long rx_bytes;
int tx_rate;
int rx_rate;
int rssi;
} Detail;
typedef struct {
bool exists;
bool local;