[broadcom]: build broadcom kernel modules from gpl source codes
Signed-off-by: Guohan Lu <gulv@microsoft.com>
This commit is contained in:
parent
3021e4efd6
commit
aa2e340f5a
@ -1,4 +1,4 @@
|
||||
include $(PLATFORM_PATH)/sdk.mk
|
||||
include $(PLATFORM_PATH)/sai-modules.mk
|
||||
include $(PLATFORM_PATH)/sai.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-s6000.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-dell.mk
|
||||
|
11
platform/broadcom/sai-modules.mk
Normal file
11
platform/broadcom/sai-modules.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# Broadcom SAI modules
|
||||
|
||||
KVERSION = 4.9.0-5-amd64
|
||||
BRCM_OPENNSL_KERNEL_VERSION = 3.4.1.11-1
|
||||
|
||||
BRCM_OPENNSL_KERNEL = opennsl-modules-$(KVERSION)_$(BRCM_OPENNSL_KERNEL_VERSION)_amd64.deb
|
||||
$(BRCM_OPENNSL_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/saibcm-modules
|
||||
$(BRCM_OPENNSL_KERNEL)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||
SONIC_DPKG_DEBS += $(BRCM_OPENNSL_KERNEL)
|
||||
|
||||
SONIC_STRETCH_DEBS += $(BRCM_OPENNSL_KERNEL)
|
4
platform/broadcom/saibcm-modules/.gitignore
vendored
Normal file
4
platform/broadcom/saibcm-modules/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.debhelper.log
|
||||
*.debhelper
|
||||
*.substvars
|
||||
*.ko
|
48
platform/broadcom/saibcm-modules/debian/changelog
Normal file
48
platform/broadcom/saibcm-modules/debian/changelog
Normal file
@ -0,0 +1,48 @@
|
||||
opennsl (3.4.1.11-1) unstable; urgency=medium
|
||||
|
||||
* Port Broadcom SAI 3.4.1.11
|
||||
* Cherry-pick change from master branch, 3.4.1.11-1
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Fri, 05 Jan 2018 23:21:47 +0000
|
||||
|
||||
opennsl (3.4.1.10-1) unstable; urgency=medium
|
||||
|
||||
* Upgrade to 3.4.1.10-1
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Tue, 19 Dec 2017 21:33:48 +0000
|
||||
|
||||
opennsl (3.4.1.9-1) unstable; urgency=medium
|
||||
|
||||
* Upgrade to 3.4.1.9-1
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Thu, 14 Dec 2017 22:04:11 +0000
|
||||
|
||||
opennsl (3.4.1.7-2) unstable; urgency=medium
|
||||
|
||||
* Add Arista 7260cx3 Rev2 hardware support
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Mon, 27 Nov 2017 18:13:50 +0000
|
||||
|
||||
opennsl (3.4.1.7-1) unstable; urgency=medium
|
||||
|
||||
* Importing opennsl 3.4.1.7
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Mon, 23 Oct 2017 23:47:25 +0000
|
||||
|
||||
opennsl (3.4.1.5-2) unstable; urgency=medium
|
||||
|
||||
* Importing TD2 changes from opennsl 3.2.2.2
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Tue, 26 Sep 2017 01:28:44 +0000
|
||||
|
||||
opennsl (3.4.1.5-1) unstable; urgency=medium
|
||||
|
||||
* Importing opennsl 3.4.1.5
|
||||
|
||||
-- Ying Xie <yinxi@microsoft.com> Wed, 20 Sep 2017 16:42:12 +0000
|
||||
|
||||
opennsl (3.4.1.3-1) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- Guohan Lu <gulv@microsoft.com> Fri, 17 Jul 2015 04:46:01 -0700
|
1
platform/broadcom/saibcm-modules/debian/compat
Normal file
1
platform/broadcom/saibcm-modules/debian/compat
Normal file
@ -0,0 +1 @@
|
||||
8
|
14
platform/broadcom/saibcm-modules/debian/control
Normal file
14
platform/broadcom/saibcm-modules/debian/control
Normal file
@ -0,0 +1,14 @@
|
||||
Source: opennsl
|
||||
Section: main
|
||||
Priority: extra
|
||||
Maintainer: Guohan Lu <gulv@microsoft.com>
|
||||
Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||
Standards-Version: 3.9.3
|
||||
#Vcs-Git: git://git.debian.org/collab-maint/bcmsdk.git
|
||||
#Vcs-Browser: http://git.debian.org/?p=collab-maint/bcmsdk.git;a=summary
|
||||
|
||||
Package: opennsl-modules-4.9.0-5-amd64
|
||||
Architecture: amd64
|
||||
Section: main
|
||||
Depends: linux-image-4.9.0-5-amd64
|
||||
Description: kernel modules for broadcom SAI
|
@ -0,0 +1 @@
|
||||
lib/modules/4.9.0-5-amd64/extra
|
47
platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-5-amd64.init
Executable file
47
platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-5-amd64.init
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# This script load/unload opennsl kernel modules
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: load-opennsl-modules
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Load OpenNSL kernel modules
|
||||
### END INIT INFO
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Load OpenNSL kernel modules... "
|
||||
|
||||
modprobe linux-kernel-bde dmasize=32M maxpayload=128
|
||||
modprobe linux-user-bde
|
||||
modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238
|
||||
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
stop)
|
||||
echo -n "Unload OpenNSL kernel modules... "
|
||||
|
||||
rmmod linux-bcm-knet
|
||||
rmmod linux-user-bde
|
||||
rmmod linux-kernel-bde
|
||||
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
force-reload|restart)
|
||||
echo "Not supported"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/opennsl-modules-4.9.0-5-amd64.init {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
@ -0,0 +1,4 @@
|
||||
systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/4.9.0-5-amd64/extra
|
||||
systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/4.9.0-5-amd64/extra
|
||||
systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/4.9.0-5-amd64/extra
|
||||
systemd/opennsl-modules-4.9.0-5-amd64.service lib/systemd/system
|
183
platform/broadcom/saibcm-modules/debian/rules
Executable file
183
platform/broadcom/saibcm-modules/debian/rules
Executable file
@ -0,0 +1,183 @@
|
||||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# Sample debian/rules that uses debhelper.
|
||||
# This file was originally written by Joey Hess and Craig Small.
|
||||
# As a special exception, when this file is copied by dh-make into a
|
||||
# dh-make output file, you may use that output file without restriction.
|
||||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||
#
|
||||
# This version is for a hypothetical package that can build a kernel modules
|
||||
# architecture-dependant package via make-kpkg, as well as an
|
||||
# architecture-independent module source package, and other packages
|
||||
# either dep/indep for things like common files or userspace components
|
||||
# needed for the kernel modules.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
|
||||
|
||||
|
||||
# some default definitions, important!
|
||||
#
|
||||
# Name of the source package
|
||||
psource:=opennsl-source
|
||||
|
||||
# The short upstream name, used for the module source directory
|
||||
sname:=opennsl
|
||||
|
||||
### KERNEL SETUP
|
||||
### Setup the stuff needed for making kernel module packages
|
||||
### taken from /usr/share/kernel-package/sample.module.rules
|
||||
|
||||
# prefix of the target package name
|
||||
PACKAGE=opennsl-modules
|
||||
# modifieable for experiments or debugging m-a
|
||||
MA_DIR ?= /usr/share/modass
|
||||
# load generic variable handling
|
||||
-include $(MA_DIR)/include/generic.make
|
||||
# load default rules, including kdist, kdist_image, ...
|
||||
-include $(MA_DIR)/include/common-rules.make
|
||||
|
||||
|
||||
|
||||
# module assistant calculates all needed things for us and sets
|
||||
# following variables:
|
||||
# KSRC (kernel source directory), KVERS (kernel version string), KDREV
|
||||
# (revision of the Debian kernel-image package), CC (the correct
|
||||
# compiler), VERSION (the final package version string), PKGNAME (full
|
||||
# package name with KVERS included), DEB_DESTDIR (path to store DEBs)
|
||||
|
||||
# The kdist_config target is called by make-kpkg modules_config and
|
||||
# by kdist* rules by dependency. It should configure the module so it is
|
||||
# ready for compilation (mostly useful for calling configure).
|
||||
# prep-deb-files from module-assistant creates the neccessary debian/ files
|
||||
kdist_config: prep-deb-files
|
||||
|
||||
# the kdist_clean target is called by make-kpkg modules_clean and from
|
||||
# kdist* rules. It is responsible for cleaning up any changes that have
|
||||
# been made by the other kdist_commands (except for the .deb files created)
|
||||
kdist_clean: clean
|
||||
dh_testdir
|
||||
dh_clean
|
||||
SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 KERNDIR=/usr/src/linux-headers-4.9.0-5-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-5-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean
|
||||
# rm -f driver/*.o driver/*.ko
|
||||
#
|
||||
### end KERNEL SETUP
|
||||
|
||||
configure: configure-stamp
|
||||
configure-stamp:
|
||||
dh_testdir
|
||||
# Add here commands to configure the package.
|
||||
|
||||
touch configure-stamp
|
||||
|
||||
|
||||
build-arch: configure-stamp build-arch-stamp
|
||||
build-arch-stamp:
|
||||
dh_testdir
|
||||
|
||||
# Add here command to compile/build the package.
|
||||
SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 KERNDIR=/usr/src/linux-headers-4.9.0-5-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-5-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6
|
||||
|
||||
touch $@
|
||||
|
||||
#k = $(shell echo $(KVERS) | grep -q ^2.6 && echo k)
|
||||
|
||||
build-indep: configure-stamp build-indep-stamp
|
||||
build-indep-stamp:
|
||||
dh_testdir
|
||||
|
||||
# Add here command to compile/build the arch indep package.
|
||||
# It's ok not to do anything here, if you don't need to build
|
||||
# anything for this package.
|
||||
#docbook-to-man debian/opennsl.sgml > opennsl.1
|
||||
|
||||
touch $@
|
||||
|
||||
build: build-arch
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
#dh_testroot
|
||||
rm -f build-arch-stamp build-indep-stamp configure-stamp
|
||||
|
||||
# Add here commands to clean up after the build process.
|
||||
SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 KERNDIR=/usr/src/linux-headers-4.9.0-5-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-5-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean
|
||||
|
||||
dh_clean
|
||||
|
||||
install: DH_OPTIONS=
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_prep
|
||||
dh_installdirs
|
||||
dh_install
|
||||
|
||||
# Build architecture-independent files here.
|
||||
# Pass -i to all debhelper commands in this target to reduce clutter.
|
||||
binary-indep: build install
|
||||
dh_testdir -i
|
||||
dh_testroot -i
|
||||
dh_installchangelogs -i
|
||||
dh_installdocs -i
|
||||
dh_installexamples -i
|
||||
# dh_install -i
|
||||
# dh_installmenu -i
|
||||
# dh_installdebconf -i
|
||||
# dh_installlogrotate -i
|
||||
# dh_installemacsen -i
|
||||
# dh_installpam -i
|
||||
# dh_installmime -i
|
||||
# dh_installinit -i
|
||||
# dh_installcron -i
|
||||
# dh_installinfo -i
|
||||
dh_installman -i
|
||||
dh_link -i
|
||||
dh_compress -i
|
||||
dh_fixperms -i
|
||||
dh_installdeb -i
|
||||
# dh_perl -i
|
||||
# dh_makeshlibs -i
|
||||
dh_installdeb -i
|
||||
dh_shlibdeps -i
|
||||
dh_gencontrol -i
|
||||
dh_md5sums -i
|
||||
dh_builddeb -i
|
||||
|
||||
# Build architecture-dependent files here.
|
||||
binary-arch: build install
|
||||
dh_testdir -s
|
||||
dh_testroot -s
|
||||
# dh_installdebconf -s
|
||||
|
||||
dh_installdocs -s
|
||||
dh_installexamples -s
|
||||
dh_installmenu -s
|
||||
# dh_installlogrotate -s
|
||||
# dh_installemacsen -s
|
||||
# dh_installpam -s
|
||||
# dh_installmime -s
|
||||
dh_installmodules -s
|
||||
dh_systemd_enable -s
|
||||
dh_installinit -s
|
||||
dh_systemd_start -s
|
||||
dh_installcron -s
|
||||
# dh_installman -s
|
||||
dh_installinfo -s
|
||||
dh_installchangelogs -s
|
||||
dh_strip -s
|
||||
dh_link -s
|
||||
dh_compress -s
|
||||
dh_fixperms -s
|
||||
dh_makeshlibs -s
|
||||
dh_installdeb -s
|
||||
# dh_perl -s
|
||||
dh_shlibdeps -s
|
||||
dh_gencontrol -s
|
||||
dh_md5sums -s
|
||||
dh_builddeb -s
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install configure binary-modules kdist kdist_configure kdist_image kdist_clean
|
158
platform/broadcom/saibcm-modules/include/ibde.h
Normal file
158
platform/broadcom/saibcm-modules/include/ibde.h
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: ibde.h,v 1.27 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef __IBDE_H__
|
||||
#define __IBDE_H__
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
/*
|
||||
* Represents a collection of devices
|
||||
*/
|
||||
|
||||
typedef struct ibde_dev_s {
|
||||
uint16 device;
|
||||
uint8 rev;
|
||||
sal_vaddr_t base_address;
|
||||
sal_vaddr_t base_address1;
|
||||
sal_vaddr_t base_address2;
|
||||
} ibde_dev_t;
|
||||
|
||||
|
||||
typedef struct ibde_s {
|
||||
|
||||
const char *(*name)(void);
|
||||
|
||||
/* Returns the number of devices available */
|
||||
/* Each device is is accessed through a handle */
|
||||
/* Handles are assumed to index the array of devices */
|
||||
|
||||
/* Support SWITCH or ETHERNET or CPU devices */
|
||||
int (*num_devices)(int type);
|
||||
#define BDE_ALL_DEVICES 0
|
||||
#define BDE_SWITCH_DEVICES 1
|
||||
#define BDE_ETHER_DEVICES 2
|
||||
#define BDE_CPU_DEVICES 3
|
||||
|
||||
const ibde_dev_t *(*get_dev)(int d);
|
||||
|
||||
/*
|
||||
* Get types of underlaying devices.
|
||||
* A combination of bus type and functional type is returned.
|
||||
* In case of bus type, support PCI and SPI device types.
|
||||
* In case of functional type, specify if underlaying device is
|
||||
* a switching or ethernet device.
|
||||
*/
|
||||
uint32 (*get_dev_type)(int d);
|
||||
#define BDE_PCI_DEV_TYPE SAL_PCI_DEV_TYPE /* PCI device */
|
||||
#define BDE_SPI_DEV_TYPE SAL_SPI_DEV_TYPE /* SPI device */
|
||||
#define BDE_EB_DEV_TYPE SAL_EB_DEV_TYPE /* EB device */
|
||||
#define BDE_ICS_DEV_TYPE SAL_ICS_DEV_TYPE /* ICS device */
|
||||
#define BDE_MII_DEV_TYPE SAL_MII_DEV_TYPE /* MII device */
|
||||
#define BDE_I2C_DEV_TYPE SAL_I2C_DEV_TYPE /* I2C device */
|
||||
#define BDE_AXI_DEV_TYPE SAL_AXI_DEV_TYPE /* AXI device */
|
||||
#define BDE_EMMI_DEV_TYPE SAL_EMMI_DEV_TYPE /* EMMI device */
|
||||
#define BDE_DEV_BUS_ALT SAL_DEV_BUS_ALT /* Alternate Access */
|
||||
#define BDE_DEV_BUS_MSI SAL_DEV_BUS_MSI /* Message-signaled interrupts */
|
||||
|
||||
#define BDE_DEV_BUS_TYPE_MASK SAL_DEV_BUS_TYPE_MASK
|
||||
|
||||
#define BDE_SWITCH_DEV_TYPE SAL_SWITCH_DEV_TYPE /* Switch device */
|
||||
#define BDE_ETHER_DEV_TYPE SAL_ETHER_DEV_TYPE /* Ethernet device */
|
||||
#define BDE_CPU_DEV_TYPE SAL_CPU_DEV_TYPE /* CPU device */
|
||||
|
||||
#define BDE_BYTE_SWAP 0x01000000 /* SW byte swap */
|
||||
#define BDE_NO_IPROC 0x02000000 /* Device uses two BARs, but is not iProc */
|
||||
|
||||
#define BDE_256K_REG_SPACE 0x20000000 /* Map 256K (v 64K) */
|
||||
#define BDE_128K_REG_SPACE 0x40000000 /* Map 128K (v 64K) */
|
||||
#define BDE_320K_REG_SPACE 0x80000000 /* Map 256K+64K */
|
||||
|
||||
/* Bus supports only 16bit reads */
|
||||
#define BDE_DEV_BUS_RD_16BIT SAL_DEV_BUS_RD_16BIT
|
||||
|
||||
/* Bus supports only 16bit writes */
|
||||
#define BDE_DEV_BUS_WR_16BIT SAL_DEV_BUS_WR_16BIT
|
||||
|
||||
/* Backward compatibility */
|
||||
#define BDE_ET_DEV_TYPE BDE_MII_DEV_TYPE
|
||||
|
||||
#define BDE_DEV_MEM_MAPPED(_d) \
|
||||
((_d) & (BDE_PCI_DEV_TYPE | BDE_ICS_DEV_TYPE | BDE_EB_DEV_TYPE |\
|
||||
BDE_EMMI_DEV_TYPE | BDE_AXI_DEV_TYPE))
|
||||
|
||||
/*
|
||||
* PCI Bus Access
|
||||
*/
|
||||
uint32 (*pci_conf_read)(int d, uint32 addr);
|
||||
int (*pci_conf_write)(int d, uint32 addr, uint32 data);
|
||||
void (*pci_bus_features)(int d, int *be_pio, int *be_packet,
|
||||
int *be_other);
|
||||
|
||||
uint32 (*read)(int d, uint32 addr);
|
||||
int (*write)(int d, uint32 addr, uint32 data);
|
||||
|
||||
uint32* (*salloc)(int d, int size, const char *name);
|
||||
void (*sfree)(int d, void *ptr);
|
||||
int (*sflush)(int d, void *addr, int length);
|
||||
int (*sinval)(int d, void *addr, int length);
|
||||
|
||||
int (*interrupt_connect)(int d, void (*)(void*), void *data);
|
||||
int (*interrupt_disconnect)(int d);
|
||||
|
||||
sal_paddr_t (*l2p)(int d, void *laddr);
|
||||
void* (*p2l)(int d, sal_paddr_t paddr);
|
||||
|
||||
/*
|
||||
* SPI Access via SMP
|
||||
*/
|
||||
int (*spi_read)(int d, uint32 addr, uint8 *buf, int len);
|
||||
int (*spi_write)(int d, uint32 addr, uint8 *buf, int len);
|
||||
/* Special SPI access addresses */
|
||||
#define BDE_DEV_OP_EMMI_INIT SAL_DEV_OP_EMMI_INIT
|
||||
|
||||
/*
|
||||
* iProc register access
|
||||
*/
|
||||
uint32 (*iproc_read)(int d, uint32 addr);
|
||||
int (*iproc_write)(int d, uint32 addr, uint32 data);
|
||||
|
||||
/*
|
||||
* Shared memory access
|
||||
*/
|
||||
uint32 (*shmem_read)(int dev, uint32 addr, uint8 *buf, uint32 len);
|
||||
void (*shmem_write)(int dev, uint32 addr, uint8 *buf, uint32 len);
|
||||
sal_vaddr_t (*shmem_map)(int dev, uint32 addr, uint32 size);
|
||||
|
||||
/*
|
||||
* cmic
|
||||
*/
|
||||
int (*get_cmic_ver)(int d, uint32 *ver);
|
||||
|
||||
} ibde_t;
|
||||
|
||||
|
||||
/* System BDE */
|
||||
extern ibde_t *bde;
|
||||
|
||||
|
||||
#endif /* __IBDE_H__ */
|
541
platform/broadcom/saibcm-modules/include/kcom.h
Normal file
541
platform/broadcom/saibcm-modules/include/kcom.h
Normal file
@ -0,0 +1,541 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: kcom.h,v 1.9 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
* File: kcom.h
|
||||
* Purpose: User/Kernel message definitions
|
||||
*/
|
||||
|
||||
#ifndef _KCOM_H
|
||||
#define _KCOM_H
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
#define KCOM_CHAN_KNET "KCOM_KNET"
|
||||
|
||||
/*
|
||||
* Message types
|
||||
*/
|
||||
#define KCOM_MSG_TYPE_CMD 1 /* Command */
|
||||
#define KCOM_MSG_TYPE_RSP 2 /* Command response */
|
||||
#define KCOM_MSG_TYPE_EVT 3 /* Unsolicited event */
|
||||
|
||||
|
||||
/*
|
||||
* Message opcodes
|
||||
*/
|
||||
#define KCOM_M_NONE 0 /* Should not be used */
|
||||
#define KCOM_M_VERSION 1 /* Protocol version */
|
||||
#define KCOM_M_STRING 2 /* For debug messages */
|
||||
#define KCOM_M_HW_RESET 3 /* H/W not ready */
|
||||
#define KCOM_M_HW_INIT 4 /* H/W initialized */
|
||||
#define KCOM_M_ETH_HW_CONFIG 5 /* ETH HW config*/
|
||||
#define KCOM_M_DETACH 6 /* Detach kernel module */
|
||||
#define KCOM_M_NETIF_CREATE 11 /* Create network interface */
|
||||
#define KCOM_M_NETIF_DESTROY 12 /* Destroy network interface */
|
||||
#define KCOM_M_NETIF_LIST 13 /* Get list of network interface IDs */
|
||||
#define KCOM_M_NETIF_GET 14 /* Get network interface info */
|
||||
#define KCOM_M_FILTER_CREATE 21 /* Create Rx filter */
|
||||
#define KCOM_M_FILTER_DESTROY 22 /* Destroy Rx filter */
|
||||
#define KCOM_M_FILTER_LIST 23 /* Get list of Rx filter IDs */
|
||||
#define KCOM_M_FILTER_GET 24 /* Get Rx filter info */
|
||||
#define KCOM_M_DMA_INFO 31 /* Tx/Rx DMA info */
|
||||
#define KCOM_M_DBGPKT_SET 41 /* Enbale debug packet function */
|
||||
#define KCOM_M_DBGPKT_GET 42 /* Get debug packet function info */
|
||||
|
||||
#define KCOM_VERSION 8 /* Protocol version */
|
||||
|
||||
/*
|
||||
* Message status codes
|
||||
*/
|
||||
#define KCOM_E_NONE 0 /* No errors */
|
||||
#define KCOM_E_PARAM 1 /* Invalid/unsupported parameter */
|
||||
#define KCOM_E_RESOURCE 2 /* Out of memory or other resource */
|
||||
#define KCOM_E_NOT_FOUND 3 /* Requested object not found */
|
||||
|
||||
typedef struct kcom_msg_hdr_s {
|
||||
uint8 type;
|
||||
uint8 opcode;
|
||||
uint8 seqno;
|
||||
uint8 status;
|
||||
uint8 unit;
|
||||
uint8 reserved;
|
||||
uint16 id;
|
||||
} kcom_msg_hdr_t;
|
||||
|
||||
|
||||
/*
|
||||
* Object types
|
||||
*/
|
||||
|
||||
/*
|
||||
* System network interface
|
||||
*
|
||||
* Network interface types:
|
||||
*
|
||||
* KCOM_NETIF_T_VLAN
|
||||
* Transmits to this interface will go to ingress PIPE of switch
|
||||
* CPU port using specified VLAN ID. Packet will be switched.
|
||||
*
|
||||
* KCOM_NETIF_T_PORT
|
||||
* Transmits to this interface will go to unmodified to specified
|
||||
* physical switch port. All switching logic is bypassed.
|
||||
*
|
||||
* KCOM_NETIF_T_META
|
||||
* Transmits to this interface will be done using raw meta data
|
||||
* as DMA descriptors. Currently used for RCPU mode only.
|
||||
*
|
||||
* Network interface flags:
|
||||
*
|
||||
* KCOM_NETIF_F_ADD_TAG
|
||||
* Add VLAN tag to packets sent directly to physical port.
|
||||
*
|
||||
* KCOM_NETIF_F_RCPU_ENCAP
|
||||
* Use RCPU encapsulation for packets that enter and exit this
|
||||
* interface.
|
||||
*/
|
||||
#define KCOM_NETIF_T_VLAN 0
|
||||
#define KCOM_NETIF_T_PORT 1
|
||||
#define KCOM_NETIF_T_META 2
|
||||
|
||||
#define KCOM_NETIF_F_ADD_TAG (1U << 0)
|
||||
#define KCOM_NETIF_F_RCPU_ENCAP (1U << 1)
|
||||
/* If a netif has this flag, the packet sent to the netif can't be stripped tag or added tag */
|
||||
#define KCOM_NETIF_F_KEEP_RX_TAG (1U << 2)
|
||||
|
||||
#define KCOM_NETIF_NAME_MAX 16
|
||||
|
||||
typedef struct kcom_netif_s {
|
||||
uint16 id;
|
||||
uint8 type;
|
||||
uint8 flags;
|
||||
uint32 cb_user_data;
|
||||
uint8 port;
|
||||
uint8 reserved;
|
||||
uint16 vlan;
|
||||
uint16 qnum;
|
||||
uint8 macaddr[6];
|
||||
uint8 ptch[2];
|
||||
uint8 itmh[4];
|
||||
char name[KCOM_NETIF_NAME_MAX];
|
||||
} kcom_netif_t;
|
||||
|
||||
/*
|
||||
* Packet filters
|
||||
*
|
||||
* Filters work like software TCAMs where a mask is applied to the
|
||||
* source data, and the result is then compared to the filter data.
|
||||
*
|
||||
* Filters are checked in priority order with the lowest priority
|
||||
* values being checked first (i.e. 0 is the highest priority).
|
||||
*
|
||||
* Filter types:
|
||||
*
|
||||
* KCOM_FILTER_T_RX_PKT
|
||||
* Filter data and mask are applied to the Rx DMA control block
|
||||
* as well as to the Rx packet contents.
|
||||
*
|
||||
* Destination types:
|
||||
*
|
||||
* KCOM_DEST_T_NULL
|
||||
* Packet is dropped.
|
||||
*
|
||||
* KCOM_DEST_T_NETIF
|
||||
* Packet is sent to network interface with ID <dest_id>.
|
||||
*
|
||||
* KCOM_DEST_T_API
|
||||
* Packet is sent to Rx API through queue <dest_id>.
|
||||
*
|
||||
* KCOM_DEST_T_CB
|
||||
* Packet destination is obtained from kernel call-back function.
|
||||
*
|
||||
* Filter flags:
|
||||
*
|
||||
* KCOM_FILTER_F_ANY_DATA
|
||||
* When this flags is set the filter will match any packet on
|
||||
* the associated unit.
|
||||
*
|
||||
* KCOM_FILTER_F_STRIP_TAG
|
||||
* Strip VLAN tag before packet is sent to destination.
|
||||
* This flag only applies to KCOM_DEST_T_NETIF.
|
||||
*
|
||||
*/
|
||||
#define KCOM_FILTER_BYTES_MAX 256
|
||||
#define KCOM_FILTER_WORDS_MAX BYTES2WORDS(KCOM_FILTER_BYTES_MAX)
|
||||
|
||||
#define KCOM_FILTER_T_RX_PKT 1
|
||||
|
||||
#define KCOM_DEST_T_NULL 0
|
||||
#define KCOM_DEST_T_NETIF 1
|
||||
#define KCOM_DEST_T_API 2
|
||||
#define KCOM_DEST_T_CB 3
|
||||
|
||||
#define KCOM_FILTER_F_ANY_DATA (1U << 0)
|
||||
#define KCOM_FILTER_F_STRIP_TAG (1U << 1)
|
||||
|
||||
#define KCOM_FILTER_DESC_MAX 32
|
||||
|
||||
typedef struct kcom_filter_s {
|
||||
uint16 id;
|
||||
uint8 type;
|
||||
uint8 priority;
|
||||
char desc[KCOM_FILTER_DESC_MAX];
|
||||
uint32 flags;
|
||||
uint32 cb_user_data;
|
||||
uint16 dest_type;
|
||||
uint16 dest_id;
|
||||
uint16 dest_proto;
|
||||
uint16 mirror_type;
|
||||
uint16 mirror_id;
|
||||
uint16 mirror_proto;
|
||||
uint16 oob_data_offset;
|
||||
uint16 oob_data_size;
|
||||
uint16 pkt_data_offset;
|
||||
uint16 pkt_data_size;
|
||||
union {
|
||||
uint8 b[KCOM_FILTER_BYTES_MAX];
|
||||
uint32 w[KCOM_FILTER_WORDS_MAX];
|
||||
} data;
|
||||
union {
|
||||
uint8 b[KCOM_FILTER_BYTES_MAX];
|
||||
uint32 w[KCOM_FILTER_WORDS_MAX];
|
||||
} mask;
|
||||
} kcom_filter_t;
|
||||
|
||||
/*
|
||||
* DMA buffer information
|
||||
*
|
||||
* Cookie field is reserved use by application (32/64-bit pointer).
|
||||
*
|
||||
* For Tx operation the application will submit the start address of
|
||||
* the Tx DCB chain which is queued for transfer by the kernel module.
|
||||
* Once DMA is done a DMA event is returned to the application with an
|
||||
* optional sequence number.
|
||||
*
|
||||
* For Rx operation the application will submit the start address of
|
||||
* the Rx DCB chain which should be use for packet reception by the
|
||||
* kernel module. Once DMA is done a DMA event is returned to the
|
||||
* application with an optional sequence number.
|
||||
*
|
||||
* Cookie field is reserved use by application (32/64-bit pointer).
|
||||
*
|
||||
* Packet info types:
|
||||
*
|
||||
* KCOM_DMA_INFO_T_TX_DCB
|
||||
* Data is physical start address of Tx DCB chain.
|
||||
*
|
||||
* KCOM_DMA_INFO_T_RX_DCB
|
||||
* Data is physical start address of Rx DCB chain.
|
||||
*
|
||||
* Packet info flags:
|
||||
*
|
||||
* KCOM_DMA_INFO_F_TX_DONE
|
||||
* This flag is set by the kernel module and means that one or more
|
||||
* packets have been sent.
|
||||
*
|
||||
* KCOM_DMA_INFO_F_RX_DONE
|
||||
* This flag is set by the kernel module and means that one or more
|
||||
* Rx buffers contain valid packet data.
|
||||
*/
|
||||
#define KCOM_DMA_INFO_T_TX_DCB 1
|
||||
#define KCOM_DMA_INFO_T_RX_DCB 2
|
||||
|
||||
#define KCOM_DMA_INFO_F_TX_DONE (1U << 0)
|
||||
#define KCOM_DMA_INFO_F_RX_DONE (1U << 1)
|
||||
|
||||
typedef struct kcom_dma_info_s {
|
||||
uint8 type;
|
||||
uint8 cnt;
|
||||
uint16 size;
|
||||
uint16 chan;
|
||||
uint16 flags;
|
||||
union {
|
||||
void *p;
|
||||
uint8 b[8];
|
||||
} cookie;
|
||||
union {
|
||||
uint32 dcb_start;
|
||||
struct {
|
||||
uint32 tx;
|
||||
uint32 rx;
|
||||
} seqno;
|
||||
} data;
|
||||
} kcom_dma_info_t;
|
||||
|
||||
/* Default channel configuration */
|
||||
#define KCOM_DMA_TX_CHAN 0
|
||||
#define KCOM_DMA_RX_CHAN 1
|
||||
|
||||
|
||||
#define KCOM_ETH_HW_T_RESET 1
|
||||
#define KCOM_ETH_HW_T_INIT 2
|
||||
#define KCOM_ETH_HW_T_OTHER 3
|
||||
|
||||
#define KCOM_ETH_HW_C_ALL 0xff
|
||||
|
||||
#define KCOM_ETH_HW_RESET_F_TX (1U << 0)
|
||||
#define KCOM_ETH_HW_RESET_F_RX (1U << 1)
|
||||
#define KCOM_ETH_HW_RESET_F_TX_RECLAIM (1U << 2)
|
||||
#define KCOM_ETH_HW_RESET_F_RX_RECLAIM (1U << 3)
|
||||
|
||||
#define KCOM_ETH_HW_INIT_F_TX (1U << 0)
|
||||
#define KCOM_ETH_HW_INIT_F_RX (1U << 1)
|
||||
#define KCOM_ETH_HW_INIT_F_RX_FILL (1U << 2)
|
||||
|
||||
|
||||
#define KCOM_ETH_HW_OTHER_F_FIFO_LOOPBACK (1U << 0)
|
||||
#define KCOM_ETH_HW_OTHER_F_INTERRUPT (1U << 1)
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct kcom_eth_hw_config_s {
|
||||
uint8 type;
|
||||
uint8 chan;
|
||||
uint32 flags;
|
||||
uint32 value;
|
||||
} kcom_eth_hw_config_t;
|
||||
|
||||
/*
|
||||
* Message types
|
||||
*/
|
||||
|
||||
/*
|
||||
* Request KCOM interface version of kernel module.
|
||||
*/
|
||||
typedef struct kcom_msg_version_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint32 version;
|
||||
uint32 netif_max;
|
||||
uint32 filter_max;
|
||||
} kcom_msg_version_t;
|
||||
|
||||
/*
|
||||
* Send literal string to/from kernel module.
|
||||
* Mainly for debugging purposes.
|
||||
*/
|
||||
#define KCOM_MSG_STRING_MAX 128
|
||||
|
||||
typedef struct kcom_msg_string_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint32 len;
|
||||
char val[KCOM_MSG_STRING_MAX];
|
||||
} kcom_msg_string_t;
|
||||
|
||||
|
||||
/*
|
||||
* Indicate that eth hardware is about to be reset. Active
|
||||
* DMA operations should be aborted and DMA and interrupts
|
||||
* should be disabled.
|
||||
*/
|
||||
/*
|
||||
* Indicate that eth hardware has been properly initialized
|
||||
* for DMA operation to commence.
|
||||
*/
|
||||
typedef struct kcom_msg_eth_hw_config_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_eth_hw_config_t config;
|
||||
} kcom_msg_eth_hw_config_t;
|
||||
|
||||
|
||||
/*
|
||||
* Indicate that switch hardware is about to be reset. Active
|
||||
* DMA operations should be aborted and DMA and interrupts
|
||||
* should be disabled.
|
||||
*/
|
||||
typedef struct kcom_msg_hw_reset_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint32 channels;
|
||||
} kcom_msg_hw_reset_t;
|
||||
|
||||
/*
|
||||
* Indicate that switch hardware has been properly initialized
|
||||
* for DMA operation to commence.
|
||||
*/
|
||||
typedef struct kcom_msg_hw_init_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint16 dcb_size;
|
||||
uint16 dcb_type;
|
||||
uint32 cdma_channels;
|
||||
} kcom_msg_hw_init_t;
|
||||
|
||||
/*
|
||||
* Release blocked IOCTL threads and clean up as necessary.
|
||||
*/
|
||||
typedef struct kcom_msg_detach_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint32 flags;
|
||||
} kcom_msg_detach_t;
|
||||
|
||||
/*
|
||||
* Enable/Disable debugging packet function.
|
||||
*/
|
||||
typedef struct kcom_msg_dbg_pkt_set_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
int enable;
|
||||
} kcom_msg_dbg_pkt_set_t;
|
||||
|
||||
/*
|
||||
* Get debugging packet function info.
|
||||
*/
|
||||
typedef struct kcom_msg_dbg_pkt_get_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
int value;
|
||||
} kcom_msg_dbg_pkt_get_t;
|
||||
|
||||
/*
|
||||
* Create new system network interface. The network interface will
|
||||
* be associated with the specified switch unit number.
|
||||
* The interface id and name will be assigned by the kernel module.
|
||||
*/
|
||||
typedef struct kcom_msg_netif_create_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_netif_t netif;
|
||||
} kcom_msg_netif_create_t;
|
||||
|
||||
/*
|
||||
* Destroy system network interface.
|
||||
*/
|
||||
typedef struct kcom_msg_netif_destroy_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
} kcom_msg_netif_destroy_t;
|
||||
|
||||
/*
|
||||
* Get list of currently defined system network interfaces.
|
||||
*/
|
||||
#ifndef KCOM_NETIF_MAX
|
||||
#define KCOM_NETIF_MAX 128
|
||||
#endif
|
||||
|
||||
typedef struct kcom_msg_netif_list_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint32 ifcnt;
|
||||
uint16 id[KCOM_NETIF_MAX];
|
||||
} kcom_msg_netif_list_t;
|
||||
|
||||
/*
|
||||
* Get detailed network interface information.
|
||||
*/
|
||||
typedef struct kcom_msg_netif_get_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_netif_t netif;
|
||||
} kcom_msg_netif_get_t;
|
||||
|
||||
/*
|
||||
* Create new packet filter.
|
||||
* The filter id will be assigned by the kernel module.
|
||||
*/
|
||||
typedef struct kcom_msg_filter_create_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_filter_t filter;
|
||||
} kcom_msg_filter_create_t;
|
||||
|
||||
/*
|
||||
* Destroy packet filter.
|
||||
*/
|
||||
typedef struct kcom_msg_filter_destroy_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
} kcom_msg_filter_destroy_t;
|
||||
|
||||
/*
|
||||
* Get list of currently defined packet filters.
|
||||
*/
|
||||
#ifndef KCOM_FILTER_MAX
|
||||
/* OPENNSL_FIXUP - Increased the filters to 1024 from 128 */
|
||||
#define KCOM_FILTER_MAX 1024
|
||||
#endif
|
||||
|
||||
typedef struct kcom_msg_filter_list_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
uint32 fcnt;
|
||||
uint16 id[KCOM_FILTER_MAX];
|
||||
} kcom_msg_filter_list_t;
|
||||
|
||||
/*
|
||||
* Get detailed packet filter information.
|
||||
*/
|
||||
typedef struct kcom_msg_filter_get_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_filter_t filter;
|
||||
} kcom_msg_filter_get_t;
|
||||
|
||||
/*
|
||||
* DMA info
|
||||
*/
|
||||
typedef struct kcom_msg_dma_info_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_dma_info_t dma_info;
|
||||
} kcom_msg_dma_info_t;
|
||||
|
||||
|
||||
/*
|
||||
* All messages (e.g. for generic receive)
|
||||
*/
|
||||
|
||||
typedef union kcom_msg_s {
|
||||
kcom_msg_hdr_t hdr;
|
||||
kcom_msg_version_t version;
|
||||
kcom_msg_string_t string;
|
||||
kcom_msg_hw_reset_t hw_reset;
|
||||
kcom_msg_hw_init_t hw_init;
|
||||
kcom_msg_eth_hw_config_t eth_hw_config;
|
||||
kcom_msg_detach_t detach;
|
||||
kcom_msg_netif_create_t netif_create;
|
||||
kcom_msg_netif_destroy_t netif_destroy;
|
||||
kcom_msg_netif_list_t netif_list;
|
||||
kcom_msg_netif_get_t netif_get;
|
||||
kcom_msg_filter_create_t filter_create;
|
||||
kcom_msg_filter_destroy_t filter_destroy;
|
||||
kcom_msg_filter_list_t filter_list;
|
||||
kcom_msg_filter_get_t filter_get;
|
||||
kcom_msg_dma_info_t dma_info;
|
||||
kcom_msg_dbg_pkt_set_t dbg_pkt_set;
|
||||
kcom_msg_dbg_pkt_get_t dbg_pkt_get;
|
||||
} kcom_msg_t;
|
||||
|
||||
|
||||
/*
|
||||
* KCOM communication channel vectors
|
||||
*
|
||||
* open
|
||||
* Open KCOM channel.
|
||||
*
|
||||
* close
|
||||
* Close KCOM channel.
|
||||
*
|
||||
* send
|
||||
* Send KCOM message. If bufsz is non-zero, a synchronous send will be
|
||||
* performed (if supported) and the function will return the number of
|
||||
* bytes in the response.
|
||||
*
|
||||
* recv
|
||||
* Receive KCOM message. This function is used t oreceive unsolicited
|
||||
* messages from the kernel. If synchronous send is not supported, this
|
||||
* function is also used to retrieve responses to command messages.
|
||||
*/
|
||||
|
||||
typedef struct kcom_chan_s {
|
||||
void *(*open)(char *name);
|
||||
int (*close)(void *handle);
|
||||
int (*send)(void *handle, void *msg, unsigned int len, unsigned int bufsz);
|
||||
int (*recv)(void *handle, void *msg, unsigned int bufsz);
|
||||
} kcom_chan_t;
|
||||
|
||||
#endif /* _KCOM_H */
|
39
platform/broadcom/saibcm-modules/include/sal/core/sync.h
Normal file
39
platform/broadcom/saibcm-modules/include/sal/core/sync.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: sync.h,v 1.1 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef _SAL_SYNC_H
|
||||
#define _SAL_SYNC_H
|
||||
|
||||
typedef struct sal_sem_s{
|
||||
char sal_opaque_type;
|
||||
} *sal_sem_t;
|
||||
|
||||
#define sal_sem_FOREVER (-1)
|
||||
#define sal_sem_BINARY 1
|
||||
#define sal_sem_COUNTING 0
|
||||
|
||||
sal_sem_t sal_sem_create(char *desc, int binary, int initial_count);
|
||||
void sal_sem_destroy(sal_sem_t b);
|
||||
int sal_sem_take(sal_sem_t b, int usec);
|
||||
int sal_sem_give(sal_sem_t b);
|
||||
|
||||
#endif /* !_SAL_SYNC_H */
|
31
platform/broadcom/saibcm-modules/include/sal/core/thread.h
Normal file
31
platform/broadcom/saibcm-modules/include/sal/core/thread.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: thread.h,v 1.1 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef _SAL_THREAD_H
|
||||
#define _SAL_THREAD_H
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
void sal_usleep(uint32 usec);
|
||||
void sal_udelay(uint32 usec);
|
||||
|
||||
#endif /* !_SAL_THREAD_H */
|
156
platform/broadcom/saibcm-modules/include/sal/types.h
Normal file
156
platform/broadcom/saibcm-modules/include/sal/types.h
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: types.h,v 1.3 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
* File: types.h
|
||||
* Purpose: SAL type definitions
|
||||
*/
|
||||
|
||||
#ifndef _SAL_TYPES_H
|
||||
#define _SAL_TYPES_H
|
||||
|
||||
/*
|
||||
* Define platform-independent types
|
||||
*/
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef DONT_CARE
|
||||
#define DONT_CARE 0
|
||||
#endif
|
||||
|
||||
#define VOL volatile
|
||||
|
||||
/*
|
||||
* 64-bit type
|
||||
*/
|
||||
|
||||
#ifdef LONGS_ARE_64BITS
|
||||
|
||||
#define COMPILER_64BIT
|
||||
#define COMPILER_UINT64 unsigned long
|
||||
#define u64_H(v) (((uint32 *) &(v))[u64_MSW])
|
||||
#define u64_L(v) (((uint32 *) &(v))[u64_LSW])
|
||||
|
||||
#else /* !LONGS_ARE_64BITS */
|
||||
|
||||
#define COMPILER_64BIT
|
||||
#define COMPILER_UINT64 unsigned long long
|
||||
#define u64_H(v) (((uint32 *) &(v))[u64_MSW])
|
||||
#define u64_L(v) (((uint32 *) &(v))[u64_LSW])
|
||||
|
||||
#endif /* LONGS_ARE_64BITS */
|
||||
|
||||
/*
|
||||
* Define unsigned and signed integers with guaranteed sizes.
|
||||
* Adjust if your compiler uses different sizes for short or int.
|
||||
*/
|
||||
|
||||
typedef unsigned char uint8; /* 8-bit quantity */
|
||||
typedef unsigned short uint16; /* 16-bit quantity */
|
||||
typedef unsigned int uint32; /* 32-bit quantity */
|
||||
typedef COMPILER_UINT64 uint64; /* 64-bit quantity */
|
||||
|
||||
typedef signed char int8; /* 8-bit quantity */
|
||||
typedef signed short int16; /* 16-bit quantity */
|
||||
typedef signed int int32; /* 32-bit quantity */
|
||||
|
||||
#define BITS2BYTES(x) (((x) + 7) / 8)
|
||||
#define BITS2WORDS(x) (((x) + 31) / 32)
|
||||
|
||||
#define BYTES2BITS(x) ((x) * 8)
|
||||
#define BYTES2WORDS(x) (((x) + 3) / 4)
|
||||
|
||||
#define WORDS2BITS(x) ((x) * 32)
|
||||
#define WORDS2BYTES(x) ((x) * 4)
|
||||
|
||||
#define COUNTOF(ary) ((int) (sizeof (ary) / sizeof ((ary)[0])))
|
||||
|
||||
typedef uint32 sal_paddr_t; /* Physical address (PCI address) */
|
||||
|
||||
#ifdef PTRS_ARE_64BITS
|
||||
typedef uint64 sal_vaddr_t; /* Virtual address (Host address) */
|
||||
#define PTR_TO_INT(x) ((uint32)(((sal_vaddr_t)(x))&0xFFFFFFFF))
|
||||
#else
|
||||
typedef uint32 sal_vaddr_t; /* Virtual address (Host address) */
|
||||
#define PTR_TO_INT(x) ((uint32)(x))
|
||||
#endif
|
||||
|
||||
#define INT_TO_PTR(x) ((void *)((sal_vaddr_t)(x)))
|
||||
|
||||
#define PTR_TO_UINTPTR(x) ((sal_vaddr_t)(x))
|
||||
#define UINTPTR_TO_PTR(x) ((void *)(x))
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8 u8;
|
||||
uint16 u16;
|
||||
uint32 u32;
|
||||
uint64 u64;
|
||||
sal_paddr_t paddr;
|
||||
sal_vaddr_t vaddr;
|
||||
void *ptr;
|
||||
} any_t;
|
||||
|
||||
/* Device bus types */
|
||||
#define SAL_PCI_DEV_TYPE 0x00001 /* PCI device */
|
||||
#define SAL_SPI_DEV_TYPE 0x00002 /* SPI device */
|
||||
#define SAL_EB_DEV_TYPE 0x00004 /* EB device */
|
||||
#define SAL_ICS_DEV_TYPE 0x00008 /* ICS device */
|
||||
#define SAL_MII_DEV_TYPE 0x00010 /* MII device */
|
||||
#define SAL_RCPU_DEV_TYPE 0x00020 /* RCPU device */
|
||||
#define SAL_I2C_DEV_TYPE 0x00040 /* I2C device */
|
||||
#define SAL_AXI_DEV_TYPE 0x00080 /* AXI device */
|
||||
#define SAL_EMMI_DEV_TYPE 0x10000 /* EMMI device */
|
||||
#define SAL_DEV_BUS_TYPE_MASK 0xf00ff /* Odd for historical reasons */
|
||||
|
||||
/* Device types */
|
||||
#define SAL_SWITCH_DEV_TYPE 0x00100 /* Switch device */
|
||||
#define SAL_ETHER_DEV_TYPE 0x00200 /* Ethernet device */
|
||||
#define SAL_CPU_DEV_TYPE 0x00400 /* CPU device */
|
||||
#define SAL_DEV_TYPE_MASK 0x00f00
|
||||
|
||||
/* Access types */
|
||||
#define SAL_DEV_BUS_RD_16BIT 0x01000 /* 16 bit reads on bus */
|
||||
#define SAL_DEV_BUS_WR_16BIT 0x02000 /* 16 bit writes on bus */
|
||||
#define SAL_DEV_BUS_ALT 0x04000 /* Alternate access */
|
||||
#define SAL_DEV_BUS_MSI 0x08000 /* Message-signaled interrupts */
|
||||
#define SAL_DEV_FLAG_MASK 0x0f000
|
||||
|
||||
/* BDE reserved mask (cannot be used by SAL) */
|
||||
#define SAL_DEV_BDE_MASK 0xff000000
|
||||
|
||||
/* Backward compatibility */
|
||||
#define SAL_ET_DEV_TYPE SAL_MII_DEV_TYPE
|
||||
|
||||
/* Special access addresses */
|
||||
#define SAL_DEV_OP_EMMI_INIT 0x0fff1000
|
||||
|
||||
#endif /* !_SAL_TYPES_H */
|
46
platform/broadcom/saibcm-modules/include/sdk_config.h
Normal file
46
platform/broadcom/saibcm-modules/include/sdk_config.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: sdk_config.h,v 1.5 Broadcom SDK $
|
||||
* $Copyright: (c) 2006 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SDK_CONFIG_H__
|
||||
#define __SDK_CONFIG_H__
|
||||
|
||||
/*
|
||||
* Include custom overrides
|
||||
*/
|
||||
#ifdef SDK_INCLUDE_CUSTOM_CONFIG
|
||||
#include <sdk_custom_config.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Memory Barrier operation if required.
|
||||
* Defaults to nothing.
|
||||
*/
|
||||
#ifndef SDK_CONFIG_MEMORY_BARRIER
|
||||
#define SDK_CONFIG_MEMORY_BARRIER
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* __SDK_CONFIG_H__ */
|
38
platform/broadcom/saibcm-modules/include/soc/cmic.h
Normal file
38
platform/broadcom/saibcm-modules/include/soc/cmic.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: cmic.h,v 1.1 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
* File: cmic.h
|
||||
* Purpose: Maps out structures used for CMIC operations and
|
||||
* exports routines and constants.
|
||||
*/
|
||||
|
||||
#ifndef _SOC_CMIC_H
|
||||
#define _SOC_CMIC_H
|
||||
|
||||
/* IRQ Register (RO) */
|
||||
#define CMIC_IRQ_STAT 0x00000144
|
||||
|
||||
/* IRQ Mask Registers (R/W) */
|
||||
#define CMIC_IRQ_MASK 0x00000148
|
||||
#define CMIC_IRQ_MASK_1 0x0000006C
|
||||
#define CMIC_IRQ_MASK_2 0x00000070
|
||||
|
||||
#endif /* !_SOC_CMIC_H */
|
1948
platform/broadcom/saibcm-modules/include/soc/devids.h
Normal file
1948
platform/broadcom/saibcm-modules/include/soc/devids.h
Normal file
File diff suppressed because it is too large
Load Diff
364
platform/broadcom/saibcm-modules/make/Make.config
Normal file
364
platform/broadcom/saibcm-modules/make/Make.config
Normal file
@ -0,0 +1,364 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Make.config,v 1.3 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
|
||||
ifneq ($(strip $(override-target)),)
|
||||
override TARGET=$(override-target)
|
||||
endif
|
||||
|
||||
export TARGET
|
||||
|
||||
#
|
||||
# Set up the target name, and the target base variables.
|
||||
#
|
||||
# target = The full name of the target such as vxworks-bmw
|
||||
# targetbase = 1st part of target (e.g. vxworks)
|
||||
# targetplat = 2nd part of target (e.g. x86) if any; otherwise same as 1st
|
||||
#
|
||||
target = ${TARGET}
|
||||
targetsplt = $(subst -, , ${target}) # change hyphens to spaces
|
||||
targetbase = $(word 1,${targetsplt})
|
||||
targetplat = $(subst ${targetbase}-,,${TARGET})
|
||||
|
||||
#
|
||||
# Common configuration for all platforms
|
||||
# (Additional platform-dependent configurations are in Makefile.xxx)
|
||||
#
|
||||
|
||||
#
|
||||
# THIS FILE SHOULD NOT BE MODIFIED LOCALLY, to override, add a file
|
||||
# $SDK/make/Make.local that sets your local settings, and/or provide
|
||||
# a path to your settings using the MAKE_LOCAL variable. If
|
||||
# either of these files exists, their values will override those in this makefile.
|
||||
#
|
||||
ifdef MAKE_LOCAL
|
||||
-include ${MAKE_LOCAL}
|
||||
endif
|
||||
|
||||
-include ${SDK}/make/Make.local
|
||||
|
||||
ifdef ALL_CHIPS
|
||||
ROBO_CHIPS = 1
|
||||
ESW_CHIPS = 1
|
||||
else
|
||||
ifndef ROBO_CHIPS
|
||||
ESW_CHIPS = 1
|
||||
endif
|
||||
endif # ALL_CHIPS
|
||||
|
||||
#
|
||||
# By default, turn off the "changing directory" message.
|
||||
#
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
#
|
||||
# Use gmake by default
|
||||
#
|
||||
|
||||
include ${SDK}/make/Make.tools
|
||||
include ${SDK}/make/Makefile.${target}
|
||||
|
||||
# use QUIET=1 to control printing of compilation lines
|
||||
ifdef QUIET
|
||||
Q:=@
|
||||
else
|
||||
Q:=
|
||||
endif
|
||||
|
||||
#
|
||||
# Suffix to add to the "target" files to allow local builds with different
|
||||
# flags. Set "target_suffix" to XXX to cause the build to put built objects
|
||||
# in ${target}${target_suffix}. This allows things like building a debug
|
||||
# version with different flags. This may also be set in another Makefile.
|
||||
#
|
||||
|
||||
#target_suffix :=
|
||||
|
||||
#
|
||||
# Optional suffix to add to the build directory and output binary files
|
||||
# to allow multiple builds to co-exist for various reasons.
|
||||
#
|
||||
#chip_suffix := -$(shell echo $(CHIP) | tr A-Z a-z)
|
||||
|
||||
#
|
||||
# Combined suffixes
|
||||
#
|
||||
all_suffix = ${chip_suffix}${target_suffix}
|
||||
|
||||
#
|
||||
# Default location to place binaries and make depend files for building
|
||||
# purposes.
|
||||
#
|
||||
ifeq "$(HOSTTYPE)" "Windows2000PC"
|
||||
BLDROOTWITHDRIVE = ${SDK}/build/${target}${all_suffix}${bldroot_suffix}
|
||||
BLDROOT = ${SDK_NO_DRIVE_NAME}/build/${target}${all_suffix}${bldroot_suffix}
|
||||
else # ifeq "$(HOSTTYPE)" "Windows2000PC"
|
||||
|
||||
ifndef SDKBUILD
|
||||
SDKBUILD :=build
|
||||
endif
|
||||
|
||||
BLDROOT = ${SDK}/${SDKBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${target}${all_suffix}${bldroot_suffix}
|
||||
|
||||
endif # ifeq "$(HOSTTYPE)" "Windows2000PC"
|
||||
|
||||
# This is needed because we cannot include Make.vxworks before Make.config
|
||||
ifndef DEST_DIR_SUFFIX
|
||||
export DEST_DIR_SUFFIX :=$(subst $(realpath $(SDK))/systems,,$(realpath $(CURDIR)/$(dir ($(firstword $(MAKEFILE_LIST))))))
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(DEST_DIR),)
|
||||
export DEST_DIR :=${SDK}/${SDKBUILD}$(if ${BLDCONFIG},/${BLDCONFIG})$(DEST_DIR_SUFFIX)
|
||||
endif
|
||||
|
||||
ifdef LOCALDIR
|
||||
BLDDIR = ${BLDROOT}/${LOCALDIR}
|
||||
ifeq "$(HOSTTYPE)" "Windows2000PC"
|
||||
BLDDIRWITHDRIVE = ${BLDROOTWITHDRIVE}/${LOCALDIR}
|
||||
endif
|
||||
else # ifdef LOCALDIR
|
||||
BLDDIR = ${BLDROOT}
|
||||
ifeq "$(HOSTTYPE)" "Windows2000PC"
|
||||
BLDDIRWITHDRIVE = ${BLDROOTWITHDRIVE}
|
||||
endif
|
||||
endif # ifdef LOCALDIR
|
||||
|
||||
LIBDIR = ${BLDROOT}
|
||||
|
||||
#
|
||||
# Export directory, where build objects used by the outside world are
|
||||
# placed (exported header files, libs, bins)
|
||||
#
|
||||
EXPDIR = ${SDK}/export/${target}${all_suffix}
|
||||
|
||||
#
|
||||
# Standard include paths
|
||||
#
|
||||
INCDIR = ${SDK}/include
|
||||
|
||||
#
|
||||
# Compilation Flags
|
||||
#
|
||||
# Flags may be added to (see below)
|
||||
#
|
||||
|
||||
INCFLAGS = -I${INCDIR} -I${SDK}/systems
|
||||
|
||||
CFLAGS += ${INCFLAGS}
|
||||
CXXFLAGS += ${INCFLAGS}
|
||||
CPPFLAGS += ${INCFLAGS}
|
||||
|
||||
#
|
||||
# Debug #ifdef control
|
||||
#
|
||||
# Compiling out #ifdef DEBUG code saves about 1.3% on executable size.
|
||||
# It is recommended to leave debug enabled when developing applications.
|
||||
#
|
||||
ifndef DEBUG_IFDEFS
|
||||
DEBUG_IFDEFS=TRUE
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG_IFDEFS),TRUE)
|
||||
CFLAGS += -DBROADCOM_DEBUG
|
||||
CXXFLAGS += -DBROADCOM_DEBUG
|
||||
CPPFLAGS += -DBROADCOM_DEBUG
|
||||
endif
|
||||
|
||||
#
|
||||
# Debug symbol information control
|
||||
#
|
||||
ifndef DEBUG_SYMBOLS
|
||||
DEBUG_SYMBOLS=TRUE
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG_SYMBOLS),TRUE)
|
||||
CFLAGS += -g
|
||||
CXXFLAGS += -g
|
||||
CPPFLAGS += -g
|
||||
endif
|
||||
|
||||
#
|
||||
# If DEBUG_CFLAGS is set, add its contents to CFLAGS.
|
||||
# May be useful for setting on the command line or adding to Make.local.
|
||||
# Example: gmake DEBUG_CFLAGS=-save-temps system.c
|
||||
#
|
||||
|
||||
ifneq ($(DEBUG_CFLAGS),)
|
||||
CFLAGS += $(DEBUG_CFLAGS)
|
||||
CXXFLAGS += $(DEBUG_CFLAGS)
|
||||
CPPFLAGS += $(DEBUG_CFLAGS)
|
||||
endif
|
||||
|
||||
#
|
||||
# Optimization level
|
||||
#
|
||||
# Set DEBUG_OPTIMIZE to TRUE (default) to use a normal optimization
|
||||
# determined by OPTFLAGS_DEFAULT in the platform Makefile.
|
||||
# Set DEBUG_OPTIMIZE to FALSE to use no optimization,
|
||||
# strongly recommended when using any debugger.
|
||||
# Set DEBUG_OPTIMIZE to any other option string to request specific
|
||||
# optimization flags (for example -O2).
|
||||
#
|
||||
ifndef DEBUG_OPTIMIZE
|
||||
DEBUG_OPTIMIZE=TRUE
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG_OPTIMIZE),TRUE)
|
||||
OPTFLAGS += $(OPTFLAGS_DEFAULT)
|
||||
else
|
||||
ifneq ($(DEBUG_OPTIMIZE),FALSE)
|
||||
OPTFLAGS += $(DEBUG_OPTIMIZE)
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Debug assertion control.
|
||||
#
|
||||
# Compiling out assert() saves about 1.1% on executable size,
|
||||
# however doing so is VERY MUCH discouraged.
|
||||
#
|
||||
ifndef DEBUG_ASSERTS
|
||||
DEBUG_ASSERTS=TRUE
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG_ASSERTS),FALSE)
|
||||
CFLAGS += -DNDEBUG
|
||||
CXXFLAGS += -DNDEBUG
|
||||
CPPFLAGS += -DNDEBUG
|
||||
endif
|
||||
|
||||
#
|
||||
# GCC pedantic mode.
|
||||
#
|
||||
ifeq ($(DEBUG_PEDANTIC),TRUE)
|
||||
CFGFLAGS += -D__PEDANTIC__
|
||||
CFLAGS += --pedantic
|
||||
CXXFLAGS += --pedantic
|
||||
endif
|
||||
|
||||
#
|
||||
# In each directory, build a list of local sources, objects, and headers
|
||||
#
|
||||
LSRCS = $(wildcard *.c *.cpp *.s *.cc *.C)
|
||||
LOBJS = $(addsuffix .o, $(basename ${LSRCS}))
|
||||
BOBJS = $(addprefix ${BLDDIR}/,${LOBJS})
|
||||
LHDRS = $(wildcard *.h *.H)
|
||||
LDOTIS = $(wildcard *.i)
|
||||
|
||||
|
||||
#
|
||||
# Rule to create object file (build) directory
|
||||
#
|
||||
|
||||
.PHONY: all install clean distclean
|
||||
|
||||
.PRECIOUS: ${BLDDIR}/.tree
|
||||
|
||||
%/.tree:
|
||||
@$(ECHO) 'Creating build directory $(dir $@)'
|
||||
@$(MKDIR) $(dir $@)
|
||||
@$(ECHO) "Build Directory for ${LOCALDIR} Created" > $@
|
||||
|
||||
# Rule allowing build through CPP only, creates .E file from .c file.
|
||||
|
||||
%.E: %.c
|
||||
$Q${CC} -E ${CFLAGS} $< | sed -e '/^ *$$/d' -e p -e d > $@
|
||||
|
||||
# Rule allowing build through source only, creates .s file from .c file.
|
||||
|
||||
%.s: %.c
|
||||
$Q${CC} -S ${CFLAGS} $<
|
||||
|
||||
#
|
||||
# Default Build rules for .c --> .o, leaving the binary in BLDDIR/X.o,
|
||||
# even if file not built from directory of source.
|
||||
#
|
||||
ifeq ($(FAST),1)
|
||||
${BLDDIR}/%.o: %.c
|
||||
else
|
||||
ifdef GENERATE_C_FILES
|
||||
${BLDDIR}/%.o: %.c
|
||||
else
|
||||
${BLDDIR}/%.o: %.c
|
||||
endif
|
||||
endif
|
||||
ifdef QUIET
|
||||
@${ECHO} Compiling ${LOCALDIR}/$<
|
||||
endif
|
||||
ifdef LOCAL_D_FILE
|
||||
$Q$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< --write-user-dependencies
|
||||
-@/bin/cp $*.d $(BLDDIR)/$*.d
|
||||
-@/bin/rm -f $*.d
|
||||
else
|
||||
$Q$(CC) -MD -MF $(BLDDIR)/$*.d $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
|
||||
endif
|
||||
@/bin/cp $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp;\
|
||||
/bin/sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
||||
-e '/^$$/ d' -e 's/$$/ :/' \
|
||||
< $(BLDDIR)/$*.d >> $(BLDDIR)/$*.tmp; \
|
||||
/bin/sed \
|
||||
-e 's| \([0-9a-zA-Z]\)| '$(SDK)/$(LOCALDIR)'\/\1|g' \
|
||||
-e 's|^\([0-9a-zA-Z]\)|'$(SDK)/$(LOCALDIR)'/\1|g' \
|
||||
-e 's| \(\.\.\/\)| '$(SDK)/$(LOCALDIR)'\/\1|g' \
|
||||
-e 's|'$(SDK)'|'$$\{SDK\}'|g' \
|
||||
-e 's/\w*\/\.\.\/*//g' \
|
||||
-e 's/\w*\/\.\.\/*//g' \
|
||||
-e 's/\w*\/\.\.\/*//g' \
|
||||
< $(BLDDIR)/$*.tmp > $(BLDDIR)/$*.P; \
|
||||
/bin/rm -f $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp
|
||||
|
||||
${BLDDIR}/%.o: %.s
|
||||
ifdef QUIET
|
||||
@${ECHO} Assembling ${LOCALDIR}/$<
|
||||
endif
|
||||
$Q${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c $< -o $@
|
||||
|
||||
${BLDDIR}/%.o: %.cpp
|
||||
ifdef QUIET
|
||||
@${ECHO} Compiling ${LOCALDIR}/$<
|
||||
endif
|
||||
$Q${CXX} -c ${CXXFLAGS} -c $< -o $@
|
||||
|
||||
${BLDDIR}/%.o: %.cc ${BLDDIR}/.tree
|
||||
ifdef QUIET
|
||||
@${ECHO} Compiling ${LOCALDIR}/$<
|
||||
endif
|
||||
$Q${CXX} -c ${CXXFLAGS} -c $< -o $@
|
||||
|
||||
#
|
||||
# Cause "make foo.o" in any subdirectory to put the object in the build
|
||||
# directory instead of the local directory.
|
||||
#
|
||||
%.o: ${BLDDIR}/%.o
|
||||
@
|
||||
|
||||
#
|
||||
# List of directories where built objects live.
|
||||
# (we are not making the export directories for now)
|
||||
#
|
||||
#DIRS = ${BLDDIR} ${EXPDIR}/lib ${EXPDIR}/bin ${EXPDIR}/include
|
||||
DIRS = ${BLDDIR}
|
||||
|
||||
ifeq (C_COMPILER,$(MAKECMDGOALS))
|
||||
C_COMPILER:
|
||||
@echo $(CC)
|
||||
endif
|
109
platform/broadcom/saibcm-modules/make/Make.depend
Normal file
109
platform/broadcom/saibcm-modules/make/Make.depend
Normal file
@ -0,0 +1,109 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Make.depend,v 1.14 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Default rule to build dependencies. This builds a x.d file for each
|
||||
# x.c file that describes the dependencies. We then conditionally include
|
||||
# the generated .d files.
|
||||
#
|
||||
|
||||
#
|
||||
# If making 'clean', do not include any .d files. If they are included,
|
||||
# gmake intrinsically tries to remake them all.
|
||||
#
|
||||
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
|
||||
|
||||
ZFS :=$(wildcard *.zf)
|
||||
ZFC := $(ZFS:.zf=.c)
|
||||
|
||||
ifdef GENERATE_C_FILES
|
||||
ifndef GEN_INCS
|
||||
$(error "GEN_INCS was not defined")
|
||||
endif
|
||||
|
||||
ZF_GEN = ${SDK}/tools/zFrameCodeGen.pl
|
||||
|
||||
# 1=.zf
|
||||
define ZFS_RULE
|
||||
$(1:.zf=Console.c) : $(1:.zf=.c)
|
||||
@echo updated $$@ from $$?
|
||||
|
||||
$(1:.zf=.c) : $(1) $(ZF_GEN)
|
||||
@$(PERL) $(ZF_GEN) -s -z . -p . -g $1 -t c
|
||||
@echo generated ${LOCALDIR}/$$@ from $(1)
|
||||
@mv $$(*F).cx $$@
|
||||
@if [ -e $$(*F)Console.cx ] ; then \
|
||||
mv $$(*F)Console.cx $$(*F)Console.c; \
|
||||
echo Created $$(*F)Console.c ;\
|
||||
fi
|
||||
@if [ -e $$(*F)Console.hx ] ; then \
|
||||
echo Created $(GEN_INCS)/$$(*F)Console.hx ;\
|
||||
mv $$(*F)Console.hx $(GEN_INCS)/ ; \
|
||||
fi
|
||||
@mv $$(*F).hx $(GEN_INCS)/
|
||||
endef
|
||||
|
||||
$(foreach zf,$(ZFS),$(eval $(call ZFS_RULE,$(zf))))
|
||||
|
||||
${BLDDIR}/%.P : ${BLDDIR}/.tree %.c
|
||||
|
||||
.PHONY: GENFILES
|
||||
GENFILES: $(ZFC)
|
||||
|
||||
$(BOBJS) : $(ZFC)
|
||||
|
||||
else
|
||||
#
|
||||
# Attempt to build the depend files. If it fails, the depend file is
|
||||
# removed so that it is not included in later builds.
|
||||
#
|
||||
${BLDDIR}/%.P : %.c ${BLDDIR}/.tree
|
||||
@$(ECHO) Dependencies for ${LOCALDIR}/$<
|
||||
|
||||
${BLDDIR}/%.P : %.cc ${BLDDIR}/.tree
|
||||
@$(ECHO) Dependencies for ${LOCALDIR}/$<
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# If there are C or C++ files in this directory, include the
|
||||
# depend files for them.
|
||||
#
|
||||
|
||||
ifeq ($(findstring _COMPILER,$(MAKECMDGOALS))$(findstring variable,$(MAKECMDGOALS)),)
|
||||
ifneq ($(strip ${LSRCS}),)
|
||||
ifneq (,$(findstring .o,$(MAKECMDGOALS)))
|
||||
-include $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.P)) $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.sig))
|
||||
else
|
||||
-include $(addprefix ${BLDDIR}/,$(addsuffix .P,$(basename $(LSRCS)))) $(addprefix ${BLDDIR}/,$(addsuffix .sig,$(basename $(LSRCS))))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
endif # !CLEANING
|
||||
|
||||
clean_d::
|
||||
ifdef QUIET
|
||||
@$(ECHO) Cleaning dependencies for ${LOCALDIR}
|
||||
endif
|
||||
ifdef GENERATE_C_FILES
|
||||
$Q$(RM) $(ZFC:%=$(SDK)/$(LOCALDIR)/%) $(ZFC:%.c=$(SDK)/$(LOCALDIR)/%Console.c)
|
||||
endif
|
||||
|
||||
clean:: clean_d
|
70
platform/broadcom/saibcm-modules/make/Make.kernlib
Normal file
70
platform/broadcom/saibcm-modules/make/Make.kernlib
Normal file
@ -0,0 +1,70 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Make.kernlib,v 1.7 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Make rules/targets for handling libraries
|
||||
|
||||
.SECONDARY:: ${BOBJS}
|
||||
|
||||
targetlibsoname = ${lib}.so.${SHAREDLIBVER}
|
||||
targetlibrealname = ${targetlibsoname}
|
||||
targetlibso = ${LIBDIR}/${targetlibrealname}
|
||||
|
||||
ifeq ($(TOOLS),Borland)
|
||||
|
||||
LIBSUFFIX=lib
|
||||
|
||||
${LIBDIR}/%.lib: ${BORLAND_BOBJS}
|
||||
$(RM) $@
|
||||
$(FOREACH) -subdir "$(LIBDIR)" \
|
||||
"tlib $@ $(foreach obj, $(BORLAND_LOBJS), +-$(obj))"
|
||||
|
||||
else # !Borland
|
||||
|
||||
LIBSUFFIX=a
|
||||
|
||||
${LIBDIR}/%.a: ${BOBJS}
|
||||
ifdef QUIET
|
||||
@$(ECHO) Building library $(notdir $@)
|
||||
endif
|
||||
$Q$(RM) $@
|
||||
$Q$(AR) ${ARFLAGS} $@ $(sort ${BOBJS})
|
||||
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
|
||||
ifeq ($(targetbase),unix)
|
||||
$(CC) -shared -Wl,-soname,${targetlibsoname} -o ${targetlibso} ${BOBJS} -lc
|
||||
endif
|
||||
endif # LINUX_MAKE_SHARED_LIB #
|
||||
endif # !Borland
|
||||
|
||||
targetlib = ${LIBDIR}/${lib}.${LIBSUFFIX}
|
||||
|
||||
all:: ${BLDDIR}/.tree ${targetlib}
|
||||
|
||||
install:: all
|
||||
|
||||
clean::
|
||||
ifdef QUIET
|
||||
@$(ECHO) Cleaning objects for ${LOCALDIR} and ${lib}
|
||||
endif
|
||||
$Q$(RM) ${BOBJS}
|
||||
$Q$(RM) ${targetlib}
|
||||
$Q$(RM) ${targetlibso}
|
||||
|
||||
distclean:: clean
|
||||
|
81
platform/broadcom/saibcm-modules/make/Make.lib
Normal file
81
platform/broadcom/saibcm-modules/make/Make.lib
Normal file
@ -0,0 +1,81 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Make.lib,v 1.14 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Make rules/targets for handling libraries
|
||||
|
||||
.SECONDARY:: ${BOBJS}
|
||||
|
||||
BOBJS_FAST = ${BOBJS}
|
||||
BOBJS_MAKE_CMD =
|
||||
|
||||
ifeq ($(FAST),1)
|
||||
ifneq ($(strip $(BOBJS)),)
|
||||
BOBJS_FAST =
|
||||
BOBJS_ARGS = -j9
|
||||
BOBJS_MAKE_CMD = pwd && make LSRUN=$(SDK)/tools/lsrun.pl $(BOBJS_ARGS) ${BOBJS}
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TOOLS),Borland)
|
||||
|
||||
LIBSUFFIX=lib
|
||||
|
||||
${LIBDIR}/%.lib: ${BORLAND_BOBJS}
|
||||
$(RM) $@
|
||||
$(FOREACH) -subdir "$(LIBDIR)" \
|
||||
"tlib $@ $(foreach obj, $(BORLAND_LOBJS), +-$(obj))"
|
||||
|
||||
else # !Borland
|
||||
|
||||
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
|
||||
LIBSUFFIX=so.${SHAREDLIBVER}
|
||||
else
|
||||
LIBSUFFIX=a
|
||||
endif
|
||||
|
||||
targetlib = ${LIBDIR}/${lib}.${LIBSUFFIX}
|
||||
|
||||
all:: ${BLDDIR}/.tree ${targetlib}
|
||||
|
||||
${LIBDIR}/%.${LIBSUFFIX}: ${BOBJS_FAST}
|
||||
$(BOBJS_MAKE_CMD)
|
||||
ifdef QUIET
|
||||
@$(ECHO) Building library $(notdir $@)
|
||||
endif
|
||||
$Q$(RM) $@
|
||||
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
|
||||
$(CC) -shared -Wl,-soname,${lib}.${LIBSUFFIX}${EXTRA_LIB_LDFLAGS} -o ${targetlib} ${BOBJS} -lc
|
||||
else
|
||||
${Q}cd $(dir $(word 1,${BOBJS}));$(AR) ${ARFLAGS} $@ $(sort $(notdir ${BOBJS}))
|
||||
endif
|
||||
|
||||
endif # !Borland
|
||||
|
||||
|
||||
install:: all
|
||||
|
||||
clean::
|
||||
ifdef QUIET
|
||||
@$(ECHO) Cleaning objects for ${LOCALDIR} and ${lib}
|
||||
endif
|
||||
$Q$(RM) ${BOBJS}
|
||||
$Q$(RM) ${targetlib}
|
||||
|
||||
distclean:: clean
|
98
platform/broadcom/saibcm-modules/make/Make.linux
Normal file
98
platform/broadcom/saibcm-modules/make/Make.linux
Normal file
@ -0,0 +1,98 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
#
|
||||
# $Id: Make.linux,v 1.18 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Common make targets for Linux user and kernel builds included by top
|
||||
# level Linux makefiles
|
||||
#
|
||||
# Variables referenced:
|
||||
#
|
||||
# LINUX_MAKE_FLAGS
|
||||
# Additional flags passed to Make
|
||||
#
|
||||
# LINUX_MAKE_USER
|
||||
# Defined: user build
|
||||
# Undefined: kernel build
|
||||
#
|
||||
# LINUX_MAKE_DIR
|
||||
# Common makefile location, if it is not ../common
|
||||
#
|
||||
#
|
||||
|
||||
export DEST_DIR_SUFFIX :=$(subst $(realpath $(SDK))/systems,,$(realpath $(CURDIR)/$(dir ($(firstword $(MAKEFILE_LIST))))))
|
||||
|
||||
ifeq (,$(kernel_version))
|
||||
kernel_version=2_4
|
||||
endif
|
||||
|
||||
ifndef LINUX_MAKE_SHARED_LIB
|
||||
LINUX_MAKE_SHARED_LIB=0
|
||||
endif
|
||||
|
||||
ifeq (,$(SHAREDLIBVER))
|
||||
SHAREDLIBVER=1
|
||||
endif
|
||||
|
||||
ifndef LINUX_MAKE_DIR
|
||||
ifdef LINUX_MAKE_USER
|
||||
LINUX_MAKE_DIR := $(SDK)/systems/linux/user/common
|
||||
else
|
||||
LINUX_MAKE_DIR := $(SDK)/systems/linux/kernel/common
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef LINUX_MAKE_USER
|
||||
CMD = $(LINUX_MAKE_FLAGS) -C $(LINUX_MAKE_DIR) \
|
||||
platform=$(platform) bldroot_suffix=/$(platform) kernel_version=$(kernel_version) \
|
||||
LINUX_MAKE_SHARED_LIB=$(LINUX_MAKE_SHARED_LIB) SHAREDLIBVER=$(SHAREDLIBVER)
|
||||
else
|
||||
export LINUX_MAKE_KERNEL := 1
|
||||
CMD = $(LINUX_MAKE_FLAGS) -C $(LINUX_MAKE_DIR) \
|
||||
platform=$(platform) kernel_version=$(kernel_version)
|
||||
endif
|
||||
|
||||
ifneq (,$(MIPS_TOOLS_DIR))
|
||||
CMD += MIPS_TOOLS_DIR=$(MIPS_TOOLS_DIR)
|
||||
endif
|
||||
|
||||
ifneq (,$(MIPS_CROSS_COMPILE))
|
||||
CMD += MIPS_CROSS_COMPILE=$(MIPS_CROSS_COMPILE)
|
||||
endif
|
||||
|
||||
ifneq (,$(LINUX_INCLUDE))
|
||||
CMD += LINUX_INCLUDE=$(LINUX_INCLUDE)
|
||||
endif
|
||||
|
||||
# gmake does not understand $(CMD) to be a submake
|
||||
# options are to +$(CMD) or $(MAKE) $(CMD)
|
||||
# trying the latter
|
||||
build:
|
||||
$(MAKE) $(CMD)
|
||||
|
||||
DELIVER clean C_COMPILER CXX_COMPILER variable mod bcm user:
|
||||
$(MAKE) $(CMD) $@
|
||||
|
||||
clean_d: clean
|
||||
|
||||
distclean:
|
||||
$(MAKE) $(CMD) $@
|
||||
|
||||
.PHONY: build clean distclean clean_d DELIVER variable mod bcm user
|
||||
|
2
platform/broadcom/saibcm-modules/make/Make.local
Normal file
2
platform/broadcom/saibcm-modules/make/Make.local
Normal file
@ -0,0 +1,2 @@
|
||||
#Changing value of this Knet filter
|
||||
CFGFLAGS += -UKCOM_FILTER_MAX -DKCOM_FILTER_MAX=256
|
45
platform/broadcom/saibcm-modules/make/Make.subdirs
Normal file
45
platform/broadcom/saibcm-modules/make/Make.subdirs
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Make.subdirs,v 1.8 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Make rules/targets for handling subdirectories
|
||||
|
||||
.PHONY: ${subdirs}
|
||||
|
||||
all:: ${subdirs}
|
||||
ifdef QUIET
|
||||
@$(ECHO) Subdirectory build for ${subdirs}
|
||||
endif
|
||||
|
||||
${subdirs}::
|
||||
$Q$(MAKE) -C $@ kernel_version=$(kernel_version) LINUX_MAKE_SHARED_LIB=${LINUX_MAKE_SHARED_LIB} SHAREDLIBVER=${SHAREDLIBVER}
|
||||
|
||||
ifeq "$(HOSTTYPE)" "Windows2000PC"
|
||||
clean clean_d install distclean::
|
||||
ifdef QUIET
|
||||
@$(ECHO) Subdirectory $@ for ${subdirs}
|
||||
endif
|
||||
$Q$(FOREACH) "$(subdirs)" "${MAKE} -C ## $@"
|
||||
else
|
||||
clean clean_d install distclean::
|
||||
ifdef QUIET
|
||||
@$(ECHO) Subdirectory $@ for ${subdirs}
|
||||
endif
|
||||
@(for name in $(subdirs); do $(MAKE) -C $$name $@; done)
|
||||
endif
|
39
platform/broadcom/saibcm-modules/make/Make.tools
Normal file
39
platform/broadcom/saibcm-modules/make/Make.tools
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Make.tools,v 1.2 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
SYSNAME := $(shell uname -s)
|
||||
HCC ?=/usr/bin/gcc
|
||||
SED = /bin/sed
|
||||
COMPRESS = /usr/bin/compress
|
||||
PERL = /usr/bin/perl
|
||||
LN = /bin/ln
|
||||
HOSTTYPE= i386-linux
|
||||
|
||||
#
|
||||
# Platform Independent
|
||||
#
|
||||
MKTOOL = $(PERL) ${SDK}/tools/mktool.pl
|
||||
RM = $(MKTOOL) -rm
|
||||
MKDIR = $(MKTOOL) -md
|
||||
FOREACH = $(MKTOOL) -foreach
|
||||
CP = $(MKTOOL) -cp
|
||||
MAKEDEP = $(MKTOOL) -dep
|
||||
ECHO = $(MKTOOL) -echo
|
||||
MKBEEP = ${MKTOOL} -beep
|
115
platform/broadcom/saibcm-modules/make/Makefile.linux-gto
Normal file
115
platform/broadcom/saibcm-modules/make/Makefile.linux-gto
Normal file
@ -0,0 +1,115 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-gto-4_4,v 1.42 Broadcom SDK $
|
||||
# $Copyright: (c) 2015 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# User must select one platform from below.
|
||||
ifeq (,$(BUILD_PLATFORM))
|
||||
BUILD_PLATFORM=POWERPC_LINUX
|
||||
endif
|
||||
|
||||
# TOOLCHAIN_BASE_DIR Toolchain base directory for GTO devices
|
||||
# TARGET_ARCHITECTURE Compiler for target architecture
|
||||
# KERNDIR Kernel directory for iPROC-CMICd devices
|
||||
TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/gto
|
||||
TARGET_ARCHITECTURE := powerpc-broadcom-linux-gnuspe
|
||||
KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/current
|
||||
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := $(TARGET_ARCHITECTURE)-
|
||||
endif
|
||||
|
||||
|
||||
# GTO toolchain
|
||||
TOOLCHAIN_BIN_DIR := $(TOOLCHAIN_BASE_DIR)/toolchain/host/usr/bin
|
||||
override PATH := $(TOOLCHAIN_BIN_DIR)/../$(TARGET_ARCHITECTURE)/bin:$(TOOLCHAIN_BIN_DIR):$(PATH)
|
||||
export TOOLCHAIN_BIN_DIR
|
||||
|
||||
|
||||
# Default Linux include directory
|
||||
ifeq (,$(LINUX_INCLUDE))
|
||||
LINUX_INCLUDE := $(KERNDIR)/include
|
||||
endif
|
||||
|
||||
CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1
|
||||
ENDIAN = BE_HOST=1
|
||||
CFGFLAGS += -D$(ENDIAN)
|
||||
CFGFLAGS += -DBCM_PLATFORM_STRING=\"GTO_MPC8548\"
|
||||
CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=32
|
||||
|
||||
# Extra variables.
|
||||
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
|
||||
|
||||
ARCH = powerpc
|
||||
KBUILD_VERBOSE = 1
|
||||
|
||||
export ARCH KBUILD_VERBOSE
|
||||
|
||||
|
||||
# From linux/arch/ppc/Makefile
|
||||
comma = ,
|
||||
basetarget = $(basename $(notdir $@))
|
||||
modname = $(basetarget)
|
||||
|
||||
name-fix = $(subst $(comma),_,$(subst -,_,$1))
|
||||
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
|
||||
modname_flags = $(if $(filter 1,$(words $(modname))),\
|
||||
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
|
||||
|
||||
KFLAG_INCLD = $(TOOLCHAIN_BIN_DIR)/../lib/gcc/$(TARGET_ARCHITECTURE)/4.6.4/include
|
||||
|
||||
ifdef BROADCOM_SVK
|
||||
ifdef BCM_BME3200_B0
|
||||
PLX_PCI2LBUS=1
|
||||
endif
|
||||
ifdef BCM_BM9600_B0
|
||||
PLX_PCI2LBUS=1
|
||||
endif
|
||||
ifeq ($PLX_PCI2LBUS, 1)
|
||||
CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef DPP_CHIPS
|
||||
CFLAGS += -DDUNE_BCM -D__DUNE_GTO_BCM_CPU__ -D__DUNE_LINUX_BCM_CPU_PCIE__ -D__DUNE_LINUX_BCM_CPU_PCP_DMA__
|
||||
CFGFLAGS += -DSOC_CM_FUNCTION
|
||||
endif
|
||||
|
||||
ifdef DFE_CHIPS
|
||||
CFLAGS += -DDUNE_BCM -D__DUNE_GTO_BCM_CPU__ -D__DUNE_LINUX_BCM_CPU_PCIE__
|
||||
CFGFLAGS += -DSOC_CM_FUNCTION
|
||||
endif
|
||||
|
||||
ifdef SHADOW_PLX
|
||||
CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE -DSHADOW_SVK
|
||||
endif
|
||||
|
||||
ifeq (,$(KFLAGS))
|
||||
KFLAGS := -D__KERNEL__ -m32 -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/generated/uapi/linux/version.h -include $(LINUX_INCLUDE)/generated/autoconf.h -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc/include -I$(KERNDIR)/include/asm-powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -msoft-float -pipe -ffixed-r2 -mmultiple -mno-altivec -funit-at-a-time -Wa,-me500 -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring TCL,$(FEATURE_LIST)))
|
||||
#LINK_STATIC = 0
|
||||
#export LINK_STATIC
|
||||
endif
|
||||
|
||||
ifneq ($(targetplat),user)
|
||||
include ${SDK}/make/Makefile.linux-kernel-4_4
|
||||
endif
|
||||
|
271
platform/broadcom/saibcm-modules/make/Makefile.linux-gto-2_6
Normal file
271
platform/broadcom/saibcm-modules/make/Makefile.linux-gto-2_6
Normal file
@ -0,0 +1,271 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-gto-2_6,v 1.42 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# User must select one platform from below.By default WR_LINUX is selected. .
|
||||
ifeq (,$(BUILD_PLATFORM))
|
||||
#BUILD_PLATFORM=ELDK
|
||||
BUILD_PLATFORM=WR_LINUX
|
||||
endif
|
||||
|
||||
# Specify the ELDK version you want to use for building SDK.
|
||||
ifeq (,$(ELDK_VERSION))
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
ELDK_VERSION=4.0
|
||||
endif
|
||||
endif
|
||||
|
||||
# Specify the KERNEL VERSION you want to use for building SDK.
|
||||
ifeq (,$(KERN_VER))
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
KERN_VER=2.6.21.7
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# Specify the Windriver Linux version here.For example '2.0' as shown below.
|
||||
ifeq (WR_LINUX,$(BUILD_PLATFORM))
|
||||
ifeq (,$(WRS_LINUX_VERSION))
|
||||
WRS_LINUX_VERSION=2.0
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
#glibc_small and glibc_std have their own cross-compilation tools and and path for these tools are different as implemented below. To enable glibc_small build, line given below should be uncommented.
|
||||
|
||||
#WRL_GLIBC_SMALL=TRUE
|
||||
|
||||
ifeq (2.0,$(WRS_LINUX_VERSION))
|
||||
ifeq ($(WRL_GLIBC_SMALL),TRUE)
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_small-
|
||||
endif
|
||||
|
||||
KERNDIR ?=/projects/ntsw-tools/linux/wrslinux_2.0/gto/glibc_small/build/linux-2.6.21-standard
|
||||
|
||||
else
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_std-
|
||||
endif
|
||||
|
||||
KERNDIR ?= /projects/ntsw-tools/linux/wrslinux_2.0/gto/glibc_std/build/linux-2.6.21-standard
|
||||
|
||||
endif
|
||||
|
||||
export WRL_GLIBC_SMALL
|
||||
|
||||
# After this point glibc_std and glibc_small share these flags
|
||||
|
||||
WRLINUX_BASE ?=/tools/windriver/linux_ed/2.0_GA/Linux
|
||||
TOOLCHAIN_EXEC_PREFIX=$(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2
|
||||
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_EXEC_PREFIX)
|
||||
WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin
|
||||
WRLINUX_GNU_PATH = $(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2/bin
|
||||
override PATH := $(TOOLCHAIN_EXEC_PREFIX):$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/powerpc-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH)
|
||||
export TOOLCHAIN_EXEC_PREFIX TOOLCHAIN_BIN_DIR WIND_LIC_PROXY
|
||||
endif
|
||||
|
||||
|
||||
ifeq (3.0,$(WRS_LINUX_VERSION))
|
||||
ifeq ($(WRL_GLIBC_SMALL),TRUE)
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_small-
|
||||
endif
|
||||
|
||||
KERNDIR ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_small/build/linux-broadcom_bcm98548xmc-standard-build
|
||||
KERNDIR_STD ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_small/build/linux
|
||||
|
||||
else
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_std-
|
||||
endif
|
||||
|
||||
KERNDIR ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_std_debug/build/linux-broadcom_bcm98548xmc-standard-build
|
||||
KERNDIR_STD ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_std_debug/build/linux
|
||||
|
||||
endif
|
||||
|
||||
export WRL_GLIBC_SMALL
|
||||
|
||||
# After this point glibc_std and glibc_small share these flags
|
||||
|
||||
WRLINUX_BASE ?=/tools/windriver/linux_ed/3.0/Linux
|
||||
TOOLCHAIN_EXEC_PREFIX=$(WRLINUX_BASE)/wrlinux-3.0/layers/wrll-toolchain-4.3-85/powerpc/toolchain/x86-linux2
|
||||
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_EXEC_PREFIX)
|
||||
WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin
|
||||
WRLINUX_GNU_PATH = $(WRLINUX_BASE)/wrlinux-3.0/layers/wrll-toolchain-4.3-85/powerpc/toolchain/x86-linux2/bin
|
||||
override PATH := $(TOOLCHAIN_EXEC_PREFIX):$(KERNDIR_STD)/../../host-cross/bin:$(KERNDIR_STD)/../../host-cross/powerpc-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH)
|
||||
export TOOLCHAIN_EXEC_PREFIX TOOLCHAIN_BIN_DIR WIND_LIC_PROXY
|
||||
|
||||
LINUX_INCLUDE_STD := $(KERNDIR_STD)/include
|
||||
|
||||
endif
|
||||
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
ifeq (2.6.21.7, $(KERN_VER))
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := ppc_85xx-
|
||||
endif
|
||||
|
||||
ifeq (4.0, $(ELDK_VERSION))
|
||||
override PATH := /tools/eldk/4.0/usr/bin:$(PATH)
|
||||
else
|
||||
override PATH := /tools/eldk/4.1/usr/bin:$(PATH)
|
||||
endif
|
||||
KERNDIR ?= /projects/ntsw-tools/linux/eldk/gto_eldk/linux-2.6.21.7
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
ifeq (2.6.24.4, $(KERN_VER))
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := ppc_85xx-
|
||||
endif
|
||||
|
||||
ifeq (4.0, $(ELDK_VERSION))
|
||||
override PATH := /tools/eldk/4.0/usr/bin:$(PATH)
|
||||
else
|
||||
override PATH := /tools/eldk/4.1/usr/bin:$(PATH)
|
||||
endif
|
||||
KERNDIR ?= /projects/ntsw-tools/linux/eldk/gto_eldk/linux-2.6.24.4
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
ifeq (2.6.25, $(KERN_VER))
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := ppc_85xx-
|
||||
endif
|
||||
|
||||
ifeq (4.0, $(ELDK_VERSION))
|
||||
override PATH := /tools/eldk/4.0/usr/bin:$(PATH)
|
||||
else
|
||||
override PATH := /tools/eldk/4.1/usr/bin:$(PATH)
|
||||
endif
|
||||
KERNDIR ?= /projects/ntsw-tools/linux/eldk/gto_eldk/linux-2.6.25
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# Default Linux include directory
|
||||
ifeq (,$(LINUX_INCLUDE))
|
||||
LINUX_INCLUDE := $(KERNDIR)/include
|
||||
endif
|
||||
|
||||
CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1
|
||||
ENDIAN = BE_HOST=1
|
||||
CFGFLAGS += -D$(ENDIAN)
|
||||
CFGFLAGS += -DBCM_PLATFORM_STRING=\"GTO_MPC8548\"
|
||||
CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=32
|
||||
|
||||
# Extra variables.
|
||||
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
|
||||
|
||||
ARCH = powerpc
|
||||
KBUILD_VERBOSE = 1
|
||||
|
||||
export ARCH KBUILD_VERBOSE
|
||||
|
||||
|
||||
# From linux/arch/ppc/Makefile
|
||||
comma = ,
|
||||
basetarget = $(basename $(notdir $@))
|
||||
modname = $(basetarget)
|
||||
|
||||
name-fix = $(subst $(comma),_,$(subst -,_,$1))
|
||||
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
|
||||
modname_flags = $(if $(filter 1,$(words $(modname))),\
|
||||
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
|
||||
|
||||
|
||||
ifeq (,$(KFLAG_INCLD))
|
||||
ifeq (4.0,$(ELDK_VERSION))
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
KFLAG_INCLD = /tools/eldk/4.0/usr/lib/gcc/powerpc-linux/4.0.0/include
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (4.1,$(ELDK_VERSION))
|
||||
ifeq (ELDK,$(BUILD_PLATFORM))
|
||||
KFLAG_INCLD = /tools/eldk/4.1/usr/lib/gcc/powerpc-linux/4.0.0/include
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (2.0,$(WRS_LINUX_VERSION))
|
||||
KFLAG_INCLD = $(WRLINUX_GNU_PATH)/../lib/gcc/powerpc-wrs-linux-gnu/4.1.2/include
|
||||
endif
|
||||
|
||||
ifeq (3.0,$(WRS_LINUX_VERSION))
|
||||
KFLAG_INCLD = $(WRLINUX_GNU_PATH)/../lib/gcc/powerpc-wrs-linux-gnu/4.3.2/include
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef BROADCOM_SVK
|
||||
ifdef BCM_BME3200_B0
|
||||
PLX_PCI2LBUS=1
|
||||
endif
|
||||
ifdef BCM_BM9600_B0
|
||||
PLX_PCI2LBUS=1
|
||||
endif
|
||||
ifeq ($PLX_PCI2LBUS, 1)
|
||||
CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef DPP_CHIPS
|
||||
CFLAGS += -DDUNE_BCM -D__DUNE_LINUX_BCM_CPU_PCP_DMA__
|
||||
CFGFLAGS += -DSOC_CM_FUNCTION
|
||||
endif
|
||||
|
||||
ifdef DFE_CHIPS
|
||||
CFLAGS += -DDUNE_BCM
|
||||
CFGFLAGS += -DSOC_CM_FUNCTION
|
||||
endif
|
||||
|
||||
ifdef SAND_CHIPS
|
||||
CFLAGS += -D__DUNE_GTO_BCM_CPU__ -D__DUNE_LINUX_BCM_CPU_PCIE__
|
||||
endif
|
||||
|
||||
ifdef SHADOW_PLX
|
||||
CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE -DSHADOW_SVK
|
||||
endif
|
||||
|
||||
ifeq (,$(KFLAGS))
|
||||
KFLAGS := -D__KERNEL__ -m32 -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/version.h -include $(LINUX_INCLUDE)/generated/autoconf.h -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc/include -I$(KERNDIR)/include/asm-powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -msoft-float -pipe -ffixed-r2 -mmultiple -mno-altivec -funit-at-a-time -Wa,-me500 -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign
|
||||
endif
|
||||
|
||||
#Wind river Linux 3.0 needs addtional flags
|
||||
ifeq (3.0,$(WRS_LINUX_VERSION))
|
||||
|
||||
# Use MSI interrupts if kernel is compiled with MSI support.
|
||||
#CFLAGS += -DBDE_LINUX_USE_MSI_INTERRUPT
|
||||
KFLAGS += -I$(LINUX_INCLUDE_STD) -I$(KERNDIR_STD)/arch/powerpc -I$(KERNDIR_STD)/arch/powerpc/include -I$(KERNDIR_STD)/include.asm-powerpc -mno-spe
|
||||
endif
|
||||
|
||||
ifneq ($(targetplat),user)
|
||||
include ${SDK}/make/Makefile.linux-kernel-2_6
|
||||
endif
|
93
platform/broadcom/saibcm-modules/make/Makefile.linux-iproc
Normal file
93
platform/broadcom/saibcm-modules/make/Makefile.linux-iproc
Normal file
@ -0,0 +1,93 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-iproc Exp $
|
||||
# $Copyright: (c) 2007 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
# Makefile for iproc-CMICd
|
||||
|
||||
# User must select one platform from below.By default ARM_LINUX is selected. .
|
||||
ifeq (,$(BUILD_PLATFORM))
|
||||
BUILD_PLATFORM=ARM_LINUX
|
||||
endif
|
||||
|
||||
# TOOLCHAIN_BASE_DIR Toolchain base directory for iPROC-CMICd devices
|
||||
# TARGET_ARCHITECTURE Compiler for target architecture
|
||||
# KERNDIR Kernel directory for iPROC-CMICd devices
|
||||
ifeq (BE,$(ENDIAN_MODE))
|
||||
TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/iproc-be/XLDK
|
||||
TARGET_ARCHITECTURE:=armeb-broadcom-linux-uclibcgnueabi
|
||||
KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux
|
||||
else
|
||||
TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/iproc/XLDK
|
||||
TARGET_ARCHITECTURE:= arm-broadcom-linux-uclibcgnueabi
|
||||
KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux
|
||||
endif
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE:= $(TARGET_ARCHITECTURE)-
|
||||
endif
|
||||
|
||||
# arm9tools
|
||||
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_BASE_DIR)/buildroot/host/usr/bin
|
||||
override PATH:=$(TOOLCHAIN_BASE_DIR)/buildroot/host/usr/$(TARGET_ARCHITECTURE)/bin:$(TOOLCHAIN_BIN_DIR):$(PATH)
|
||||
LD_LIBRARY_PATH=$(TOOLCHAIN_BASE_DIR)/buildroot/host/usr/lib
|
||||
|
||||
export TOOLCHAIN_BIN_DIR LD_LIBRARY_PATH
|
||||
|
||||
# Default Linux include directory
|
||||
ifeq (,$(LINUX_INCLUDE))
|
||||
LINUX_INCLUDE := $(KERNDIR)/include
|
||||
endif
|
||||
|
||||
ifeq (BE,$(ENDIAN_MODE))
|
||||
CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1
|
||||
ENDIAN = BE_HOST=1
|
||||
else
|
||||
CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=0
|
||||
ENDIAN = LE_HOST=1
|
||||
endif
|
||||
|
||||
CFGFLAGS += -D$(ENDIAN) -DIPROC_CMICD
|
||||
CFGFLAGS += -DBCM_PLATFORM_STRING=\"IPROC_CMICD\"
|
||||
|
||||
ARCH = arm
|
||||
KBUILD_VERBOSE = 1
|
||||
|
||||
export ARCH KBUILD_VERBOSE
|
||||
|
||||
comma = ,
|
||||
basetarget = $(basename $(notdir $@))
|
||||
modname = $(basetarget)
|
||||
|
||||
# Extra variables.
|
||||
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
|
||||
|
||||
name-fix = $(subst $(comma),_,$(subst -,_,$1))
|
||||
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
|
||||
modname_flags = $(if $(filter 1,$(words $(modname))),\
|
||||
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
|
||||
|
||||
KFLAG_INCLD ?= $(TOOLCHAIN_BASE_DIR)/buildroot/host/usr/lib/gcc/$(TARGET_ARCHITECTURE)/4.9.3/include
|
||||
|
||||
ifeq (,$(KFLAGS))
|
||||
KFLAGS := -D__LINUX_ARM_ARCH__=7 -D__KERNEL__ -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/generated/autoconf.h -I$(KERNDIR)/arch/arm/include -I$(KERNDIR)/arch/arm/include/generated -I$(KERNDIR)/arch/arm/mach-iproc/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -marm -mabi=aapcs-linux -fno-pic -pipe -msoft-float -ffreestanding -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -mlong-calls
|
||||
KFLAGS += -I$(LINUX_INCLUDE)/uapi -I$(LINUX_INCLUDE)/generated/uapi -I$(KERNDIR)/arch/arm/include/uapi -I$(KERNDIR)/arch/arm/include/generated/uapi
|
||||
endif
|
||||
|
||||
ifneq ($(targetplat),user)
|
||||
include ${SDK}/make/Makefile.linux-kernel-3_6
|
||||
endif
|
104
platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14
Normal file
104
platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14
Normal file
@ -0,0 +1,104 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-iproc-3_6,v 1.1 Broadcom SDK $
|
||||
# $Copyright: (c) 2007 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
# Makefile for iproc-CMICd
|
||||
|
||||
# User must select one platform from below.By default ARM_LINUX is selected. .
|
||||
ifeq (,$(BUILD_PLATFORM))
|
||||
BUILD_PLATFORM=ARM_LINUX
|
||||
endif
|
||||
|
||||
# TOOLCHAIN_BASE_DIR Toolchain base directory for iPROC-CMICd devices
|
||||
# TARGET_ARCHITECTURE Compiler for target architecture
|
||||
# KERNDIR Kernel directory for iPROC-CMICd devices
|
||||
ifeq (BE,$(ENDIAN_MODE))
|
||||
TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk37-be/buildroot-2013.11-gcc48-opt-broadcom
|
||||
TARGET_ARCHITECTURE:=armeb-buildroot-linux-gnueabi
|
||||
KERNDIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk37-be/XLDK/kernel/linux
|
||||
else
|
||||
TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk37/XLDK
|
||||
TARGET_ARCHITECTURE:= arm-broadcom-linux-uclibcgnueabi
|
||||
KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux
|
||||
endif
|
||||
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE:= $(TARGET_ARCHITECTURE)-
|
||||
endif
|
||||
|
||||
# arm9tools
|
||||
ifeq (BE,$(ENDIAN_MODE))
|
||||
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_BASE_DIR)/host/usr/bin
|
||||
override PATH:=$(TOOLCHAIN_BASE_DIR)/host/usr/$(TARGET_ARCHITECTURE)/bin:$(TOOLCHAIN_BIN_DIR):$(PATH)
|
||||
LD_LIBRARY_PATH=$(TOOLCHAIN_BASE_DIR)/host/usr/lib
|
||||
else
|
||||
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_BASE_DIR)/buildroot/usr/bin
|
||||
override PATH:=$(TOOLCHAIN_BASE_DIR)/buildroot/usr/$(TARGET_ARCHITECTURE)/bin:$(TOOLCHAIN_BIN_DIR):$(PATH)
|
||||
LD_LIBRARY_PATH=$(TOOLCHAIN_BASE_DIR)/buildroot/usr/lib
|
||||
endif
|
||||
|
||||
export TOOLCHAIN_BIN_DIR LD_LIBRARY_PATH
|
||||
|
||||
# Default Linux include directory
|
||||
ifeq (,$(LINUX_INCLUDE))
|
||||
LINUX_INCLUDE := $(KERNDIR)/include
|
||||
endif
|
||||
|
||||
ifeq (BE,$(ENDIAN_MODE))
|
||||
CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1
|
||||
ENDIAN = BE_HOST=1
|
||||
else
|
||||
CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=0
|
||||
ENDIAN = LE_HOST=1
|
||||
endif
|
||||
|
||||
CFGFLAGS += -D$(ENDIAN) -DIPROC_CMICD
|
||||
CFGFLAGS += -DBCM_PLATFORM_STRING=\"IPROC_CMICD\"
|
||||
|
||||
ARCH = arm
|
||||
KBUILD_VERBOSE = 1
|
||||
|
||||
export ARCH KBUILD_VERBOSE
|
||||
|
||||
comma = ,
|
||||
basetarget = $(basename $(notdir $@))
|
||||
modname = $(basetarget)
|
||||
|
||||
# Extra variables.
|
||||
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
|
||||
|
||||
name-fix = $(subst $(comma),_,$(subst -,_,$1))
|
||||
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
|
||||
modname_flags = $(if $(filter 1,$(words $(modname))),\
|
||||
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
|
||||
|
||||
ifeq (BE,$(ENDIAN_MODE))
|
||||
KFLAG_INCLD ?= $(TOOLCHAIN_BASE_DIR)/host/usr/lib/gcc/$(TARGET_ARCHITECTURE)/4.8.2/include
|
||||
else
|
||||
KFLAG_INCLD ?= $(TOOLCHAIN_BASE_DIR)/buildroot/usr/lib/gcc/$(TARGET_ARCHITECTURE)/4.7.2/include
|
||||
endif
|
||||
|
||||
ifeq (,$(KFLAGS))
|
||||
KFLAGS := -D__LINUX_ARM_ARCH__=7 -D__KERNEL__ -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/generated/autoconf.h -I$(KERNDIR)/arch/arm/include -I$(KERNDIR)/arch/arm/include/generated -I$(KERNDIR)/arch/arm/mach-northstar/include -I$(KERNDIR)/arch/arm/plat-iproc/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -marm -mabi=aapcs-linux -fno-pic -pipe -msoft-float -ffreestanding -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -mlong-calls
|
||||
KFLAGS += -I$(LINUX_INCLUDE)/uapi -I$(LINUX_INCLUDE)/generated/uapi -I$(KERNDIR)/arch/arm/include/uapi -I$(KERNDIR)/arch/arm/include/generated/uapi
|
||||
endif
|
||||
|
||||
ifneq ($(targetplat),user)
|
||||
include ${SDK}/make/Makefile.linux-kernel-3_6
|
||||
endif
|
113
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel
Normal file
113
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel
Normal file
@ -0,0 +1,113 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-kernel,v 1.27 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# Configuration Flags
|
||||
|
||||
# Filter out features that cannot or should not be supported in kernel mode
|
||||
_FEATURE_EXCLUDE_LIST += EDITLINE TCL OOB_RCPU CINT APIMODE DUNE_UI C_UNIT
|
||||
FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST))
|
||||
# Tools
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
|
||||
# Handle differences between gcc 2.x and gcc 3.x
|
||||
gcc-tune-flag = $(shell if ${CC} -dumpspecs | grep mcpu >/dev/null; then echo cpu; else echo tune; fi)
|
||||
|
||||
# Configuration Variables
|
||||
|
||||
# OSType Defines: This defines the type of RTOS or microkernel which you
|
||||
# are compiling the SAL (and its associated driver) for. New platforms
|
||||
# can be created by porting the routines (system.c) to your platform and
|
||||
# adding the define in this Makefile.
|
||||
|
||||
OSTYPE = LINUX
|
||||
|
||||
#
|
||||
# ORIGIN is used to Optionally select different CFLAGS. It is used to import
|
||||
# source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added
|
||||
# to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT
|
||||
# added.
|
||||
#
|
||||
# Default specifies Broadcom
|
||||
#
|
||||
ifndef ORIGIN
|
||||
ORIGIN = Broadcom
|
||||
endif
|
||||
|
||||
#
|
||||
# STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations
|
||||
# BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files
|
||||
# OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of
|
||||
# this Makefile, to define local "Extra" flags.
|
||||
#
|
||||
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE)
|
||||
|
||||
CFGFLAGS += -DNO_FILEIO -DNO_CTRL_C -DNO_MEMTUNE
|
||||
|
||||
CFGFLAGS += -D$(OSTYPE)
|
||||
|
||||
# No user sal for the linux kernel
|
||||
# NO_SAL_APPL=1
|
||||
|
||||
STD_CFLAGS = $(KFLAGS) $(CFGFLAGS)
|
||||
|
||||
|
||||
STD_CPPFLAGS = ${STD_CFLAGS}
|
||||
STD_CXXFLAGS = ${STD_CFLAGS}
|
||||
|
||||
BCM_CFLAGS = -Wall -Werror
|
||||
BCM_CPPFLAGS = ${BCM_CFLAGS}
|
||||
BCM_CXXFLAGS = ${BCM_CFLAGS}
|
||||
|
||||
ifeq (${ORIGIN}, Broadcom)
|
||||
CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
else
|
||||
CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
endif
|
||||
|
||||
#
|
||||
# Ignore pedantic flag for kernel modules
|
||||
#
|
||||
ifdef DEBUG_PEDANTIC
|
||||
DEBUG_PEDANTIC = FALSE
|
||||
endif
|
||||
|
||||
#
|
||||
# DEPEND is used as a command to generate the list of dependencies.
|
||||
# The format of the output must be
|
||||
# "file.o : file.c a/b/c.h d/e/f.h ...",
|
||||
# if it is on multiple lines, each line must end in a backslash.
|
||||
# The output MUST be on standard out.
|
||||
#
|
||||
DEPEND = ${CC} -M $(CFLAGS) $<
|
149
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6
Normal file
149
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6
Normal file
@ -0,0 +1,149 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-kernel-2_6,v 1.40 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# Configuration Flags
|
||||
|
||||
# Filter out features that cannot or should not be supported in kernel mode
|
||||
|
||||
_FEATURE_EXCLUDE_LIST += EDITLINE TCL OOB_RCPU CINT APIMODE DUNE_UI C_UNIT
|
||||
FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST))
|
||||
|
||||
# Tools
|
||||
|
||||
# Conditionally Replaces DEFAULT var
|
||||
ifeq ($(origin CC),default)
|
||||
CC = $(LSRUN) $(CROSS_COMPILE)gcc
|
||||
endif
|
||||
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
endif
|
||||
|
||||
ifeq ($(origin LD),default)
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
endif
|
||||
|
||||
ifeq ($(origin AR),default)
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
endif
|
||||
|
||||
ifeq ($(origin AS),default)
|
||||
AS = $(CROSS_COMPILE)as
|
||||
endif
|
||||
|
||||
ifeq ($(origin ARFLAGS),default)
|
||||
ARFLAGS = -rc
|
||||
endif
|
||||
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
NM = $(CROSS_COMPILE)nm
|
||||
|
||||
# Handle differences between gcc 2.x and gcc 3.x
|
||||
gcc-tune-flag = $(shell if ${CC} -dumpspecs | grep mcpu >/dev/null; then echo cpu; else echo tune; fi)
|
||||
|
||||
# Configuration Variables
|
||||
|
||||
# OSType Defines: This defines the type of RTOS or microkernel which you
|
||||
# are compiling the SAL (and its associated driver) for. New platforms
|
||||
# can be created by porting the routines (system.c) to your platform and
|
||||
# adding the define in this Makefile.
|
||||
|
||||
OSTYPE = LINUX
|
||||
|
||||
#
|
||||
# ORIGIN is used to Optionally select different CFLAGS. It is used to import
|
||||
# source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added
|
||||
# to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT
|
||||
# added.
|
||||
#
|
||||
# Default specifies Broadcom
|
||||
#
|
||||
ifndef ORIGIN
|
||||
ORIGIN = Broadcom
|
||||
endif
|
||||
|
||||
#
|
||||
# STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations
|
||||
# BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files
|
||||
# OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of
|
||||
# this Makefile, to define local "Extra" flags.
|
||||
#
|
||||
|
||||
ifdef IPROC_BUILD
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE) \
|
||||
-I$(KERNDIR)/arch/$(ARCH)
|
||||
else
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE) \
|
||||
-I$(LINUX_INCLUDE)/asm/gcc \
|
||||
-I$(LINUX_INCLUDE)/asm/mach-generic \
|
||||
-I$(KERNDIR)/arch/$(ARCH)
|
||||
endif
|
||||
|
||||
CFGFLAGS += -DNO_FILEIO -DNO_CTRL_C -DNO_MEMTUNE
|
||||
|
||||
CFGFLAGS += -D$(OSTYPE)
|
||||
|
||||
# No user sal for the linux kernel
|
||||
# NO_SAL_APPL=1
|
||||
|
||||
STD_CFLAGS = $(KFLAGS) $(CFGFLAGS)
|
||||
|
||||
|
||||
STD_CPPFLAGS = ${STD_CFLAGS}
|
||||
STD_CXXFLAGS = ${STD_CFLAGS}
|
||||
|
||||
ifndef BCM_CFLAGS
|
||||
BCM_CFLAGS = -Wall -Werror
|
||||
endif
|
||||
|
||||
BCM_CPPFLAGS = ${BCM_CFLAGS}
|
||||
BCM_CXXFLAGS = ${BCM_CFLAGS}
|
||||
|
||||
ifeq (${ORIGIN}, Broadcom)
|
||||
CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
else
|
||||
CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
endif
|
||||
|
||||
#
|
||||
# Ignore pedantic flag for kernel modules
|
||||
#
|
||||
ifdef DEBUG_PEDANTIC
|
||||
DEBUG_PEDANTIC = FALSE
|
||||
endif
|
||||
|
||||
#
|
||||
# DEPEND is used as a command to generate the list of dependencies.
|
||||
# The format of the output must be
|
||||
# "file.o : file.c a/b/c.h d/e/f.h ...",
|
||||
# if it is on multiple lines, each line must end in a backslash.
|
||||
# The output MUST be on standard out.
|
||||
#
|
||||
DEPEND = ${CC} -M $(CFLAGS) $<
|
149
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6
Normal file
149
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6
Normal file
@ -0,0 +1,149 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-kernel-3_6,v 1.2 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# Configuration Flags
|
||||
|
||||
# Filter out features that cannot or should not be supported in kernel mode
|
||||
|
||||
_FEATURE_EXCLUDE_LIST += EDITLINE TCL OOB_RCPU CINT APIMODE DUNE_UI
|
||||
FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST))
|
||||
|
||||
# Tools
|
||||
|
||||
# Conditionally Replaces DEFAULT var
|
||||
ifeq ($(origin CC),default)
|
||||
CC = $(LSRUN) $(CROSS_COMPILE)gcc
|
||||
endif
|
||||
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
endif
|
||||
|
||||
ifeq ($(origin LD),default)
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
endif
|
||||
|
||||
ifeq ($(origin AR),default)
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
endif
|
||||
|
||||
ifeq ($(origin AS),default)
|
||||
AS = $(CROSS_COMPILE)as
|
||||
endif
|
||||
|
||||
ifeq ($(origin ARFLAGS),default)
|
||||
ARFLAGS = -rc
|
||||
endif
|
||||
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
NM = $(CROSS_COMPILE)nm
|
||||
|
||||
# Handle differences between gcc 2.x and gcc 3.x
|
||||
gcc-tune-flag = $(shell if ${CC} -dumpspecs | grep mcpu >/dev/null; then echo cpu; else echo tune; fi)
|
||||
|
||||
# Configuration Variables
|
||||
|
||||
# OSType Defines: This defines the type of RTOS or microkernel which you
|
||||
# are compiling the SAL (and its associated driver) for. New platforms
|
||||
# can be created by porting the routines (system.c) to your platform and
|
||||
# adding the define in this Makefile.
|
||||
|
||||
OSTYPE = LINUX
|
||||
|
||||
#
|
||||
# ORIGIN is used to Optionally select different CFLAGS. It is used to import
|
||||
# source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added
|
||||
# to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT
|
||||
# added.
|
||||
#
|
||||
# Default specifies Broadcom
|
||||
#
|
||||
ifndef ORIGIN
|
||||
ORIGIN = Broadcom
|
||||
endif
|
||||
|
||||
#
|
||||
# STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations
|
||||
# BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files
|
||||
# OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of
|
||||
# this Makefile, to define local "Extra" flags.
|
||||
#
|
||||
|
||||
ifdef IPROC_BUILD
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE) \
|
||||
-I$(KERNDIR)/arch/$(ARCH)
|
||||
else
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE) \
|
||||
-I$(LINUX_INCLUDE)/asm/gcc \
|
||||
-I$(LINUX_INCLUDE)/asm/mach-generic \
|
||||
-I$(KERNDIR)/arch/$(ARCH)
|
||||
endif
|
||||
|
||||
CFGFLAGS += -DNO_FILEIO -DNO_CTRL_C -DNO_MEMTUNE
|
||||
|
||||
CFGFLAGS += -D$(OSTYPE)
|
||||
|
||||
# No user sal for the linux kernel
|
||||
# NO_SAL_APPL=1
|
||||
|
||||
STD_CFLAGS = $(KFLAGS) $(CFGFLAGS)
|
||||
|
||||
|
||||
STD_CPPFLAGS = ${STD_CFLAGS}
|
||||
STD_CXXFLAGS = ${STD_CFLAGS}
|
||||
|
||||
ifndef BCM_CFLAGS
|
||||
BCM_CFLAGS = -Wall -Werror
|
||||
endif
|
||||
|
||||
BCM_CPPFLAGS = ${BCM_CFLAGS}
|
||||
BCM_CXXFLAGS = ${BCM_CFLAGS}
|
||||
|
||||
ifeq (${ORIGIN}, Broadcom)
|
||||
CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
else
|
||||
CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
endif
|
||||
|
||||
#
|
||||
# Ignore pedantic flag for kernel modules
|
||||
#
|
||||
ifdef DEBUG_PEDANTIC
|
||||
DEBUG_PEDANTIC = FALSE
|
||||
endif
|
||||
|
||||
#
|
||||
# DEPEND is used as a command to generate the list of dependencies.
|
||||
# The format of the output must be
|
||||
# "file.o : file.c a/b/c.h d/e/f.h ...",
|
||||
# if it is on multiple lines, each line must end in a backslash.
|
||||
# The output MUST be on standard out.
|
||||
#
|
||||
DEPEND = ${CC} -M $(CFLAGS) $<
|
158
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4
Normal file
158
platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4
Normal file
@ -0,0 +1,158 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-kernel-2_6,v 1.40 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# Configuration Flags
|
||||
|
||||
# Filter out features that cannot or should not be supported in kernel mode
|
||||
|
||||
_FEATURE_EXCLUDE_LIST += EDITLINE TCL OOB_RCPU CINT APIMODE DUNE_UI C_UNIT
|
||||
FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST))
|
||||
|
||||
# Tools
|
||||
|
||||
# Conditionally Replaces DEFAULT var
|
||||
ifeq ($(origin CC),default)
|
||||
CC = $(LSRUN) $(CROSS_COMPILE)gcc
|
||||
endif
|
||||
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
endif
|
||||
|
||||
ifeq ($(origin LD),default)
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
endif
|
||||
|
||||
ifeq ($(origin AR),default)
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
endif
|
||||
|
||||
ifeq ($(origin AS),default)
|
||||
AS = $(CROSS_COMPILE)as
|
||||
endif
|
||||
|
||||
ifeq ($(origin ARFLAGS),default)
|
||||
ARFLAGS = -rc
|
||||
endif
|
||||
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
NM = $(CROSS_COMPILE)nm
|
||||
|
||||
# Handle differences between gcc 2.x and gcc 3.x
|
||||
gcc-tune-flag = $(shell if ${CC} -dumpspecs | grep mcpu >/dev/null; then echo cpu; else echo tune; fi)
|
||||
|
||||
# Configuration Variables
|
||||
|
||||
# OSType Defines: This defines the type of RTOS or microkernel which you
|
||||
# are compiling the SAL (and its associated driver) for. New platforms
|
||||
# can be created by porting the routines (system.c) to your platform and
|
||||
# adding the define in this Makefile.
|
||||
OSTYPE = LINUX
|
||||
|
||||
#
|
||||
# ORIGIN is used to Optionally select different CFLAGS. It is used to import
|
||||
# source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added
|
||||
# to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT
|
||||
# added.
|
||||
#
|
||||
# Default specifies Broadcom
|
||||
#
|
||||
ifndef ORIGIN
|
||||
ORIGIN = Broadcom
|
||||
endif
|
||||
|
||||
#
|
||||
# STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations
|
||||
# BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files
|
||||
# OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of
|
||||
# this Makefile, to define local "Extra" flags.
|
||||
#
|
||||
ifdef IPROC_BUILD
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE) \
|
||||
-I$(LINUX_INCLUDE)/uapi \
|
||||
-I$(LINUX_INCLUDE)/generated/uapi \
|
||||
-I$(KERNDIR)/arch/$(ARCH) \
|
||||
-I$(KERNDIR)/arch/$(ARCH)/include/uapi \
|
||||
-I$(KERNDIR)/arch/$(ARCH)/include/generated \
|
||||
-I$(KERNDIR)/arch/$(ARCH)/include/generated/uapi
|
||||
else
|
||||
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
|
||||
-I$(SDK)/systems/bde/linux/include \
|
||||
-I$(LINUX_INCLUDE) \
|
||||
-I$(LINUX_INCLUDE)/asm/gcc \
|
||||
-I$(LINUX_INCLUDE)/asm/mach-generic \
|
||||
-I$(LINUX_INCLUDE)/uapi \
|
||||
-I$(LINUX_INCLUDE)/generated/uapi \
|
||||
-I$(KERNDIR)/arch/$(ARCH) \
|
||||
-I$(KERNDIR)/arch/$(ARCH)/include/uapi \
|
||||
-I$(KERNDIR)/arch/$(ARCH)/include/generated \
|
||||
-I$(KERNDIR)/arch/$(ARCH)/include/generated/uapi
|
||||
endif
|
||||
|
||||
CFGFLAGS += -DNO_FILEIO -DNO_CTRL_C -DNO_MEMTUNE
|
||||
|
||||
CFGFLAGS += -D$(OSTYPE)
|
||||
|
||||
# No user sal for the linux kernel
|
||||
# NO_SAL_APPL=1
|
||||
|
||||
STD_CFLAGS = $(KFLAGS) $(CFGFLAGS)
|
||||
|
||||
|
||||
STD_CPPFLAGS = ${STD_CFLAGS}
|
||||
STD_CXXFLAGS = ${STD_CFLAGS}
|
||||
|
||||
ifndef BCM_CFLAGS
|
||||
BCM_CFLAGS = -Wall -Werror
|
||||
endif
|
||||
|
||||
BCM_CPPFLAGS = ${BCM_CFLAGS}
|
||||
BCM_CXXFLAGS = ${BCM_CFLAGS}
|
||||
|
||||
ifeq (${ORIGIN}, Broadcom)
|
||||
CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
else
|
||||
CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS}
|
||||
CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS}
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS}
|
||||
endif
|
||||
|
||||
#
|
||||
# Ignore pedantic flag for kernel modules
|
||||
#
|
||||
ifdef DEBUG_PEDANTIC
|
||||
DEBUG_PEDANTIC = FALSE
|
||||
endif
|
||||
|
||||
#
|
||||
# DEPEND is used as a command to generate the list of dependencies.
|
||||
# The format of the output must be
|
||||
# "file.o : file.c a/b/c.h d/e/f.h ...",
|
||||
# if it is on multiple lines, each line must end in a backslash.
|
||||
# The output MUST be on standard out.
|
||||
#
|
||||
DEPEND = ${CC} -M $(CFLAGS) $<
|
||||
|
82
platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule
Normal file
82
platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule
Normal file
@ -0,0 +1,82 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-kmodule-3_6,v 1.2 Broadcom SDK $
|
||||
# $Copyright: (c) 2006 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# Due to the extensive use of driver libraries, the SDK usually builds
|
||||
# kernel modules from a precompiled object. To avoid various warnings
|
||||
# and conflicts, the pre-compiled object must be named differently
|
||||
# from the target module, and the object file itself should be
|
||||
# appended with "_shipped".
|
||||
|
||||
# If a module exports any symbols, then the exporting source file must
|
||||
# be compiled within the kernel source tree for correct generation of
|
||||
# module symbol versions. The symbol source file should be passed to
|
||||
# this Makefile via the MODULE_SYM variable.
|
||||
|
||||
MODULE := $(MOD_NAME).o
|
||||
KMODULE := $(MOD_NAME).ko
|
||||
PRE_COMPILED_OBJ := obj_$(MOD_NAME).o
|
||||
|
||||
obj-m := $(MODULE)
|
||||
$(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ)
|
||||
|
||||
|
||||
ifeq (,$(CROSS_COMPILE))
|
||||
|
||||
export CROSS_COMPILE
|
||||
|
||||
endif
|
||||
|
||||
SAVE_CFLAGS := ${CFLAGS}
|
||||
|
||||
include $(SDK)/make/Make.config
|
||||
|
||||
PWD := $(shell pwd)
|
||||
|
||||
ifneq ($(ARCH),)
|
||||
# ELDK does not seem to `automatically' define ARCH where other gccs may
|
||||
A := ARCH=$(ARCH)
|
||||
export ARCH
|
||||
endif
|
||||
|
||||
# Provide an option in case kernel was built in separate directory
|
||||
KERNBLDDIR ?= $(KERNDIR)
|
||||
|
||||
# Standard SDK include path for building source files that export
|
||||
# kernel symbols.
|
||||
|
||||
override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include
|
||||
|
||||
# The precopiled object needs a dummy command file to avoid warnings
|
||||
# from the Kbuild scripts (modpost stage).
|
||||
# Kernels before 2.6.17 do not support external module symbols files,
|
||||
# so we create a dummy to prevent build failures.
|
||||
|
||||
$(KMODULE):
|
||||
rm -f *.o *.ko .*.cmd
|
||||
rm -fr .tmp_versions
|
||||
ln -s $(LIBDIR)/$(MODULE) $(PRE_COMPILED_OBJ)_shipped
|
||||
echo "suppress warning" > .$(PRE_COMPILED_OBJ).cmd
|
||||
$(MAKE) -C $(KERNBLDDIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
|
||||
if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi
|
||||
cp -f $(KMODULE) $(LIBDIR)
|
||||
rm -f $(PRE_COMPILED_OBJ)_shipped
|
||||
|
||||
EXTRA_CFLAGS = $(CFLAGS)
|
||||
CFLAGS := ${SAVE_CFLAGS}
|
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-x86-common-2_6,v 1.13 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=0
|
||||
ENDIAN = LE_HOST=1
|
||||
CFGFLAGS += -D$(ENDIAN)
|
||||
CFGFLAGS += -DBCM_PLATFORM_STRING=\"X86\"
|
||||
ifeq (,$(findstring -DSAL_BDE_DMA_MEM_DEFAULT,$(CFGFLAGS)))
|
||||
CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=16
|
||||
endif
|
||||
|
||||
# Extra variables.
|
||||
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
|
||||
|
||||
comma = ,
|
||||
basetarget = $(basename $(notdir $@))
|
||||
modname = $(basetarget)
|
||||
|
||||
name-fix = $(subst $(comma),_,$(subst -,_,$1))
|
||||
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
|
||||
modname_flags = $(if $(filter 1,$(words $(modname))),\
|
||||
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
|
||||
|
||||
ifneq ($(targetplat),user)
|
||||
# By default we exclude -Werror from x86 kernel builds
|
||||
BCM_CFLAGS = -Wall
|
||||
include ${SDK}/make/Makefile.linux-kernel-2_6
|
||||
endif
|
@ -0,0 +1,52 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-x86-generic-common-2_6,v 1.2 Broadcom SDK $
|
||||
# $Copyright: (c) 2008 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
# Default kernel source directory
|
||||
ifeq (,$(KERNDIR))
|
||||
KERNDIR := /lib/modules/$(shell uname -r)/build
|
||||
export KERNDIR
|
||||
endif
|
||||
|
||||
# Default architecture
|
||||
ifeq (,$(ARCH))
|
||||
ARCH = $(shell uname -p)
|
||||
ifneq (x86_64,$(ARCH))
|
||||
ARCH = i386
|
||||
endif
|
||||
endif
|
||||
|
||||
# Noisy kernel build
|
||||
KBUILD_VERBOSE = 1
|
||||
|
||||
export ARCH KBUILD_VERBOSE KERNDIR
|
||||
|
||||
# Default Linux include directory
|
||||
ifeq (,$(LINUX_INCLUDE))
|
||||
LINUX_INCLUDE := $(KERNDIR)/include
|
||||
endif
|
||||
|
||||
# autoconf.h was moved in later kernels
|
||||
AUTOCONF = $(KERNDIR)/include/generated/autoconf.h
|
||||
ifeq (,$(shell ls $(AUTOCONF) 2>/dev/null))
|
||||
AUTOCONF = $(KERNDIR)/include/linux/autoconf.h
|
||||
endif
|
||||
|
||||
# gcc system include path
|
||||
SYSINC = $(shell gcc -print-search-dirs | grep install | cut -c 10-)include
|
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# $Id: Makefile.linux-x86-smp_generic_64-2_6,v 1.5 Broadcom SDK $
|
||||
# $Copyright: (c) 2008 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
CFGFLAGS += -DLONGS_ARE_64BITS
|
||||
CFGFLAGS += -DPTRS_ARE_64BITS
|
||||
CFGFLAGS += -DPHYS_ADDRS_ARE_64BITS
|
||||
CFGFLAGS += -DSAL_SPL_LOCK_ON_IRQ
|
||||
|
||||
include ${SDK}/make/Makefile.linux-x86-generic-common-2_6
|
||||
|
||||
ifeq (,$(KFLAGS))
|
||||
KFLAGS := -nostdinc -isystem $(SYSINC) -I$(KERNDIR)/include -I$(KERNDIR)/arch/x86/include -include $(AUTOCONF) -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign
|
||||
endif
|
||||
|
||||
KFLAGS += -I$(LINUX_INCLUDE)/uapi -I$(LINUX_INCLUDE)/generated/uapi -I$(KERNDIR)/arch/x86/include/generated -I$(KERNDIR)/arch/x86/include/uapi -I$(KERNDIR)/arch/x86/include/generated/uapi
|
||||
|
||||
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
|
||||
KFLAGS += -fPIC -mcmodel=small
|
||||
else
|
||||
KFLAGS += -mcmodel=kernel -fno-pie
|
||||
endif
|
||||
|
||||
ifeq (1,$(DEBIAN_LINUX_HEADER))
|
||||
KERNDIR_COMMON := $(subst amd64,common,$(KERNDIR))
|
||||
KFLAGS += -I$(KERNDIR_COMMON)/include -I$(KERNDIR_COMMON)/include/uapi -I$(KERNDIR_COMMON)/arch/x86/include -I$(KERNDIR_COMMON)/arch/x86/include/uapi
|
||||
endif
|
||||
|
||||
include ${SDK}/make/Makefile.linux-x86-common-2_6
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Opennsl kernel modules init
|
||||
After=local-fs.target
|
||||
Before=syncd.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/opennsl-modules-4.9.0-5-amd64 start
|
||||
ExecStop=-/etc/init.d/opennsl-modules-4.9.0-5-amd64 stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,275 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/***********************************************************************
|
||||
*
|
||||
* $Id: linux-bde.h,v 1.24 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
* Linux Broadcom Device Enumerators
|
||||
*
|
||||
*
|
||||
* There are two Linux BDEs:
|
||||
*
|
||||
* 1. Linux Kernel BDE
|
||||
*
|
||||
* This is a kernel module implementing a BDE
|
||||
* for the driver running as part of the kernel.
|
||||
*
|
||||
* It manages the devices through the linux PCI interfaces,
|
||||
* and manages a chunk of contiguous, boot-time allocated
|
||||
* DMA memory. This is all that is needed if the BCM driver
|
||||
* is run as part of the kernel (in another module).
|
||||
*
|
||||
* 2. Linux User BDE
|
||||
*
|
||||
* This is a kernel module and userland library which implement
|
||||
* a complete BDE for applications running in userland.
|
||||
*
|
||||
* The kernel module relies upon the real kernel bde,
|
||||
* and allows a user space application (through the user library)
|
||||
* to talk directly to the devices. It also virtualized the device
|
||||
* interrupts, so the entire driver can be run as a userspace
|
||||
* application.
|
||||
*
|
||||
* While this causes a significant degradation in performance,
|
||||
* because the system runs as a user application, the development
|
||||
* and debugging process is about a gillion times easier.
|
||||
* After the core logic is debugged, it can be retargeted using
|
||||
* only the kernel bde and run in the kernel.
|
||||
*
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __LINUX_BDE_H__
|
||||
#define __LINUX_BDE_H__
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
#include <ibde.h>
|
||||
|
||||
|
||||
/*
|
||||
* Device Major Numbers
|
||||
*
|
||||
* The kernel and user bdes need unique major numbers
|
||||
* on systems that do not use devfs.
|
||||
*
|
||||
* They are defined here, along with the module names,
|
||||
* to document them if you need to mknod them (or open) them,
|
||||
* and to keep them unique.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/types.h>
|
||||
/* Key stone and Raptor has 2.6.21 but don't have definition */
|
||||
#if defined(KEYSTONE) || defined(RAPTOR)
|
||||
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21))
|
||||
#ifdef PHYS_ADDRS_ARE_64BITS
|
||||
typedef u64 phys_addr_t;
|
||||
#else
|
||||
typedef u32 phys_addr_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
|
||||
#define LINUX_BDE_DMA_DEVICE_SUPPORT
|
||||
#endif
|
||||
|
||||
#define LINUX_KERNEL_BDE_NAME "linux-kernel-bde"
|
||||
#define LINUX_KERNEL_BDE_MAJOR 127
|
||||
|
||||
#define LINUX_USER_BDE_NAME "linux-user-bde"
|
||||
#define LINUX_USER_BDE_MAJOR 126
|
||||
|
||||
|
||||
/* Max devices */
|
||||
/* 16 switch chips + 2 out-of-band Ethernet + 2 CPUs */
|
||||
#define LINUX_BDE_MAX_SWITCH_DEVICES 16
|
||||
#define LINUX_BDE_MAX_ETHER_DEVICES 2
|
||||
#define LINUX_BDE_MAX_CPU_DEVICES 2
|
||||
#define LINUX_BDE_MAX_DEVICES (LINUX_BDE_MAX_SWITCH_DEVICES + \
|
||||
LINUX_BDE_MAX_ETHER_DEVICES + \
|
||||
LINUX_BDE_MAX_CPU_DEVICES)
|
||||
|
||||
/*
|
||||
* PCI devices will be initialized by the Linux Kernel,
|
||||
* regardless of architecture.
|
||||
*
|
||||
* You need only provide bus endian settings.
|
||||
*/
|
||||
|
||||
typedef struct linux_bde_bus_s {
|
||||
int be_pio;
|
||||
int be_packet;
|
||||
int be_other;
|
||||
} linux_bde_bus_t;
|
||||
|
||||
|
||||
|
||||
/* Device state used for PCI hot swap case. */
|
||||
/*
|
||||
* BDE_DEV_STATE_NORMAL : A device is probed normally. Or when the device
|
||||
* resource has been updated after "CHANGED", the state will move back to
|
||||
* "NORMAL".
|
||||
*/
|
||||
#define BDE_DEV_STATE_NORMAL (0)
|
||||
/*
|
||||
* BDE_DEV_STATE_REMOVED : A previous probed device was removed.
|
||||
* We will avoid any device access while the device is in this state.
|
||||
* The state will be moved to "CHANGED" if the device is re-inserted
|
||||
* and re-probed.
|
||||
*/
|
||||
#define BDE_DEV_STATE_REMOVED (1)
|
||||
/*
|
||||
* BDE_DEV_STATE_CHANGED : The device is re-probed after having been removed.
|
||||
* The resouces assigned to the device might have been changed after
|
||||
* re-probing, so we need to re-initialize our resource database accordingly.
|
||||
* The state will change to "NORMAL" when the resource have been updated.
|
||||
*/
|
||||
#define BDE_DEV_STATE_CHANGED (2)
|
||||
|
||||
extern int linux_bde_create(linux_bde_bus_t* bus, ibde_t** bde);
|
||||
extern int linux_bde_destroy(ibde_t* bde);
|
||||
#ifdef BCM_INSTANCE_SUPPORT
|
||||
extern int linux_bde_instance_attach(unsigned int dev_mask,unsigned int dma_size);
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/*
|
||||
* Backdoors provided by the kernel bde
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The user bde needs to get cpu physical address for
|
||||
* the userland code to mmap.
|
||||
* And the second address is bus address, it is either
|
||||
* identical to cpu physical address or another address
|
||||
* (IOVA) translated by IOMMU.
|
||||
*/
|
||||
extern int lkbde_get_dma_info(phys_addr_t *cpu_pbase, phys_addr_t *dma_pbase, ssize_t *size);
|
||||
extern uint32 lkbde_get_dev_phys(int d);
|
||||
extern uint32 lkbde_get_dev_phys_hi(int d);
|
||||
|
||||
/*
|
||||
* Virtual device address needed by kernel space
|
||||
* interrupt handler.
|
||||
*/
|
||||
extern void *lkbde_get_dev_virt(int d);
|
||||
|
||||
/*
|
||||
* The user bde needs to get some physical addresses for
|
||||
* the userland code to mmap. The following functions
|
||||
* supports multiple resources for a single device.
|
||||
*/
|
||||
extern int lkbde_get_dev_resource(int d, int rsrc, uint32 *flags,
|
||||
uint32 *phys_lo, uint32 *phys_hi);
|
||||
|
||||
/*
|
||||
* Backdoor to retrieve OS device structure to be used for
|
||||
* DMA operations.
|
||||
*/
|
||||
extern void *lkbde_get_dma_dev(int d);
|
||||
|
||||
/*
|
||||
* Backdoor to retrieve original hardware/OS device.
|
||||
*/
|
||||
extern void *lkbde_get_hw_dev(int d);
|
||||
|
||||
/*
|
||||
* Retrive the device state from Kernel BDE.
|
||||
* Used for KNET and User BDE for pci hot swap case.
|
||||
*/
|
||||
extern int lkbde_dev_state_get(int d, uint32 *state);
|
||||
extern int lkbde_dev_state_set(int d, uint32 state);
|
||||
|
||||
/*
|
||||
* Retrive the mapping between emulated HW device and instance id
|
||||
*/
|
||||
extern int lkbde_dev_instid_get(int d, uint32 *instid);
|
||||
extern int lkbde_dev_instid_set(int d, uint32 instid);
|
||||
|
||||
/*
|
||||
* Functions that allow an interrupt handler in user mode to
|
||||
* coexist with interrupt handler in kernel module.
|
||||
*/
|
||||
extern int lkbde_irq_mask_set(int d, uint32 addr, uint32 mask, uint32 fmask);
|
||||
extern int lkbde_irq_mask_get(int d, uint32 *mask, uint32 *fmask);
|
||||
|
||||
#if (defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT))
|
||||
extern int lkbde_cpu_write(int d, uint32 addr, uint32 *buf);
|
||||
extern int lkbde_cpu_read(int d, uint32 addr, uint32 *buf);
|
||||
extern int lkbde_cpu_pci_register(int d);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This flag must be OR'ed onto the device number when calling
|
||||
* interrupt_connect/disconnect and irq_mask_set functions from
|
||||
* a secondary device driver.
|
||||
*/
|
||||
#define LKBDE_ISR2_DEV 0x8000
|
||||
|
||||
#if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)
|
||||
#include <linux/version.h>
|
||||
#if defined(__DUNE_LINUX_BCM_CPU_PCIE__) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
|
||||
#ifndef _SIMPLE_MEMORY_ALLOCATION_
|
||||
#define _SIMPLE_MEMORY_ALLOCATION_ 1
|
||||
#endif
|
||||
#ifndef USE_LINUX_BDE_MMAP
|
||||
#define USE_LINUX_BDE_MMAP 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(IPROC_CMICD) && defined(CONFIG_CMA)
|
||||
#ifndef _SIMPLE_MEMORY_ALLOCATION_
|
||||
#define _SIMPLE_MEMORY_ALLOCATION_ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Don't use _SIMPLE_MEMORY_ALLOCATION_ method for newer kernel than 3.10.0 */
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
|
||||
#ifndef _SIMPLE_MEMORY_ALLOCATION_
|
||||
#define _SIMPLE_MEMORY_ALLOCATION_ 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Allocation via dma_alloc_coherent is turned off by default */
|
||||
#ifndef _SIMPLE_MEMORY_ALLOCATION_
|
||||
#define _SIMPLE_MEMORY_ALLOCATION_ 9 /* compile in the allocation method, but do not use it by default */
|
||||
#endif
|
||||
|
||||
/* By default we use our private mmap only if /dev/mem mmap has restrictions */
|
||||
#ifndef USE_LINUX_BDE_MMAP
|
||||
#ifdef CONFIG_STRICT_DEVMEM
|
||||
#define USE_LINUX_BDE_MMAP 1
|
||||
#else
|
||||
#define USE_LINUX_BDE_MMAP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __LINUX_BDE_H__ */
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/***********************************************************************
|
||||
*
|
||||
* $Id: linux_dma.h,v 1.24 Broadcom SDK $
|
||||
* $Copyright: (c) 2016 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __LINUX_DMA_H__
|
||||
#define __LINUX_DMA_H__
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#ifdef SAL_BDE_XLP
|
||||
#define KMALLOC(size, flags) __kmalloc(size, flags)
|
||||
#else
|
||||
#define KMALLOC(size, flags) kmalloc(size, flags)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IDT_79EB334) || defined(CONFIG_BCM4702)
|
||||
/* ioremap is broken in kernel */
|
||||
#define IOREMAP(addr, size) ((void *)KSEG1ADDR(addr))
|
||||
#else
|
||||
#define IOREMAP(addr, size) ioremap_nocache(addr, size)
|
||||
#endif
|
||||
|
||||
#if defined (__mips__)
|
||||
#if defined(CONFIG_NONCOHERENT_IO) || defined(CONFIG_DMA_NONCOHERENT)
|
||||
/* Use flush/invalidate for cached memory */
|
||||
#define NONCOHERENT_DMA_MEMORY
|
||||
/* Remap virtual DMA addresses to non-cached segment */
|
||||
#define REMAP_DMA_NONCACHED
|
||||
#endif /* CONFIG_NONCOHERENT_IO || CONFIG_DMA_NONCOHERENT */
|
||||
#endif /* __mips__ */
|
||||
|
||||
#if defined(BCM958525) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,5))
|
||||
#define REMAP_DMA_NONCACHED
|
||||
#endif
|
||||
|
||||
#ifndef DMA_BIT_MASK
|
||||
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
|
||||
#endif
|
||||
|
||||
extern void _dma_init(int robo_switch);
|
||||
extern int _dma_cleanup(void);
|
||||
extern void _dma_pprint(void);
|
||||
extern uint32_t *_salloc(int d, int size, const char *name);
|
||||
extern void _sfree(int d, void *ptr);
|
||||
extern int _sinval(int d, void *ptr, int length);
|
||||
extern int _sflush(int d, void *ptr, int length);
|
||||
extern sal_paddr_t _l2p(int d, void *vaddr);
|
||||
extern void *_p2l(int d, sal_paddr_t paddr);
|
||||
extern int _dma_pool_allocated(void);
|
||||
extern int _dma_range_valid(unsigned long phys_addr, unsigned long size);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __LINUX_DMA_H__ */
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: mpool.h,v 1.2 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef __MPOOL_H__
|
||||
#define __MPOOL_H__
|
||||
|
||||
struct mpool_mem_s;
|
||||
typedef struct mpool_mem_s* mpool_handle_t;
|
||||
|
||||
extern int mpool_init(void);
|
||||
extern mpool_handle_t mpool_create(void* base_address, int size);
|
||||
extern void* mpool_alloc(mpool_handle_t pool, int size);
|
||||
extern void mpool_free(mpool_handle_t pool, void* ptr);
|
||||
extern int mpool_destroy(mpool_handle_t pool);
|
||||
|
||||
extern int mpool_usage(mpool_handle_t pool);
|
||||
|
||||
#endif /* __MPOOL_H__ */
|
@ -0,0 +1,115 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.18 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Makefile for Linux kernel BDE
|
||||
#
|
||||
LOCALDIR = systems/bde/linux/kernel
|
||||
|
||||
# Make sure we build for the kernel if this is a user-mode build
|
||||
ifneq ($(platform), )
|
||||
override-target=linux-$(platform)
|
||||
endif
|
||||
|
||||
include $(SDK)/make/Make.config
|
||||
|
||||
LIBS = $(LIBDIR)/libkern.a
|
||||
|
||||
BDE = linux-kernel-bde.o
|
||||
|
||||
ifdef ROBO_CHIPS
|
||||
CFLAGS += -I$(ET_ROBO) -I${SDK}/include/shared/et
|
||||
ET_ROBO = ${SDK}/systems/drv/et
|
||||
endif
|
||||
|
||||
# need to add vpath sources
|
||||
VPATH = ../shared $(ET_ROBO)
|
||||
|
||||
# Add the srcs to be found by vpath
|
||||
LSRCS += mpool.c
|
||||
ifdef ROBO_CHIPS
|
||||
platformsplt = $(subst -, , ${platform}) # change hyphens to spaces
|
||||
platformbase = $(word 1,${platformsplt})
|
||||
|
||||
ifeq ($(platformbase), keystone)
|
||||
LSRCS += etc_robo_spi.c aiutils.c
|
||||
else
|
||||
ifeq ($(platformbase), keystone_le)
|
||||
LSRCS += etc_robo_spi.c aiutils.c
|
||||
else
|
||||
ifeq ($(platformbase), iproc)
|
||||
LSRCS += robo_srab.c robo_spi.c aiutils.c
|
||||
endif
|
||||
endif
|
||||
endif # platformbase
|
||||
|
||||
endif # ROBO_CHIPS
|
||||
|
||||
# Add shared BDE sources
|
||||
VPATH += ../../shared
|
||||
LSRCS += shbde_pci.c shbde_iproc.c shbde_mdio.c
|
||||
CFLAGS += -I../../shared/include
|
||||
|
||||
LHDRS += mpool.h
|
||||
LOBJS = $(addsuffix .o, $(basename $(LSRCS)))
|
||||
BOBJS = $(addprefix $(BLDDIR)/,$(LOBJS))
|
||||
|
||||
ifneq ($(kernel_version),2_4)
|
||||
KERNEL_MODULE_DIR = kernel_module
|
||||
|
||||
THIS_MOD_NAME := linux-kernel-bde
|
||||
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
|
||||
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
|
||||
|
||||
build: kernel_libs $(MODULE) $(KMODULE)
|
||||
else
|
||||
MODULE = $(LIBDIR)/linux-kernel-bde.o
|
||||
|
||||
build: kernel_libs $(MODULE)
|
||||
endif
|
||||
|
||||
$(MODULE): $(BLDDIR)/.tree kernel_libs $(BOBJS)
|
||||
mkdir -p $(@D)
|
||||
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
|
||||
ifneq ($(kernel_version),2_4)
|
||||
$(KMODULE): $(MODULE)
|
||||
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
|
||||
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
|
||||
endif
|
||||
|
||||
kernel_libs:
|
||||
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared
|
||||
|
||||
include $(SDK)/make/Make.depend
|
||||
|
||||
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
|
||||
|
||||
clean::
|
||||
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared $@
|
||||
$(RM) $(BOBJS) $(MODULE)
|
||||
$(RM) $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
|
||||
distclean::
|
||||
|
||||
ifneq ($(kernel_version),2_4)
|
||||
.PHONY: build kernel_libs
|
||||
endif
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,906 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: linux_dma.c,v 1.414 Broadcom SDK $
|
||||
* $Copyright: (c) 2016 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
* Linux Kernel BDE DMA memory allocation
|
||||
*
|
||||
*
|
||||
* DMA memory allocation modes
|
||||
* ===========================
|
||||
*
|
||||
* 1. Using private pool in kernel memory
|
||||
* --------------------------------------
|
||||
* In this mode the BDE module will try to assemble a physically contiguous
|
||||
* of memory using the kernel page allocator. This memory block is then
|
||||
* administered by the mpool allocation functions. Note that once a system
|
||||
* has been running for a while, the memory fragmentation may prevent the
|
||||
* allocator from assembling a contiguous memory block, however, if the
|
||||
* module is loaded shortly after system startup, it is very unlikely to
|
||||
* fail.
|
||||
*
|
||||
* This allocation method is used by default.
|
||||
*
|
||||
* 2. Using private pool in high memory
|
||||
* ------------------------------------
|
||||
* In this mode the BDE module will assume that unused physical memory is
|
||||
* present at the high_memory address, i.e. memory not managed by the Linux
|
||||
* memory manager. This memory block is mapped into kernel space and
|
||||
* administered by the mpool allocation functions. High memory must be
|
||||
* reserved using either the mem=xxx kernel parameter (recommended), or by
|
||||
* hardcoding the memory limit in the kernel image.
|
||||
*
|
||||
* The module parameter himem=1 enables this allocation mode.
|
||||
*
|
||||
* 3. Using kernel allocators (kmalloc, __get_free_pages)
|
||||
* ------------------------------------------------------
|
||||
* In this mode all DMA memory is allocated from the kernel on the fly, i.e.
|
||||
* no private DMA memory pool will be created. If large memory blocks are
|
||||
* only allocated at system startup (or not at all), this allocation method
|
||||
* is the most flexible and memory-efficient, however, it is not recommended
|
||||
* for non-coherent memory platforms due to an overall system performance
|
||||
* degradation arising from the use of cache flush/invalidate instructions.
|
||||
*
|
||||
* The module parameter dmasize=0M enables this allocation mode, however if
|
||||
* DMA memory is requested from a user mode application, a private memory
|
||||
* pool will be created and used irrespectively.
|
||||
*/
|
||||
|
||||
#include <gmodule.h>
|
||||
#include <linux-bde.h>
|
||||
#include <linux_dma.h>
|
||||
#include <mpool.h>
|
||||
#include <sdk_config.h>
|
||||
|
||||
#ifdef BCM_PLX9656_LOCAL_BUS
|
||||
#include <asm/cacheflush.h>
|
||||
#endif
|
||||
|
||||
/* allocation types/methods for the DMA memory pool */
|
||||
#define ALLOC_TYPE_CHUNK 0 /* use small allocations and join them */
|
||||
#define ALLOC_TYPE_API 1 /* use one allocation */
|
||||
#if _SIMPLE_MEMORY_ALLOCATION_
|
||||
#include <linux/dma-mapping.h>
|
||||
#if defined(IPROC_CMICD) && defined(CONFIG_CMA) && defined(CONFIG_CMA_SIZE_MBYTES)
|
||||
#define DMA_MAX_ALLOC_SIZE (CONFIG_CMA_SIZE_MBYTES * 1024 * 1024)
|
||||
#else
|
||||
#define DMA_MAX_ALLOC_SIZE (1 << (MAX_ORDER - 1 + PAGE_SHIFT)) /* Maximum size the kernel can allocate in one allocation */
|
||||
#endif
|
||||
#endif /* _SIMPLE_MEMORY_ALLOCATION_ */
|
||||
|
||||
#if _SIMPLE_MEMORY_ALLOCATION_ == 1
|
||||
#define ALLOC_METHOD_DEFAULT ALLOC_TYPE_API
|
||||
#else
|
||||
#define ALLOC_METHOD_DEFAULT ALLOC_TYPE_CHUNK
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
|
||||
#include <linux/slab.h>
|
||||
#define virt_to_bus virt_to_phys
|
||||
#define bus_to_virt phys_to_virt
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))
|
||||
#define VIRT_TO_PAGE(p) virt_to_page((void*)(p))
|
||||
#else
|
||||
#define VIRT_TO_PAGE(p) virt_to_page((p))
|
||||
#endif
|
||||
|
||||
/* Compatibility */
|
||||
#ifdef LKM_2_4
|
||||
#define MEM_MAP_RESERVE mem_map_reserve
|
||||
#define MEM_MAP_UNRESERVE mem_map_unreserve
|
||||
#else /* LKM_2_6 */
|
||||
#define MEM_MAP_RESERVE SetPageReserved
|
||||
#define MEM_MAP_UNRESERVE ClearPageReserved
|
||||
#endif /* LKM_2_x */
|
||||
|
||||
#ifndef GFP_DMA32
|
||||
#define GFP_DMA32 0
|
||||
#endif
|
||||
|
||||
/* Flags for memory allocations */
|
||||
#ifdef SAL_BDE_XLP
|
||||
static int mem_flags = GFP_ATOMIC | GFP_KERNEL | GFP_DMA;
|
||||
#else
|
||||
#if defined(CONFIG_ZONE_DMA32)
|
||||
static int mem_flags = GFP_ATOMIC | GFP_DMA32;
|
||||
#else
|
||||
static int mem_flags = GFP_ATOMIC | GFP_DMA;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Debug output */
|
||||
static int dma_debug = 0;
|
||||
module_param(dma_debug, int, 0);
|
||||
MODULE_PARM_DESC(dma_debug,
|
||||
"DMA debug output enable (default 0).");
|
||||
|
||||
/* DMA memory pool size */
|
||||
static char *dmasize;
|
||||
LKM_MOD_PARAM(dmasize, "s", charp, 0);
|
||||
MODULE_PARM_DESC(dmasize,
|
||||
"Specify DMA memory size (default 4MB)");
|
||||
|
||||
/* Select DMA memory pool allocation method */
|
||||
static int dmaalloc = ALLOC_METHOD_DEFAULT;
|
||||
LKM_MOD_PARAM(dmaalloc, "i", int, 0);
|
||||
MODULE_PARM_DESC(dmaalloc, "Select DMA memory allocation method");
|
||||
|
||||
/* Use high memory for DMA */
|
||||
static char *himem;
|
||||
LKM_MOD_PARAM(himem, "s", charp, 0);
|
||||
MODULE_PARM_DESC(himem,
|
||||
"Use high memory for DMA (default no)");
|
||||
|
||||
/* DMA memory allocation */
|
||||
|
||||
#define ONE_KB 1024
|
||||
#define ONE_MB (1024*1024)
|
||||
|
||||
/* Default DMA memory size */
|
||||
#ifdef SAL_BDE_DMA_MEM_DEFAULT
|
||||
#define DMA_MEM_DEFAULT (SAL_BDE_DMA_MEM_DEFAULT * ONE_MB)
|
||||
#else
|
||||
#define DMA_MEM_DEFAULT (8 * ONE_MB)
|
||||
#endif
|
||||
#define DMA_MEM_DEFAULT_ROBO (4 * ONE_MB)
|
||||
|
||||
/* We try to assemble a contiguous segment from chunks of this size */
|
||||
#define DMA_BLOCK_SIZE (512 * ONE_KB)
|
||||
|
||||
typedef struct _dma_segment {
|
||||
struct list_head list;
|
||||
unsigned long req_size; /* Requested DMA segment size */
|
||||
unsigned long blk_size; /* DMA block size */
|
||||
unsigned long blk_order; /* DMA block size in alternate format */
|
||||
unsigned long seg_size; /* Current DMA segment size */
|
||||
unsigned long seg_begin; /* Logical address of segment */
|
||||
unsigned long seg_end; /* Logical end address of segment */
|
||||
unsigned long *blk_ptr; /* Array of logical DMA block addresses */
|
||||
int blk_cnt_max; /* Maximum number of block to allocate */
|
||||
int blk_cnt; /* Current number of blocks allocated */
|
||||
} dma_segment_t;
|
||||
|
||||
static unsigned int _dma_mem_size = DMA_MEM_DEFAULT;
|
||||
static mpool_handle_t _dma_pool = NULL;
|
||||
static void __iomem *_dma_vbase = NULL;
|
||||
/* cpu physical address for mmap */
|
||||
static phys_addr_t _cpu_pbase = 0;
|
||||
/*
|
||||
* DMA bus address, it is either identical to cpu physical address
|
||||
* or another address(IOVA) translated by IOMMU.
|
||||
*/
|
||||
static phys_addr_t _dma_pbase = 0;
|
||||
static int _use_himem = 0;
|
||||
static int _use_dma_mapping = 0;
|
||||
static LIST_HEAD(_dma_seg);
|
||||
|
||||
#define DMA_DEV(n) lkbde_get_dma_dev(n)
|
||||
|
||||
/*
|
||||
* Function: _find_largest_segment
|
||||
*
|
||||
* Purpose:
|
||||
* Find largest contiguous segment from a pool of DMA blocks.
|
||||
* Parameters:
|
||||
* dseg - DMA segment descriptor
|
||||
* Returns:
|
||||
* 0 on success, < 0 on error.
|
||||
* Notes:
|
||||
* Assembly stops if a segment of the requested segment size
|
||||
* has been obtained.
|
||||
*
|
||||
* Lower address bits of the DMA blocks are used as follows:
|
||||
* 0: Untagged
|
||||
* 1: Discarded block
|
||||
* 2: Part of largest contiguous segment
|
||||
* 3: Part of current contiguous segment
|
||||
*/
|
||||
static int
|
||||
_find_largest_segment(dma_segment_t *dseg)
|
||||
{
|
||||
int i, j, blks, found;
|
||||
unsigned long b, e, a;
|
||||
|
||||
blks = dseg->blk_cnt;
|
||||
/* Clear all block tags */
|
||||
for (i = 0; i < blks; i++) {
|
||||
dseg->blk_ptr[i] &= ~3;
|
||||
}
|
||||
for (i = 0; i < blks && dseg->seg_size < dseg->req_size; i++) {
|
||||
/* First block must be an untagged block */
|
||||
if ((dseg->blk_ptr[i] & 3) == 0) {
|
||||
/* Initial segment size is the block size */
|
||||
b = dseg->blk_ptr[i];
|
||||
e = b + dseg->blk_size;
|
||||
dseg->blk_ptr[i] |= 3;
|
||||
/* Loop looking for adjacent blocks */
|
||||
do {
|
||||
found = 0;
|
||||
for (j = i + 1; j < blks && (e - b) < dseg->req_size; j++) {
|
||||
a = dseg->blk_ptr[j];
|
||||
/* Check untagged blocks only */
|
||||
if ((a & 3) == 0) {
|
||||
if (a == (b - dseg->blk_size)) {
|
||||
/* Found adjacent block below current segment */
|
||||
dseg->blk_ptr[j] |= 3;
|
||||
b = a;
|
||||
found = 1;
|
||||
} else if (a == e) {
|
||||
/* Found adjacent block above current segment */
|
||||
dseg->blk_ptr[j] |= 3;
|
||||
e += dseg->blk_size;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (found);
|
||||
if ((e - b) > dseg->seg_size) {
|
||||
/* The current block is largest so far */
|
||||
dseg->seg_begin = b;
|
||||
dseg->seg_end = e;
|
||||
dseg->seg_size = e - b;
|
||||
/* Re-tag current and previous largest segment */
|
||||
for (j = 0; j < blks; j++) {
|
||||
if ((dseg->blk_ptr[j] & 3) == 3) {
|
||||
/* Tag current segment as the largest */
|
||||
dseg->blk_ptr[j] &= ~1;
|
||||
} else if ((dseg->blk_ptr[j] & 3) == 2) {
|
||||
/* Discard previous largest segment */
|
||||
dseg->blk_ptr[j] ^= 3;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Discard all blocks in current segment */
|
||||
for (j = 0; j < blks; j++) {
|
||||
if ((dseg->blk_ptr[j] & 3) == 3) {
|
||||
dseg->blk_ptr[j] &= ~2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _alloc_dma_blocks
|
||||
*
|
||||
* Purpose:
|
||||
* Allocate DMA blocks and add them to the pool.
|
||||
* Parameters:
|
||||
* dseg - DMA segment descriptor
|
||||
* blks - number of DMA blocks to allocate
|
||||
* Returns:
|
||||
* 0 on success, < 0 on error.
|
||||
* Notes:
|
||||
* DMA blocks are allocated using the page allocator.
|
||||
*/
|
||||
static int
|
||||
_alloc_dma_blocks(dma_segment_t *dseg, int blks)
|
||||
{
|
||||
int i, start;
|
||||
unsigned long addr;
|
||||
|
||||
if (dseg->blk_cnt + blks > dseg->blk_cnt_max) {
|
||||
gprintk("No more DMA blocks\n");
|
||||
return -1;
|
||||
}
|
||||
start = dseg->blk_cnt;
|
||||
dseg->blk_cnt += blks;
|
||||
for (i = start; i < dseg->blk_cnt; i++) {
|
||||
/*
|
||||
* Note that we cannot use pci_alloc_consistent when we
|
||||
* want to be able to map DMA memory to user space.
|
||||
*
|
||||
* The GFP_DMA flag is omitted as this imposes the ISA
|
||||
* addressing limitations on x86 platforms. As long as
|
||||
* we have less than 1GB of memory, we can do PCI DMA
|
||||
* to all physical RAM locations.
|
||||
*/
|
||||
addr = __get_free_pages(mem_flags, dseg->blk_order);
|
||||
if (addr) {
|
||||
dseg->blk_ptr[i] = addr;
|
||||
} else {
|
||||
gprintk("DMA allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _dma_segment_alloc
|
||||
*
|
||||
* Purpose:
|
||||
* Allocate large physically contiguous DMA segment.
|
||||
* Parameters:
|
||||
* size - requested DMA segment size
|
||||
* blk_size - assemble segment from blocks of this size
|
||||
* Returns:
|
||||
* DMA segment descriptor.
|
||||
* Notes:
|
||||
* Since we cannot allocate large blocks of contiguous
|
||||
* memory from the kernel, we simply keep allocating
|
||||
* smaller chunks until we can assemble a contiguous
|
||||
* block of the desired size.
|
||||
*
|
||||
* When system allowed maximum bytes of memory has been allocated
|
||||
* without a successful assembly of a contiguous DMA
|
||||
* segment, the allocation function will return the
|
||||
* largest contiguous segment found so far. It is up
|
||||
* to the calling function to decide whether this
|
||||
* amount is sufficient to proceed.
|
||||
*/
|
||||
static dma_segment_t *
|
||||
_dma_segment_alloc(size_t size, size_t blk_size)
|
||||
{
|
||||
dma_segment_t *dseg;
|
||||
int i, blk_ptr_size;
|
||||
unsigned long page_addr;
|
||||
struct sysinfo si;
|
||||
|
||||
/* Sanity check */
|
||||
if (size == 0 || blk_size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
/* Allocate an initialize DMA segment descriptor */
|
||||
if ((dseg = kmalloc(sizeof(dma_segment_t), GFP_KERNEL)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset(dseg, 0, sizeof(dma_segment_t));
|
||||
dseg->req_size = size;
|
||||
dseg->blk_size = PAGE_ALIGN(blk_size);
|
||||
while ((PAGE_SIZE << dseg->blk_order) < dseg->blk_size) {
|
||||
dseg->blk_order++;
|
||||
}
|
||||
|
||||
si_meminfo(&si);
|
||||
dseg->blk_cnt_max = (si.totalram << PAGE_SHIFT) / dseg->blk_size;
|
||||
blk_ptr_size = dseg->blk_cnt_max * sizeof(unsigned long);
|
||||
/* Allocate an initialize DMA block pool */
|
||||
dseg->blk_ptr = KMALLOC(blk_ptr_size, GFP_KERNEL);
|
||||
if (dseg->blk_ptr == NULL) {
|
||||
kfree(dseg);
|
||||
return NULL;
|
||||
}
|
||||
memset(dseg->blk_ptr, 0, blk_ptr_size);
|
||||
/* Allocate minimum number of blocks */
|
||||
_alloc_dma_blocks(dseg, dseg->req_size / dseg->blk_size);
|
||||
/* Allocate more blocks until we have a complete segment */
|
||||
do {
|
||||
_find_largest_segment(dseg);
|
||||
if (dseg->seg_size >= dseg->req_size) {
|
||||
break;
|
||||
}
|
||||
} while (_alloc_dma_blocks(dseg, 8) == 0);
|
||||
/* Reserve all pages in the DMA segment and free unused blocks */
|
||||
for (i = 0; i < dseg->blk_cnt; i++) {
|
||||
if ((dseg->blk_ptr[i] & 3) == 2) {
|
||||
dseg->blk_ptr[i] &= ~3;
|
||||
for (page_addr = dseg->blk_ptr[i];
|
||||
page_addr < dseg->blk_ptr[i] + dseg->blk_size;
|
||||
page_addr += PAGE_SIZE) {
|
||||
MEM_MAP_RESERVE(VIRT_TO_PAGE(page_addr));
|
||||
}
|
||||
} else if (dseg->blk_ptr[i]) {
|
||||
dseg->blk_ptr[i] &= ~3;
|
||||
free_pages(dseg->blk_ptr[i], dseg->blk_order);
|
||||
dseg->blk_ptr[i] = 0;
|
||||
}
|
||||
}
|
||||
return dseg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _dma_segment_free
|
||||
*
|
||||
* Purpose:
|
||||
* Release resources used by DMA segment.
|
||||
* Parameters:
|
||||
* dseg - DMA segment descriptor
|
||||
* Returns:
|
||||
* Nothing.
|
||||
*/
|
||||
static void
|
||||
_dma_segment_free(dma_segment_t *dseg)
|
||||
{
|
||||
int i;
|
||||
unsigned long page_addr;
|
||||
|
||||
if (dseg->blk_ptr) {
|
||||
for (i = 0; i < dseg->blk_cnt; i++) {
|
||||
if (dseg->blk_ptr[i]) {
|
||||
for (page_addr = dseg->blk_ptr[i];
|
||||
page_addr < dseg->blk_ptr[i] + dseg->blk_size;
|
||||
page_addr += PAGE_SIZE) {
|
||||
MEM_MAP_UNRESERVE(VIRT_TO_PAGE(page_addr));
|
||||
}
|
||||
free_pages(dseg->blk_ptr[i], dseg->blk_order);
|
||||
}
|
||||
}
|
||||
kfree(dseg->blk_ptr);
|
||||
kfree(dseg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _pgalloc
|
||||
*
|
||||
* Purpose:
|
||||
* Allocate DMA memory using page allocator
|
||||
* Parameters:
|
||||
* size - number of bytes to allocate
|
||||
* Returns:
|
||||
* Pointer to allocated DMA memory or NULL if failure.
|
||||
* Notes:
|
||||
* For any sizes less than DMA_BLOCK_SIZE, we ask the page
|
||||
* allocator for the entire memory block, otherwise we try
|
||||
* to assemble a contiguous segment ourselves.
|
||||
*/
|
||||
static void *
|
||||
_pgalloc(size_t size)
|
||||
{
|
||||
dma_segment_t *dseg;
|
||||
size_t blk_size;
|
||||
|
||||
blk_size = (size < DMA_BLOCK_SIZE) ? size : DMA_BLOCK_SIZE;
|
||||
if ((dseg = _dma_segment_alloc(size, blk_size)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (dseg->seg_size < size) {
|
||||
/* If we didn't get the full size then forget it */
|
||||
_dma_segment_free(dseg);
|
||||
return NULL;
|
||||
}
|
||||
list_add(&dseg->list, &_dma_seg);
|
||||
return (void *)dseg->seg_begin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _pgfree
|
||||
*
|
||||
* Purpose:
|
||||
* Free memory allocated by _pgalloc
|
||||
* Parameters:
|
||||
* ptr - pointer returned by _pgalloc
|
||||
* Returns:
|
||||
* 0 if succesfully freed, otherwise -1.
|
||||
*/
|
||||
static int
|
||||
_pgfree(void *ptr)
|
||||
{
|
||||
struct list_head *pos;
|
||||
list_for_each(pos, &_dma_seg) {
|
||||
dma_segment_t *dseg = list_entry(pos, dma_segment_t, list);
|
||||
if (ptr == (void *)dseg->seg_begin) {
|
||||
list_del(&dseg->list);
|
||||
_dma_segment_free(dseg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _pgcleanup
|
||||
*
|
||||
* Purpose:
|
||||
* Free all memory allocated by _pgalloc
|
||||
* Parameters:
|
||||
* None
|
||||
* Returns:
|
||||
* Nothing.
|
||||
*/
|
||||
static void
|
||||
_pgcleanup(void)
|
||||
{
|
||||
switch (dmaalloc) {
|
||||
#if _SIMPLE_MEMORY_ALLOCATION_
|
||||
case ALLOC_TYPE_API:
|
||||
if (_dma_vbase) {
|
||||
if (dma_debug >= 1) gprintk("freeing v=%p p=0x%lx size=0x%lx\n", _dma_vbase,(unsigned long) _dma_pbase, (unsigned long)_dma_mem_size);
|
||||
dma_free_coherent(DMA_DEV(0), _dma_mem_size, _dma_vbase, _dma_pbase);
|
||||
}
|
||||
break;
|
||||
#endif /* _SIMPLE_MEMORY_ALLOCATION_ */
|
||||
|
||||
case ALLOC_TYPE_CHUNK: {
|
||||
struct list_head *pos, *tmp;
|
||||
if (_use_dma_mapping) {
|
||||
dma_unmap_single(DMA_DEV(0), (dma_addr_t)_dma_pbase, _dma_mem_size, DMA_BIDIRECTIONAL);
|
||||
_use_dma_mapping = 0;
|
||||
}
|
||||
list_for_each_safe(pos, tmp, &_dma_seg) {
|
||||
dma_segment_t *dseg = list_entry(pos, dma_segment_t, list);
|
||||
list_del(&dseg->list);
|
||||
_dma_segment_free(dseg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
gprintk("DMA memory allocation method dmaalloc=%d is not supported\n", dmaalloc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _alloc_mpool
|
||||
*
|
||||
* Purpose:
|
||||
* Allocate DMA memory pool
|
||||
* Parameters:
|
||||
* size - size of DMA memory pool
|
||||
* Returns:
|
||||
* Nothing.
|
||||
* Notes:
|
||||
* If set up to use high memory, we simply map the memory into
|
||||
* kernel space.
|
||||
* It is assumed there is only one pool.
|
||||
*/
|
||||
static void
|
||||
_alloc_mpool(size_t size)
|
||||
{
|
||||
unsigned long pbase = 0;
|
||||
|
||||
#if defined(__arm__) && !defined(CONFIG_HIGHMEM)
|
||||
if (_use_himem) {
|
||||
gprintk("DMA in high memory requires CONFIG_HIGHMEM on ARM CPUs.\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_use_himem) {
|
||||
/* Use high memory for DMA */
|
||||
pbase = virt_to_bus(high_memory);
|
||||
if (((pbase + (size - 1)) >> 16) > DMA_BIT_MASK(16)) {
|
||||
gprintk("DMA in high memory at 0x%lx size 0x%lx is beyond the 4GB limit and not supported.\n", pbase, (unsigned long)size);
|
||||
return;
|
||||
}
|
||||
_cpu_pbase = _dma_pbase = pbase;
|
||||
_dma_vbase = IOREMAP(_dma_pbase, size);
|
||||
} else {
|
||||
/* Get DMA memory from kernel */
|
||||
switch (dmaalloc) {
|
||||
#if _SIMPLE_MEMORY_ALLOCATION_
|
||||
case ALLOC_TYPE_API: {
|
||||
size_t alloc_size = size; /* size of memory allocated in current iteration */
|
||||
if (alloc_size > DMA_MAX_ALLOC_SIZE) {
|
||||
alloc_size = DMA_MAX_ALLOC_SIZE;
|
||||
}
|
||||
/* get a memory allocation from the kernel */
|
||||
{
|
||||
dma_addr_t dma_handle;
|
||||
if (!(_dma_vbase = dma_alloc_coherent(DMA_DEV(0), alloc_size, &dma_handle, GFP_KERNEL)) || !dma_handle) {
|
||||
gprintk("_alloc_mpool: Kernel failed to allocate the memory pool of size 0x%lx\n", (unsigned long)alloc_size);
|
||||
return;
|
||||
}
|
||||
pbase = dma_handle;
|
||||
}
|
||||
|
||||
if (alloc_size != size) {
|
||||
gprintk("_alloc_mpool: allocated 0x%lx bytes instead of 0x%lx bytes.\n",
|
||||
(unsigned long)alloc_size, (unsigned long)size);
|
||||
}
|
||||
size = _dma_mem_size = alloc_size;
|
||||
break;
|
||||
}
|
||||
#endif /* _SIMPLE_MEMORY_ALLOCATION_ */
|
||||
|
||||
case ALLOC_TYPE_CHUNK:
|
||||
_dma_vbase = _pgalloc(size);
|
||||
if (DMA_DEV(0)) {
|
||||
/*
|
||||
* Use dma_map_single to obtain dma bus address or IOVA if iommu is present.
|
||||
*/
|
||||
pbase = dma_map_single(DMA_DEV(0), _dma_vbase, size, DMA_BIDIRECTIONAL);
|
||||
_use_dma_mapping = 1;
|
||||
} else {
|
||||
pbase = virt_to_bus(_dma_vbase);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_dma_vbase = NULL;
|
||||
pbase = 0;
|
||||
gprintk("DMA memory allocation method dmaalloc=%d is not supported\n", dmaalloc);
|
||||
}
|
||||
|
||||
_dma_pbase = pbase;
|
||||
|
||||
if (dma_debug >= 1) {
|
||||
gprintk("_alloc_mpool:%s _dma_vbase:%p pbase:%lx allocated:%lx dmaalloc:%d\n",
|
||||
DMA_DEV(0)?"dma_dev":"", _dma_vbase, pbase, (unsigned long)size, dmaalloc);
|
||||
}
|
||||
|
||||
if (((pbase + (size - 1)) >> 16) > DMA_BIT_MASK(16)) {
|
||||
gprintk("DMA memory allocated at 0x%lx size 0x%lx is beyond the 4GB limit and not supported.\n", pbase, (unsigned long)size);
|
||||
_pgcleanup();
|
||||
_dma_vbase = NULL;
|
||||
_dma_pbase = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_dma_vbase) {
|
||||
_cpu_pbase = virt_to_bus(_dma_vbase);
|
||||
if (dma_debug >= 1) gprintk("_cpu_pbase at %lx\n", (unsigned long)_cpu_pbase);
|
||||
}
|
||||
#ifdef REMAP_DMA_NONCACHED
|
||||
_dma_vbase = IOREMAP(_dma_pbase, size);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: _dma_cleanup
|
||||
*
|
||||
* Purpose:
|
||||
* DMA cleanup function.
|
||||
* Parameters:
|
||||
* None
|
||||
* Returns:
|
||||
* Always 0
|
||||
*/
|
||||
int
|
||||
_dma_cleanup(void)
|
||||
{
|
||||
if (_dma_vbase) {
|
||||
mpool_destroy(_dma_pool);
|
||||
if (_use_himem) {
|
||||
iounmap(_dma_vbase);
|
||||
} else {
|
||||
#ifdef REMAP_DMA_NONCACHED
|
||||
iounmap(_dma_vbase);
|
||||
#endif
|
||||
_pgcleanup();
|
||||
}
|
||||
_dma_vbase = NULL;
|
||||
_dma_pbase = 0;
|
||||
_cpu_pbase = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _dma_init(int robo_switch)
|
||||
{
|
||||
/* DMA Setup */
|
||||
if (dmasize) {
|
||||
if ((dmasize[strlen(dmasize)-1] & ~0x20) == 'M') {
|
||||
_dma_mem_size = simple_strtoul(dmasize, NULL, 0);
|
||||
_dma_mem_size *= ONE_MB;
|
||||
} else {
|
||||
gprintk("DMA memory size must be specified as e.g. dmasize=8M\n");
|
||||
}
|
||||
if (_dma_mem_size & (_dma_mem_size-1)) {
|
||||
gprintk("dmasize must be a power of 2 (1M, 2M, 4M, 8M etc.)\n");
|
||||
_dma_mem_size = 0;
|
||||
}
|
||||
} else {
|
||||
if(robo_switch){
|
||||
_dma_mem_size = DMA_MEM_DEFAULT_ROBO;
|
||||
}
|
||||
}
|
||||
|
||||
if (himem) {
|
||||
if ((himem[0] & ~0x20) == 'Y' || himem[0] == '1') {
|
||||
_use_himem = 1;
|
||||
} else if ((himem[0] & ~0x20) == 'N' || himem[0] == '0') {
|
||||
_use_himem = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_dma_mem_size) {
|
||||
_alloc_mpool(_dma_mem_size);
|
||||
if (_dma_vbase == NULL) {
|
||||
gprintk("no DMA memory available\n");
|
||||
}
|
||||
else {
|
||||
mpool_init();
|
||||
_dma_pool = mpool_create(_dma_vbase, _dma_mem_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_LINUX_BDE_MMAP
|
||||
/*
|
||||
* Function: _dma_range_valid
|
||||
*
|
||||
* Purpose:
|
||||
* Check if DMA address range is valid.
|
||||
* Parameters:
|
||||
* phys_addr - start physical address
|
||||
* size - range size
|
||||
* Returns:
|
||||
* 0 : not valid
|
||||
* 1 : valid
|
||||
*/
|
||||
int
|
||||
_dma_range_valid(unsigned long phys_addr, unsigned long size)
|
||||
{
|
||||
unsigned long pool_start = _cpu_pbase;
|
||||
unsigned long pool_end = pool_start + _dma_mem_size;
|
||||
|
||||
if (phys_addr < pool_start || (phys_addr + size) > pool_end) {
|
||||
gprintk("range 0x%lx-0x%lx outside DMA pool 0x%lx-0x%lx\n",
|
||||
phys_addr, phys_addr + size, pool_start, pool_end);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function: _dma_pool_allocated
|
||||
*
|
||||
* Purpose:
|
||||
* Check if DMA pool has been allocated.
|
||||
* Parameters:
|
||||
* None
|
||||
* Returns:
|
||||
* 0 : not allocated
|
||||
* 1 : allocated
|
||||
*/
|
||||
int
|
||||
_dma_pool_allocated(void)
|
||||
{
|
||||
return (_dma_vbase) ? 1 : 0;
|
||||
}
|
||||
|
||||
sal_paddr_t
|
||||
_l2p(int d, void *vaddr)
|
||||
{
|
||||
if (_dma_mem_size) {
|
||||
/* dma memory is a contiguous block */
|
||||
if (vaddr) {
|
||||
return _dma_pbase + (PTR_TO_UINTPTR(vaddr) - PTR_TO_UINTPTR(_dma_vbase));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return ((sal_paddr_t)virt_to_bus(vaddr));
|
||||
}
|
||||
|
||||
void *
|
||||
_p2l(int d, sal_paddr_t paddr)
|
||||
{
|
||||
sal_vaddr_t vaddr = (sal_vaddr_t)_dma_vbase;
|
||||
|
||||
if (_dma_mem_size) {
|
||||
/* DMA memory is a contiguous block */
|
||||
if (paddr == 0) {
|
||||
return NULL;
|
||||
}
|
||||
return (void *)(vaddr + (sal_vaddr_t)(paddr - _dma_pbase));
|
||||
}
|
||||
return bus_to_virt(paddr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Some of the driver malloc's are too large for
|
||||
* kmalloc(), so 'sal_alloc' and 'sal_free' in the
|
||||
* linux kernel sal cannot be implemented with kmalloc().
|
||||
*
|
||||
* Instead, they expect someone to provide an allocator
|
||||
* that can handle the gimongous size of some of the
|
||||
* allocations, and we provide it here, by allocating
|
||||
* this memory out of the boot-time dma pool.
|
||||
*
|
||||
* These are the functions in question:
|
||||
*/
|
||||
|
||||
void* kmalloc_giant(int sz)
|
||||
{
|
||||
return mpool_alloc(_dma_pool, sz);
|
||||
}
|
||||
|
||||
void kfree_giant(void* ptr)
|
||||
{
|
||||
return mpool_free(_dma_pool, ptr);
|
||||
}
|
||||
|
||||
uint32_t *
|
||||
_salloc(int d, int size, const char *name)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (_dma_mem_size) {
|
||||
return mpool_alloc(_dma_pool, size);
|
||||
}
|
||||
if ((ptr = kmalloc(size, mem_flags)) == NULL) {
|
||||
ptr = _pgalloc(size);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void
|
||||
_sfree(int d, void *ptr)
|
||||
{
|
||||
if (_dma_mem_size) {
|
||||
return mpool_free(_dma_pool, ptr);
|
||||
}
|
||||
if (_pgfree(ptr) < 0) {
|
||||
kfree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_sinval(int d, void *ptr, int length)
|
||||
{
|
||||
#if defined(dma_cache_wback_inv)
|
||||
dma_cache_wback_inv((unsigned long)ptr, length);
|
||||
#else
|
||||
#if defined(IPROC_CMICD) || defined(BCM958525)
|
||||
/* FIXME: need proper function to replace dma_cache_sync */
|
||||
dma_sync_single_for_cpu(NULL, (unsigned long)ptr, length, DMA_BIDIRECTIONAL);
|
||||
#else
|
||||
dma_cache_sync(NULL, ptr, length, DMA_BIDIRECTIONAL);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_sflush(int d, void *ptr, int length)
|
||||
{
|
||||
#if defined(dma_cache_wback_inv)
|
||||
dma_cache_wback_inv((unsigned long)ptr, length);
|
||||
#else
|
||||
#if defined(IPROC_CMICD) || defined(BCM958525)
|
||||
/* FIXME: need proper function to replace dma_cache_sync */
|
||||
dma_sync_single_for_cpu(NULL, (unsigned long)ptr, length, DMA_BIDIRECTIONAL);
|
||||
#else
|
||||
dma_cache_sync(NULL, ptr, length, DMA_BIDIRECTIONAL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
lkbde_get_dma_info(phys_addr_t* cpu_pbase, phys_addr_t* dma_pbase, ssize_t* size)
|
||||
{
|
||||
if (_dma_vbase == NULL) {
|
||||
if (_dma_mem_size == 0) {
|
||||
_dma_mem_size = DMA_MEM_DEFAULT;
|
||||
}
|
||||
_alloc_mpool(_dma_mem_size);
|
||||
}
|
||||
*cpu_pbase = _cpu_pbase;
|
||||
*dma_pbase = _dma_pbase;
|
||||
*size = (_dma_vbase) ? _dma_mem_size : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_dma_pprint(void)
|
||||
{
|
||||
pprintf("DMA Memory (%s): %d bytes, %d used, %d free%s\n",
|
||||
(_use_himem) ? "high" : "kernel",
|
||||
(_dma_vbase) ? _dma_mem_size : 0,
|
||||
(_dma_vbase) ? mpool_usage(_dma_pool) : 0,
|
||||
(_dma_vbase) ? _dma_mem_size - mpool_usage(_dma_pool) : 0,
|
||||
USE_LINUX_BDE_MMAP ? ", local mmap" : "");
|
||||
}
|
||||
|
||||
/*
|
||||
* Export functions
|
||||
*/
|
||||
LKM_EXPORT_SYM(kmalloc_giant);
|
||||
LKM_EXPORT_SYM(kfree_giant);
|
||||
LKM_EXPORT_SYM(lkbde_get_dma_info);
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gmodule.h>
|
||||
#include <shbde.h>
|
||||
#include <shbde_iproc.h>
|
||||
#include "linux_shbde.h"
|
||||
|
||||
/* Hardware abstractions for shared BDE functions */
|
||||
|
||||
static unsigned short
|
||||
linux_pcic16_read(void *pci_dev, unsigned int addr)
|
||||
{
|
||||
u16 data = 0;
|
||||
|
||||
pci_read_config_word((struct pci_dev *)pci_dev, addr, &data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_pcic16_write(void *pci_dev, unsigned int addr, unsigned short data)
|
||||
{
|
||||
pci_write_config_word((struct pci_dev *)pci_dev, addr, (u16)data);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
linux_pcic32_read(void *pci_dev, unsigned int addr)
|
||||
{
|
||||
u32 data = 0;
|
||||
|
||||
pci_read_config_dword((struct pci_dev *)pci_dev, addr, &data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_pcic32_write(void *pci_dev, unsigned int addr, unsigned int data)
|
||||
{
|
||||
pci_write_config_dword((struct pci_dev *)pci_dev, addr, (u32)data);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
linux_io32_read(void *addr)
|
||||
{
|
||||
return *((volatile u32 *)addr);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_io32_write(void *addr, unsigned int data)
|
||||
{
|
||||
*((volatile u32 *)addr) = data;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_usleep(int usec)
|
||||
{
|
||||
udelay(usec);
|
||||
}
|
||||
|
||||
|
||||
/* To get the PCI parent device under linux, from only the device pointer */
|
||||
static void *
|
||||
linux_pci_parent_device_get(void *pci_dev)
|
||||
{
|
||||
return (void *)(((struct pci_dev *)pci_dev)->bus->self);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* linux_shbde_hal_init
|
||||
* Purpose:
|
||||
* Initialize hardware abstraction module for Linux kernel.
|
||||
* Parameters:
|
||||
* shbde - pointer to uninitialized hardware abstraction module
|
||||
* log_func - optional log output function
|
||||
* Returns:
|
||||
* Always 0
|
||||
*/
|
||||
int
|
||||
linux_shbde_hal_init(shbde_hal_t *shbde, shbde_log_func_t log_func)
|
||||
{
|
||||
memset(shbde, 0, sizeof(*shbde));
|
||||
|
||||
shbde->log_func = log_func;
|
||||
|
||||
shbde->pcic16_read = linux_pcic16_read;
|
||||
shbde->pcic16_write = linux_pcic16_write;
|
||||
shbde->pcic32_read = linux_pcic32_read;
|
||||
shbde->pcic32_write = linux_pcic32_write;
|
||||
|
||||
shbde->io32_read = linux_io32_read;
|
||||
shbde->io32_write = linux_io32_write;
|
||||
|
||||
shbde->usleep = linux_usleep;
|
||||
|
||||
shbde->pci_parent_device_get = linux_pci_parent_device_get;
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_SHBDE_H__
|
||||
#define __LINUX_SHBDE_H__
|
||||
|
||||
#include <shbde.h>
|
||||
#include <shbde_pci.h>
|
||||
#include <shbde_iproc.h>
|
||||
|
||||
extern int
|
||||
linux_shbde_hal_init(shbde_hal_t *shbde, shbde_log_func_t log_func);
|
||||
|
||||
#endif /* __LINUX_SHBDE_H__ */
|
@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: mpool.c,v 1.18 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#include <mpool.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/*
|
||||
* Abstractions used when compiling for Linux kernel mode.
|
||||
*/
|
||||
|
||||
#include <lkm.h>
|
||||
|
||||
/*
|
||||
* We cannot use the linux kernel SAL for MALLOC/FREE because
|
||||
* the current implementation of sal_alloc() allocates memory
|
||||
* out of an mpool created by this module...
|
||||
*/
|
||||
#define MALLOC(x) kmalloc(x, GFP_ATOMIC)
|
||||
#define FREE(x) kfree(x)
|
||||
|
||||
static spinlock_t _mpool_lock;
|
||||
#define MPOOL_LOCK_INIT() spin_lock_init(&_mpool_lock)
|
||||
#define MPOOL_LOCK() unsigned long flags; spin_lock_irqsave(&_mpool_lock, flags)
|
||||
#define MPOOL_UNLOCK() spin_unlock_irqrestore(&_mpool_lock, flags)
|
||||
|
||||
#else /* !__KERNEL__*/
|
||||
|
||||
/*
|
||||
* Abstractions used when compiling for Linux user mode.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sal/core/sync.h>
|
||||
|
||||
#define MALLOC(x) malloc(x)
|
||||
#define FREE(x) free(x)
|
||||
|
||||
static sal_sem_t _mpool_lock;
|
||||
#define MPOOL_LOCK_INIT() _mpool_lock = sal_sem_create("mpool_lock", 1, 1)
|
||||
#define MPOOL_LOCK() sal_sem_take(_mpool_lock, sal_sem_FOREVER)
|
||||
#define MPOOL_UNLOCK() sal_sem_give(_mpool_lock)
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/* Allow external override for system cache line size */
|
||||
#ifndef BCM_CACHE_LINE_BYTES
|
||||
#ifdef L1_CACHE_BYTES
|
||||
#define BCM_CACHE_LINE_BYTES L1_CACHE_BYTES
|
||||
#else
|
||||
#define BCM_CACHE_LINE_BYTES 128 /* Should be fine on most platforms */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct mpool_mem_s {
|
||||
unsigned char *address;
|
||||
int size;
|
||||
struct mpool_mem_s *next;
|
||||
} mpool_mem_t;
|
||||
|
||||
/*
|
||||
* Function: mpool_init
|
||||
*
|
||||
* Purpose:
|
||||
* Initialize mpool lock.
|
||||
* Parameters:
|
||||
* None
|
||||
* Returns:
|
||||
* Always 0
|
||||
*/
|
||||
int
|
||||
mpool_init(void)
|
||||
{
|
||||
MPOOL_LOCK_INIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef TRACK_DMA_USAGE
|
||||
static int _dma_mem_used = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function: mpool_alloc
|
||||
*
|
||||
* Purpose:
|
||||
* Allocate memory block from mpool.
|
||||
* Parameters:
|
||||
* pool - mpool handle (from mpool_create)
|
||||
* size - size of memory block to allocate
|
||||
* Returns:
|
||||
* Pointer to allocated memory block or NULL if allocation fails.
|
||||
*/
|
||||
void *
|
||||
mpool_alloc(mpool_handle_t pool, int size)
|
||||
{
|
||||
mpool_mem_t *ptr = pool, *newptr = NULL;
|
||||
int mod;
|
||||
|
||||
MPOOL_LOCK();
|
||||
|
||||
mod = size & (BCM_CACHE_LINE_BYTES - 1);
|
||||
if (mod != 0 ) {
|
||||
size += (BCM_CACHE_LINE_BYTES - mod);
|
||||
}
|
||||
while (ptr && ptr->next) {
|
||||
if (ptr->next->address - (ptr->address + ptr->size) >= size) {
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
if (!(ptr && ptr->next)) {
|
||||
MPOOL_UNLOCK();
|
||||
return NULL;
|
||||
}
|
||||
newptr = MALLOC(sizeof(mpool_mem_t));
|
||||
if (!newptr) {
|
||||
MPOOL_UNLOCK();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newptr->address = ptr->address + ptr->size;
|
||||
newptr->size = size;
|
||||
newptr->next = ptr->next;
|
||||
ptr->next = newptr;
|
||||
#ifdef TRACK_DMA_USAGE
|
||||
_dma_mem_used += size;
|
||||
#endif
|
||||
MPOOL_UNLOCK();
|
||||
|
||||
return newptr->address;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: mpool_free
|
||||
*
|
||||
* Purpose:
|
||||
* Free memory block allocated from mpool..
|
||||
* Parameters:
|
||||
* pool - mpool handle (from mpool_create)
|
||||
* addr - address of memory block to free
|
||||
* Returns:
|
||||
* Nothing
|
||||
*/
|
||||
void
|
||||
mpool_free(mpool_handle_t pool, void *addr)
|
||||
{
|
||||
unsigned char *address = (unsigned char *)addr;
|
||||
mpool_mem_t *ptr = pool, *prev = NULL;
|
||||
|
||||
MPOOL_LOCK();
|
||||
|
||||
while (ptr && ptr->next) {
|
||||
if (ptr->next->address == address) {
|
||||
#ifdef TRACK_DMA_USAGE
|
||||
_dma_mem_used -= ptr->next->size;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
if (ptr && ptr->next) {
|
||||
prev = ptr;
|
||||
ptr = ptr->next;
|
||||
prev->next = ptr->next;
|
||||
FREE(ptr);
|
||||
}
|
||||
|
||||
MPOOL_UNLOCK();
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: mpool_create
|
||||
*
|
||||
* Purpose:
|
||||
* Create and initialize mpool control structures.
|
||||
* Parameters:
|
||||
* base_ptr - pointer to mpool memory block
|
||||
* size - total size of mpool memory block
|
||||
* Returns:
|
||||
* mpool handle
|
||||
* Notes
|
||||
* The mpool handle returned must be used for subsequent
|
||||
* memory allocations from the mpool.
|
||||
*/
|
||||
mpool_handle_t
|
||||
mpool_create(void *base_ptr, int size)
|
||||
{
|
||||
mpool_mem_t *head, *tail;
|
||||
int mod = (int)(((unsigned long)base_ptr) & (BCM_CACHE_LINE_BYTES - 1));
|
||||
|
||||
MPOOL_LOCK();
|
||||
|
||||
if (mod) {
|
||||
base_ptr = (char*)base_ptr + (BCM_CACHE_LINE_BYTES - mod);
|
||||
size -= (BCM_CACHE_LINE_BYTES - mod);
|
||||
}
|
||||
size &= ~(BCM_CACHE_LINE_BYTES - 1);
|
||||
|
||||
|
||||
head = (mpool_mem_t *)MALLOC(sizeof(mpool_mem_t));
|
||||
if (head == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
tail = (mpool_mem_t *)MALLOC(sizeof(mpool_mem_t));
|
||||
if (tail == NULL) {
|
||||
FREE(head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
head->size = tail->size = 0;
|
||||
head->address = base_ptr;
|
||||
tail->address = head->address + size;
|
||||
head->next = tail;
|
||||
tail->next = NULL;
|
||||
|
||||
MPOOL_UNLOCK();
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: mpool_destroy
|
||||
*
|
||||
* Purpose:
|
||||
* Free mpool control structures.
|
||||
* Parameters:
|
||||
* pool - mpool handle (from mpool_create)
|
||||
* Returns:
|
||||
* Always 0
|
||||
*/
|
||||
int
|
||||
mpool_destroy(mpool_handle_t pool)
|
||||
{
|
||||
mpool_mem_t *ptr, *next;
|
||||
|
||||
MPOOL_LOCK();
|
||||
|
||||
for (ptr = pool; ptr; ptr = next) {
|
||||
next = ptr->next;
|
||||
FREE(ptr);
|
||||
}
|
||||
|
||||
MPOOL_UNLOCK();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: mpool_usage
|
||||
*
|
||||
* Purpose:
|
||||
* Report total sum of allocated mpool memory.
|
||||
* Parameters:
|
||||
* pool - mpool handle (from mpool_create)
|
||||
* Returns:
|
||||
* Number of bytes currently allocated using mpool_alloc.
|
||||
*/
|
||||
int
|
||||
mpool_usage(mpool_handle_t pool)
|
||||
{
|
||||
int usage = 0;
|
||||
mpool_mem_t *ptr;
|
||||
|
||||
MPOOL_LOCK();
|
||||
|
||||
for (ptr = pool; ptr; ptr = ptr->next) {
|
||||
usage += ptr->size;
|
||||
}
|
||||
|
||||
MPOOL_UNLOCK();
|
||||
|
||||
return usage;
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.1 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
LOCALDIR = systems/bde/linux/user/kernel
|
||||
|
||||
# Make sure we build for the kernel if this is a user-mode build
|
||||
ifneq ($(platform), )
|
||||
override-target=linux-$(platform)
|
||||
endif
|
||||
|
||||
include $(SDK)/make/Make.config
|
||||
|
||||
LIBS = $(LIBDIR)/libkern.a
|
||||
|
||||
ifneq ($(kernel_version),2_4)
|
||||
KERNEL_MODULE_DIR = kernel_module
|
||||
|
||||
THIS_MOD_NAME := linux-user-bde
|
||||
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
|
||||
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
|
||||
|
||||
build: kernel_libs $(MODULE) $(KMODULE)
|
||||
else
|
||||
MODULE = $(LIBDIR)/linux-user-bde.o
|
||||
|
||||
build: kernel_libs $(MODULE)
|
||||
endif
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../kernel/kernel_module/Module.symvers
|
||||
|
||||
$(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS)
|
||||
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
|
||||
ifneq ($(kernel_version),2_4)
|
||||
$(KMODULE): $(MODULE)
|
||||
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
|
||||
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
|
||||
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
|
||||
endif
|
||||
|
||||
kernel_libs:
|
||||
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared
|
||||
|
||||
include $(SDK)/make/Make.depend
|
||||
|
||||
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
|
||||
|
||||
clean::
|
||||
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared $@
|
||||
$(RM) $(BOBJS) $(MODULE)
|
||||
|
||||
.PHONY: build kernel_libs
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: linux-user-bde.h,v 1.23 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USER_BDE_H__
|
||||
#define __LINUX_USER_BDE_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
#include <linux-bde.h>
|
||||
#ifndef __KERNEL__
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(SAL_BDE_32BIT_USER_64BIT_KERNEL) || defined(PTRS_ARE_64BITS)
|
||||
typedef uint64_t bde_kernel_addr_t;
|
||||
#else
|
||||
typedef uint32_t bde_kernel_addr_t;
|
||||
#endif
|
||||
|
||||
/* Ioctl control structure */
|
||||
typedef struct {
|
||||
unsigned int dev; /* Device ID */
|
||||
unsigned int rc; /* Operation Return Code */
|
||||
unsigned int d0; /* Operation specific data */
|
||||
unsigned int d1;
|
||||
unsigned int d2;
|
||||
unsigned int d3;
|
||||
bde_kernel_addr_t p0;
|
||||
union {
|
||||
unsigned int dw[2];
|
||||
unsigned char buf[64];
|
||||
} dx;
|
||||
} lubde_ioctl_t;
|
||||
|
||||
|
||||
/* LUBDE ioctls */
|
||||
#define LUBDE_MAGIC 'L'
|
||||
|
||||
#define LUBDE_VERSION _IO(LUBDE_MAGIC, 0)
|
||||
#define LUBDE_GET_NUM_DEVICES _IO(LUBDE_MAGIC, 1)
|
||||
#define LUBDE_GET_DEVICE _IO(LUBDE_MAGIC, 2)
|
||||
#define LUBDE_PCI_CONFIG_PUT32 _IO(LUBDE_MAGIC, 3)
|
||||
#define LUBDE_PCI_CONFIG_GET32 _IO(LUBDE_MAGIC, 4)
|
||||
#define LUBDE_GET_DMA_INFO _IO(LUBDE_MAGIC, 5)
|
||||
#define LUBDE_ENABLE_INTERRUPTS _IO(LUBDE_MAGIC, 6)
|
||||
#define LUBDE_DISABLE_INTERRUPTS _IO(LUBDE_MAGIC, 7)
|
||||
#define LUBDE_USLEEP _IO(LUBDE_MAGIC, 8)
|
||||
#define LUBDE_WAIT_FOR_INTERRUPT _IO(LUBDE_MAGIC, 9)
|
||||
#define LUBDE_SEM_OP _IO(LUBDE_MAGIC, 10)
|
||||
#define LUBDE_UDELAY _IO(LUBDE_MAGIC, 11)
|
||||
#define LUBDE_GET_DEVICE_TYPE _IO(LUBDE_MAGIC, 12)
|
||||
#define LUBDE_SPI_READ_REG _IO(LUBDE_MAGIC, 13)
|
||||
#define LUBDE_SPI_WRITE_REG _IO(LUBDE_MAGIC, 14)
|
||||
#define LUBDE_READ_REG_16BIT_BUS _IO(LUBDE_MAGIC, 19)
|
||||
#define LUBDE_WRITE_REG_16BIT_BUS _IO(LUBDE_MAGIC, 20)
|
||||
#define LUBDE_GET_BUS_FEATURES _IO(LUBDE_MAGIC, 21)
|
||||
#define LUBDE_WRITE_IRQ_MASK _IO(LUBDE_MAGIC, 22)
|
||||
#define LUBDE_CPU_WRITE_REG _IO(LUBDE_MAGIC, 23)
|
||||
#define LUBDE_CPU_READ_REG _IO(LUBDE_MAGIC, 24)
|
||||
#define LUBDE_CPU_PCI_REGISTER _IO(LUBDE_MAGIC, 25)
|
||||
#define LUBDE_DEV_RESOURCE _IO(LUBDE_MAGIC, 26)
|
||||
#define LUBDE_IPROC_READ_REG _IO(LUBDE_MAGIC, 27)
|
||||
#define LUBDE_IPROC_WRITE_REG _IO(LUBDE_MAGIC, 28)
|
||||
#define LUBDE_ATTACH_INSTANCE _IO(LUBDE_MAGIC, 29)
|
||||
#define LUBDE_GET_DEVICE_STATE _IO(LUBDE_MAGIC, 30)
|
||||
|
||||
#define LUBDE_SEM_OP_CREATE 1
|
||||
#define LUBDE_SEM_OP_DESTROY 2
|
||||
#define LUBDE_SEM_OP_TAKE 3
|
||||
#define LUBDE_SEM_OP_GIVE 4
|
||||
|
||||
#define LUBDE_SUCCESS 0
|
||||
#define LUBDE_FAIL ((unsigned int)-1)
|
||||
|
||||
|
||||
/*
|
||||
* Version history
|
||||
* 1:add LUBDE_GET_DEVICE_STATE to support PCI hot plug
|
||||
*/
|
||||
#define KBDE_VERSION 1
|
||||
|
||||
|
||||
/* This is the signal that will be used
|
||||
* when an interrupt occurs
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#define LUBDE_INTERRUPT_SIGNAL SIGUSR1
|
||||
#define LUBDE_ETHER_INTERRUPT_SIGNAL SIGUSR2
|
||||
|
||||
#endif /* __LUBDE_H__ */
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SHBDE_H__
|
||||
#define __SHBDE_H__
|
||||
|
||||
typedef void (*shbde_log_func_t)(int level, const char *str, int param);
|
||||
|
||||
#define SHBDE_ERR 0
|
||||
#define SHBDE_WARN 1
|
||||
#define SHBDE_DBG 2
|
||||
|
||||
/* iProc configuration (primarily used for PCI-AXI bridge) */
|
||||
typedef struct shbde_iproc_config_s {
|
||||
unsigned int dev_id;
|
||||
unsigned int dev_rev;
|
||||
unsigned int use_msi;
|
||||
unsigned int iproc_ver;
|
||||
unsigned int cmic_ver;
|
||||
unsigned int cmic_rev;
|
||||
unsigned int dma_hi_bits;
|
||||
unsigned int mdio_base_addr;
|
||||
unsigned int pcie_phy_addr;
|
||||
unsigned int adjust_pcie_preemphasis;
|
||||
} shbde_iproc_config_t;
|
||||
|
||||
/* Hardware abstraction functions */
|
||||
typedef struct shbde_hal_s {
|
||||
|
||||
/* Optional log output interface */
|
||||
shbde_log_func_t log_func;
|
||||
|
||||
/* PCI configuration access */
|
||||
unsigned char (*pcic8_read)(void *pci_dev, unsigned int reg);
|
||||
void (*pcic8_write)(void *pci_dev, unsigned int reg, unsigned char data);
|
||||
unsigned short (*pcic16_read)(void *pci_dev, unsigned int reg);
|
||||
void (*pcic16_write)(void *pci_dev, unsigned int reg, unsigned short data);
|
||||
unsigned int (*pcic32_read)(void *pci_dev, unsigned int reg);
|
||||
void (*pcic32_write)(void *pci_dev, unsigned int reg, unsigned int data);
|
||||
|
||||
/* iProc register access */
|
||||
unsigned int (*io32_read)(void *addr);
|
||||
void (*io32_write)(void *addr, unsigned int);
|
||||
|
||||
/* usleep function (optional) */
|
||||
void (*usleep)(int usec);
|
||||
|
||||
/* PCI parent device access */
|
||||
void *(*pci_parent_device_get)(void *pci_dev);
|
||||
|
||||
/* iProc configuration */
|
||||
shbde_iproc_config_t icfg;
|
||||
|
||||
} shbde_hal_t;
|
||||
|
||||
|
||||
#endif /* __SHBDE_H__ */
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SHBDE_IPROC_H__
|
||||
#define __SHBDE_IPROC_H__
|
||||
|
||||
#include <shbde.h>
|
||||
|
||||
extern int
|
||||
shbde_iproc_config_init(shbde_iproc_config_t *icfg,
|
||||
unsigned int dev_id, unsigned int dev_rev);
|
||||
|
||||
extern int
|
||||
shbde_iproc_paxb_init(shbde_hal_t *shbde, void *iproc_regs,
|
||||
shbde_iproc_config_t *icfg);
|
||||
|
||||
extern unsigned int
|
||||
shbde_iproc_pci_read(shbde_hal_t *shbde, void *iproc_regs,
|
||||
unsigned int addr);
|
||||
|
||||
extern void
|
||||
shbde_iproc_pci_write(shbde_hal_t *shbde, void *iproc_regs,
|
||||
unsigned int addr, unsigned int data);
|
||||
|
||||
extern int
|
||||
shbde_iproc_pcie_preemphasis_set(shbde_hal_t *shbde, void *iproc_regs,
|
||||
shbde_iproc_config_t *icfg, void *pci_dev);
|
||||
|
||||
#endif /* __SHBDE_IPROC_H__ */
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2015 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SHBDE_MDIO_H__
|
||||
#define __SHBDE_MDIO_H__
|
||||
|
||||
#include <shbde.h>
|
||||
|
||||
typedef struct shbde_mdio_ctrl_s {
|
||||
|
||||
/* Primary HAL*/
|
||||
shbde_hal_t *shbde;
|
||||
|
||||
/* Context for iProc MDIO register access */
|
||||
void *regs;
|
||||
|
||||
/* Base address for MDIO registers */
|
||||
unsigned int base_addr;
|
||||
|
||||
/* iProc MDIO register access */
|
||||
unsigned int (*io32_read)(shbde_hal_t *shbde, void *iproc_regs,
|
||||
unsigned int addr);
|
||||
void (*io32_write)(shbde_hal_t *shbde, void *iproc_regs,
|
||||
unsigned int addr, unsigned int data);
|
||||
|
||||
} shbde_mdio_ctrl_t;
|
||||
|
||||
|
||||
extern int
|
||||
shbde_iproc_mdio_init(shbde_mdio_ctrl_t *smc);
|
||||
|
||||
extern int
|
||||
shbde_iproc_mdio_read(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
|
||||
unsigned int reg, unsigned int *val);
|
||||
|
||||
extern int
|
||||
shbde_iproc_mdio_write(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
|
||||
unsigned int reg, unsigned int val);
|
||||
|
||||
#endif /* __SHBDE_MDIO_H__ */
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SHBDE_PCI_H__
|
||||
#define __SHBDE_PCI_H__
|
||||
|
||||
#include <shbde.h>
|
||||
|
||||
extern unsigned int
|
||||
shbde_pci_pcie_cap(shbde_hal_t *shbde, void *pci_dev);
|
||||
|
||||
extern int
|
||||
shbde_pci_is_pcie(shbde_hal_t *shbde, void *pci_dev);
|
||||
|
||||
extern int
|
||||
shbde_pci_is_iproc(shbde_hal_t *shbde, void *pci_dev, int *cmic_bar);
|
||||
|
||||
extern int
|
||||
shbde_pci_max_payload_set(shbde_hal_t *shbde, void *pci_dev, int maxpayload);
|
||||
|
||||
extern int
|
||||
shbde_pci_iproc_version_get(shbde_hal_t *shbde, void *pci_dev,
|
||||
unsigned int *iproc_ver,
|
||||
unsigned int *cmic_ver,
|
||||
unsigned int *cmic_rev);
|
||||
|
||||
#endif /* __SHBDE_PCI_H__ */
|
@ -0,0 +1,466 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <shbde_iproc.h>
|
||||
#include <shbde_mdio.h>
|
||||
#include <shbde_pci.h>
|
||||
|
||||
/* PAXB register offsets within PCI BAR0 window */
|
||||
#define BAR0_PAXB_ENDIANESS 0x2030
|
||||
#define BAR0_PAXB_PCIE_EP_AXI_CONFIG 0x2104
|
||||
#define BAR0_PAXB_CONFIG_IND_ADDR 0x2120
|
||||
#define BAR0_PAXB_CONFIG_IND_DATA 0x2124
|
||||
|
||||
#define BAR0_PAXB_IMAP0_0 (0x2c00)
|
||||
#define BAR0_PAXB_IMAP0_1 (0x2c04)
|
||||
#define BAR0_PAXB_IMAP0_2 (0x2c08)
|
||||
#define BAR0_PAXB_IMAP0_7 (0x2c1c)
|
||||
|
||||
#define BAR0_PAXB_OARR_FUNC0_MSI_PAGE 0x2d34
|
||||
#define BAR0_PAXB_OARR_2 0x2d60
|
||||
#define BAR0_PAXB_OARR_2_UPPER 0x2d64
|
||||
#define BAR0_DMU_PCU_PCIE_SLAVE_RESET_MODE 0x7024
|
||||
|
||||
/* Force byte pointer for offset adjustments */
|
||||
#define ROFFS(_ptr, _offset) ((unsigned char*)(_ptr) + (_offset))
|
||||
|
||||
#define PAXB_CONFIG_IND_ADDRr_PROTOCOL_LAYERf_SHFT 11
|
||||
#define PAXB_CONFIG_IND_ADDRr_PROTOCOL_LAYERf_MASK 0x3
|
||||
#define PAXB_CONFIG_IND_ADDRr_ADDRESSf_SHFT 0
|
||||
#define PAXB_CONFIG_IND_ADDRr_ADDRESSf_MASK 0x7ff
|
||||
|
||||
/* Register value set/get by field */
|
||||
#define REG_FIELD_SET(_r, _f, _r_val, _f_val) \
|
||||
_r_val = ((_r_val) & ~(_r##_##_f##_MASK << _r##_##_f##_SHFT)) | \
|
||||
(((_f_val) & _r##_##_f##_MASK) << _r##_##_f##_SHFT)
|
||||
#define REG_FIELD_GET(_r, _f, _r_val) \
|
||||
(((_r_val) >> _r##_##_f##_SHFT) & _r##_##_f##_MASK)
|
||||
|
||||
/* PCIe capabilities definition */
|
||||
#ifndef PCI_EXP_LNKSTA
|
||||
#define PCI_EXP_LNKSTA 0x12
|
||||
#endif
|
||||
/* Current Link Speed 5.0GT/s */
|
||||
#ifndef PCI_EXP_LNKSTA_CLS_5_0GB
|
||||
#define PCI_EXP_LNKSTA_CLS_5_0GB 2
|
||||
#endif
|
||||
#ifndef PCI_EXP_LNKSTA2
|
||||
#define PCI_EXP_LNKSTA2 0x32
|
||||
#endif
|
||||
/* Current Deemphasis Level -3.5 dB */
|
||||
#ifndef PCI_EXP_LNKSTA2_CDL_3_5DB
|
||||
#define PCI_EXP_LNKSTA2_CDL_3_5DB 0x1
|
||||
#endif
|
||||
|
||||
static unsigned int
|
||||
iproc32_read(shbde_hal_t *shbde, void *addr)
|
||||
{
|
||||
if (!shbde || !shbde->io32_read) {
|
||||
return 0;
|
||||
}
|
||||
return shbde->io32_read(addr);
|
||||
}
|
||||
|
||||
static void
|
||||
iproc32_write(shbde_hal_t *shbde, void *addr, unsigned int data)
|
||||
{
|
||||
if (!shbde || !shbde->io32_write) {
|
||||
return;
|
||||
}
|
||||
shbde->io32_write(addr, data);
|
||||
}
|
||||
|
||||
static void
|
||||
wait_usec(shbde_hal_t *shbde, int usec)
|
||||
{
|
||||
if (shbde && shbde->usleep) {
|
||||
shbde->usleep(usec);
|
||||
} else {
|
||||
int idx;
|
||||
volatile int count;
|
||||
for (idx = 0; idx < usec; idx++) {
|
||||
for (count = 0; count < 100; count++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_iproc_config_init
|
||||
* Purpose:
|
||||
* Initialize iProc configuration parameters
|
||||
* Parameters:
|
||||
* icfg - pointer to empty iProc configuration structure
|
||||
* Returns:
|
||||
* -1 if error, otherwise 0
|
||||
*/
|
||||
int
|
||||
shbde_iproc_config_init(shbde_iproc_config_t *icfg,
|
||||
unsigned int dev_id, unsigned int dev_rev)
|
||||
{
|
||||
if (!icfg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save device ID and revision */
|
||||
icfg->dev_id = dev_id;
|
||||
icfg->dev_rev = dev_rev;
|
||||
|
||||
/* Check device families first */
|
||||
switch (icfg->dev_id & 0xfff0) {
|
||||
case 0x8400: /* Greyhound Lite */
|
||||
case 0x8410: /* Greyhound */
|
||||
case 0x8420: /* Bloodhound */
|
||||
case 0x8450: /* Elkhound */
|
||||
case 0xb060: /* Ranger2(Greyhound) */
|
||||
case 0x8360: /* Greyhound 53365 & 53369 */
|
||||
case 0xb260: /* saber2 */
|
||||
case 0xb460: /* saber2+ */
|
||||
case 0xb170: /* Hurricane3-MG */
|
||||
case 0x8570: /* Greyhound2 */
|
||||
case 0xb070: /* Greyhound2(emulation) */
|
||||
case 0x8580: /* Greyhound2(emulation) */
|
||||
case 0xb230: /* Dagger2 */
|
||||
icfg->iproc_ver = 7;
|
||||
icfg->dma_hi_bits = 0x2;
|
||||
break;
|
||||
case 0xb560: /* Apache */
|
||||
case 0xb760: /* Maverick */
|
||||
icfg->iproc_ver = 0xB;
|
||||
break;
|
||||
case 0xb160: /* Hurricane3 */
|
||||
case 0x8440: /* Wolfhound2 */
|
||||
case 0x8430: /* Foxhound2 */
|
||||
icfg->iproc_ver = 10;
|
||||
icfg->dma_hi_bits = 0x2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for exceptions */
|
||||
switch (icfg->dev_id) {
|
||||
case 0xb069:
|
||||
case 0xb068:
|
||||
icfg->iproc_ver = 0xB; /*Ranger2+ Apache Family */
|
||||
icfg->dma_hi_bits = 0;
|
||||
break;
|
||||
case 0xb168: /* Ranger3+ */
|
||||
case 0xb169:
|
||||
icfg->iproc_ver = 0;
|
||||
icfg->dma_hi_bits = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* Check for PCIe PHY address that needs PCIe preemphasis and
|
||||
* assign the MDIO base address
|
||||
*/
|
||||
switch (icfg->dev_id & 0xfff0) {
|
||||
case 0xb150: /* Hurricane2 */
|
||||
case 0x8340: /* Wolfhound */
|
||||
case 0x8330: /* Foxhound */
|
||||
case 0x8390: /* Dearhound */
|
||||
icfg->mdio_base_addr = 0x18032000;
|
||||
icfg->pcie_phy_addr = 0x2;
|
||||
break;
|
||||
case 0xb340: /* Helilx4 */
|
||||
case 0xb540: /* FireScout */
|
||||
case 0xb040: /* Spiral, Ranger */
|
||||
icfg->mdio_base_addr = 0x18032000;
|
||||
icfg->pcie_phy_addr = 0x5;
|
||||
icfg->adjust_pcie_preemphasis = 1;
|
||||
break;
|
||||
case 0xa450: /* Katana2 */
|
||||
case 0xb240:
|
||||
case 0xb450:
|
||||
icfg->mdio_base_addr = 0x18032000;
|
||||
icfg->pcie_phy_addr = 0x5;
|
||||
icfg->adjust_pcie_preemphasis = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for exceptions */
|
||||
switch (icfg->dev_id) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_iproc_paxb_init
|
||||
* Purpose:
|
||||
* Initialize iProc PCI-AXI bridge for CMIC access
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* iproc_regs - memory mapped iProc registers in PCI BAR
|
||||
* icfg - iProc configuration parameters
|
||||
* Returns:
|
||||
* -1 if error, otherwise 0
|
||||
*/
|
||||
int
|
||||
shbde_iproc_paxb_init(shbde_hal_t *shbde, void *iproc_regs,
|
||||
shbde_iproc_config_t *icfg)
|
||||
{
|
||||
void *reg;
|
||||
unsigned int data;
|
||||
int pci_num;
|
||||
|
||||
if (!iproc_regs || !icfg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following code attempts to auto-detect the correct
|
||||
* iProc PCI endianess configuration by reading a well-known
|
||||
* register (the endianess configuration register itself).
|
||||
* Note that the PCI endianess may be different for different
|
||||
* big endian host processors.
|
||||
*/
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_ENDIANESS);
|
||||
/* Select big endian */
|
||||
iproc32_write(shbde, reg, 0x01010101);
|
||||
/* Check if endianess register itself is correct endian */
|
||||
if (iproc32_read(shbde, reg) != 1) {
|
||||
/* If not, then assume little endian */
|
||||
iproc32_write(shbde, reg, 0x0);
|
||||
}
|
||||
|
||||
/* Select which PCI core to use */
|
||||
pci_num = 0;
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_2);
|
||||
data = iproc32_read(shbde, reg);
|
||||
if (data & 0x1000) {
|
||||
/* PAXB_1 is mapped to sub-window 2 */
|
||||
pci_num = 1;
|
||||
}
|
||||
|
||||
/* Default DMA mapping if uninitialized */
|
||||
if (icfg->dma_hi_bits == 0) {
|
||||
icfg->dma_hi_bits = 0x1;
|
||||
if (pci_num == 1) {
|
||||
icfg->dma_hi_bits = 0x2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable iProc DMA to external host memory */
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_PCIE_EP_AXI_CONFIG);
|
||||
iproc32_write(shbde, reg, 0x0);
|
||||
if(icfg->cmic_ver < 4) { /* Non-CMICX */
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2);
|
||||
iproc32_write(shbde, reg, 0x1);
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2_UPPER);
|
||||
iproc32_write(shbde, reg, icfg->dma_hi_bits);
|
||||
|
||||
/* Configure MSI interrupt page */
|
||||
if (icfg->use_msi) {
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_FUNC0_MSI_PAGE);
|
||||
data = iproc32_read(shbde, reg);
|
||||
iproc32_write(shbde, reg, data | 0x1);
|
||||
}
|
||||
}
|
||||
return pci_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_iproc_pci_read
|
||||
* Purpose:
|
||||
* Read iProc register through PCI BAR 0
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* iproc_regs - memory mapped iProc registers in PCI BAR
|
||||
* addr - iProc register address in AXI memory space
|
||||
* Returns:
|
||||
* Register value
|
||||
*/
|
||||
unsigned int
|
||||
shbde_iproc_pci_read(shbde_hal_t *shbde, void *iproc_regs,
|
||||
unsigned int addr)
|
||||
{
|
||||
unsigned int subwin_base;
|
||||
void *reg;
|
||||
shbde_iproc_config_t *icfg = &shbde->icfg;
|
||||
|
||||
if (!iproc_regs) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Sub-window size is 0x1000 (4K) */
|
||||
subwin_base = (addr & ~0xfff);
|
||||
|
||||
if((icfg->cmic_ver >= 4) && (subwin_base == 0x18013000)) {
|
||||
/* Route the INTC block access through IMAP0_6 */
|
||||
reg = ROFFS(iproc_regs, 0x6000 + (addr & 0xfff));
|
||||
} else {
|
||||
/* Update base address for sub-window 7 */
|
||||
subwin_base |= 1; /* Valid bit */
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7);
|
||||
iproc32_write(shbde, reg, subwin_base);
|
||||
/* Read it to make sure the write actually goes through */
|
||||
subwin_base = iproc32_read(shbde, reg);
|
||||
|
||||
/* Read register through sub-window 7 */
|
||||
reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff));
|
||||
}
|
||||
|
||||
return iproc32_read(shbde, reg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_iproc_pci_write
|
||||
* Purpose:
|
||||
* Write iProc register through PCI BAR 0
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* iproc_regs - memory mapped iProc registers in PCI BAR
|
||||
* addr - iProc register address in AXI memory space
|
||||
* data - data to write to iProc register
|
||||
* Returns:
|
||||
* Register value
|
||||
*/
|
||||
void
|
||||
shbde_iproc_pci_write(shbde_hal_t *shbde, void *iproc_regs,
|
||||
unsigned int addr, unsigned int data)
|
||||
{
|
||||
unsigned int subwin_base;
|
||||
void *reg;
|
||||
shbde_iproc_config_t *icfg = &shbde->icfg;
|
||||
|
||||
if (!iproc_regs) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Sub-window size is 0x1000 (4K) */
|
||||
subwin_base = (addr & ~0xfff);
|
||||
|
||||
if((icfg->cmic_ver >= 4) && (subwin_base == 0x18013000)) {
|
||||
/* Route the INTC block access through IMAP0_6 */
|
||||
reg = ROFFS(iproc_regs, 0x6000 + (addr & 0xfff));
|
||||
} else {
|
||||
/* Update base address for sub-window 7 */
|
||||
subwin_base |= 1; /* Valid bit */
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7);
|
||||
iproc32_write(shbde, reg, subwin_base);
|
||||
/* Read it to make sure the write actually goes through */
|
||||
subwin_base = iproc32_read(shbde, reg);
|
||||
|
||||
/* Read register through sub-window 7 */
|
||||
reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff));
|
||||
}
|
||||
|
||||
iproc32_write(shbde, reg, data);
|
||||
}
|
||||
|
||||
int
|
||||
shbde_iproc_pcie_preemphasis_set(shbde_hal_t *shbde, void *iproc_regs,
|
||||
shbde_iproc_config_t *icfg, void *pci_dev)
|
||||
{
|
||||
shbde_mdio_ctrl_t mdio_ctrl, *smc = &mdio_ctrl;
|
||||
unsigned int phy_addr, data;
|
||||
void *reg;
|
||||
unsigned int pcie_cap_base;
|
||||
unsigned short link_stat, link_stat2;
|
||||
|
||||
if (!icfg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* PHY address for PCIe link */
|
||||
phy_addr = icfg->pcie_phy_addr;
|
||||
if (phy_addr == 0 || icfg->mdio_base_addr == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize MDIO control */
|
||||
smc->shbde = shbde;
|
||||
smc->regs = iproc_regs;
|
||||
smc->base_addr = icfg->mdio_base_addr;
|
||||
smc->io32_read = shbde_iproc_pci_read;
|
||||
smc->io32_write = shbde_iproc_pci_write;
|
||||
shbde_iproc_mdio_init(smc);
|
||||
|
||||
/* PCIe SerDes Gen1/Gen2 CDR Track Bandwidth Adjustment
|
||||
* for Better Jitter Tolerance
|
||||
*/
|
||||
shbde_iproc_mdio_write(smc, phy_addr, 0x1f, 0x8630);
|
||||
shbde_iproc_mdio_write(smc, phy_addr, 0x13, 0x190);
|
||||
shbde_iproc_mdio_write(smc, phy_addr, 0x19, 0x191);
|
||||
|
||||
if (!icfg->adjust_pcie_preemphasis) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check to see if the PCIe SerDes deemphasis needs to be changed
|
||||
* based on the advertisement from the root complex
|
||||
*/
|
||||
/* Find PCIe capability base */
|
||||
if (!shbde || !shbde->pcic16_read || !pci_dev) {
|
||||
return -1;
|
||||
}
|
||||
pcie_cap_base = shbde_pci_pcie_cap(shbde, pci_dev);
|
||||
if (pcie_cap_base) {
|
||||
link_stat = shbde->pcic16_read(pci_dev,
|
||||
pcie_cap_base + PCI_EXP_LNKSTA);
|
||||
link_stat2 = shbde->pcic16_read(pci_dev,
|
||||
pcie_cap_base + PCI_EXP_LNKSTA2);
|
||||
if (((link_stat & 0xf) == PCI_EXP_LNKSTA_CLS_5_0GB) &&
|
||||
(link_stat2 & PCI_EXP_LNKSTA2_CDL_3_5DB)) {
|
||||
/* Device is operating at Gen2 speeds and RC requested -3.5dB */
|
||||
/* Change the transmitter setting */
|
||||
shbde_iproc_mdio_write(smc, phy_addr, 0x1f, 0x8610);
|
||||
shbde_iproc_mdio_read(smc, phy_addr, 0x17, &data);
|
||||
data &= ~0xf00;
|
||||
data |= 0x700;
|
||||
shbde_iproc_mdio_write(smc, phy_addr, 0x17, data);
|
||||
|
||||
/* Force the PCIe link to retrain */
|
||||
data = 0;
|
||||
REG_FIELD_SET(PAXB_CONFIG_IND_ADDRr, PROTOCOL_LAYERf, data, 0x2);
|
||||
REG_FIELD_SET(PAXB_CONFIG_IND_ADDRr, ADDRESSf, data, 0x4);
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_CONFIG_IND_ADDR);
|
||||
iproc32_write(shbde, reg, data);
|
||||
|
||||
reg = ROFFS(iproc_regs, BAR0_PAXB_CONFIG_IND_DATA);
|
||||
data = iproc32_read(shbde, reg);
|
||||
data &= ~0x4000;
|
||||
iproc32_write(shbde, reg, data);
|
||||
data |= 0x4000;
|
||||
iproc32_write(shbde, reg, data);
|
||||
data &= ~0x4000;
|
||||
iproc32_write(shbde, reg, data);
|
||||
|
||||
/* Wait a short while for the retraining to complete */
|
||||
wait_usec(shbde, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
187
platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c
Normal file
187
platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2015 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <shbde_mdio.h>
|
||||
|
||||
/* iProc MDIO register offset */
|
||||
#define MII_MGMT_CTRL 0x0
|
||||
#define MII_MGMT_CMD_DATA 0x4
|
||||
|
||||
/* iProc MII register with fields definition */
|
||||
#define MII_MGMT_CTRLr_MDCDIVf_SHFT 0
|
||||
#define MII_MGMT_CTRLr_MDCDIVf_MASK 0x7f
|
||||
#define MII_MGMT_CTRLr_BSYf_SHFT 8
|
||||
#define MII_MGMT_CTRLr_BSYf_MASK 0x1
|
||||
|
||||
#define MII_MGMT_CMD_DATAr_DATAf_SHFT 0
|
||||
#define MII_MGMT_CMD_DATAr_DATAf_MASK 0xffff
|
||||
#define MII_MGMT_CMD_DATAr_TAf_SHFT 16
|
||||
#define MII_MGMT_CMD_DATAr_TAf_MASK 0x3
|
||||
#define MII_MGMT_CMD_DATAr_RAf_SHFT 18
|
||||
#define MII_MGMT_CMD_DATAr_RAf_MASK 0x1f
|
||||
#define MII_MGMT_CMD_DATAr_PAf_SHFT 23
|
||||
#define MII_MGMT_CMD_DATAr_PAf_MASK 0x1f
|
||||
#define MII_MGMT_CMD_DATAr_OPf_SHFT 28
|
||||
#define MII_MGMT_CMD_DATAr_OPf_MASK 0x3
|
||||
#define MII_MGMT_CMD_DATAr_SBf_SHFT 30
|
||||
#define MII_MGMT_CMD_DATAr_SBf_MASK 0x3
|
||||
|
||||
/* Register field value set/get */
|
||||
#define REG_FIELD_SET(_r, _f, _r_val, _f_val) \
|
||||
_r_val = ((_r_val) & ~(_r##_##_f##_MASK << _r##_##_f##_SHFT)) | \
|
||||
(((_f_val) & _r##_##_f##_MASK) << _r##_##_f##_SHFT)
|
||||
#define REG_FIELD_GET(_r, _f, _r_val) \
|
||||
(((_r_val) >> _r##_##_f##_SHFT) & _r##_##_f##_MASK)
|
||||
|
||||
#define LOG_OUT(_shbde, _lvl, _str, _prm) \
|
||||
if ((_shbde)->log_func) { \
|
||||
(_shbde)->log_func(_lvl, _str, _prm); \
|
||||
}
|
||||
#define LOG_ERR(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_ERR, _str, _prm)
|
||||
#define LOG_WARN(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_WARN, _str, _prm)
|
||||
#define LOG_DBG(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_DBG, _str, _prm)
|
||||
|
||||
static unsigned int
|
||||
mdio32_read(shbde_mdio_ctrl_t *smc, unsigned int offset)
|
||||
{
|
||||
if (!smc || !smc->io32_read) {
|
||||
return 0;
|
||||
}
|
||||
return smc->io32_read(smc->shbde, smc->regs, smc->base_addr + offset);
|
||||
}
|
||||
|
||||
static void
|
||||
mdio32_write(shbde_mdio_ctrl_t *smc, unsigned int offset, unsigned int data)
|
||||
{
|
||||
if (!smc || !smc->io32_read) {
|
||||
return;
|
||||
}
|
||||
smc->io32_write(smc->shbde, smc->regs, smc->base_addr + offset, data);
|
||||
}
|
||||
|
||||
static void
|
||||
wait_usec(shbde_mdio_ctrl_t *smc, int usec)
|
||||
{
|
||||
shbde_hal_t *shbde = smc->shbde;
|
||||
|
||||
if (shbde && shbde->usleep) {
|
||||
shbde->usleep(usec);
|
||||
} else {
|
||||
int idx;
|
||||
volatile int count;
|
||||
for (idx = 0; idx < usec; idx++) {
|
||||
for (count = 0; count < 100; count++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
iproc_mdio_wait_for_busy(shbde_mdio_ctrl_t *smc)
|
||||
{
|
||||
int mii_busy;
|
||||
unsigned int reg_val;
|
||||
int count = 1000;
|
||||
|
||||
/* Wait until MII is not busy */
|
||||
do {
|
||||
reg_val = mdio32_read(smc, MII_MGMT_CTRL);
|
||||
mii_busy = REG_FIELD_GET(MII_MGMT_CTRLr, BSYf, reg_val);
|
||||
if (!mii_busy) {
|
||||
break;
|
||||
}
|
||||
wait_usec(smc, 10);
|
||||
count --;
|
||||
} while (count > 0);
|
||||
|
||||
return mii_busy;
|
||||
}
|
||||
|
||||
int
|
||||
shbde_iproc_mdio_init(shbde_mdio_ctrl_t *smc)
|
||||
{
|
||||
shbde_hal_t *shbde = smc->shbde;
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
/* Enable the iProc internal MDIO interface */
|
||||
REG_FIELD_SET(MII_MGMT_CTRLr, MDCDIVf, reg_val, 0x7f);
|
||||
mdio32_write(smc, MII_MGMT_CTRL, reg_val);
|
||||
|
||||
if (shbde && !shbde->usleep) {
|
||||
LOG_DBG(shbde, "shbde_mdio: no registration of usleep vector", 0);
|
||||
}
|
||||
|
||||
wait_usec(smc, 100);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
shbde_iproc_mdio_read(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
|
||||
unsigned int reg, unsigned int *val)
|
||||
{
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, SBf, reg_val, 0x1);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, TAf, reg_val, 0x2);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, OPf, reg_val, 0x2);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, PAf, reg_val, phy_addr);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, RAf, reg_val, reg);
|
||||
mdio32_write(smc, MII_MGMT_CMD_DATA, reg_val);
|
||||
|
||||
if (iproc_mdio_wait_for_busy(smc)) {
|
||||
*val = 0;
|
||||
LOG_DBG(smc->shbde, "shbde_iproc_mdio_read busy", reg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
reg_val = mdio32_read(smc, MII_MGMT_CMD_DATA);
|
||||
*val = REG_FIELD_GET(MII_MGMT_CMD_DATAr, DATAf, reg_val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
shbde_iproc_mdio_write(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
|
||||
unsigned int reg, unsigned int val)
|
||||
{
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, SBf, reg_val, 0x1);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, TAf, reg_val, 0x2);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, OPf, reg_val, 0x1);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, PAf, reg_val, phy_addr);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, RAf, reg_val, reg);
|
||||
REG_FIELD_SET(MII_MGMT_CMD_DATAr, DATAf, reg_val, val);
|
||||
mdio32_write(smc, MII_MGMT_CMD_DATA, reg_val);
|
||||
|
||||
if (iproc_mdio_wait_for_busy(smc)) {
|
||||
LOG_DBG(smc->shbde, "shbde_iproc_mdio_write busy", reg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for some time for the write to take effect */
|
||||
wait_usec(smc, 100);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
393
platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c
Normal file
393
platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c
Normal file
@ -0,0 +1,393 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
* $Copyright: (c) 2014 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <shbde_pci.h>
|
||||
|
||||
/* PCIe capabilities */
|
||||
#ifndef PCI_CAPABILITY_LIST
|
||||
#define PCI_CAPABILITY_LIST 0x34
|
||||
#endif
|
||||
#ifndef PCI_CAP_ID_EXP
|
||||
#define PCI_CAP_ID_EXP 0x10
|
||||
#endif
|
||||
#ifndef PCI_EXP_DEVCAP
|
||||
#define PCI_EXP_DEVCAP 4
|
||||
#endif
|
||||
#ifndef PCI_EXP_DEVCTL
|
||||
#define PCI_EXP_DEVCTL 8
|
||||
#endif
|
||||
#ifndef PCI_EXT_CAP_START
|
||||
#define PCI_EXT_CAP_START 0x100
|
||||
#endif
|
||||
#ifndef PCI_EXT_CAP_ID
|
||||
#define PCI_EXT_CAP_ID(_hdr) (_hdr & 0x0000ffff)
|
||||
#endif
|
||||
#ifndef PCI_EXT_CAP_VER
|
||||
#define PCI_EXT_CAP_VER(_hdr) ((_hdr >> 16) & 0xf)
|
||||
#endif
|
||||
#ifndef PCI_EXT_CAP_NEXT
|
||||
#define PCI_EXT_CAP_NEXT(_hdr) ((_hdr >> 20) & 0xffc)
|
||||
#endif
|
||||
#ifndef PCI_EXT_CAP_ID_VNDR
|
||||
#define PCI_EXT_CAP_ID_VNDR 0x0b
|
||||
#endif
|
||||
|
||||
#define LOG_OUT(_shbde, _lvl, _str, _prm) \
|
||||
if ((_shbde)->log_func) { \
|
||||
(_shbde)->log_func(_lvl, _str, _prm); \
|
||||
}
|
||||
#define LOG_ERR(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_ERR, _str, _prm)
|
||||
#define LOG_WARN(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_WARN, _str, _prm)
|
||||
#define LOG_DBG(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_DBG, _str, _prm)
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Warpper functions with null-pointer checks.
|
||||
*/
|
||||
static unsigned int
|
||||
pcic16_read(shbde_hal_t *shbde, void *pci_dev,
|
||||
unsigned int addr)
|
||||
{
|
||||
if (!shbde || !shbde->pcic16_read) {
|
||||
return 0;
|
||||
}
|
||||
return shbde->pcic16_read(pci_dev, addr);
|
||||
}
|
||||
|
||||
static void
|
||||
pcic16_write(shbde_hal_t *shbde, void *pci_dev,
|
||||
unsigned int addr, unsigned int data)
|
||||
{
|
||||
if (!shbde || !shbde->pcic16_write) {
|
||||
return;
|
||||
}
|
||||
shbde->pcic16_write(pci_dev, addr, data);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
pcic32_read(shbde_hal_t *shbde, void *pci_dev,
|
||||
unsigned int addr)
|
||||
{
|
||||
if (!shbde || !shbde->pcic32_read) {
|
||||
return 0;
|
||||
}
|
||||
return shbde->pcic32_read(pci_dev, addr);
|
||||
}
|
||||
|
||||
static void *
|
||||
pci_parent_device_get(shbde_hal_t *shbde, void *pci_dev)
|
||||
{
|
||||
if (!shbde || !shbde->pci_parent_device_get) {
|
||||
return NULL;
|
||||
}
|
||||
return shbde->pci_parent_device_get(pci_dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_pci_pcie_cap
|
||||
* Purpose:
|
||||
* Return offset of PCIe capabilities in PCI configuration space
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* dev - PCI device handle (passed back to PCI HAL functions)
|
||||
* Returns:
|
||||
* PCI_CAP_ID_EXP offset in PCI configuration space if PCIe, otherwise 0
|
||||
*/
|
||||
unsigned int
|
||||
shbde_pci_pcie_cap(shbde_hal_t *shbde, void *pci_dev)
|
||||
{
|
||||
unsigned int cap_base, rval;
|
||||
|
||||
cap_base = pcic16_read(shbde, pci_dev, PCI_CAPABILITY_LIST);
|
||||
while (cap_base) {
|
||||
rval = pcic16_read(shbde, pci_dev, cap_base);
|
||||
if ((rval & 0xff) == PCI_CAP_ID_EXP) {
|
||||
break;
|
||||
}
|
||||
cap_base = (rval >> 8) & 0xff;
|
||||
}
|
||||
|
||||
return cap_base;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_pci_is_pcie
|
||||
* Purpose:
|
||||
* Check if PCI device is PCIe device
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* dev - PCI device handle (passed back to PCI HAL functions)
|
||||
* Returns:
|
||||
* 1 if PCIe, otherwise 0
|
||||
*/
|
||||
int
|
||||
shbde_pci_is_pcie(shbde_hal_t *shbde, void *pci_dev)
|
||||
{
|
||||
return shbde_pci_pcie_cap(shbde, pci_dev) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_pci_is_iproc
|
||||
* Purpose:
|
||||
* Check if PCI device is iProc-based
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* dev - PCI device handle (passed back to PCI HAL functions)
|
||||
* cmic_bar - (OUT) PCI BAR which contains switch CMIC registers
|
||||
* Returns:
|
||||
* 1 if iProc-based, otherwise 0
|
||||
*/
|
||||
int
|
||||
shbde_pci_is_iproc(shbde_hal_t *shbde, void *pci_dev, int *cmic_bar)
|
||||
{
|
||||
unsigned int cap_base, rval;
|
||||
|
||||
if (!shbde_pci_is_pcie(shbde, pci_dev)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Look for PCIe vendor-specific extended capability (VSEC) */
|
||||
cap_base = PCI_EXT_CAP_START;
|
||||
while (cap_base) {
|
||||
rval = pcic32_read(shbde, pci_dev, cap_base);
|
||||
if (rval == 0xffffffff) {
|
||||
/* Assume PCI HW read error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PCI_EXT_CAP_ID(rval) == PCI_EXT_CAP_ID_VNDR) {
|
||||
break;
|
||||
}
|
||||
cap_base = PCI_EXT_CAP_NEXT(rval);
|
||||
}
|
||||
if (cap_base) {
|
||||
/*
|
||||
* VSEC layout:
|
||||
*
|
||||
* 0x00: PCI Express Extended Capability Header
|
||||
* 0x04: Vendor-Specific Header
|
||||
* 0x08: Vendor-Specific Register 1
|
||||
* 0x0c: Vendor-Specific Register 2
|
||||
* ...
|
||||
* 0x24: Vendor-Specific Register 8
|
||||
*/
|
||||
/* 32'b // 31:12=0 Reserved; 11:08=CMIC BAR; 07:00=iProc Configuration ID */
|
||||
rval = pcic32_read(shbde, pci_dev, cap_base + 8);
|
||||
LOG_DBG(shbde, "Found VSEC", rval);
|
||||
|
||||
/* Determine PCI BAR of CMIC */
|
||||
*cmic_bar = 0;
|
||||
if ((rval & 0x100) == 0x100) {
|
||||
*cmic_bar = 2;
|
||||
}
|
||||
/* Assume iProc device */
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_pci_iproc_version_get
|
||||
* Purpose:
|
||||
* Get iproc, cmic versions and revisions
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* dev - PCI device handle (passed back to PCI HAL functions)
|
||||
* iproc_ver - (OUT) iProc version
|
||||
* cmic_ver - (OUT) CMIC version
|
||||
* cmic_rev - (OUT) CMIC revision
|
||||
* Returns:
|
||||
* 1 for no error, otherwise 0
|
||||
*/
|
||||
int
|
||||
shbde_pci_iproc_version_get(shbde_hal_t *shbde, void *pci_dev,
|
||||
unsigned int *iproc_ver,
|
||||
unsigned int *cmic_ver,
|
||||
unsigned int *cmic_rev)
|
||||
{
|
||||
unsigned int cap_base, rval;
|
||||
|
||||
if (!shbde_pci_is_pcie(shbde, pci_dev)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Look for PCIe vendor-specific extended capability (VSEC) */
|
||||
cap_base = PCI_EXT_CAP_START;
|
||||
while (cap_base) {
|
||||
rval = pcic32_read(shbde, pci_dev, cap_base);
|
||||
if (rval == 0xffffffff) {
|
||||
/* Assume PCI HW read error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PCI_EXT_CAP_ID(rval) == PCI_EXT_CAP_ID_VNDR) {
|
||||
break;
|
||||
}
|
||||
cap_base = PCI_EXT_CAP_NEXT(rval);
|
||||
}
|
||||
if (cap_base) {
|
||||
/*
|
||||
* VSEC layout:
|
||||
*
|
||||
* 0x00: PCI Express Extended Capability Header
|
||||
* 0x04: Vendor-Specific Header
|
||||
* 0x08: Vendor-Specific Register 1
|
||||
* 0x0c: Vendor-Specific Register 2
|
||||
* ...
|
||||
* 0x24: Vendor-Specific Register 8
|
||||
*/
|
||||
|
||||
/* Read PCIe Vendor Specific Register 1 */
|
||||
/* VENODR REG FORMAT
|
||||
* [7:0] iProc Rev = 8'h0E (for P14)
|
||||
* [11:8] CMIC BAR = 4'h1 (BAR64-1)
|
||||
* [15:12] CMIC Version = 4'h4
|
||||
* [19:16] CMIC Rev = 4'h1
|
||||
* [22:20] SBUS Version = 4'h4
|
||||
*/
|
||||
|
||||
rval = pcic32_read(shbde, pci_dev, cap_base + 8);
|
||||
LOG_DBG(shbde, "Found VSEC", rval);
|
||||
|
||||
/* Determine PCI BAR of CMIC */
|
||||
*iproc_ver = rval & 0xff;
|
||||
*cmic_ver = (rval >> 12) & 0xf;
|
||||
*cmic_rev = (rval >> 16) & 0xf;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function:
|
||||
* shbde_pci_max_payload_set
|
||||
* Purpose:
|
||||
* Set PCIe maximum payload
|
||||
* Parameters:
|
||||
* shbde - pointer to initialized hardware abstraction module
|
||||
* dev - PCI device handle (passed back to PCI HAL functions)
|
||||
* maxpayload - maximum payload (in byte)
|
||||
* Returns:
|
||||
* -1 if error, otherwise 0
|
||||
* Notes:
|
||||
* If not PCIe device, set the PCI retry count to infinte instead.
|
||||
*/
|
||||
int
|
||||
shbde_pci_max_payload_set(shbde_hal_t *shbde, void *pci_dev, int maxpayload)
|
||||
{
|
||||
unsigned int cap_base, parent_cap_base;
|
||||
unsigned int devcap, devctl, parent_devctl;
|
||||
int max_val, max_cap, parent_max_val;
|
||||
void *parent_pci_dev;
|
||||
|
||||
cap_base = shbde_pci_pcie_cap(shbde, pci_dev);
|
||||
|
||||
if (cap_base == 0) {
|
||||
/* Not PCIe */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get current device control settings */
|
||||
devctl = pcic16_read(shbde, pci_dev, cap_base + PCI_EXP_DEVCTL);
|
||||
|
||||
/* Get current max payload setting */
|
||||
max_val = (devctl >> 5) & 0x7;
|
||||
|
||||
if (maxpayload) {
|
||||
/* Get encoding from byte value */
|
||||
max_val = 0;
|
||||
while ((1 << (max_val + 7)) < maxpayload) {
|
||||
max_val++;
|
||||
}
|
||||
LOG_DBG(shbde, "Set max payload size", maxpayload);
|
||||
LOG_DBG(shbde, "Set max payload val", max_val);
|
||||
|
||||
/* Get max supported payload size */
|
||||
devcap = pcic16_read(shbde, pci_dev, cap_base + PCI_EXP_DEVCAP);
|
||||
max_cap = (devcap & 0x7);
|
||||
|
||||
/* Do not exceed device capabilities */
|
||||
if (max_val > max_cap) {
|
||||
max_val = max_cap;
|
||||
LOG_DBG(shbde,
|
||||
"Payload size exceeds device capability",
|
||||
maxpayload);
|
||||
}
|
||||
|
||||
/* Get currently set max payload size for the parent device
|
||||
* in the PCI tree (if it exists).
|
||||
*/
|
||||
parent_pci_dev = pci_parent_device_get(shbde, pci_dev);
|
||||
if (parent_pci_dev != NULL) {
|
||||
parent_cap_base = shbde_pci_pcie_cap(shbde, parent_pci_dev);
|
||||
parent_devctl = pcic16_read(shbde,
|
||||
parent_pci_dev,
|
||||
parent_cap_base + PCI_EXP_DEVCTL);
|
||||
parent_max_val = (parent_devctl >> 5) & 0x7;
|
||||
|
||||
/* Do not exceed current parent max payload setting (our device
|
||||
* should have an MPS setting <= current parent MPS setting in
|
||||
* the tree of PCIe devices).
|
||||
*/
|
||||
if (max_val > parent_max_val) {
|
||||
max_val = parent_max_val;
|
||||
LOG_DBG(shbde,
|
||||
"Payload size exceeds current parent device setting",
|
||||
maxpayload);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update max payload size */
|
||||
devctl &= ~(0x7 << 5);
|
||||
devctl |= (max_val) << 5;
|
||||
|
||||
/* Update max request size */
|
||||
devctl &= ~(0x7 << 12);
|
||||
devctl |= (max_val << 12);
|
||||
}
|
||||
|
||||
/* Always disable relaxed ordering */
|
||||
devctl &= ~(1 << 4);
|
||||
|
||||
/* Update device control settings */
|
||||
pcic16_write(shbde, pci_dev, cap_base + PCI_EXP_DEVCTL, devctl);
|
||||
|
||||
/* Warn if non-default setting is used */
|
||||
if (max_val > 0) {
|
||||
LOG_WARN(shbde,
|
||||
"Selected payload size may not be supported by all "
|
||||
"PCIe bridges by default.",
|
||||
(1 << (max_val + 7)));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.10 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
# Makefile for SOC SAL support
|
||||
#
|
||||
LOCALDIR = systems/linux/kernel/modules
|
||||
|
||||
include ${SDK}/make/Make.config
|
||||
|
||||
subdirs=shared uk-proxy bcm-diag-full bcm-core bcm-net bcm-diag
|
||||
|
||||
include ${SDK}/make/Make.subdirs
|
||||
|
||||
include ${SDK}/make/Make.depend
|
@ -0,0 +1,68 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.3 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
LOCALDIR = systems/linux/kernel/modules/bcm-knet
|
||||
|
||||
include ${SDK}/make/Make.config
|
||||
|
||||
LIBS = $(LIBDIR)/libkern.a
|
||||
|
||||
ifeq ($(kernel_version),2_4)
|
||||
MODULE = $(LIBDIR)/linux-bcm-knet.o
|
||||
else
|
||||
KERNEL_MODULE_DIR = kernel_module
|
||||
|
||||
THIS_MOD_NAME := linux-bcm-knet
|
||||
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
|
||||
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
|
||||
|
||||
build: $(MODULE) $(KMODULE)
|
||||
endif
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/kernel_module/Module.symvers
|
||||
ifeq (,$(findstring -DPROXY_SUPPORT=0,$(CFLAGS)))
|
||||
KBUILD_EXTRA_SYMBOLS += ${BLDDIR}/../uk-proxy/kernel_module/Module.symvers
|
||||
endif
|
||||
|
||||
# BCM Network Device
|
||||
|
||||
$(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS)
|
||||
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
|
||||
ifneq ($(kernel_version),2_4)
|
||||
$(KMODULE): $(MODULE)
|
||||
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
|
||||
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
|
||||
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
|
||||
endif
|
||||
|
||||
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
|
||||
|
||||
include ${SDK}/make/Make.depend
|
||||
|
||||
clean::
|
||||
$(RM) $(BLDDIR)/version.c $(BLDDIR)/version.o
|
||||
$(RM) $(BOBJS) $(MODULE)
|
||||
|
||||
ifneq ($(kernel_version),2_4)
|
||||
.PHONY: build
|
||||
endif
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: bcm-knet.h,v 1.4 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
#ifndef __LINUX_BCM_KNET_H__
|
||||
#define __LINUX_BCM_KNET_H__
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int rc;
|
||||
int len;
|
||||
int bufsz;
|
||||
int reserved;
|
||||
uint64_t buf;
|
||||
} bkn_ioctl_t;
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/*
|
||||
* Call-back interfaces for other Linux kernel drivers.
|
||||
*/
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
typedef struct {
|
||||
uint32 netif_user_data;
|
||||
uint32 filter_user_data;
|
||||
uint16 dcb_type;
|
||||
} knet_skb_cb_t;
|
||||
|
||||
#define KNET_SKB_CB(__skb) ((knet_skb_cb_t *)&((__skb)->cb[0]))
|
||||
|
||||
typedef struct sk_buff *
|
||||
(*knet_skb_cb_f)(struct sk_buff *skb, int dev_no, void *meta);
|
||||
|
||||
typedef int
|
||||
(*knet_filter_cb_f)(uint8_t *pkt, int size, int dev_no, void *meta,
|
||||
int chan, kcom_filter_t *filter);
|
||||
|
||||
extern int
|
||||
bkn_rx_skb_cb_register(knet_skb_cb_f rx_cb);
|
||||
|
||||
extern int
|
||||
bkn_rx_skb_cb_unregister(knet_skb_cb_f rx_cb);
|
||||
|
||||
extern int
|
||||
bkn_tx_skb_cb_register(knet_skb_cb_f tx_cb);
|
||||
|
||||
extern int
|
||||
bkn_tx_skb_cb_unregister(knet_skb_cb_f tx_cb);
|
||||
|
||||
extern int
|
||||
bkn_filter_cb_register(knet_filter_cb_f filter_cb);
|
||||
|
||||
extern int
|
||||
bkn_filter_cb_unregister(knet_filter_cb_f filter_cb);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_BCM_KNET_H__ */
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: gmodule.h,v 1.9 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_LINUX_KRN_GMODULE_H__
|
||||
#define __COMMON_LINUX_KRN_GMODULE_H__
|
||||
|
||||
#include <lkm.h>
|
||||
|
||||
typedef struct gmodule_s {
|
||||
|
||||
const char* name;
|
||||
int major;
|
||||
int minor;
|
||||
|
||||
int (*init)(void);
|
||||
int (*cleanup)(void);
|
||||
|
||||
int (*pprint)(void);
|
||||
|
||||
int (*open)(void);
|
||||
int (*ioctl)(unsigned int cmd, unsigned long arg);
|
||||
int (*close)(void);
|
||||
int (*mmap) (struct file *filp, struct vm_area_struct *vma);
|
||||
|
||||
} gmodule_t;
|
||||
|
||||
|
||||
/* The framework will ask for your module definition */
|
||||
extern gmodule_t* gmodule_get(void);
|
||||
|
||||
|
||||
/* Proc Filesystem information */
|
||||
extern int pprintf(const char* fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
extern int gmodule_vpprintf(char** page, const char* fmt, va_list args)
|
||||
__attribute__ ((format (printf, 2, 0)));
|
||||
extern int gmodule_pprintf(char** page, const char* fmt, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
extern int gprintk(const char* fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
extern int gdbg(const char* fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
#define GDBG gdbg
|
||||
|
||||
#endif /* __COMMON_LINUX_KRN_GMODULE_H__ */
|
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: lkm.h,v 1.22 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_LINUX_KRN_LKM_H__
|
||||
#define __COMMON_LINUX_KRN_LKM_H__
|
||||
|
||||
#ifndef __KERNEL__
|
||||
# define __KERNEL__
|
||||
#endif
|
||||
#ifndef MODULE
|
||||
# define MODULE
|
||||
#endif
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
|
||||
#include <linux/config.h>
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
|
||||
#include <linux/kconfig.h>
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
|
||||
#include <linux/slab.h>
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
|
||||
#include <linux/smp_lock.h>
|
||||
#endif
|
||||
#include <linux/module.h>
|
||||
|
||||
/* Helper defines for multi-version kernel support */
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
|
||||
#define LKM_2_4
|
||||
#else
|
||||
#define LKM_2_6
|
||||
#endif
|
||||
|
||||
#include <linux/kernel.h> /* printk() */
|
||||
#include <linux/fs.h> /* everything... */
|
||||
#include <linux/errno.h> /* error codes */
|
||||
#include <linux/types.h> /* size_t */
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/fcntl.h> /* O_ACCMODE */
|
||||
#include <linux/pci.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/stat.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <asm/io.h>
|
||||
#include <asm/hardirq.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#ifdef CONFIG_DEVFS_FS
|
||||
#include <linux/devfs_fs_kernel.h>
|
||||
#endif
|
||||
|
||||
#define PROC_INTERFACE_KERN_VER_3_10 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
|
||||
|
||||
/* Compatibility Macros */
|
||||
|
||||
#ifdef LKM_2_4
|
||||
|
||||
#include <linux/compatmac.h>
|
||||
#include <linux/wrapper.h>
|
||||
#define LKM_MOD_PARAM(n,ot,nt,d) MODULE_PARM(n,ot)
|
||||
#define LKM_MOD_PARAM_ARRAY(n,ot,nt,c,d) MODULE_PARM(n,ot)
|
||||
#define LKM_EXPORT_SYM(s)
|
||||
#define _free_netdev kfree
|
||||
|
||||
#else /* LKM_2_6 */
|
||||
|
||||
#define LKM_MOD_PARAM(n,ot,nt,d) module_param(n,nt,d)
|
||||
#define LKM_MOD_PARAM_ARRAY(n,ot,nt,c,d) module_param_array(n,nt,c,d)
|
||||
#define LKM_EXPORT_SYM(s) EXPORT_SYMBOL(s)
|
||||
#define _free_netdev free_netdev
|
||||
|
||||
#endif /* LKM_2_x */
|
||||
|
||||
#ifndef list_for_each_safe
|
||||
#define list_for_each_safe(l,t,i) t = 0; list_for_each((l),(i))
|
||||
#endif
|
||||
|
||||
#ifndef reparent_to_init
|
||||
#define reparent_to_init()
|
||||
#endif
|
||||
|
||||
#ifndef MODULE_LICENSE
|
||||
#define MODULE_LICENSE(str)
|
||||
#endif
|
||||
|
||||
#ifndef EXPORT_NO_SYMBOLS
|
||||
#define EXPORT_NO_SYMBOLS
|
||||
#endif
|
||||
|
||||
#ifndef DEFINE_SPINLOCK
|
||||
#define DEFINE_SPINLOCK(_lock) spinlock_t _lock = SPIN_LOCK_UNLOCKED
|
||||
#endif
|
||||
|
||||
#ifndef __SPIN_LOCK_UNLOCKED
|
||||
#define __SPIN_LOCK_UNLOCKED(_lock) SPIN_LOCK_UNLOCKED
|
||||
#endif
|
||||
|
||||
#ifndef lock_kernel
|
||||
#ifdef preempt_disable
|
||||
#define lock_kernel() preempt_disable()
|
||||
#else
|
||||
#define lock_kernel()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef unlock_kernel
|
||||
#ifdef preempt_enable
|
||||
#define unlock_kernel() preempt_enable()
|
||||
#else
|
||||
#define unlock_kernel()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef init_MUTEX_LOCKED
|
||||
#define init_MUTEX_LOCKED(_sem) sema_init(_sem, 0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM98245
|
||||
#define CONFIG_BMW
|
||||
#endif
|
||||
|
||||
#if PROC_INTERFACE_KERN_VER_3_10
|
||||
#define PROC_CREATE(_entry, _name, _acc, _path, _fops) \
|
||||
do { \
|
||||
_entry = proc_create(_name, _acc, _path, _fops); \
|
||||
} while (0)
|
||||
|
||||
#define PROC_CREATE_DATA(_entry, _name, _acc, _path, _fops, _data) \
|
||||
do { \
|
||||
_entry = proc_create_data(_name, _acc, _path, _fops, _data); \
|
||||
} while (0)
|
||||
|
||||
#define PROC_PDE_DATA(_node) PDE_DATA(_node)
|
||||
|
||||
#else
|
||||
#define PROC_CREATE(_entry, _name, _acc, _path, _fops) \
|
||||
do { \
|
||||
_entry = create_proc_entry(_name, _acc, _path); \
|
||||
if (_entry) { \
|
||||
_entry->proc_fops = _fops; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PROC_CREATE_DATA(_entry, _name, _acc, _path, _fops, _data) \
|
||||
do { \
|
||||
_entry = create_proc_entry(_name, _acc, _path); \
|
||||
if (_entry) { \
|
||||
_entry->proc_fops = _fops; \
|
||||
_entry->data=_data; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PROC_PDE_DATA(_node) PROC_I(_node)->pde->data
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_LINUX_KRN_LKM_H__ */
|
@ -0,0 +1,65 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id:
|
||||
# $Copyright: (c) 2017 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
LOCALDIR = systems/linux/kernel/modules/knet-cb
|
||||
|
||||
include ${SDK}/make/Make.config
|
||||
|
||||
LIBS = $(LIBDIR)/libkern.a
|
||||
|
||||
ifeq ($(kernel_version),2_4)
|
||||
MODULE = $(LIBDIR)/linux-knet-cb.o
|
||||
else
|
||||
KERNEL_MODULE_DIR = kernel_module
|
||||
|
||||
THIS_MOD_NAME := linux-knet-cb
|
||||
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
|
||||
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
|
||||
|
||||
build: $(MODULE) $(KMODULE)
|
||||
endif
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../bcm-knet/kernel_module/Module.symvers
|
||||
|
||||
# BCM Network Device
|
||||
|
||||
$(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS)
|
||||
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
|
||||
ifneq ($(kernel_version),2_4)
|
||||
$(KMODULE): $(MODULE)
|
||||
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
|
||||
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
|
||||
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
|
||||
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
|
||||
endif
|
||||
|
||||
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
|
||||
|
||||
include ${SDK}/make/Make.depend
|
||||
|
||||
clean::
|
||||
$(RM) $(BLDDIR)/version.c $(BLDDIR)/version.o
|
||||
$(RM) $(BOBJS) $(MODULE)
|
||||
|
||||
ifneq ($(kernel_version),2_4)
|
||||
.PHONY: build
|
||||
endif
|
@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id:
|
||||
* $Copyright: (c) 2017 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Driver for call-back functions for Linux KNET driver.
|
||||
*
|
||||
* This is sample code that demonstrates how to selectively strip VLAN tags
|
||||
* from an incoming packet based on tag information in the DMA control block
|
||||
* (DCB). The switch will automatically add a VLAN tag to packets that ingress
|
||||
* without an outer VLAN tag. Outer tagged and double tagged packets are
|
||||
* not modified. The call back defined here determines which packets have
|
||||
* had tags added by those and strips only those tags from the packet.
|
||||
*
|
||||
* This is sample code, the customer is responsible for maintaining and
|
||||
* modifying this code as necessary.
|
||||
*
|
||||
* The module can be built from the standard Linux user mode target
|
||||
* directories using the following command (assuming bash), e.g.
|
||||
*
|
||||
* cd $SDK/systems/linux/user/<target>
|
||||
* make BUILD_KNET_CB=1
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gmodule.h> /* Must be included first */
|
||||
#include <kcom.h>
|
||||
#include <bcm-knet.h>
|
||||
#include <linux/if_vlan.h>
|
||||
|
||||
MODULE_AUTHOR("Broadcom Corporation");
|
||||
MODULE_DESCRIPTION("Broadcom Linux KNET Call-Back Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
/* Module Information */
|
||||
#define MODULE_MAJOR 121
|
||||
#define MODULE_NAME "linux-knet-cb"
|
||||
|
||||
/* set KNET_CB_DEBUG for debug info */
|
||||
#define KNET_CB_DEBUG
|
||||
|
||||
/* Maintain tag strip statistics */
|
||||
struct strip_stats_s {
|
||||
unsigned long stripped; /* Number of packets that have been stripped */
|
||||
unsigned long checked;
|
||||
unsigned long skipped;
|
||||
};
|
||||
|
||||
static struct strip_stats_s strip_stats;
|
||||
|
||||
/* Local function prototypes */
|
||||
static void strip_vlan_tag(struct sk_buff *skb);
|
||||
static int get_tag_status(int dcb_type, void *meta);
|
||||
static struct sk_buff *strip_tag_rx_cb(struct sk_buff *skb, int dev_no, void *meta);
|
||||
static struct sk_buff *strip_tag_tx_cb(struct sk_buff *skb, int dev_no, void *meta);
|
||||
static int strip_tag_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta,
|
||||
int chan, kcom_filter_t * kf);
|
||||
static int _pprint(void);
|
||||
static int _cleanup(void);
|
||||
static int _init(void);
|
||||
|
||||
/* Remove VLAN tag for select TPIDs */
|
||||
static void
|
||||
strip_vlan_tag(struct sk_buff *skb)
|
||||
{
|
||||
uint16_t vlan_proto = (uint16_t) ((skb->data[12] << 8) | skb->data[13]);
|
||||
if ((vlan_proto == 0x8100) || (vlan_proto == 0x88a8) || (vlan_proto == 0x9100)) {
|
||||
/* Move first 12 bytes of packet back by 4 */
|
||||
((u32 *) skb->data)[3] = ((u32 *) skb->data)[2];
|
||||
((u32 *) skb->data)[2] = ((u32 *) skb->data)[1];
|
||||
((u32 *) skb->data)[1] = ((u32 *) skb->data)[0];
|
||||
skb_pull(skb, 4); /* Remove 4 bytes from start of buffer */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Location of tagging status in select DCB types found below:
|
||||
*
|
||||
* DCB type 14: word 12, bits 10.11
|
||||
* DCB type 19, 20, 21, 22, 30: word 12, bits 10..11
|
||||
* DCB type 23, 29: word 13, bits 0..1
|
||||
* DCB type 31, 34, 37: word 13, bits 0..1
|
||||
* DCB type 26, 32, 33, 35: word 13, bits 0..1
|
||||
*
|
||||
* The function get_tag_status() returns the tag status for known DCB types.
|
||||
* 0 = Untagged
|
||||
* 1 = Single inner-tag
|
||||
* 2 = Single outer-tag
|
||||
* 3 = Double tagged.
|
||||
* -1 = Unsupported DCB type
|
||||
*/
|
||||
static int
|
||||
get_tag_status(int dcb_type, void *meta)
|
||||
{
|
||||
uint32 *dcb = (uint32 *) meta;
|
||||
int tag_status;
|
||||
switch (dcb_type) {
|
||||
case 14:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 30:
|
||||
tag_status = (dcb[12] > 10) & 0x3;
|
||||
break;
|
||||
case 23:
|
||||
case 29:
|
||||
case 31:
|
||||
case 34:
|
||||
case 37:
|
||||
case 26:
|
||||
case 32:
|
||||
case 33:
|
||||
case 35:
|
||||
tag_status = dcb[13] & 0x3;
|
||||
break;
|
||||
default:
|
||||
tag_status = -1;
|
||||
break;
|
||||
}
|
||||
return tag_status;
|
||||
}
|
||||
|
||||
/*
|
||||
* SDK-134189 added the ability to pass two 4 byte unsigned values to the
|
||||
* KNET callback function, one from the matching filter and one from the
|
||||
* network interface. The usage of this data is completely defined by the
|
||||
* user. In this case, if bit 0 of the interface value is set, tag stripping
|
||||
* is enabled for that interface. When creating the interface and filter,
|
||||
* something like the following is necessary: "netif.cb_user_data = uflags".
|
||||
*/
|
||||
#define NETIF_UNTAGGED_STRIP (1 << 0)
|
||||
|
||||
/* Rx packet callback function */
|
||||
static struct sk_buff *
|
||||
strip_tag_rx_cb(struct sk_buff *skb, int dev_no, void *meta)
|
||||
{
|
||||
unsigned netif_flags = KNET_SKB_CB(skb)->netif_user_data;
|
||||
unsigned dcb_type;
|
||||
int tag_status;
|
||||
/* Currently not using filter flags:
|
||||
* unsigned filter_flags = KNET_SKB_CB(skb)->filter_user_data;
|
||||
*/
|
||||
|
||||
#ifdef KNET_CB_DEBUG
|
||||
gprintk("%s Enter; Flags: %08X\n", __func__, netif_flags);
|
||||
#endif
|
||||
|
||||
if ((netif_flags & NETIF_UNTAGGED_STRIP) == 0) {
|
||||
/* Untagged stripping not enabled on this netif */
|
||||
strip_stats.skipped++;
|
||||
return skb;
|
||||
}
|
||||
|
||||
/* Get DCB type for this packet, passed by KNET driver */
|
||||
dcb_type = KNET_SKB_CB(skb)->dcb_type;
|
||||
|
||||
/* Get tag status from DCB */
|
||||
tag_status = get_tag_status(dcb_type, meta);
|
||||
|
||||
#ifdef KNET_CB_DEBUG
|
||||
gprintk("%s; DCB Type: %d; tag status: %d\n", __func__, dcb_type, tag_status);
|
||||
#endif
|
||||
|
||||
if (tag_status < 0) {
|
||||
/* Unsupported DCB type */
|
||||
return skb;
|
||||
}
|
||||
|
||||
strip_stats.checked++;
|
||||
/*
|
||||
* Untagged and inner tagged packet will get a new tag from the switch
|
||||
* device, we need to strip this off.
|
||||
*/
|
||||
if (tag_status < 2) {
|
||||
#ifdef KNET_CB_DEBUG
|
||||
gprintk("%s; Stripping VLAN\n", __func__);
|
||||
#endif
|
||||
strip_stats.stripped++;
|
||||
strip_vlan_tag(skb);
|
||||
}
|
||||
#ifdef KNET_CB_DEBUG
|
||||
else {
|
||||
gprintk("%s; Preserve VLAN\n", __func__);
|
||||
}
|
||||
#endif
|
||||
return skb;
|
||||
}
|
||||
|
||||
/* Tx callback not used */
|
||||
static struct sk_buff *
|
||||
strip_tag_tx_cb(struct sk_buff *skb, int dev_no, void *meta)
|
||||
{
|
||||
/* Pass through for now */
|
||||
return skb;
|
||||
}
|
||||
|
||||
/* Filter callback not used */
|
||||
static int
|
||||
strip_tag_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta,
|
||||
int chan, kcom_filter_t *kf)
|
||||
{
|
||||
/* Pass through for now */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get statistics.
|
||||
* % cat /proc/linux-knet-cb
|
||||
*/
|
||||
static int
|
||||
_pprint(void)
|
||||
{
|
||||
pprintf("Broadcom Linux KNET Call-Back: Untagged VLAN Stripper\n");
|
||||
pprintf(" %lu stripped packets\n", strip_stats.stripped);
|
||||
pprintf(" %lu packets checked\n", strip_stats.checked);
|
||||
pprintf(" %lu packets skipped\n", strip_stats.skipped);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_cleanup(void)
|
||||
{
|
||||
bkn_rx_skb_cb_unregister(strip_tag_rx_cb);
|
||||
bkn_tx_skb_cb_unregister(strip_tag_tx_cb);
|
||||
bkn_filter_cb_unregister(strip_tag_filter_cb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_init(void)
|
||||
{
|
||||
bkn_rx_skb_cb_register(strip_tag_rx_cb);
|
||||
bkn_tx_skb_cb_register(strip_tag_tx_cb);
|
||||
bkn_filter_cb_register(strip_tag_filter_cb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gmodule_t _gmodule = {
|
||||
name: MODULE_NAME,
|
||||
major: MODULE_MAJOR,
|
||||
init: _init,
|
||||
cleanup: _cleanup,
|
||||
pprint: _pprint,
|
||||
ioctl: NULL,
|
||||
open: NULL,
|
||||
close: NULL,
|
||||
};
|
||||
|
||||
gmodule_t*
|
||||
gmodule_get(void)
|
||||
{
|
||||
EXPORT_NO_SYMBOLS;
|
||||
return &_gmodule;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.2 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
LOCALDIR = systems/linux/kernel/modules/shared
|
||||
|
||||
include ${SDK}/make/Make.config
|
||||
|
||||
lib = libkern
|
||||
|
||||
include ${SDK}/make/Make.kernlib
|
||||
|
||||
include ${SDK}/make/Make.depend
|
@ -0,0 +1,428 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: gmodule.c,v 1.20 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*
|
||||
* Generic Linux Module Framework
|
||||
*
|
||||
* Hooks up your driver to the kernel
|
||||
*/
|
||||
|
||||
#include <lkm.h>
|
||||
#include <gmodule.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
/* Module Vector Table */
|
||||
static gmodule_t* _gmodule = NULL;
|
||||
|
||||
|
||||
/* Allow DEVFS Support on 2.4 Kernels */
|
||||
#if defined(LKM_2_4) && defined(CONFIG_DEVFS_FS)
|
||||
#define GMODULE_CONFIG_DEVFS_FS
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef GMODULE_CONFIG_DEVFS_FS
|
||||
devfs_handle_t devfs_handle = NULL;
|
||||
#endif
|
||||
|
||||
/* FIXME: support dynamic debugging */
|
||||
|
||||
static int _dbg_enable = 0;
|
||||
|
||||
static int
|
||||
gvprintk(const char* fmt, va_list args)
|
||||
__attribute__ ((format (printf, 1, 0)));
|
||||
|
||||
static int
|
||||
gvprintk(const char* fmt, va_list args)
|
||||
{
|
||||
static char _buf[256];
|
||||
|
||||
strcpy(_buf, "");
|
||||
sprintf(_buf, "%s (%d): ", _gmodule->name, current->pid);
|
||||
vsprintf(_buf+strlen(_buf), fmt, args);
|
||||
printk("%s",_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gprintk(const char* fmt, ...)
|
||||
{
|
||||
int rv;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
rv = gvprintk(fmt, args);
|
||||
va_end(args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
gdbg(const char* fmt, ...)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
if(_dbg_enable) {
|
||||
rv = gvprintk(fmt, args);
|
||||
}
|
||||
va_end(args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Proc FS Utilities
|
||||
*/
|
||||
#if PROC_INTERFACE_KERN_VER_3_10
|
||||
static struct seq_file* _proc_buf = NULL;
|
||||
|
||||
int
|
||||
pprintf(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
seq_vprintf(_proc_buf, fmt, args);
|
||||
va_end(args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _gmodule_proc_show(struct seq_file *m, void *v){
|
||||
_proc_buf = m;
|
||||
_gmodule->pprint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_gmodule_proc_open(struct inode * inode, struct file * file) {
|
||||
if(_gmodule->open) {
|
||||
_gmodule->open();
|
||||
}
|
||||
|
||||
return single_open(file, _gmodule_proc_show, NULL);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
_gmodule_proc_write(struct file *file, const char *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
/* Workaround to toggle debugging */
|
||||
if(count > 2) {
|
||||
if(buffer[0] == 'd') {
|
||||
_dbg_enable = buffer[1] - '0';
|
||||
GDBG("Debugging Enabled");
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static int _gmodule_proc_release(struct inode * inode, struct file * file) {
|
||||
if(_gmodule->close) {
|
||||
_gmodule->close();
|
||||
}
|
||||
|
||||
return single_release(inode, file);
|
||||
}
|
||||
|
||||
struct file_operations _gmodule_proc_fops = {
|
||||
owner: THIS_MODULE,
|
||||
open: _gmodule_proc_open,
|
||||
read: seq_read,
|
||||
llseek: seq_lseek,
|
||||
write: _gmodule_proc_write,
|
||||
release: _gmodule_proc_release,
|
||||
};
|
||||
#else
|
||||
int
|
||||
gmodule_vpprintf(char** page_ptr, const char* fmt, va_list args)
|
||||
{
|
||||
*page_ptr += vsprintf(*page_ptr, fmt, args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gmodule_pprintf(char** page_ptr, const char* fmt, ...)
|
||||
{
|
||||
int rv;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
rv = gmodule_vpprintf(page_ptr, fmt, args);
|
||||
va_end(args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static char* _proc_buf = NULL;
|
||||
|
||||
int
|
||||
pprintf(const char* fmt, ...)
|
||||
{
|
||||
int rv;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
rv = gmodule_vpprintf(&_proc_buf, fmt, args);
|
||||
va_end(args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define PSTART(b) _proc_buf = b
|
||||
#define PPRINT proc_print
|
||||
#define PEND(b) (_proc_buf-b)
|
||||
|
||||
static int
|
||||
_gmodule_pprint(char* buf)
|
||||
{
|
||||
PSTART(buf);
|
||||
_gmodule->pprint();
|
||||
return PEND(buf);
|
||||
}
|
||||
|
||||
static int
|
||||
_gmodule_read_proc(char *page, char **start, off_t off,
|
||||
int count, int *eof, void *data)
|
||||
{
|
||||
*eof = 1;
|
||||
return _gmodule_pprint(page);
|
||||
}
|
||||
|
||||
static int
|
||||
_gmodule_write_proc(struct file *file, const char *buffer,
|
||||
unsigned long count, void *data)
|
||||
{
|
||||
/* Workaround to toggle debugging */
|
||||
if(count > 2) {
|
||||
if(buffer[0] == 'd') {
|
||||
_dbg_enable = buffer[1] - '0';
|
||||
GDBG("Debugging Enabled");
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
_gmodule_create_proc(void)
|
||||
{
|
||||
struct proc_dir_entry* ent;
|
||||
#if PROC_INTERFACE_KERN_VER_3_10
|
||||
if((ent = proc_create(_gmodule->name,
|
||||
S_IRUGO | S_IWUGO,
|
||||
NULL,
|
||||
&_gmodule_proc_fops)) != NULL) {
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if((ent = create_proc_entry(_gmodule->name, S_IRUGO | S_IWUGO, NULL)) != NULL) {
|
||||
ent->read_proc = _gmodule_read_proc;
|
||||
ent->write_proc = _gmodule_write_proc;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_gmodule_remove_proc(void)
|
||||
{
|
||||
remove_proc_entry(_gmodule->name, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
_gmodule_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
if(_gmodule->open) {
|
||||
_gmodule->open();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_gmodule_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
if(_gmodule->close) {
|
||||
_gmodule->close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_UNLOCKED_IOCTL
|
||||
static long
|
||||
_gmodule_unlocked_ioctl(struct file *filp,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
if(_gmodule->ioctl) {
|
||||
return _gmodule->ioctl(cmd, arg);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static int
|
||||
_gmodule_ioctl(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
if(_gmodule->ioctl) {
|
||||
return _gmodule->ioctl(cmd, arg);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COMPAT_IOCTL
|
||||
static long
|
||||
_gmodule_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
if(_gmodule->ioctl) {
|
||||
return _gmodule->ioctl(cmd, arg);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
_gmodule_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||
{
|
||||
if (_gmodule->mmap) {
|
||||
return _gmodule->mmap(filp, vma);
|
||||
}
|
||||
#ifdef BCM_PLX9656_LOCAL_BUS
|
||||
vma->vm_flags |= VM_RESERVED | VM_IO;
|
||||
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE | _PAGE_GUARDED;
|
||||
|
||||
if (io_remap_pfn_range( vma,
|
||||
vma->vm_start,
|
||||
vma->vm_pgoff,
|
||||
vma->vm_end - vma->vm_start,
|
||||
vma->vm_page_prot)) {
|
||||
return (-EAGAIN);
|
||||
}
|
||||
return (0);
|
||||
#else/* BCM_PLX9656_LOCAL_BUS */
|
||||
return -EPERM;
|
||||
#endif/* BCM_PLX9656_LOCAL_BUS */
|
||||
}
|
||||
|
||||
/* FILE OPERATIONS */
|
||||
|
||||
struct file_operations _gmodule_fops = {
|
||||
#ifdef HAVE_UNLOCKED_IOCTL
|
||||
unlocked_ioctl: _gmodule_unlocked_ioctl,
|
||||
#else
|
||||
ioctl: _gmodule_ioctl,
|
||||
#endif
|
||||
open: _gmodule_open,
|
||||
release: _gmodule_release,
|
||||
mmap: _gmodule_mmap,
|
||||
#ifdef HAVE_COMPAT_IOCTL
|
||||
compat_ioctl: _gmodule_compat_ioctl,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void __exit
|
||||
cleanup_module(void)
|
||||
{
|
||||
if(!_gmodule) return;
|
||||
|
||||
/* Specific Cleanup */
|
||||
if(_gmodule->cleanup) {
|
||||
_gmodule->cleanup();
|
||||
}
|
||||
|
||||
/* Remove any proc entries */
|
||||
if(_gmodule->pprint) {
|
||||
_gmodule_remove_proc();
|
||||
}
|
||||
|
||||
/* Finally, remove ourselves from the universe */
|
||||
#ifdef GMODULE_CONFIG_DEVFS_FS
|
||||
if(devfs_handle) devfs_unregister(devfs_handle);
|
||||
#else
|
||||
unregister_chrdev(_gmodule->major, _gmodule->name);
|
||||
#endif
|
||||
}
|
||||
|
||||
int __init
|
||||
init_module(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Get our definition */
|
||||
_gmodule = gmodule_get();
|
||||
if(!_gmodule) return -ENODEV;
|
||||
|
||||
|
||||
/* Register ourselves */
|
||||
#ifdef GMODULE_CONFIG_DEVFS_FS
|
||||
devfs_handle = devfs_register(NULL,
|
||||
_gmodule->name,
|
||||
DEVFS_FL_NONE,
|
||||
_gmodule->major,
|
||||
_gmodule->minor,
|
||||
S_IFCHR | S_IRUGO | S_IWUGO,
|
||||
&_gmodule_fops,
|
||||
NULL);
|
||||
if(!devfs_handle) {
|
||||
printk(KERN_WARNING "%s: can't register device with devfs",
|
||||
_gmodule->name);
|
||||
}
|
||||
rc = 0;
|
||||
#else
|
||||
rc = register_chrdev(_gmodule->major,
|
||||
_gmodule->name,
|
||||
&_gmodule_fops);
|
||||
if (rc < 0) {
|
||||
printk(KERN_WARNING "%s: can't get major %d",
|
||||
_gmodule->name, _gmodule->major);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if(_gmodule->major == 0) {
|
||||
_gmodule->major = rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Specific module Initialization */
|
||||
if(_gmodule->init) {
|
||||
int rc;
|
||||
if((rc = _gmodule->init()) < 0) {
|
||||
#ifdef GMODULE_CONFIG_DEVFS_FS
|
||||
if(devfs_handle) devfs_unregister(devfs_handle);
|
||||
#else
|
||||
unregister_chrdev(_gmodule->major, _gmodule->name);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a /proc entry, if valid */
|
||||
if(_gmodule->pprint) {
|
||||
_gmodule_create_proc();
|
||||
}
|
||||
|
||||
return 0; /* succeed */
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Unless you and Broadcom execute a separate written software license
|
||||
* agreement governing use of this software, this software is licensed to
|
||||
* you under the terms of the GNU General Public License version 2 (the
|
||||
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
* with the following added to such license:
|
||||
*
|
||||
* As a special exception, the copyright holders of this software give
|
||||
* you permission to link this software with independent modules, and to
|
||||
* copy and distribute the resulting executable under terms of your
|
||||
* choice, provided that you also meet, for each linked independent
|
||||
* module, the terms and conditions of the license of that module. An
|
||||
* independent module is a module which is not derived from this
|
||||
* software. The special exception does not apply to any modifications
|
||||
* of the software.
|
||||
*/
|
||||
/*
|
||||
* $Id: ksal.c,v 1.1 Broadcom SDK $
|
||||
* $Copyright: (c) 2005 Broadcom Corp.
|
||||
* All Rights Reserved.$
|
||||
*/
|
||||
|
||||
#include <sal/core/sync.h>
|
||||
#include <sal/core/thread.h>
|
||||
|
||||
#include "lkm.h"
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
|
||||
#include <linux/semaphore.h>
|
||||
#else
|
||||
#include <asm/semaphore.h>
|
||||
#endif
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/sched.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
|
||||
#include <linux/sched/rt.h>
|
||||
#endif
|
||||
#include <linux/time.h>
|
||||
|
||||
#ifdef MAX_USER_RT_PRIO
|
||||
/* Assume 2.6 scheduler */
|
||||
#define SAL_YIELD(task) \
|
||||
yield()
|
||||
#else
|
||||
/* Assume 2.4 scheduler */
|
||||
#define SAL_YIELD(task) \
|
||||
do { \
|
||||
task->policy |= SCHED_YIELD; \
|
||||
schedule(); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define SECOND_USEC (1000000)
|
||||
#define USECS_PER_JIFFY (SECOND_USEC / HZ)
|
||||
#define USEC_TO_JIFFIES(usec) ((usec + (USECS_PER_JIFFY - 1)) / USECS_PER_JIFFY)
|
||||
|
||||
#define sal_alloc(size, desc) kmalloc(size, GFP_KERNEL)
|
||||
#define sal_free(ptr) kfree(ptr)
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
|
||||
#define WQ_SLEEP(a, b) wait_event_interruptible_timeout(a, NULL, b)
|
||||
#else
|
||||
#define WQ_SLEEP(a, b) interruptible_sleep_on_timeout(&(a), b)
|
||||
#endif
|
||||
/*
|
||||
* sem_ctrl_t
|
||||
*
|
||||
* The semaphore control type uses the binary property to implement
|
||||
* timed semaphores with improved performance using wait queues.
|
||||
*/
|
||||
|
||||
typedef struct sem_ctrl_s {
|
||||
struct semaphore sem;
|
||||
int binary;
|
||||
int cnt;
|
||||
wait_queue_head_t wq;
|
||||
} sem_ctrl_t;
|
||||
|
||||
sal_sem_t
|
||||
sal_sem_create(char *desc, int binary, int initial_count)
|
||||
{
|
||||
sem_ctrl_t *s;
|
||||
|
||||
if ((s = sal_alloc(sizeof(*s), desc)) != 0) {
|
||||
sema_init(&s->sem, initial_count);
|
||||
s->binary = binary;
|
||||
if (s->binary) {
|
||||
init_waitqueue_head(&s->wq);
|
||||
}
|
||||
}
|
||||
|
||||
return (sal_sem_t) s;
|
||||
}
|
||||
|
||||
void
|
||||
sal_sem_destroy(sal_sem_t b)
|
||||
{
|
||||
sem_ctrl_t *s = (sem_ctrl_t *) b;
|
||||
|
||||
if (s == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* the linux kernel does not have a sema_destroy(s)
|
||||
*/
|
||||
sal_free(s);
|
||||
}
|
||||
|
||||
int
|
||||
sal_sem_take(sal_sem_t b, int usec)
|
||||
{
|
||||
sem_ctrl_t *s = (sem_ctrl_t *) b;
|
||||
int err;
|
||||
|
||||
if (usec == sal_sem_FOREVER && !in_interrupt()) {
|
||||
err = down_interruptible(&s->sem);
|
||||
} else {
|
||||
int time_wait = 1;
|
||||
int cnt = s->cnt;
|
||||
|
||||
for (;;) {
|
||||
if (down_trylock(&s->sem) == 0) {
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (s->binary) {
|
||||
|
||||
/* Wait for event or timeout */
|
||||
|
||||
if (time_wait > 1) {
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
err = wait_event_interruptible_timeout(s->wq, cnt != s->cnt,
|
||||
USEC_TO_JIFFIES(usec));
|
||||
if (err < 0) {
|
||||
break;
|
||||
}
|
||||
time_wait++;
|
||||
|
||||
} else {
|
||||
|
||||
/* Retry algorithm with exponential backoff */
|
||||
|
||||
if (time_wait > usec) {
|
||||
time_wait = usec;
|
||||
}
|
||||
|
||||
sal_usleep(time_wait);
|
||||
|
||||
usec -= time_wait;
|
||||
|
||||
if (usec == 0) {
|
||||
err = ETIMEDOUT;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((time_wait *= 2) > 100000) {
|
||||
time_wait = 100000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err ? -1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
sal_sem_give(sal_sem_t b)
|
||||
{
|
||||
sem_ctrl_t *s = (sem_ctrl_t *) b;
|
||||
|
||||
up(&s->sem);
|
||||
if (s->binary) {
|
||||
s->cnt++;
|
||||
wake_up_interruptible(&s->wq);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32
|
||||
sal_time_usecs(void)
|
||||
{
|
||||
struct timeval ltv;
|
||||
do_gettimeofday(<v);
|
||||
return (ltv.tv_sec * SECOND_USEC + ltv.tv_usec);
|
||||
}
|
||||
|
||||
void
|
||||
sal_usleep(uint32 usec)
|
||||
{
|
||||
uint32 start_usec;
|
||||
wait_queue_head_t queue;
|
||||
|
||||
if (usec <= SECOND_USEC / HZ) {
|
||||
start_usec = sal_time_usecs();
|
||||
do {
|
||||
SAL_YIELD(current);
|
||||
} while ((sal_time_usecs() - start_usec) < usec);
|
||||
} else {
|
||||
init_waitqueue_head(&queue);
|
||||
WQ_SLEEP(queue, USEC_TO_JIFFIES(usec));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sal_udelay(uint32 usec)
|
||||
{
|
||||
static volatile int _sal_udelay_counter;
|
||||
static int loops = 0;
|
||||
int ix, iy;
|
||||
|
||||
if (loops == 0 || usec == 0) { /* Need calibration? */
|
||||
int max_loops;
|
||||
int start = 0, stop = 0;
|
||||
int mpt = USECS_PER_JIFFY; /* usec/tick */
|
||||
|
||||
for (loops = 1; loops < 0x1000 && stop == start; loops <<= 1) {
|
||||
/* Wait for clock turn over */
|
||||
for (stop = start = jiffies; start == stop; start = jiffies) {
|
||||
/* Empty */
|
||||
}
|
||||
sal_udelay(mpt); /* Single recursion */
|
||||
stop = jiffies;
|
||||
}
|
||||
|
||||
max_loops = loops / 2; /* Loop above overshoots */
|
||||
|
||||
start = stop = 0;
|
||||
|
||||
if (loops < 4) {
|
||||
loops = 4;
|
||||
}
|
||||
|
||||
for (loops /= 4; loops < max_loops && stop == start; loops++) {
|
||||
/* Wait for clock turn over */
|
||||
for (stop = start = jiffies; start == stop; start = jiffies) {
|
||||
/* Empty */
|
||||
}
|
||||
sal_udelay(mpt); /* Single recursion */
|
||||
stop = jiffies;
|
||||
}
|
||||
}
|
||||
|
||||
for (iy = 0; iy < usec; iy++) {
|
||||
for (ix = 0; ix < loops; ix++) {
|
||||
_sal_udelay_counter++; /* Prevent optimizations */
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.4 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
#
|
||||
|
||||
SDK :=$(shell if [ -n "$$SDK" ] ; then\
|
||||
echo $$SDK;\
|
||||
else\
|
||||
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
|
||||
dir=`cd ../;pwd`; \
|
||||
if [ "$$dir" = "/" ] ; then \
|
||||
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
cd $$dir; \
|
||||
done ; \
|
||||
pwd; \
|
||||
fi)
|
||||
|
||||
ifeq ($(SDK),)
|
||||
$(error Please run this in a tree)
|
||||
endif
|
||||
|
||||
export SDK
|
||||
|
||||
override-target=linux-$(platform)
|
||||
|
||||
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
|
||||
libext = so.$(SHAREDLIBVER)
|
||||
else
|
||||
libext = a
|
||||
endif
|
||||
|
||||
ifeq (,$(platform))
|
||||
$(error Internal error: platform variable is not set)
|
||||
endif
|
||||
|
||||
include $(SDK)/make/Make.config
|
||||
LOCALDIR=systems/linux/user/common
|
||||
include $(SDK)/make/Make.depend
|
||||
kernel-override=linux-$(platform)
|
||||
ifdef BLDCONFIG
|
||||
KERN_BLDROOT=${SDK}/${SDKBUILD}/${BLDCONFIG}/$(kernel-override)$(bldroot_suffix)
|
||||
else
|
||||
KERN_BLDROOT=${SDK}/${SDKBUILD}/$(kernel-override)$(bldroot_suffix)
|
||||
endif
|
||||
|
||||
ifeq (,$(kernel_version))
|
||||
kernel_version=2_4
|
||||
endif
|
||||
|
||||
ifeq ($(kernel_version),2_6)
|
||||
KOBJ=ko
|
||||
else
|
||||
KOBJ=o
|
||||
endif
|
||||
|
||||
ifneq (,$(TOOLS_DIR))
|
||||
override PATH := $(TOOLS_DIR):$(PATH)
|
||||
endif
|
||||
|
||||
ifeq ($(DEST_DIR),)
|
||||
DEST_DIR=${BLDDIR}
|
||||
endif
|
||||
|
||||
KERNEL_BDE_LOCAL :=linux-kernel-bde.$(KOBJ)
|
||||
KERNEL_BDE :=$(DEST_DIR)/$(KERNEL_BDE_LOCAL)
|
||||
|
||||
USER_BDE_LOCAL :=linux-user-bde.$(KOBJ)
|
||||
USER_BDE=$(DEST_DIR)/$(USER_BDE_LOCAL)
|
||||
|
||||
BCM_KNET_LOCAL :=linux-bcm-knet.$(KOBJ)
|
||||
BCM_KNET=$(DEST_DIR)/$(BCM_KNET_LOCAL)
|
||||
|
||||
KNET_CB_LOCAL := linux-knet-cb.$(KOBJ)
|
||||
KNET_CB := $(DEST_DIR)/$(KNET_CB_LOCAL)
|
||||
|
||||
ifeq (,$(findstring DELIVER,$(MAKECMDGOALS)))
|
||||
.DEFAULT_GOAL := all
|
||||
all_targets := kernel_modules $(KERNEL_BDE) $(USER_BDE)
|
||||
|
||||
LOCAL_TARGETS :=
|
||||
|
||||
ifeq ($(NO_LOCAL_TARGETS),)
|
||||
LOCAL_TARGETS +=$(patsubst %,$(realpath ..)/$(platform)/%,$(KERNEL_BDE_LOCAL) $(USER_BDE_LOCAL))
|
||||
|
||||
all_targets +=$(LOCAL_TARGETS)
|
||||
endif
|
||||
|
||||
# Build all by default
|
||||
ifndef BUILD_KNET
|
||||
BUILD_KNET = 1
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_KNET),1)
|
||||
# Kernel network support
|
||||
all_targets += $(BCM_KNET)
|
||||
|
||||
ifeq ($(NO_LOCAL_TARGETS),)
|
||||
LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_KNET_LOCAL))
|
||||
all_targets +=$(LOCAL_TARGETS)
|
||||
endif
|
||||
|
||||
ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include
|
||||
COND_KNET_LIBS = libuser.$(libext)
|
||||
|
||||
ifeq ($(BUILD_KNET_CB),1)
|
||||
# KNET callback module support
|
||||
all_targets += $(KNET_CB)
|
||||
|
||||
ifeq ($(NO_LOCAL_TARGETS),)
|
||||
LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(KNET_CB_LOCAL))
|
||||
all_targets +=$(LOCAL_TARGETS)
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
#OPENNSL_FIXUP
|
||||
.NOTPARALLEL:
|
||||
|
||||
all: $(BLDDIR)/.tree $(all_targets)
|
||||
|
||||
ifeq ($(NO_LOCAL_TARGETS),)
|
||||
define LOCAL_TARGET_DEF
|
||||
$(1) : $(DEST_DIR)/$(notdir $(1))
|
||||
cp $$? $$@
|
||||
endef
|
||||
endif
|
||||
|
||||
# User BDE libraries
|
||||
ADD_TO_CFLAGS += -I$(SDK)/systems/bde/linux/include
|
||||
|
||||
# Use raw IOCTL for KNET
|
||||
ADD_TO_CFLAGS += -DPROXY_SUPPORT=0
|
||||
|
||||
CFLAGS += $(ADD_TO_CFLAGS)
|
||||
|
||||
# Kernel network support
|
||||
ifdef BUILD_KNET
|
||||
|
||||
knet_subdirs = shared bcm-knet
|
||||
|
||||
ifdef BUILD_KNET_CB
|
||||
knet_subdirs += knet-cb
|
||||
endif
|
||||
|
||||
endif # BUILD_KNET
|
||||
|
||||
kernel_modules:
|
||||
$(MAKE) -C $(SDK)/systems/bde/linux/kernel kernel_version=$(kernel_version)
|
||||
$(MAKE) -C $(SDK)/systems/bde/linux/user/kernel kernel_version=$(kernel_version)
|
||||
ifeq ($(BUILD_KNET),1)
|
||||
$(MAKE) -j1 -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \
|
||||
subdirs="$(knet_subdirs)" override-target=linux-$(platform) CFLAGS="$(CFLAGS)"
|
||||
endif
|
||||
|
||||
$(KERNEL_BDE): $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ)
|
||||
mkdir -p $(@D)
|
||||
$(OBJCOPY) --strip-debug $< $@
|
||||
|
||||
$(USER_BDE): $(KERN_BLDROOT)/linux-user-bde.$(KOBJ)
|
||||
$(OBJCOPY) --strip-debug $< $@
|
||||
|
||||
$(BCM_KNET): $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ)
|
||||
$(OBJCOPY) --strip-debug $< $@
|
||||
|
||||
$(KNET_CB): $(KERN_BLDROOT)/linux-knet-cb.$(KOBJ)
|
||||
$(OBJCOPY) --strip-debug $< $@
|
||||
|
||||
ifeq ($(NO_LOCAL_TARGETS),)
|
||||
$(foreach targ,$(LOCAL_TARGETS),$(eval $(call LOCAL_TARGET_DEF,$(targ))))
|
||||
endif
|
||||
|
||||
clean::
|
||||
$(MAKE) -C $(SDK)/systems/bde/linux/kernel $@
|
||||
$(MAKE) -C $(SDK)/systems/bde/linux/user/kernel $@
|
||||
$(MAKE) -C $(SDK)/systems/linux/kernel/modules \
|
||||
subdirs="$(knet_subdirs)" \
|
||||
override-target=linux-$(platform) $@
|
||||
$(RM) $(KERNEL_BDE) $(USER_BDE)
|
||||
$(RM) $(BCM_KNET)
|
||||
$(RM) $(KNET_CB)
|
||||
$(RM) $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ)
|
||||
$(RM) $(KERN_BLDROOT)/linux-user-bde.$(KOBJ)
|
||||
$(RM) $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ)
|
||||
$(RM) $(LOCAL_TARGETS)
|
||||
|
||||
distclean:: clean
|
||||
|
||||
.PHONY: variable
|
||||
|
||||
#
|
||||
# Echo variable values used for configuration
|
||||
# usage: make VAR=CC variable
|
||||
#
|
||||
variable::
|
||||
@echo $($(VAR))
|
||||
|
||||
else
|
||||
ifndef DELIVERY
|
||||
$(error DELIVERY required)
|
||||
endif
|
||||
|
||||
DELIVERABLES := $(KERNEL_BDE) $(USER_BDE)
|
||||
# 1= source
|
||||
define DELIVERY_RULE
|
||||
_DEL_TARG += $(DELIVERY)/$(notdir $(1))
|
||||
$(DELIVERY)/$(notdir $(1)) : $(1)
|
||||
@mkdir -p $(DELIVERY)
|
||||
ifeq ($(filter $(notdir $(BCM)) $(notdir $(BCM).dbg),$(notdir $1)),)
|
||||
$(OBJCOPY) --strip-debug $$< $$@
|
||||
else
|
||||
$(CP) -p $$< $$@
|
||||
endif
|
||||
endef
|
||||
|
||||
$(foreach f,$(DELIVERABLES),$(eval $(call DELIVERY_RULE,$(f))))
|
||||
|
||||
DELIVER: $(_DEL_TARG)
|
||||
endif
|
||||
|
||||
# Make.config defines remaining phony targets
|
||||
.PHONY: build kernel_modules DELIVER
|
||||
|
@ -0,0 +1,85 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.9 Broadcom SDK $
|
||||
# $Copyright: (c) 2007 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
#
|
||||
# This make job requires the following environment variables to be set:
|
||||
#
|
||||
# SDK - path to StrataXGS SDK root directory
|
||||
#
|
||||
# Optionally the following environment variables can be set to
|
||||
# override the default build server configuration:
|
||||
#
|
||||
# PPC_TOOLS_DIR - path to build tools (if not in PATH already)
|
||||
# PPC_CROSS_COMPILE - cross compile tools prefix
|
||||
# LINUX_INCLUDE - path to Linux kernel include directory
|
||||
#
|
||||
|
||||
SDK :=$(shell if [ -n "$$SDK" ] ; then\
|
||||
echo $$SDK;\
|
||||
else\
|
||||
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
|
||||
dir=`cd ../;pwd`; \
|
||||
if [ "$$dir" = "/" ] ; then \
|
||||
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
cd $$dir; \
|
||||
done ; \
|
||||
pwd; \
|
||||
fi)
|
||||
|
||||
ifeq ($(SDK),)
|
||||
$(error Please run this in a tree)
|
||||
endif
|
||||
|
||||
export SDK
|
||||
|
||||
override kernel_version=2_6
|
||||
platform=gto-$(kernel_version)
|
||||
LINUX_MAKE_USER=1
|
||||
export LINKER_RELAX=1
|
||||
|
||||
# Select the build environment
|
||||
#BUILD_PLATFORM=ELDK
|
||||
#BUILD_PLATFORM=WR_LINUX
|
||||
|
||||
#Select the LINUX KERNEL VERSION
|
||||
#KERN_VER = 2.6.21.7
|
||||
#KERN_VER = 2.6.24.4
|
||||
#KERN_VER = 2.6.25
|
||||
|
||||
|
||||
# Select the ELDK version
|
||||
#ELDK_VERSION=4.1
|
||||
#ELDK_VERSION=4.0
|
||||
|
||||
#Select WRS Linux version
|
||||
#WRS_LINUX_VERSION=2.0
|
||||
#WRS_LINUX_VERSION=3.0
|
||||
|
||||
|
||||
export KERN_VER
|
||||
export ELDK_VERSION
|
||||
export BUILD_PLATFORM
|
||||
export WRS_LINUX_VERSION
|
||||
|
||||
include ${SDK}/make/Make.linux
|
||||
|
@ -0,0 +1,61 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.9 Broadcom SDK $
|
||||
# $Copyright: (c) 2015 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
#
|
||||
# This make job requires the following environment variables to be set:
|
||||
#
|
||||
# SDK - path to StrataXGS SDK root directory
|
||||
#
|
||||
# Optionally the following environment variables can be set to
|
||||
# override the default build server configuration:
|
||||
#
|
||||
# PPC_TOOLS_DIR - path to build tools (if not in PATH already)
|
||||
# PPC_CROSS_COMPILE - cross compile tools prefix
|
||||
# LINUX_INCLUDE - path to Linux kernel include directory
|
||||
#
|
||||
|
||||
SDK :=$(shell if [ -n "$$SDK" ] ; then\
|
||||
echo $$SDK;\
|
||||
else\
|
||||
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
|
||||
dir=`cd ../;pwd`; \
|
||||
if [ "$$dir" = "/" ] ; then \
|
||||
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
cd $$dir; \
|
||||
done ; \
|
||||
pwd; \
|
||||
fi)
|
||||
|
||||
ifeq ($(SDK),)
|
||||
$(error Please run this in a tree)
|
||||
endif
|
||||
|
||||
export SDK
|
||||
|
||||
override kernel_version=4_4
|
||||
platform=gto
|
||||
LINUX_MAKE_USER=1
|
||||
export LINKER_RELAX=1
|
||||
|
||||
include ${SDK}/make/Make.linux
|
||||
|
@ -0,0 +1,66 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.7 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
#
|
||||
# This make job requires the following environment variables to be set:
|
||||
#
|
||||
# SDK - path to StrataXGS SDK root directory
|
||||
#
|
||||
# Optionally the following environment variables can be set to
|
||||
# override the default build server configuration:
|
||||
#
|
||||
# MIPS_TOOLS_DIR - path to build tools (if not in PATH already)
|
||||
# MIPS_CROSS_COMPILE - cross compile tools prefix
|
||||
# LINUX_INCLUDE - path to Linux kernel include directory
|
||||
#
|
||||
|
||||
SDK :=$(shell if [ -n "$$SDK" ] ; then\
|
||||
echo $$SDK;\
|
||||
else\
|
||||
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
|
||||
dir=`cd ../;pwd`; \
|
||||
if [ "$$dir" = "/" ] ; then \
|
||||
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
cd $$dir; \
|
||||
done ; \
|
||||
pwd; \
|
||||
fi)
|
||||
|
||||
ifeq ($(SDK),)
|
||||
$(error Please run this in a tree)
|
||||
endif
|
||||
|
||||
export SDK
|
||||
|
||||
override kernel_version=3_14
|
||||
platform=iproc-$(kernel_version)
|
||||
|
||||
IPROC_BUILD=1
|
||||
export IPROC_BUILD
|
||||
export BUILD_PLATFORM
|
||||
export ARM_LINUX_VERSION
|
||||
|
||||
LINUX_MAKE_USER=1
|
||||
export ADD_TO_CFLAGS
|
||||
|
||||
include ${SDK}/make/Make.linux
|
@ -0,0 +1,60 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.7 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
#
|
||||
# This make job requires the following environment variables to be set:
|
||||
#
|
||||
# SDK - path to StrataXGS SDK root directory
|
||||
#
|
||||
|
||||
SDK :=$(shell if [ -n "$$SDK" ] ; then\
|
||||
echo $$SDK;\
|
||||
else\
|
||||
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
|
||||
dir=`cd ../;pwd`; \
|
||||
if [ "$$dir" = "/" ] ; then \
|
||||
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
cd $$dir; \
|
||||
done ; \
|
||||
pwd; \
|
||||
fi)
|
||||
|
||||
ifeq ($(SDK),)
|
||||
$(error Please run this in a tree)
|
||||
endif
|
||||
|
||||
export SDK
|
||||
|
||||
override kernel_version=4_4
|
||||
platform=iproc
|
||||
|
||||
IPROC_BUILD=1
|
||||
export IPROC_BUILD
|
||||
export BUILD_PLATFORM
|
||||
export ARM_LINUX_VERSION
|
||||
|
||||
LINUX_MAKE_USER=1
|
||||
export ADD_TO_CFLAGS
|
||||
export BR_NO_CCACHE
|
||||
|
||||
include ${SDK}/make/Make.linux
|
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
# -*- Makefile -*-
|
||||
# $Id: Makefile,v 1.2 Broadcom SDK $
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved.$
|
||||
|
||||
SDK :=$(shell if [ -n "$$SDK" ] ; then\
|
||||
echo $$SDK;\
|
||||
else\
|
||||
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
|
||||
dir=`cd ../;pwd`; \
|
||||
if [ "$$dir" = "/" ] ; then \
|
||||
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
cd $$dir; \
|
||||
done ; \
|
||||
pwd; \
|
||||
fi)
|
||||
|
||||
ifeq ($(SDK),)
|
||||
$(error Please run this in a tree)
|
||||
endif
|
||||
|
||||
export SDK
|
||||
|
||||
override kernel_version=2_6
|
||||
platform=x86-smp_generic_64-$(kernel_version)
|
||||
|
||||
LINUX_MAKE_USER=1
|
||||
include ${SDK}/make/Make.linux
|
293
platform/broadcom/saibcm-modules/tools/mktool.pl
Normal file
293
platform/broadcom/saibcm-modules/tools/mktool.pl
Normal file
@ -0,0 +1,293 @@
|
||||
#
|
||||
# Unless you and Broadcom execute a separate written software license
|
||||
# agreement governing use of this software, this software is licensed to
|
||||
# you under the terms of the GNU General Public License version 2 (the
|
||||
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
||||
# with the following added to such license:
|
||||
#
|
||||
# As a special exception, the copyright holders of this software give
|
||||
# you permission to link this software with independent modules, and to
|
||||
# copy and distribute the resulting executable under terms of your
|
||||
# choice, provided that you also meet, for each linked independent
|
||||
# module, the terms and conditions of the license of that module. An
|
||||
# independent module is a module which is not derived from this
|
||||
# software. The special exception does not apply to any modifications
|
||||
# of the software.
|
||||
#
|
||||
#
|
||||
# mktool.pl
|
||||
#
|
||||
# $Id: mktool.pl,v 1.5 Broadcom SDK $
|
||||
#
|
||||
# $Copyright: (c) 2005 Broadcom Corp.
|
||||
# All Rights Reserved. $
|
||||
|
||||
use File::Path;
|
||||
use File::Find;
|
||||
use File::Copy;
|
||||
use Cwd;
|
||||
|
||||
($prog = $0) =~ s/.*\///;
|
||||
|
||||
SWITCH:
|
||||
{
|
||||
$op = shift;
|
||||
|
||||
if ($op eq "-rm") { mktool_rm(@ARGV); last SWITCH; }
|
||||
if ($op eq "-cp") { mktool_cp(@ARGV); last SWITCH; }
|
||||
if ($op eq "-md") { mktool_md(@ARGV); last SWITCH; }
|
||||
if ($op eq "-ln") { mktool_ln(@ARGV); last SWITCH; }
|
||||
if ($op eq "-foreach") { mktool_foreach(@ARGV); last SWITCH; }
|
||||
if ($op eq "-dep") { mktool_makedep(@ARGV); last SWITCH; }
|
||||
if ($op eq "-echo") { mktool_echo(@ARGV); last SWITCH; }
|
||||
if ($op eq "-beep") { mktool_beep(@ARGV); last SWITCH; }
|
||||
die("$prog: unknown option '$op'\n");
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# mktool_execute
|
||||
#
|
||||
# Executes a command, returns exist status.
|
||||
# Performs token special translation before execution.
|
||||
#
|
||||
|
||||
sub mktool_execute
|
||||
{
|
||||
my $token = shift;
|
||||
my @cmds = @_;
|
||||
|
||||
# printf("mktool_execute: token = '$token'\n");
|
||||
foreach $cmd (@cmds)
|
||||
{
|
||||
#printf("mktool_execute: cmd = '$cmd'\n");
|
||||
$cmd =~ s/\#\#/$token/g;
|
||||
if($cmd =~ /^-p/)
|
||||
{
|
||||
$cmd =~ s/^-p//;
|
||||
printf("$cmd\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
system($cmd);
|
||||
my $excode = ($? >> 8);
|
||||
exit $excode if $excode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$find_regexp = "";
|
||||
@find_cmd;
|
||||
|
||||
#
|
||||
# mktool_foreach
|
||||
#
|
||||
sub mktool_foreach
|
||||
{
|
||||
if($_[0] eq "-find")
|
||||
{
|
||||
shift;
|
||||
$find_dir = shift;
|
||||
$find_regexp = shift;
|
||||
@find_cmds = @_;
|
||||
|
||||
if(!($find_dir =~ /^\//))
|
||||
{
|
||||
$find_dir = cwd() . "/" . $find_dir;
|
||||
}
|
||||
find(\&_mktool_foreach_find_wanted, $find_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
my $subdir = 0;
|
||||
if($_[0] eq "-subdir")
|
||||
{
|
||||
$subdir = 1;
|
||||
shift;
|
||||
}
|
||||
|
||||
my @thingies = split(' ', shift);
|
||||
|
||||
foreach $thingy (@thingies)
|
||||
{
|
||||
chdir $thingy unless $subdir == 0;
|
||||
mktool_execute($thingy, @_);
|
||||
chdir ".." unless $subdir == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub _mktool_foreach_find_wanted
|
||||
{
|
||||
my $expr = "\$File::Find::name =~ /\^$find_regexp\$/";
|
||||
|
||||
if(eval($expr))
|
||||
{
|
||||
mktool_execute($File::Find::name, @find_cmds);
|
||||
exit $excode if $excode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# rm
|
||||
#
|
||||
# Removes a list of objects
|
||||
#
|
||||
sub mktool_rm
|
||||
{
|
||||
my($f);
|
||||
|
||||
foreach $f (@_) {
|
||||
eval { rmtree($f) };
|
||||
if ($@) {
|
||||
die "$prog $op: failed to remove $f: $@\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# md
|
||||
#
|
||||
# Makes a list of directories
|
||||
#
|
||||
sub mktool_md
|
||||
{
|
||||
my($dir);
|
||||
|
||||
foreach $dir (@_) {
|
||||
$dir =~ s!/+$!!;
|
||||
eval { mkpath($dir) };
|
||||
if ($@) {
|
||||
die "$prog $op: failed to make directory $dir: $@\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub mktool_cp
|
||||
{
|
||||
my($from, $to) = @_;
|
||||
|
||||
if (@_ != 2) {
|
||||
die "$prog $op: must have two arguments\n";
|
||||
}
|
||||
copy($from, $to) ||
|
||||
die "$prog $op: failed to copy $from to $to: $!\n";
|
||||
}
|
||||
|
||||
sub mktool_ln
|
||||
{
|
||||
my($old, $new) = @_;
|
||||
|
||||
if (@_ != 2) {
|
||||
die "$prog $op: must have two arguments\n";
|
||||
}
|
||||
link ($old, $new) ||
|
||||
die "$prog $op: failed to link $new to $old: $!\n";
|
||||
}
|
||||
|
||||
|
||||
# @echo "$@ \\" > ${BLDDIR}/$(notdir $@)
|
||||
# @if ($(DEPEND)) >> $(BLDDIR)/$(notdir $@); then \
|
||||
# exit 0; \
|
||||
# else \
|
||||
# rm -f ${BLDDIR}/$(notdir $@); \
|
||||
# exit 1; \
|
||||
# fi
|
||||
|
||||
# $(MAKEDEP) "$@" "$(BLDDIR)/$(notdir $@)" "$(DEPEND)"
|
||||
|
||||
sub mktool_makedep
|
||||
{
|
||||
my ($source, $target, $cmd, $curdir) = @_;
|
||||
my @result = `$cmd`;
|
||||
my $sdk = $ENV{'SDK'};
|
||||
my $count;
|
||||
my $tmp;
|
||||
local $resultant;
|
||||
|
||||
## Comman $cmd
|
||||
#Command $cmd
|
||||
print <<MKTOOL;
|
||||
|
||||
mktool.pl::
|
||||
curdir $curdir
|
||||
|
||||
MKTOOL
|
||||
|
||||
# derive the path to the target
|
||||
$curdir = "$sdk/$curdir";
|
||||
|
||||
# save the basename
|
||||
$dirName = substr($target,0,rindex($target,"\/"));
|
||||
|
||||
# prepare the top line of the %.d file
|
||||
$resultant="$source \\\n\${BLDDIR}/";
|
||||
if(!$?)
|
||||
{
|
||||
foreach $line (@result)
|
||||
{
|
||||
$line =~ s/^#.*\n//g; # some makedeps produce comments
|
||||
$line =~ s/\n+$//; # toss trailing newlines
|
||||
$line =~ s/(\s+)(\.\/)/ /g; # remove leading ./
|
||||
|
||||
# insert SDK path before ../
|
||||
$line =~ s/(\s+)(\.\.\/)/${1}$curdir\/${2}/g;
|
||||
|
||||
# insert SDK path
|
||||
$line =~ s/(\s+)(\w+)/${1}$curdir\/${2}/g;
|
||||
|
||||
$count=0;
|
||||
$tmp=$line;
|
||||
while( (index($line,"..")>-1) & ($count < 20) )
|
||||
{
|
||||
$line=~s/\/\w+\/\.\.//;
|
||||
# if we hit a major recursion, revert the line, report
|
||||
# this to the output and drop out of the loop, but do
|
||||
# continue, this should not halt generation
|
||||
if($count++>19)
|
||||
{
|
||||
print "mktool.pl: could not process $line \n\n";
|
||||
print ":: curdir $curdir\n";
|
||||
print ":: target $target\n";
|
||||
print ":: cmd $cmd\n";
|
||||
$line=$tmp;
|
||||
}
|
||||
}
|
||||
|
||||
# set all the paths to use the $SDK variable
|
||||
$line =~ s/$ENV{'SDK'}/\$\{SDK\}/g;
|
||||
$resultant=$resultant . $line;
|
||||
}
|
||||
|
||||
# some compilers return extra newlines
|
||||
$resultant=~s/\n//g;
|
||||
|
||||
# now clean up the result
|
||||
$resultant=~s/\\/\\\n/g;
|
||||
|
||||
mktool_md($dirName) unless (-d $dirName);
|
||||
open (TARGET, ">$target") ||
|
||||
die("$prog $op: cannot open '$target' for writing: $!\n");
|
||||
print TARGET "$resultant\n";
|
||||
close(TARGET);
|
||||
}
|
||||
}
|
||||
|
||||
sub mktool_echo
|
||||
{
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
sub mktool_beep
|
||||
{
|
||||
-t STDOUT && defined $ENV{MAKEBEEP} && print "\007";
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
BRCM_OPENNSL_KERNEL = opennsl-modules-4.9.0-5-amd64_3.4.1.11-1_amd64.deb
|
||||
$(BRCM_OPENNSL_KERNEL)_URL = "https://sonicstorage.blob.core.windows.net/packages/opennsl-modules-4.9.0-5-amd64_3.4.1.11-1_amd64.deb?sv=2015-04-05&sr=b&sig=vdIqSXaJhvN7Blk08WyxWhfMxky0XBx37JYAmNozx3k%3D&se=2155-01-24T09%3A08%3A25Z&sp=r"
|
||||
|
||||
SONIC_ONLINE_DEBS += $(BRCM_OPENNSL_KERNEL)
|
Loading…
Reference in New Issue
Block a user