aboutsummaryrefslogtreecommitdiffstats
path: root/package/nvram/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-04-27 12:57:57 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-04-27 12:57:57 +0000
commitace455e0c0a91444b232688a014cd358847f3c69 (patch)
tree3954dc33cb4c0855f125af58dc696a2b893a5ddf /package/nvram/src
parent6eec3954effc6702e2f8459b27d77d5fe86e8c60 (diff)
downloadupstream-ace455e0c0a91444b232688a014cd358847f3c69.tar.gz
upstream-ace455e0c0a91444b232688a014cd358847f3c69.tar.bz2
upstream-ace455e0c0a91444b232688a014cd358847f3c69.zip
remove old nvram package
SVN-Revision: 15436
Diffstat (limited to 'package/nvram/src')
-rw-r--r--package/nvram/src/Makefile16
-rw-r--r--package/nvram/src/include/bcmnvram.h144
-rw-r--r--package/nvram/src/include/bcmutils.h156
-rw-r--r--package/nvram/src/include/shutils.h199
-rw-r--r--package/nvram/src/include/typedefs.h294
-rw-r--r--package/nvram/src/include/wlutils.h81
-rw-r--r--package/nvram/src/main.c87
-rw-r--r--package/nvram/src/nvram.c188
8 files changed, 0 insertions, 1165 deletions
diff --git a/package/nvram/src/Makefile b/package/nvram/src/Makefile
deleted file mode 100644
index 144499ca65..0000000000
--- a/package/nvram/src/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-
-LIBNVRAM_OBJS := nvram.o
-
-all: libnvram.so nvram
-
-%.o: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -I. -Iinclude -o $@ $^
-
-libnvram.so: $(LIBNVRAM_OBJS)
- $(CC) -shared -o $@ $^
-
-nvram: main.o
- $(CC) -o $@ $^ -L. -lnvram
-
-clean:
- rm -f *.o *.so nvram
diff --git a/package/nvram/src/include/bcmnvram.h b/package/nvram/src/include/bcmnvram.h
deleted file mode 100644
index deca626d48..0000000000
--- a/package/nvram/src/include/bcmnvram.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * NVRAM variable manipulation
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#ifndef _bcmnvram_h_
-#define _bcmnvram_h_
-
-#ifndef _LANGUAGE_ASSEMBLY
-
-#include <typedefs.h>
-
-struct nvram_header {
- uint32 magic;
- uint32 len;
- uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:27 init, mem. test 28, 29-31 reserved */
- uint32 config_refresh; /* 0:15 config, 16:31 refresh */
- uint32 config_ncdl; /* ncdl values for memc */
-};
-
-struct nvram_tuple {
- char *name;
- char *value;
- struct nvram_tuple *next;
-};
-
-/*
- * Initialize NVRAM access. May be unnecessary or undefined on certain
- * platforms.
- */
-extern int nvram_init(void *sbh);
-
-/*
- * Disable NVRAM access. May be unnecessary or undefined on certain
- * platforms.
- */
-extern void nvram_exit(void);
-
-/*
- * Get the value of an NVRAM variable. The pointer returned may be
- * invalid after a set.
- * @param name name of variable to get
- * @return value of variable or NULL if undefined
- */
-extern char * nvram_get(const char *name);
-
-/*
- * Get the value of an NVRAM variable.
- * @param name name of variable to get
- * @return value of variable or NUL if undefined
- */
-#define nvram_safe_get(name) (nvram_get(name) ? : "")
-
-#define nvram_safe_unset(name) ({ \
- if(nvram_get(name)) \
- nvram_unset(name); \
-})
-
-#define nvram_safe_set(name, value) ({ \
- if(!nvram_get(name) || strcmp(nvram_get(name), value)) \
- nvram_set(name, value); \
-})
-
-/*
- * Match an NVRAM variable.
- * @param name name of variable to match
- * @param match value to compare against value of variable
- * @return TRUE if variable is defined and its value is string equal
- * to match or FALSE otherwise
- */
-static INLINE int
-nvram_match(char *name, char *match) {
- const char *value = nvram_get(name);
- return (value && !strcmp(value, match));
-}
-
-/*
- * Inversely match an NVRAM variable.
- * @param name name of variable to match
- * @param match value to compare against value of variable
- * @return TRUE if variable is defined and its value is not string
- * equal to invmatch or FALSE otherwise
- */
-static INLINE int
-nvram_invmatch(char *name, char *invmatch) {
- const char *value = nvram_get(name);
- return (value && strcmp(value, invmatch));
-}
-
-/*
- * Set the value of an NVRAM variable. The name and value strings are
- * copied into private storage. Pointers to previously set values
- * may become invalid. The new value may be immediately
- * retrieved but will not be permanently stored until a commit.
- * @param name name of variable to set
- * @param value value of variable
- * @return 0 on success and errno on failure
- */
-extern int nvram_set(const char *name, const char *value);
-
-/*
- * Unset an NVRAM variable. Pointers to previously set values
- * remain valid until a set.
- * @param name name of variable to unset
- * @return 0 on success and errno on failure
- * NOTE: use nvram_commit to commit this change to flash.
- */
-extern int nvram_unset(const char *name);
-
-/*
- * Commit NVRAM variables to permanent storage. All pointers to values
- * may be invalid after a commit.
- * NVRAM values are undefined after a commit.
- * @return 0 on success and errno on failure
- */
-extern int nvram_commit(void);
-
-/*
- * Get all NVRAM variables (format name=value\0 ... \0\0).
- * @param buf buffer to store variables
- * @param count size of buffer in bytes
- * @return 0 on success and errno on failure
- */
-extern int nvram_getall(char *buf, int count);
-
-#endif /* _LANGUAGE_ASSEMBLY */
-
-#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
-#define NVRAM_VERSION 1
-#define NVRAM_HEADER_SIZE 20
-#define NVRAM_SPACE 0x8000
-#define FLASH_BASE 0xbfc00000 /* Extif core */
-#define FLASH_MIN 0x00100000 /* Minimum flash size */
-#define FLASH_MAX 0x00400000 /* Maximum flash size with extif */
-
-#endif /* _bcmnvram_h_ */
diff --git a/package/nvram/src/include/bcmutils.h b/package/nvram/src/include/bcmutils.h
deleted file mode 100644
index 3933ffb73f..0000000000
--- a/package/nvram/src/include/bcmutils.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Misc useful os-independent macros and functions.
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- */
-
-#ifndef _bcmutils_h_
-#define _bcmutils_h_
-
-#ifndef MIN
-#define MIN(a, b) (((a)<(b))?(a):(b))
-#endif
-
-#ifndef MAX
-#define MAX(a, b) (((a)>(b))?(a):(b))
-#endif
-
-#define CEIL(x, y) (((x) + ((y)-1)) / (y))
-#define ROUNDUP(x, y) ((((ulong)(x)+((y)-1))/(y))*(y))
-#define ISALIGNED(a, x) (((uint)(a) & ((x)-1)) == 0)
-#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
-#define OFFSETOF(type, member) ((uint) &((type *)0)->member)
-#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
-
-/* bit map related macros */
-#ifndef setbit
-#define NBBY 8 /* 8 bits per byte */
-#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
-#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
-#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
-#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
-#endif
-
-#define NBITS(type) (sizeof (type) * 8)
-
-#define _BCM_U 0x01 /* upper */
-#define _BCM_L 0x02 /* lower */
-#define _BCM_D 0x04 /* digit */
-#define _BCM_C 0x08 /* cntrl */
-#define _BCM_P 0x10 /* punct */
-#define _BCM_S 0x20 /* white space (space/lf/tab) */
-#define _BCM_X 0x40 /* hex digit */
-#define _BCM_SP 0x80 /* hard space (0x20) */
-
-extern unsigned char bcm_ctype[];
-#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
-
-#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
-#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
-#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
-#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
-#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
-#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
-#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
-#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
-#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
-#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
-#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
-
-/*
- * Spin at most 'us' microseconds while 'exp' is true.
- * Caller should explicitly test 'exp' when this completes
- * and take appropriate error action if 'exp' is still true.
- */
-#define SPINWAIT(exp, us) { \
- uint countdown = (us) + 9; \
- while ((exp) && (countdown >= 10)) {\
- OSL_DELAY(10); \
- countdown -= 10; \
- } \
-}
-
-/* generic osl packet queue */
-struct pktq {
- void *head; /* first packet to dequeue */
- void *tail; /* last packet to dequeue */
- uint len; /* number of queued packets */
- uint maxlen; /* maximum number of queued packets */
- bool priority; /* enqueue by packet priority */
-};
-#define DEFAULT_QLEN 128
-
-#define pktq_len(q) ((q)->len)
-#define pktq_avail(q) ((q)->maxlen - (q)->len)
-#define pktq_head(q) ((q)->head)
-#define pktq_full(q) ((q)->len >= (q)->maxlen)
-
-/* crc defines */
-#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
-#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
-#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
-#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
-#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
-#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
-
-/* tag_ID/length/value_buffer tuple */
-typedef struct bcm_tlv {
- uint8 id;
- uint8 len;
- uint8 data[1];
-} bcm_tlv_t;
-
-/* Check that bcm_tlv_t fits into the given buflen */
-#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (buflen) >= 2 + (elt)->len)
-
-/* buffer length for ethernet address from bcm_ether_ntoa() */
-#define ETHER_ADDR_STR_LEN 18
-
-/*
-* load 32-bit value from unaligned byte array
-*/
-#ifdef IL_BIGENDIAN
-#define load32_ua(a) ((((uint8 *)(a))[0] << 24) + (((uint8 *)(a))[1] << 16) + \
- (((uint8 *)(a))[2] << 8) + ((uint8 *)(a))[3])
-#else
-#define load32_ua(a) ((((uint8 *)(a))[3] << 24) + (((uint8 *)(a))[2] << 16) + \
- (((uint8 *)(a))[1] << 8) + ((uint8 *)(a))[0])
-#endif
-
-/* externs */
-extern uint bcm_atoi(char *s);
-extern uchar bcm_toupper(uchar c);
-extern ulong bcm_strtoul(char *cp, char **endp, uint base);
-extern void deadbeef(char *p, uint len);
-extern void prhex(char *msg, uchar *buf, uint len);
-extern void prpkt(char *msg, void *drv, void *p0);
-extern uint pktcopy(void *drv, void *p, uint offset, int len, uchar *buf);
-extern uint pkttotlen(void *drv, void *);
-extern uchar *bcm_ether_ntoa(char *ea, char *buf);
-extern int bcm_ether_atoe(char *p, char *ea);
-extern void bcm_mdelay(uint ms);
-extern char *getvar(char *vars, char *name);
-extern int getintvar(char *vars, char *name);
-extern char *bcmstrstr(char *haystack, char *needle);
-
-extern uint8 crc8(uint8 *p, uint nbytes, uint8 crc);
-extern uint16 crc16(uint8 *p, uint nbytes, uint16 crc);
-extern uint32 crc32(uint8 *p, uint nbytes, uint32 crc);
-extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
-extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
-extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
-extern void pktq_init(struct pktq *q, uint maxlen, bool priority);
-extern bool pktenq(struct pktq *q, void *p, bool lifo);
-extern void *pktdeq(struct pktq *q);
-
-#define bcmlog(fmt, a1, a2)
-#define bcmdumplog(buf, size) *buf = '\0'
-#define bcmdumplogent(buf, idx) -1
-
-#endif /* _bcmutils_h_ */
diff --git a/package/nvram/src/include/shutils.h b/package/nvram/src/include/shutils.h
deleted file mode 100644
index 5b57618370..0000000000
--- a/package/nvram/src/include/shutils.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Shell-like utility functions
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#ifndef _shutils_h_
-#define _shutils_h_
-#include <string.h>
-/*
- * Reads file and returns contents
- * @param fd file descriptor
- * @return contents of file or NULL if an error occurred
- */
-extern char * fd2str(int fd);
-
-/*
- * Reads file and returns contents
- * @param path path to file
- * @return contents of file or NULL if an error occurred
- */
-extern char * file2str(const char *path);
-
-/*
- * Waits for a file descriptor to become available for reading or unblocked signal
- * @param fd file descriptor
- * @param timeout seconds to wait before timing out or 0 for no timeout
- * @return 1 if descriptor changed status or 0 if timed out or -1 on error
- */
-extern int waitfor(int fd, int timeout);
-
-/*
- * Concatenates NULL-terminated list of arguments into a single
- * commmand and executes it
- * @param argv argument list
- * @param path NULL, ">output", or ">>output"
- * @param timeout seconds to wait before timing out or 0 for no timeout
- * @param ppid NULL to wait for child termination or pointer to pid
- * @return return value of executed command or errno
- */
-extern int _eval(char *const argv[], char *path, int timeout, pid_t *ppid);
-
-/*
- * Concatenates NULL-terminated list of arguments into a single
- * commmand and executes it
- * @param argv argument list
- * @return stdout of executed command or NULL if an error occurred
- */
-extern char * _backtick(char *const argv[]);
-
-/*
- * Kills process whose PID is stored in plaintext in pidfile
- * @param pidfile PID file
- * @return 0 on success and errno on failure
- */
-extern int kill_pidfile(char *pidfile);
-
-/*
- * fread() with automatic retry on syscall interrupt
- * @param ptr location to store to
- * @param size size of each element of data
- * @param nmemb number of elements
- * @param stream file stream
- * @return number of items successfully read
- */
-extern int safe_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
-
-/*
- * fwrite() with automatic retry on syscall interrupt
- * @param ptr location to read from
- * @param size size of each element of data
- * @param nmemb number of elements
- * @param stream file stream
- * @return number of items successfully written
- */
-extern int safe_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
-
-/*
- * Convert Ethernet address string representation to binary data
- * @param a string in xx:xx:xx:xx:xx:xx notation
- * @param e binary data
- * @return TRUE if conversion was successful and FALSE otherwise
- */
-extern int ether_atoe(const char *a, unsigned char *e);
-
-/*
- * Convert Ethernet address binary data to string representation
- * @param e binary data
- * @param a string in xx:xx:xx:xx:xx:xx notation
- * @return a
- */
-extern char * ether_etoa(const unsigned char *e, char *a);
-
-/*
- * Concatenate two strings together into a caller supplied buffer
- * @param s1 first string
- * @param s2 second string
- * @param buf buffer large enough to hold both strings
- * @return buf
- */
-static inline char * strcat_r(const char *s1, const char *s2, char *buf)
-{
- strcpy(buf, s1);
- strcat(buf, s2);
- return buf;
-}
-
-/* Check for a blank character; that is, a space or a tab */
-#define isblank(c) ((c) == ' ' || (c) == '\t')
-
-/* Strip trailing CR/NL from string <s> */
-#define chomp(s) ({ \
- char *c = (s) + strlen((s)) - 1; \
- while ((c > (s)) && (*c == '\n' || *c == '\r' || *c == ' ')) \
- *c-- = '\0'; \
- s; \
-})
-
-/* Simple version of _backtick() */
-#define backtick(cmd, args...) ({ \
- char *argv[] = { cmd, ## args, NULL }; \
- _backtick(argv); \
-})
-
-/* Simple version of _eval() (no timeout and wait for child termination) */
-#define eval(cmd, args...) ({ \
- char *argv[] = { cmd, ## args, NULL }; \
- _eval(argv, ">/dev/console", 0, NULL); \
-})
-
-/* Copy each token in wordlist delimited by space into word */
-#define foreach(word, wordlist, next) \
- for (next = &wordlist[strspn(wordlist, " ")], \
- strncpy(word, next, sizeof(word)), \
- word[strcspn(word, " ")] = '\0', \
- word[sizeof(word) - 1] = '\0', \
- next = strchr(next, ' '); \
- strlen(word); \
- next = next ? &next[strspn(next, " ")] : "", \
- strncpy(word, next, sizeof(word)), \
- word[strcspn(word, " ")] = '\0', \
- word[sizeof(word) - 1] = '\0', \
- next = strchr(next, ' '))
-
-/* Return NUL instead of NULL if undefined */
-#define safe_getenv(s) (getenv(s) ? : "")
-
-/* Print directly to the console */
-#define cprintf(fmt, args...) do { \
- FILE *fp = fopen("/dev/console", "w"); \
- if (fp) { \
- fprintf(fp, fmt, ## args); \
- fclose(fp); \
- } \
-} while (0)
-
-/* Debug print */
-#ifdef DEBUG
-#define dprintf(fmt, args...) cprintf("%s: " fmt, __FUNCTION__, ## args)
-#else
-#define dprintf(fmt, args...)
-#endif
-
-#ifdef vxworks
-
-#include <inetLib.h>
-#define inet_aton(a, n) ((inet_aton((a), (n)) == ERROR) ? 0 : 1)
-#define inet_ntoa(n) ({ char a[INET_ADDR_LEN]; inet_ntoa_b ((n), a); a; })
-
-#include <typedefs.h>
-#include <bcmutils.h>
-#define ether_atoe(a, e) bcm_ether_atoe((a), (e))
-#define ether_etoa(e, a) bcm_ether_ntoa((e), (a))
-
-/* These declarations are not available where you would expect them */
-extern int vsnprintf (char *, size_t, const char *, va_list);
-extern int snprintf(char *str, size_t count, const char *fmt, ...);
-extern char *strdup(const char *);
-extern char *strsep(char **stringp, char *delim);
-extern int strcasecmp(const char *s1, const char *s2);
-extern int strncasecmp(const char *s1, const char *s2, size_t n);
-
-/* Neither are socket() and connect() */
-#include <sockLib.h>
-
-#ifdef DEBUG
-#undef dprintf
-#define dprintf printf
-#endif
-#endif
-
-#endif /* _shutils_h_ */
diff --git a/package/nvram/src/include/typedefs.h b/package/nvram/src/include/typedefs.h
deleted file mode 100644
index 7850a0cac3..0000000000
--- a/package/nvram/src/include/typedefs.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- */
-
-#ifndef _TYPEDEFS_H_
-#define _TYPEDEFS_H_
-
-
-/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
- * typedef file "site_typedefs.h".
- *
- * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
- * section of this file makes inferences about the compile environment
- * based on defined symbols and possibly compiler pragmas.
- *
- * Following these two sections is the "Default Typedefs"
- * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
- * defined. This section has a default set of typedefs and a few
- * proprocessor symbols (TRUE, FALSE, NULL, ...).
- */
-
-#ifdef SITE_TYPEDEFS
-
-/*******************************************************************************
- * Site Specific Typedefs
- *******************************************************************************/
-
-#include "site_typedefs.h"
-
-#else
-
-/*******************************************************************************
- * Inferred Typedefs
- *******************************************************************************/
-
-/* Infer the compile environment based on preprocessor symbols and pramas.
- * Override type definitions as needed, and include configuration dependent
- * header files to define types.
- */
-
-#ifdef __cplusplus
-
-#define TYPEDEF_BOOL
-#ifndef FALSE
-#define FALSE false
-#endif
-#ifndef TRUE
-#define TRUE true
-#endif
-
-#else /* ! __cplusplus */
-
-/* for Windows build, define bool as a uchar instead of the default int */
-#if defined(_WIN32)
-
-#define TYPEDEF_BOOL
-typedef unsigned char bool;
-
-#endif /* _WIN32 */
-
-#endif /* ! __cplusplus */
-
-#ifdef _MSC_VER /* Microsoft C */
-#define TYPEDEF_INT64
-#define TYPEDEF_UINT64
-typedef signed __int64 int64;
-typedef unsigned __int64 uint64;
-#endif
-
-#if defined(MACOSX) && defined(KERNEL)
-#define TYPEDEF_BOOL
-#endif
-
-
-#if defined(linux)
-#define TYPEDEF_UINT
-#define TYPEDEF_USHORT
-#define TYPEDEF_ULONG
-#endif
-
-#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_)
-#define TYPEDEF_UINT
-#define TYPEDEF_USHORT
-#endif
-
-
-/* Do not support the (u)int64 types with strict ansi for GNU C */
-#if defined(__GNUC__) && defined(__STRICT_ANSI__)
-#define TYPEDEF_INT64
-#define TYPEDEF_UINT64
-#endif
-
-/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
- * for singned or unsigned */
-#if defined(__ICL)
-
-#define TYPEDEF_INT64
-
-#if defined(__STDC__)
-#define TYPEDEF_UINT64
-#endif
-
-#endif /* __ICL */
-
-
-#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_)
-
-/* pick up ushort & uint from standard types.h */
-#if defined(linux) && defined(__KERNEL__)
-
-#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
-
-#else
-
-#include <sys/types.h>
-
-#endif
-
-#endif /* !_WIN32 && !PMON && !_CFE_ */
-
-#if defined(MACOSX) && defined(KERNEL)
-#include <IOKit/IOTypes.h>
-#endif
-
-
-/* use the default typedefs in the next section of this file */
-#define USE_TYPEDEF_DEFAULTS
-
-#endif /* SITE_TYPEDEFS */
-
-
-/*******************************************************************************
- * Default Typedefs
- *******************************************************************************/
-
-#ifdef USE_TYPEDEF_DEFAULTS
-#undef USE_TYPEDEF_DEFAULTS
-
-#ifndef TYPEDEF_BOOL
-typedef int bool;
-#endif
-
-/*----------------------- define uchar, ushort, uint, ulong ----------------*/
-
-#ifndef TYPEDEF_UCHAR
-typedef unsigned char uchar;
-#endif
-
-#ifndef TYPEDEF_USHORT
-typedef unsigned short ushort;
-#endif
-
-#ifndef TYPEDEF_UINT
-typedef unsigned int uint;
-#endif
-
-#ifndef TYPEDEF_ULONG
-typedef unsigned long ulong;
-#endif
-
-/*----------------------- define [u]int8/16/32/64 --------------------------*/
-
-#ifndef TYPEDEF_UINT8
-typedef unsigned char uint8;
-#endif
-
-#ifndef TYPEDEF_UINT16
-typedef unsigned short uint16;
-#endif
-
-#ifndef TYPEDEF_UINT32
-typedef unsigned int uint32;
-#endif
-
-#ifndef TYPEDEF_UINT64
-typedef unsigned long long uint64;
-#endif
-
-#ifndef TYPEDEF_INT8
-typedef signed char int8;
-#endif
-
-#ifndef TYPEDEF_INT16
-typedef signed short int16;
-#endif
-
-#ifndef TYPEDEF_INT32
-typedef signed int int32;
-#endif
-
-#ifndef TYPEDEF_INT64
-typedef signed long long int64;
-#endif
-
-/*----------------------- define float32/64, float_t -----------------------*/
-
-#ifndef TYPEDEF_FLOAT32
-typedef float float32;
-#endif
-
-#ifndef TYPEDEF_FLOAT64
-typedef double float64;
-#endif
-
-/*
- * abstracted floating point type allows for compile time selection of
- * single or double precision arithmetic. Compiling with -DFLOAT32
- * selects single precision; the default is double precision.
- */
-
-#ifndef TYPEDEF_FLOAT_T
-
-#if defined(FLOAT32)
-typedef float32 float_t;
-#else /* default to double precision floating point */
-typedef float64 float_t;
-#endif
-
-#endif /* TYPEDEF_FLOAT_T */
-
-/*----------------------- define macro values -----------------------------*/
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef OFF
-#define OFF 0
-#endif
-
-#ifndef ON
-#define ON 1
-#endif
-
-/*----------------------- define PTRSZ, INLINE ----------------------------*/
-
-#ifndef PTRSZ
-#define PTRSZ sizeof (char*)
-#endif
-
-#ifndef INLINE
-
-#ifdef _MSC_VER
-
-#define INLINE __inline
-
-#elif __GNUC__
-
-#define INLINE __inline__
-
-#else
-
-#define INLINE
-
-#endif /* _MSC_VER */
-
-#endif /* INLINE */
-
-#undef TYPEDEF_BOOL
-#undef TYPEDEF_UCHAR
-#undef TYPEDEF_USHORT
-#undef TYPEDEF_UINT
-#undef TYPEDEF_ULONG
-#undef TYPEDEF_UINT8
-#undef TYPEDEF_UINT16
-#undef TYPEDEF_UINT32
-#undef TYPEDEF_UINT64
-#undef TYPEDEF_INT8
-#undef TYPEDEF_INT16
-#undef TYPEDEF_INT32
-#undef TYPEDEF_INT64
-#undef TYPEDEF_FLOAT32
-#undef TYPEDEF_FLOAT64
-#undef TYPEDEF_FLOAT_T
-
-#define ETHER_ADDR_LEN 6
-
-#endif /* USE_TYPEDEF_DEFAULTS */
-
-#endif /* _TYPEDEFS_H_ */
diff --git a/package/nvram/src/include/wlutils.h b/package/nvram/src/include/wlutils.h
deleted file mode 100644
index 8a155e85f1..0000000000
--- a/package/nvram/src/include/wlutils.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Broadcom wireless network adapter utility functions
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#ifndef _wlutils_h_
-#define _wlutils_h_
-
-#include <typedefs.h>
-
-/* check this magic number */
-#define WLC_IOCTL_MAGIC 0x14e46c77
-
-/* maximum length buffer required */
-#define WLC_IOCTL_SMLEN 256
-
-#define WLC_IOCTL_VERSION 1
-
-#define WLC_GET_MAGIC 0
-#define WLC_GET_VERSION 1
-#define WLC_GET_VAR 262 /* get value of named variable */
-#define WLC_SET_VAR 263 /* set named variable to value */
-
-/* Linux network driver ioctl encoding */
-typedef struct wl_ioctl {
- uint cmd; /* common ioctl definition */
- void *buf; /* pointer to user buffer */
- uint len; /* length of user buffer */
- bool set; /* get or set request (optional) */
- uint used; /* bytes read or written (optional) */
- uint needed; /* bytes needed (optional) */
-} wl_ioctl_t;
-
-
-/*
- * Pass a wlioctl request to the specified interface.
- * @param name interface name
- * @param cmd WLC_GET_MAGIC <= cmd < WLC_LAST
- * @param buf buffer for passing in and/or receiving data
- * @param len length of buf
- * @return >= 0 if successful or < 0 otherwise
- */
-extern int wl_ioctl(char *name, int cmd, void *buf, int len);
-
-/*
- * Get the MAC (hardware) address of the specified interface.
- * @param name interface name
- * @param hwaddr 6-byte buffer for receiving address
- * @return >= 0 if successful or < 0 otherwise
- */
-extern int wl_hwaddr(char *name, unsigned char *hwaddr);
-
-/*
- * Probe the specified interface.
- * @param name interface name
- * @return >= 0 if a Broadcom wireless device or < 0 otherwise
- */
-extern int wl_probe(char *name);
-
-/*
- * Set/Get named variable.
- * @param name interface name
- * @param var variable name
- * @param val variable value/buffer
- * @param len variable value/buffer length
- * @return success == 0, failure != 0
- */
-extern int wl_set_val(char *name, char *var, void *val, int len);
-extern int wl_get_val(char *name, char *var, void *val, int len);
-extern int wl_set_int(char *name, char *var, int val);
-extern int wl_get_int(char *name, char *var, int *val);
-
-#endif /* _wlutils_h_ */
diff --git a/package/nvram/src/main.c b/package/nvram/src/main.c
deleted file mode 100644
index 44ecd10d1c..0000000000
--- a/package/nvram/src/main.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Frontend command-line utility for Linux NVRAM layer
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <typedefs.h>
-#include <bcmnvram.h>
-
-static void
-usage(void)
-{
- fprintf(stderr, "usage: nvram [get name] [set name=value] [unset name] [commit] [show]\n");
- exit(0);
-}
-
-/* hack for some PMON default nvram values which have '\r' appended */
-void
-puts_trim_cr(char *str)
-{
- int len= strlen(str);
- if (len && (str[len-1] == '\r')) len--;
- printf("%.*s\n", len, str);
-}
-
-/* NVRAM utility */
-int
-main(int argc, char **argv)
-{
- char *name, *value, buf[NVRAM_SPACE];
- int size;
-
- /* Skip program name */
- --argc;
- ++argv;
-
- if (!*argv)
- usage();
-
- /* Process the remaining arguments. */
- for (; *argv; argv++) {
- if (!strncmp(*argv, "get", 3)) {
- if (*++argv) {
- if ((value = nvram_get(*argv))) {
- puts_trim_cr(value);
- }
- }
- }
- else if (!strncmp(*argv, "set", 3)) {
- if (*++argv) {
- strncpy(value = buf, *argv, sizeof(buf));
- name = strsep(&value, "=");
- nvram_set(name, value);
- }
- }
- else if (!strncmp(*argv, "unset", 5)) {
- if (*++argv)
- nvram_unset(*argv);
- }
- else if (!strncmp(*argv, "commit", 5)) {
- nvram_commit();
- }
- else if (!strncmp(*argv, "show", 4) ||
- !strncmp(*argv, "getall", 6)) {
- nvram_getall(buf, sizeof(buf));
- for (name = buf; *name; name += strlen(name) + 1)
- puts_trim_cr(name);
- size = sizeof(struct nvram_header) + (int) name - (int) buf;
- fprintf(stderr, "size: %d bytes (%d left)\n", size, NVRAM_SPACE - size);
- }
- if (!*argv)
- break;
- }
-
- return 0;
-}
diff --git a/package/nvram/src/nvram.c b/package/nvram/src/nvram.c
deleted file mode 100644
index 47d09a397d..0000000000
--- a/package/nvram/src/nvram.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * NVRAM variable manipulation (Linux user mode half)
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <error.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#include <typedefs.h>
-#include <bcmnvram.h>
-#include <shutils.h>
-
-#define PATH_DEV_NVRAM "/dev/nvram"
-
-/* Globals */
-static int nvram_fd = -1;
-static char *nvram_buf = NULL;
-int file_to_buf(char *path, char *buf, int len);
-
-int
-nvram_init(void *unused)
-{
- if ((nvram_fd = open(PATH_DEV_NVRAM, O_RDWR)) < 0)
- goto err;
-
- /* Map kernel string buffer into user space */
- if ((nvram_buf = mmap(NULL, NVRAM_SPACE, PROT_READ, MAP_SHARED, nvram_fd, 0)) == MAP_FAILED) {
- close(nvram_fd);
- nvram_fd = -1;
- goto err;
- }
-
- return 0;
-
- err:
- perror(PATH_DEV_NVRAM);
- return errno;
-}
-
-char *
-nvram_get(const char *name)
-{
- size_t count = strlen(name) + 1;
- char tmp[100], *value;
- unsigned long *off = (unsigned long *) tmp;
-
- if (nvram_fd < 0)
- if (nvram_init(NULL))
- return NULL;
-
- if (count > sizeof(tmp)) {
- if (!(off = malloc(count)))
- return NULL;
- }
-
- /* Get offset into mmap() space */
- strcpy((char *) off, name);
-
- count = read(nvram_fd, off, count);
-
- if (count == sizeof(unsigned long))
- value = &nvram_buf[*off];
- else
- value = NULL;
-
- if (count < 0)
- perror(PATH_DEV_NVRAM);
-
- if (off != (unsigned long *) tmp)
- free(off);
-
- return value;
-}
-
-int
-nvram_getall(char *buf, int count)
-{
- int ret;
-
- if (nvram_fd < 0)
- if ((ret = nvram_init(NULL)))
- return ret;
-
- if (count == 0)
- return 0;
-
- /* Get all variables */
- *buf = '\0';
-
- ret = read(nvram_fd, buf, count);
-
- if (ret < 0)
- perror(PATH_DEV_NVRAM);
-
- return (ret == count) ? 0 : ret;
-}
-
-int
-nvram_set(const char *name, const char *value)
-{
- size_t count = strlen(name) + 1;
- char tmp[100], *buf = tmp;
- int ret;
-
- if (nvram_fd < 0)
- if ((ret = nvram_init(NULL)))
- return ret;
-
- /* Unset if value is NULL */
- if (value)
- count += strlen(value) + 1;
-
- if (count > sizeof(tmp)) {
- if (!(buf = malloc(count)))
- return -ENOMEM;
- }
-
- if (value)
- sprintf(buf, "%s=%s", name, value);
- else
- strcpy(buf, name);
-
- ret = write(nvram_fd, buf, count);
-
- if (ret < 0)
- perror(PATH_DEV_NVRAM);
-
- if (buf != tmp)
- free(buf);
-
- return (ret == count) ? 0 : ret;
-}
-
-int
-nvram_unset(const char *name)
-{
- return nvram_set(name, NULL);
-}
-
-int
-nvram_commit(void)
-{
- int ret;
-
- if (nvram_fd < 0)
- if ((ret = nvram_init(NULL)))
- return ret;
-
- ret = ioctl(nvram_fd, NVRAM_MAGIC, NULL);
-
- if (ret < 0)
- perror(PATH_DEV_NVRAM);
-
- return ret;
-}
-
-int
-file_to_buf(char *path, char *buf, int len)
-{
- FILE *fp;
-
- memset(buf, 0 , len);
-
- if ((fp = fopen(path, "r"))) {
- fgets(buf, len, fp);
- fclose(fp);
- return 1;
- }
-
- return 0;
-}