summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-09-08 10:54:30 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-09-08 10:54:30 +0000
commit36e1d1d1f94e5cf10e9d5cf7de1d2878b3d33ed8 (patch)
tree6815b0665e244aa5af8d2a4749e25b41ac7d86b3
parent0738cf5e684464d157816be73c0b19efb7dd4fc7 (diff)
Add skeleton for the csrinit utility
-rw-r--r--acinclude.m47
-rw-r--r--tools/Makefile.am19
-rw-r--r--tools/csrinit.835
-rw-r--r--tools/csrinit.c101
4 files changed, 159 insertions, 3 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 83adb960..4d49dc81 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -265,6 +265,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
initscripts_enable=no
avctrl_enable=${usb_found}
hid2hci_enable=${usb_found}
+ csrinit_enable=no
dfutool_enable=no
bcm203x_enable=no
bluepin_enable=yes
@@ -287,6 +288,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
initscripts_enable=${enableval}
avctrl_enable=${enableval}
hid2hci_enable=${enableval}
+ csrinit_enable=${enableval}
dfutool_enable=${enableval}
bcm203x_enable=${enableval}
bluepin_enable=${enableval}
@@ -328,6 +330,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
hid2hci_enable=${enableval}
])
+ AC_ARG_ENABLE(csrinit, AC_HELP_STRING([--enable-csrinit], [install CSR ROM chip setup utility]), [
+ csrinit_enable=${enableval}
+ ])
+
AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
dfutool_enable=${enableval}
])
@@ -358,6 +364,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
AM_CONDITIONAL(INITSCRIPTS, test "${initscripts_enable}" = "yes")
AM_CONDITIONAL(AVCTRL, test "${avctrl_enable}" = "yes" && test "${usb_found}" = "yes")
AM_CONDITIONAL(HID2HCI, test "${hid2hci_enable}" = "yes" && test "${usb_found}" = "yes")
+ AM_CONDITIONAL(CSRINIT, test "${csrinit_enable}" = "yes" && test "${usb_found}" = "yes")
AM_CONDITIONAL(DFUTOOL, test "${dfutool_enable}" = "yes" && test "${usb_found}" = "yes")
AM_CONDITIONAL(BCM203X, test "${bcm203x_enable}" = "yes" && test "${usb_found}" = "yes")
AM_CONDITIONAL(BLUEPIN, test "${bluepin_enable}" = "yes")
diff --git a/tools/Makefile.am b/tools/Makefile.am
index e3983a17..3a018bb7 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,6 +18,14 @@ hid2hci_programs =
hid2hci_manfiles =
endif
+if CSRINIT
+csrinit_programs = csrinit
+csrinit_manfiles = csrinit.8
+else
+csrinit_programs =
+csrinit_manfiles =
+endif
+
if DFUTOOL
dfutool_programs = dfutool
dfutool_manfiles = dfutool.1
@@ -26,7 +34,7 @@ dfutool_programs =
dfutool_manfiles =
endif
-sbin_PROGRAMS = hciattach hciconfig $(avctrl_programs) $(hid2hci_programs)
+sbin_PROGRAMS = hciattach hciconfig $(avctrl_programs) $(hid2hci_programs) $(csrinit_programs)
bin_PROGRAMS = hcitool l2ping sdptool ciptool $(dfutool_programs)
@@ -60,6 +68,11 @@ if HID2HCI
hid2hci_LDADD = @USB_LIBS@
endif
+if CSRINIT
+csrinit_SOURCES = csrinit.c csr.h
+csrinit_LDADD = @USB_LIBS@
+endif
+
if DFUTOOL
dfutool_SOURCES = dfutool.c dfu.h dfu.c
dfutool_LDADD = @USB_LIBS@
@@ -70,8 +83,8 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @USB_CFLAGS@
INCLUDES = -I$(top_srcdir)/common
man_MANS = hciattach.8 hciconfig.8 hcitool.1 l2ping.1 sdptool.1 ciptool.1 \
- $(avctrl_manfiles) $(hid2hci_manfiles) $(dfutool_manfiles)
+ $(avctrl_manfiles) $(hid2hci_manfiles) $(csrinit_manfiles) $(dfutool_manfiles)
-EXTRA_DIST = $(man_MANS) avctrl.8 hid2hci.8 dfutool.1 example.psr
+EXTRA_DIST = $(man_MANS) avctrl.8 hid2hci.8 csrinit.8 dfutool.1 example.psr
MAINTAINERCLEANFILES = Makefile.in
diff --git a/tools/csrinit.8 b/tools/csrinit.8
new file mode 100644
index 00000000..35a033d9
--- /dev/null
+++ b/tools/csrinit.8
@@ -0,0 +1,35 @@
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program; if not, write to the Free Software
+.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+.\"
+.\"
+.TH CSRINIT 8 "SEPTEMBER 8, 2005" "" ""
+
+.SH NAME
+csrinit \- Utility for the setting up CSR ROM chips
+.SH SYNOPSIS
+.BR "csrinit
+[
+.I options
+]
+.SH DESCRIPTION
+.B csrinit
+is used to setup the ROM chips from CSR.
+.SH OPTIONS
+.TP
+.BI -h
+Gives a list of possible options.
+.SH AUTHOR
+Written by Marcel Holtmann <marcel@holtmann.org>.
+.br
diff --git a/tools/csrinit.c b/tools/csrinit.c
new file mode 100644
index 00000000..07310175
--- /dev/null
+++ b/tools/csrinit.c
@@ -0,0 +1,101 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+ * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+ * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
+ * SOFTWARE IS DISCLAIMED.
+ *
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+
+#include <usb.h>
+
+#include "csr.h"
+
+#ifdef NEED_USB_GET_BUSSES
+static inline struct usb_bus *usb_get_busses(void)
+{
+ return usb_busses;
+}
+#endif
+
+#ifndef USB_DIR_OUT
+#define USB_DIR_OUT 0x00
+#endif
+
+#ifndef USB_DIR_IN
+#define USB_DIR_IN 0x80
+#endif
+
+static void usage(void)
+{
+ printf("csrinit - Utility for the setting up CSR ROM chips\n\n");
+
+ printf("Usage:\n"
+ "\tcsrinit [options]\n"
+ "\n");
+
+ printf("Options:\n"
+ "\t-h, --help Display help\n"
+ "\n");
+}
+
+static struct option main_options[] = {
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
+};
+
+int main(int argc, char *argv[])
+{
+ int opt;
+
+ while ((opt = getopt_long(argc, argv, "+h", main_options, NULL)) != -1) {
+ switch (opt) {
+ case 'h':
+ usage();
+ exit(0);
+
+ default:
+ exit(0);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+ optind = 0;
+
+ if (argc < 1) {
+ usage();
+ exit(1);
+ }
+
+ usb_init();
+
+ return 0;
+}